Spaces:
Runtime error
Runtime error
File size: 1,369 Bytes
1223358 e0800ba | 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 32 33 34 35 36 37 38 39 40 41 | # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
# %% auto 0
__all__ = ['path', 'learn', 'labels', 'title', 'description', 'pred']
# %% ../app.ipynb 2
from fastai.vision.all import *
import gradio as gr
# %% ../app.ipynb 3
path = Path()
# path.ls(file_exts='.pkl')
# %% ../app.ipynb 5
learn = load_learner(path/'model.pkl')
# %% ../app.ipynb 6
labels = learn.dls.vocab #['animals', 'digimons', 'pokemon']
# %% ../app.ipynb 26
def pred(img):
img = PILImage.create(img)
pred, pred_idx, prob = learn.predict(img)
return {labels[i]: float(prob[i]) for i in range(len(labels))}
# %% ../app.ipynb 28
title = 'Pokemon, Digimon, or Animal?'
description = '''
Pokemon and Digimon are popular franchises with many monster designs, as described by their titles (Pocket Monsters
and Digital Monsters, respectively). Many lot of their designs are based on or take inspiration from real animals. Despite this, people
familiar with at least one of these franchises can usually discern these monsters as Pokemon or Digimon. This model attempts to do the same.
'''
gr.Interface(fn=pred,
inputs=gr.Image(type='pil', sources=['upload', 'clipboard']),
outputs='label',
title=title,
description=description,
examples='examples',
theme='gradio/monochrome').launch(share=True)
|