Commit
·
a2ddc94
1
Parent(s):
88e5e8e
penguin puffin classifier
Browse files- app.ipynb +24 -0
- app.py +16 -4
- model.pkl +3 -0
- penguin.jpg +0 -0
- puffin.jpg +0 -0
- razorbill.jpg +0 -0
app.ipynb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [],
|
| 3 |
+
"metadata": {
|
| 4 |
+
"kernelspec": {
|
| 5 |
+
"display_name": "base",
|
| 6 |
+
"language": "python",
|
| 7 |
+
"name": "python3"
|
| 8 |
+
},
|
| 9 |
+
"language_info": {
|
| 10 |
+
"codemirror_mode": {
|
| 11 |
+
"name": "ipython",
|
| 12 |
+
"version": 3
|
| 13 |
+
},
|
| 14 |
+
"file_extension": ".py",
|
| 15 |
+
"mimetype": "text/x-python",
|
| 16 |
+
"name": "python",
|
| 17 |
+
"nbconvert_exporter": "python",
|
| 18 |
+
"pygments_lexer": "ipython3",
|
| 19 |
+
"version": "3.11.7"
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"nbformat": 4,
|
| 23 |
+
"nbformat_minor": 2
|
| 24 |
+
}
|
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
__all__ = []
|
| 2 |
+
|
| 3 |
+
from fastai.vision.all import *
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
learn = load_learner('model.pkl')
|
| 7 |
+
|
| 8 |
+
categories = ('Penguin', 'Puffin')
|
| 9 |
+
|
| 10 |
+
def classifyImage(img):
|
| 11 |
+
pred, idx, prob = learn.predict(img)
|
| 12 |
+
return dict(zip(categories, map(float, prob)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 15 |
+
label = gr.outputs.Label()
|
| 16 |
+
examples = ['penguin.jpg', 'puffin.png', 'razorbill.jpg']
|
| 17 |
|
| 18 |
+
intf = gr.Interface(fn=classifyImage, inputs=image, outputs=label, examples=examples)
|
| 19 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4d85516845e2e08ed9e25d7353cd6b4fc93e345a3355aac58aba800f8155092
|
| 3 |
+
size 46971390
|
penguin.jpg
ADDED
|
puffin.jpg
ADDED
|
razorbill.jpg
ADDED
|