forest / app.py
sbansal28's picture
Update app.py
536f151 verified
raw
history blame contribute delete
713 Bytes
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
from fastai.vision.all import *
import gradio as gr
learn = load_learner('foresty.pkl')
categories = ('Ant', 'Bird', 'Fern', 'Moss', 'Poison Oak', "Snail", "Squirrel", "Tree", "Wildflower")
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image=gr.Image(height = 192, width = 192)
label = gr.Label()
examples = ['ant.jpg', 'birde.jpg', 'fern.jpg', 'moss.jpg', 'poison_oak.jpg', "snail.jpg", 'squirrel.jpg', 'tree.JPG', "wildflower.jpg"]
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)