pksx01's picture
Adding files for Deploying gradio app to Huggingface spaces
bad1e90
raw
history blame contribute delete
686 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'interface', 'predict']
# %% app.ipynb 3
from fastai.vision.all import *
import gradio as gr
# %% app.ipynb 4
learn = load_learner('lamborghini_vs_mercedes_model.pkl')
# %% app.ipynb 5
categories = ('lamborghini', 'mercedes')
def predict(img):
pred, idx, prob = learn.predict(img)
return dict(zip(categories, map(float, prob)))
# %% app.ipynb 7
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
interface = gr.Interface(fn=predict, inputs=image, outputs=label, examples=['lambo1.jpg', 'mercedes1.jpg'])
interface.launch(inline=False)