Spaces:
Runtime error
Runtime error
File size: 881 Bytes
b9c80a4 9cd690d b9c80a4 9cd690d b9c80a4 9cd690d b9c80a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'pet_class', 'classify_image']
# %% ../app.ipynb 1
from fastai.vision.all import *
import gradio as gr
import io
from PIL import Image
def pet_class(x): return x
# %% ../app.ipynb 3
learn = load_learner('model.pkl')
# %% ../app.ipynb 6
categories = ('basketball ball','golf ball', 'rugby ball', 'soccer ball')
def classify_image(img):
pred_class, pred_idx, probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% ../app.ipynb 8
image = gr.components.Image(shape=(192,192))
label = gr.components.Label()
examples = ['basketball.png', 'golf_ball.jpg', 'rugby_ball.jpg', 'soccer_ball.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)
|