eekaiboon's picture
Rename the main python file to app.py
095fb1a
raw
history blame contribute delete
No virus
837 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: samoyed_classifier.ipynb.
# %% auto 0
__all__ = ['learn', 'labels', 'title', 'examples', 'demo', 'predict']
# %% samoyed_classifier.ipynb 26
from fastai.vision.all import *
import gradio as gr
# %% samoyed_classifier.ipynb 27
learn = load_learner('models/samoyed_classifier.pkl')
# %% samoyed_classifier.ipynb 28
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))}
# %% samoyed_classifier.ipynb 29
title = "Samoyed Classifier"
examples = ['test/samoyed_1.jpg']
demo = gr.Interface(fn=predict,
inputs="image",
outputs="label",
title=title,
examples=examples)
demo.launch()