File size: 870 Bytes
da269cf
82b1e45
 
da269cf
82b1e45
 
da269cf
82b1e45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cc65aa
da269cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('model.pkl')
labels = learn.dls.vocab

categories = ('diffenbachia', 'spider', 'monstera')


def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "Plant Classifier Classifier"
description = "A plant classifier I made with with fastai. Created as a demo for Gradio and HuggingFace Spaces."
interpretation='default'
examples = [
    ["images/diffenbachia.jpg"],
    ["images/spider.jpg"],
    ["images/monstera.jpg"]
]
article="<p style='text-align: center'><a href='https://lucasgelfond.substack.com/p/fastai-lesson-2-deployment' target='_blank'>Blog post</a></p>"
enable_queue=True

iface = gr.Interface(fn=predict, inputs="image", outputs="label")
iface.launch()