# 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)