Fatih commited on
Commit
6e44ce9
1 Parent(s): e552c9f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -0
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <br />
30
+ 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>
31
+ </p>
32
+ """,
33
+ unsafe_allow_html=True,
34
+ )
35
+
36
+ st.write("##")
37
+
38
+ with st.form(key="Streamlit Image Comparison"):
39
+ # image one inputs
40
+ col1, col2 = st.columns([3, 1])
41
+ with col1:
42
+ img1_url = st.text_input("Image one URL:", value=IMAGE_TO_URL["sample_image_1"])
43
+ with col2:
44
+ img1_text = st.text_input("Image one text:", value="YOLOX")
45
+
46
+ # image two inputs
47
+ col1, col2 = st.columns([3, 1])
48
+ with col1:
49
+ img2_url = st.text_input("Image two URL:", value=IMAGE_TO_URL["sample_image_2"])
50
+ with col2:
51
+ img2_text = st.text_input("Image two text:", value="SAHI+YOLOX")
52
+
53
+ # continious parameters
54
+ col1, col2 = st.columns([1, 1])
55
+ with col1:
56
+ starting_position = st.slider(
57
+ "Starting position of the slider:", min_value=0, max_value=100, value=50
58
+ )
59
+ with col2:
60
+ width = st.slider(
61
+ "Component width:", min_value=400, max_value=1000, value=700, step=100
62
+ )
63
+
64
+ # boolean parameters
65
+ col1, col2, col3, col4 = st.columns([1, 3, 3, 3])
66
+ with col2:
67
+ show_labels = st.checkbox("Show labels", value=True)
68
+ with col3:
69
+ make_responsive = st.checkbox("Make responsive", value=True)
70
+ with col4:
71
+ in_memory = st.checkbox("In memory", value=True)
72
+
73
+ # centered submit button
74
+ col1, col2, col3 = st.columns([6, 4, 6])
75
+ with col2:
76
+ submit = st.form_submit_button("Update Render 🔥")
77
+
78
+ static_component = image_comparison(
79
+ img1=img1_url,
80
+ img2=img2_url,
81
+ label1=img1_text,
82
+ label2=img2_text,
83
+ width=width,
84
+ starting_position=starting_position,
85
+ show_labels=show_labels,
86
+ make_responsive=make_responsive,
87
+ in_memory=in_memory,
88
+ )