# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. # %% auto 0 __all__ = ['repo_id', 'learner', 'path', 'categories', 'title', 'description', 'article', 'image', 'label', 'examples', 'intf', 'classify_image'] # %% app.ipynb 2 from fastai.vision.all import * from huggingface_hub import from_pretrained_fastai import gradio as gr # %% app.ipynb 3 repo_id = "Jimmie/snake-image-classification" # loading the model from huggingface_hub learner = from_pretrained_fastai(repo_id) # %% app.ipynb 4 path = Path('demo-images/') # %% app.ipynb 14 categories = tuple(learner.dls.vocab) def classify_image(img): pred,idx,probs = learner.predict(img) return dict(zip(categories, map(float, probs))) # %% app.ipynb 16 title = "Snake Image Classification" description = """ This demo is an ongoing iteration of a [bigger project](https://github.com/jimmiemunyi/the-snake-project) meant to classify snakes as venomous or non-venomous. Currently, it can classify snakes into 10 genera. The model can be found here: https://huggingface.co/Jimmie/snake-image-classification Enjoy! """ article = "Blog posts on how the model is being trained: ." image = gr.inputs.Image(shape=(224, 224)) label = gr.outputs.Label() examples = list(path.ls()) intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title = title, description = description, article = article, enable_queue=True, cache_examples=False) intf.launch(inline=False)