Spaces:
Sleeping
Sleeping
Odin-son commited on
Commit ·
e9bcce2
1
Parent(s): 8545691
change url to upload
Browse files
app.py
CHANGED
|
@@ -1,25 +1,33 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_image_comparison import image_comparison
|
|
|
|
| 3 |
|
| 4 |
IMAGE_PATH = {
|
| 5 |
"sample_image_1": "example/0001TP_009240.png",
|
| 6 |
"sample_image_2": "example/0001TP_009240_L.png",
|
| 7 |
}
|
| 8 |
|
| 9 |
-
st.write("##")
|
| 10 |
-
|
| 11 |
with st.form(key="Image Comparison"):
|
| 12 |
# image one inputs
|
| 13 |
col1, col2 = st.columns([3, 1])
|
|
|
|
| 14 |
with col1:
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
with col2:
|
| 17 |
img1_text = st.text_input("Image one text:", value="Input")
|
| 18 |
|
| 19 |
# image two inputs
|
| 20 |
col1, col2 = st.columns([3, 1])
|
| 21 |
with col1:
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with col2:
|
| 24 |
img2_text = st.text_input("Image two text:", value="Labeled")
|
| 25 |
|
|
@@ -30,8 +38,8 @@ with st.form(key="Image Comparison"):
|
|
| 30 |
|
| 31 |
# render image-comparison
|
| 32 |
image_comparison(
|
| 33 |
-
img1=img1_url,
|
| 34 |
-
img2=img2_url,
|
| 35 |
label1=img1_text,
|
| 36 |
label2=img2_text,
|
| 37 |
)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_image_comparison import image_comparison
|
| 3 |
+
from PIL import Image
|
| 4 |
|
| 5 |
IMAGE_PATH = {
|
| 6 |
"sample_image_1": "example/0001TP_009240.png",
|
| 7 |
"sample_image_2": "example/0001TP_009240_L.png",
|
| 8 |
}
|
| 9 |
|
|
|
|
|
|
|
| 10 |
with st.form(key="Image Comparison"):
|
| 11 |
# image one inputs
|
| 12 |
col1, col2 = st.columns([3, 1])
|
| 13 |
+
|
| 14 |
with col1:
|
| 15 |
+
image_one = st.file_uploader("Upload image one:", type=["png", "jpg", "jpeg"])
|
| 16 |
+
if image_one:
|
| 17 |
+
img1_url = image_one
|
| 18 |
+
else:
|
| 19 |
+
img1_url = IMAGE_PATH["sample_image_1"]
|
| 20 |
with col2:
|
| 21 |
img1_text = st.text_input("Image one text:", value="Input")
|
| 22 |
|
| 23 |
# image two inputs
|
| 24 |
col1, col2 = st.columns([3, 1])
|
| 25 |
with col1:
|
| 26 |
+
image_two = st.file_uploader("Upload image two:", type=["png", "jpg", "jpeg"])
|
| 27 |
+
if image_two:
|
| 28 |
+
img2_url = image_two
|
| 29 |
+
else:
|
| 30 |
+
img2_url = IMAGE_PATH["sample_image_2"]
|
| 31 |
with col2:
|
| 32 |
img2_text = st.text_input("Image two text:", value="Labeled")
|
| 33 |
|
|
|
|
| 38 |
|
| 39 |
# render image-comparison
|
| 40 |
image_comparison(
|
| 41 |
+
img1=Image.open(img1_url),
|
| 42 |
+
img2=Image.open(img2_url),
|
| 43 |
label1=img1_text,
|
| 44 |
label2=img2_text,
|
| 45 |
)
|