Swekerr's picture
Update app.py
05db21c verified
raw
history blame contribute delete
458 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
categories = [cat.capitalize() for cat in learn.dls.vocab]
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
image = gr.Image()
label = gr.Label()
examples = ['fresh.jpg', 'rotten.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)