Spaces:
Runtime error
Runtime error
import streamlit as st | |
from fastai.vision.all import * | |
learn = load_learner('stage-1_resnet.pkl') | |
categories = ('DR','NO_DR') | |
def classify_image(img): | |
img = PILImage.create(img) | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"]) | |
if uploaded_file is not None: | |
image = PILImage.create(uploaded_file) | |
st.image(image, caption='Uploaded Image.', use_column_width=True) | |
prediction = classify_image(image) | |
st.write("Prediction:", prediction) | |