File size: 1,307 Bytes
d014365
1e56fab
e9bcce2
d014365
14a317e
 
 
 
 
 
 
 
e9bcce2
14a317e
e9bcce2
 
 
 
 
14a317e
 
 
 
 
 
e9bcce2
 
 
 
 
14a317e
 
 
 
 
 
 
 
1e56fab
 
e9bcce2
 
14a317e
 
1e56fab
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
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,
)