File size: 683 Bytes
011ba28 725f017 011ba28 6a9201c 011ba28 725f017 2d1f37c 011ba28 077bc8e 011ba28 077bc8e 011ba28 6a9201c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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]
|