Spaces:
Sleeping
Sleeping
import warnings | |
from fastai.vision.all import * | |
import gradio as gr | |
warnings.simplefilter("ignore", category=UserWarning) | |
learn = load_learner('model.pkl') | |
warnings.resetwarnings() | |
categories = ('Bee', 'Wasp') | |
def classify_image(img): | |
_, _, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.Image() | |
label = gr.Label() | |
examples = ['bee.jpg', 'wasp.jpg'] | |
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
interface.launch(inline=False) |