minima / app.py
jhowardjr's picture
add last two examples
0f69abe
raw
history blame contribute delete
No virus
703 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: is_a_cat.ipynb.
# %% auto 0
__all__ = ['learn', 'labels', 'examples', 'is_cat', 'predict']
# %% is_a_cat.ipynb 1
from fastai.vision.all import *
import gradio as gr
def is_cat(x): return x[0].isupper()
# %% is_a_cat.ipynb 2
learn = load_learner('model.pkl')
# %% is_a_cat.ipynb 3
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
# %% is_a_cat.ipynb 4
examples = ["example1.webp","example2.webp","example3.webp"]
gr.Interface(fn=predict, inputs="image", examples=examples, outputs="label").launch(share=False)