dinoclass / app.py
oggyxe's picture
Update app.py
153ed78 verified
raw
history blame contribute delete
750 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: ../dino.ipynb.
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'demo', 'classify']
# %% ../dino.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% ../dino.ipynb 3
learn = load_learner('export.pkl')
# %% ../dino.ipynb 5
categories = ('ankylosaurus', 'brontosaurus', 'pterodactyl', 'trex', 'triceraptops')
def classify(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% ../dino.ipynb 7
image = gr.Image(width=512, height=512)
label = gr.Label(num_top_classes=3)
examples = ['ankylosaurus.jpg', 'images.jpeg']
demo = gr.Interface(fn=classify, inputs=image, outputs=label, examples=examples)
demo.launch(inline=False)