-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.py
38 lines (31 loc) · 1.26 KB
/
test.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
import streamlit as st
from PIL import Image
import pandas as pd
st.set_page_config(layout="wide", page_title="M3 demo", page_icon=":green_apple:")
st.header('What diseases can be predicted from Chest X-ray images?')
MAX_FILE_SIZE = 5 * 1024 * 1024 # 5MB
image_num = 1
df = pd.read_csv('result.csv')
col1, col2 = st.columns(2)
my_upload = st.sidebar.file_uploader("Upload an image :gear:", type=["png", "jpg", "jpeg"])
def show_image(upload):
image = Image.open(upload)
col1.write("X-ray Image :camera:")
col1.image(image)
col2.write("Prediction by Few-shot Learning :mag:")
col2.info(df['1-shot'][df['i']==int(image_num)].values[0], icon="1️⃣")
col2.info(df['10-shot'][df['i']==int(image_num)].values[0], icon="🔟")
# col2.markdown('---')
col2.write("Actual Label")
col2.warning(df['label'][df['i']==int(image_num)].values[0], icon="👀")
# col2.success('This is correct.', icon="⭕️")
# col2.error('This is wrong.', icon="❌")
# st.balloons()
if my_upload is not None:
image_num = my_upload.name[:-4]
if my_upload.size > MAX_FILE_SIZE:
st.error("The uploaded file is too large. Please upload an image smaller than 5MB.")
else:
show_image(upload=my_upload)
else:
show_image("test/1.jpg")