|
|
|
|
|
|
|
__all__ = ['learn', 'searches', 'title', 'description', 'examples', 'demo', 'classify_image']
|
|
|
|
|
|
from fastai.vision.all import *
|
|
import gradio as gr
|
|
|
|
|
|
learn = load_learner(Path("model.pkl"))
|
|
|
|
|
|
searches = ("grizzly bears","black bears","teddy bears")
|
|
|
|
def classify_image(img):
|
|
pred,idx,probs = learn.predict(img)
|
|
return dict(zip(searches, map(float,probs)))
|
|
|
|
|
|
title = "FastAi demo"
|
|
description = "This demo is the original"
|
|
examples = ["grizzly.jpg"]
|
|
|
|
|
|
demo = gr.Interface(
|
|
fn=classify_image,
|
|
inputs="image",
|
|
outputs="label",
|
|
title=title,
|
|
description=description,
|
|
examples = examples)
|
|
demo.launch()
|
|
|