Spaces:
Runtime error
Runtime error
File size: 494 Bytes
801ca3a 3c5f505 801ca3a 3c5f505 801ca3a 3c5f505 801ca3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
from fastai.vision.all import *
im = PILImage.create('paramecium.jpg')
examples = ['paramecium.jpg']
learn = load_learner('microbe_model.pkl')
def classify_image(img):
category_name, _, probs = learn.predict(img)
categories = learn.dls.vocab
return {category: f"{prob:.4f}" for category, prob in zip(categories, probs.tolist())}
iface = gr.Interface(fn=classify_image, inputs="image",
outputs="label", examples=examples)
iface.launch()
|