suhas1324 commited on
Commit
67ac345
1 Parent(s): 8a315a2
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner('stage-1_resnet.pkl')
5
+
6
+ categories = ('DR','NO_DR')
7
+
8
+ def classify_image(img):
9
+ img = PILImage.create(img)
10
+ pred, idx, probs = learn.predict(img)
11
+ return dict(zip(categories, map(float, probs)))
12
+
13
+ st.title('Image Classification with Fastai and Streamlit')
14
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
15
+
16
+ if uploaded_file is not None:
17
+ image = PILImage.create(uploaded_file)
18
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
19
+ prediction = classify_image(image)
20
+ st.write("Prediction:", prediction)