beartype / app.py
leftbyte's picture
wrap the zip object in a dict
6a9201c
Raw History Blame Contribute Delete
683 Bytes
from fastai.vision.all import *
import gradio as gr
categories = ('black', 'grizzly', 'teddy')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
def greet(name):
return "Hello " + name + "!!"
# gr.Interface(fn=greet, inputs="text", outputs="text").launch
learn = load_learner('model/bears.pkl')
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['images/black.jpg', 'images/grizzly.jpg', 'images/teddy.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)
# m = learn.model
# ps = list(m.parameters())
# ps[1]