forked from fcakyon/streamlit-image-comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
83 lines (70 loc) · 2.51 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import streamlit as st
from streamlit_image_comparison import exif_transpose
from streamlit_image_comparison import read_image_as_pil
from streamlit_image_comparison import pillow_to_base64
from streamlit_image_comparison import local_file_to_base64
from streamlit_image_comparison import local_file_to_base64
from streamlit_image_comparison import pillow_local_file_to_base64
from streamlit_image_comparison import image_comparison
import glob
import random
images = glob.glob('samples/*.jpeg')
IMAGE_TO_URL = {
"sample_image_1": "https://user-images.githubusercontent.com/34196005/143309873-c0c1f31c-c42e-4a36-834e-da0a2336bb19.jpg",
"sample_image_2": "https://user-images.githubusercontent.com/34196005/143309867-42841f5a-9181-4d22-b570-65f90f2da231.jpg",
}
st.set_page_config(
page_title="Histopathology Quality Control",
page_icon="🔥",
layout="centered",
initial_sidebar_state="auto",
)
st.markdown(
"""
<h2 style='text-align: center'>
Histopathology Quality Control
</h2>
""",
unsafe_allow_html=True,
)
with st.form(key="Streamlit Image Comparison"):
col1, col2 = st.columns([3, 1])
with col1:
# img1_url = st.text_input("Image one URL:", value=IMAGE_TO_URL["sample_image_1"])
img1_url = random.choice(images)
img2_url = img1_url.replace('.jpeg', '_mask.png')
#col1, col2 = st.columns([3, 1])
#with col1:
# img2_url = st.text_input("Image two URL:", value=IMAGE_TO_URL["sample_image_2"])
# img2_url = img1_url.replace('.jpeg', '_mask.png')
# col1, col2 = st.columns([1, 1])
# with col1:
# starting_position = st.slider(
# "Starting position of the slider:", min_value=0, max_value=100, value=50
# )
# with col2:
# width = st.slider(
# "Component width:", min_value=400, max_value=1000, value=700, step=100
# )
# col1, col2, col3, col4 = st.columns([1, 3, 3, 3])
# with col2:
# show_labels = st.checkbox("Show labels", value=True)
# with col3:
# make_responsive = st.checkbox("Make responsive", value=True)
# with col4:
# in_memory = st.checkbox("In memory", value=True)
# centered submit button
col1, col2, col3 = st.columns([6, 4, 6])
with col2:
submit = st.form_submit_button("Update Render 🔥")
static_component = image_comparison(
img1=img1_url,
img2=img2_url,
label1='',
label2='',
width=700,
starting_position=50,
show_labels=True,
make_responsive=True,
in_memory=True,
)