|
|
|
|
|
|
|
__all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] |
|
|
|
|
|
from fastai.vision.all import * |
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
|
|
learner = load_learner("model2.pkl") |
|
|
|
|
|
categories = ("black", "grizzly", "teddy") |
|
|
|
def classify_image(im): |
|
pred, idx, probs = learner.predict(im) |
|
return dict(zip(categories, map(float, probs))) |
|
|
|
|
|
|
|
image = gr.inputs.Image(shape=(192, 192)) |
|
label = gr.outputs.Label() |
|
examples = ["teddy.jpg", "grizzly.jpg", "black.jpg"] |
|
|
|
|
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |
|
|