test_space / app.py
danieladejumo's picture
Updated app.py
3a0a734
raw
history blame contribute delete
481 Bytes
import gradio as gr
from fastai.vision.all import *
learn = load_learner("bird_or_forest.pkl")
classes = ["Bird", "Forest"]
def classify_images(im):
cat, idx, probs = learn.predict(im)
return dict(zip(classes, map(float, probs)))
image = gr.Image()
label = gr.Label()
examples = ["forest.jpg", "bird.jpg"]
iface = gr.Interface(fn=classify_images,
inputs=image,
outputs=label,
examples=examples)
iface.launch()