Spaces:
Build error
Build error
# AUTOGENERATED! DO NOT EDIT! File to edit: drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'labels', 'predict'] | |
# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 1 | |
from fastai.vision.all import * | |
import skimage | |
# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 4 | |
learn = load_learner('export.pkl') | |
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))} | |
# %% drive/MyDrive/Colab Notebooks/fastbook/fastcourse/ch2minimal/tmabrahamgradio/gradiotest/gradiotest.ipynb 7 | |
import gradio as gr | |
#gr.Interface(fn=predict, inputs=gr.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3), title="Pet Breed Classifier", description="A pet breed classifier trained on the Oxford Pets dataset using the fastai library (5 epochs) as a proof of concept for Gradio.", article="<p style='text-align: center'><a href='https://gameologist.com/portfolio' target='_blank'>see more of my things here</a></p>", examples=['abys.jpg', 'download (3).jpg'], enable_queue=True).launch() | |
iface = gr.Interface(fn=predict, inputs=gr.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=3)) | |
iface.launch(); | |