Spaces:
Runtime error
Runtime error
Add application file
Browse files- Insects.ipynb +0 -0
- app.py +46 -0
- caterpillar-2.jpg +0 -0
- caterpillar.jpg +0 -0
- centipede.jpg +0 -0
- millipede.jpg +0 -0
- requirements.txt +2 -0
- training/.ipynb_checkpoints/Centipede vs Millipede vs Caterpillar-checkpoint.ipynb +0 -0
- training/Centipede vs Millipede vs Caterpillar.ipynb +0 -0
Insects.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
|
| 2 |
+
|
| 3 |
+
__all__ = ['repo_id', 'learn', 'classify_image', 'categories', 'title', 'description', 'article', 'image', 'label',
|
| 4 |
+
'examples', 'intf']
|
| 5 |
+
|
| 6 |
+
# Cell
|
| 7 |
+
import timm
|
| 8 |
+
from fastai.vision.all import *
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
+
# Cell
|
| 12 |
+
from huggingface_hub import from_pretrained_fastai
|
| 13 |
+
|
| 14 |
+
repo_id = "Jimmie/identify-this-insect"
|
| 15 |
+
|
| 16 |
+
learn = from_pretrained_fastai(repo_id)
|
| 17 |
+
|
| 18 |
+
# Cell
|
| 19 |
+
categories = learn.dls.vocab
|
| 20 |
+
|
| 21 |
+
def classify_image(img):
|
| 22 |
+
pred,idx,probs = learn.predict(img)
|
| 23 |
+
return dict(zip(categories, map(float, probs)))
|
| 24 |
+
|
| 25 |
+
# Cell
|
| 26 |
+
|
| 27 |
+
title = "Identify This Insect"
|
| 28 |
+
description = """
|
| 29 |
+
|
| 30 |
+
This demo was created to distinguish between three types of insects: 'caterpillar', 'centipede', and 'millipede'.
|
| 31 |
+
|
| 32 |
+
It is just a toy app created mostly because I once got a caterpillar sting and thought that the insect was a centipede and I was scared until I
|
| 33 |
+
googled how different a centipede looks from a caterpillar haha! (The insect that had stung me looked more like the fourth example image below).
|
| 34 |
+
|
| 35 |
+
Enjoy!
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
article = "Check out how the model was trained: [Training Notebook](https://github.com/jimmiemunyi/deeplearning-experiments/blob/main/notebooks/Centipede_vs_Millipede_vs_Caterpillar.ipynb)."
|
| 41 |
+
image = gr.inputs.Image(shape=(224,224))
|
| 42 |
+
label = gr.outputs.Label()
|
| 43 |
+
examples = ['caterpillar.jpg', 'centipede.jpg', 'millipede.jpg', 'caterpillar-2.jpg']
|
| 44 |
+
|
| 45 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title = title, description = description, article = article)
|
| 46 |
+
intf.launch(inline=False)
|
caterpillar-2.jpg
ADDED
|
caterpillar.jpg
ADDED
|
centipede.jpg
ADDED
|
millipede.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai==2.7.4
|
| 2 |
+
tim==0.6.5
|
training/.ipynb_checkpoints/Centipede vs Millipede vs Caterpillar-checkpoint.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training/Centipede vs Millipede vs Caterpillar.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|