Odin-son
change url to upload
e9bcce2
import streamlit as st
from streamlit_image_comparison import image_comparison
from PIL import Image
IMAGE_PATH = {
"sample_image_1": "example/0001TP_009240.png",
"sample_image_2": "example/0001TP_009240_L.png",
}
with st.form(key="Image Comparison"):
# image one inputs
col1, col2 = st.columns([3, 1])
with col1:
image_one = st.file_uploader("Upload image one:", type=["png", "jpg", "jpeg"])
if image_one:
img1_url = image_one
else:
img1_url = IMAGE_PATH["sample_image_1"]
with col2:
img1_text = st.text_input("Image one text:", value="Input")
# image two inputs
col1, col2 = st.columns([3, 1])
with col1:
image_two = st.file_uploader("Upload image two:", type=["png", "jpg", "jpeg"])
if image_two:
img2_url = image_two
else:
img2_url = IMAGE_PATH["sample_image_2"]
with col2:
img2_text = st.text_input("Image two text:", value="Labeled")
# centered submit button
col1, col2, col3 = st.columns([6, 4, 6])
with col2:
submit = st.form_submit_button("Update Render 🔥")
# render image-comparison
image_comparison(
img1=Image.open(img1_url),
img2=Image.open(img2_url),
label1=img1_text,
label2=img2_text,
)