chris-rannou HF staff commited on
Commit
00b3c6f
0 Parent(s):

Initial commit

Browse files
Files changed (4) hide show
  1. README.md +13 -0
  2. app.py +89 -0
  3. packages.txt +1 -0
  4. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test Private 2
3
+ emoji: 📚
4
+ colorFrom: green
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.2.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_image_comparison import image_comparison
3
+
4
+
5
+ IMAGE_TO_URL = {
6
+ "sample_image_1": "https://user-images.githubusercontent.com/34196005/143309873-c0c1f31c-c42e-4a36-834e-da0a2336bb19.jpg",
7
+ "sample_image_2": "https://user-images.githubusercontent.com/34196005/143309867-42841f5a-9181-4d22-b570-65f90f2da231.jpg",
8
+ }
9
+
10
+
11
+ st.set_page_config(
12
+ page_title="Streamlit Image Comparison",
13
+ page_icon="🔥",
14
+ layout="centered",
15
+ initial_sidebar_state="auto",
16
+ )
17
+
18
+ st.markdown(
19
+ """
20
+ <h2 style='text-align: center'>
21
+ Streamlit Image Comparison Demo
22
+ </h2>
23
+ """,
24
+ unsafe_allow_html=True,
25
+ )
26
+ st.markdown(
27
+ """
28
+ <p style='text-align: center'>
29
+ <a href='https://github.com/fcakyon/streamlit-image-comparison' target='_blank'>https://github.com/fcakyon/streamlit-image-comparison</a>
30
+ <br />
31
+ Follow me for more! <a href='https://twitter.com/fcakyon' target='_blank'> <img src="https://img.icons8.com/color/48/000000/twitter--v1.png" height="30"></a><a href='https://github.com/fcakyon' target='_blank'><img src="https://img.icons8.com/fluency/48/000000/github.png" height="27"></a><a href='https://www.linkedin.com/in/fcakyon/' target='_blank'><img src="https://img.icons8.com/fluency/48/000000/linkedin.png" height="30"></a> <a href='https://fcakyon.medium.com/' target='_blank'><img src="https://img.icons8.com/ios-filled/48/000000/medium-monogram.png" height="26"></a>
32
+ </p>
33
+ """,
34
+ unsafe_allow_html=True,
35
+ )
36
+
37
+ st.write("##")
38
+
39
+ with st.form(key="Streamlit Image Comparison"):
40
+ # image one inputs
41
+ col1, col2 = st.columns([3, 1])
42
+ with col1:
43
+ img1_url = st.text_input("Image one URL:", value=IMAGE_TO_URL["sample_image_1"])
44
+ with col2:
45
+ img1_text = st.text_input("Image one text:", value="YOLOX7")
46
+
47
+ # image two inputs
48
+ col1, col2 = st.columns([3, 1])
49
+ with col1:
50
+ img2_url = st.text_input("Image two URL:", value=IMAGE_TO_URL["sample_image_2"])
51
+ with col2:
52
+ img2_text = st.text_input("Image two text:", value="SAHI+YOLOX")
53
+
54
+ # continious parameters
55
+ col1, col2 = st.columns([1, 1])
56
+ with col1:
57
+ starting_position = st.slider(
58
+ "Starting position of the slider:", min_value=0, max_value=100, value=50
59
+ )
60
+ with col2:
61
+ width = st.slider(
62
+ "Component width:", min_value=400, max_value=1000, value=700, step=100
63
+ )
64
+
65
+ # boolean parameters
66
+ col1, col2, col3, col4 = st.columns([1, 3, 3, 3])
67
+ with col2:
68
+ show_labels = st.checkbox("Show labels", value=True)
69
+ with col3:
70
+ make_responsive = st.checkbox("Make responsive", value=True)
71
+ with col4:
72
+ in_memory = st.checkbox("In memory", value=True)
73
+
74
+ # centered submit button
75
+ col1, col2, col3 = st.columns([6, 4, 6])
76
+ with col2:
77
+ submit = st.form_submit_button("Update Render 🔥")
78
+
79
+ static_component = image_comparison(
80
+ img1=img1_url,
81
+ img2=img2_url,
82
+ label1=img1_text,
83
+ label2=img2_text,
84
+ width=width,
85
+ starting_position=starting_position,
86
+ show_labels=show_labels,
87
+ make_responsive=make_responsive,
88
+ in_memory=in_memory,
89
+ )
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ libgl1
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ streamlit-image-comparison==0.0.1