space3 / .ipynb_checkpoints /app-checkpoint.py
Benedict Thekkel
update
ac9ad30
raw
history blame contribute delete
811 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'searches', 'title', 'description', 'examples', 'demo', 'classify_image']
# %% app.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% app.ipynb 5
learn = load_learner(Path("model.pkl"))
# %% app.ipynb 7
searches = ("grizzly bears","black bears","teddy bears")
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(searches, map(float,probs)))
# %% app.ipynb 9
title = "FastAi demo"
description = "This demo is the original"
examples = ["grizzly.jpg"]
# %% app.ipynb 10
demo = gr.Interface(
fn=classify_image,
inputs="image",
outputs="label",
title=title,
description=description,
examples = examples)
demo.launch()