the-goat / app.py
Peter Kibuchi
Update Application
caf9f8a unverified
raw
history blame
849 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'path', 'examples', 'intf', 'classify_img']
# %% ../app.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% ../app.ipynb 2
learn = load_learner("model.pkl")
# %% ../app.ipynb 3
categories = learn.dls.vocab
def classify_img(img):
pred_class, pred_idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# %% ../app.ipynb 4
from pathlib import Path
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
path = Path("examples")
examples = [file for file in path.iterdir()]
intf = gr.Interface(
fn=classify_img,
inputs=image,
outputs=label,
examples=examples,
title="The GOAT",
description="Is it The GOAT?",
)
intf.launch(inline=False)