Spaces:
Sleeping
Sleeping
import gradio as gr | |
from fastai.vision.all import * | |
# def greet(name): | |
# return "Hello " + name + "!!" | |
# demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
# demo.launch() | |
im = PILImage.create('victory.jpg') | |
im | |
learn = load_learner('clean_model.pkl') | |
learn.predict(im) | |
categories = ('victory hand sign photo','thumbs up human hand', 'thumbs down human hand') | |
def classify_image(img): | |
pred,idx,probs = learn.predict(img) | |
return(dict(zip(categories,map(float,probs)))) | |
print(classify_image(im)) | |
## | |
image = gr.Image(width=500, height = 256) | |
label = gr.Label() | |
examples = ['victory.jpg'] | |
intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples) | |
intf.launch(inline = False) | |