Spaces:
Runtime error
Runtime error
File size: 540 Bytes
1527ca0 980c10f 1527ca0 980c10f 1527ca0 980c10f e860bdd 980c10f adff6fa 980c10f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from fastai.vision.all import *
#load the model
learn = load_learner('nothotdog.pkl')
#define the classifier function
categories = ('HotDog', 'Not HotDog')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories,map(float,probs)))
#Gradio interface
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['1.jpg','2.jpg','3.png','4.jpg']
intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
intf.launch(inline=False)
|