Spaces:
Sleeping
Sleeping
root
commited on
Commit
·
7169c5a
1
Parent(s):
b129a3a
Adding dog cat classifier
Browse files- .gitattributes +1 -0
- app.ipynb +28 -0
- app.py +23 -4
- cat.jpg +0 -0
- dog.jpg +0 -0
- dunno.jpg +0 -0
- model.pkl +3 -0
- model.pkl:Zone.Identifier +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model.pkl filter=lfs diff=lfs merge=lfs -text
|
app.ipynb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"#|default_exp app "
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": null,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": []
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"metadata": {
|
| 21 |
+
"language_info": {
|
| 22 |
+
"name": "python"
|
| 23 |
+
},
|
| 24 |
+
"orig_nbformat": 4
|
| 25 |
+
},
|
| 26 |
+
"nbformat": 4,
|
| 27 |
+
"nbformat_minor": 2
|
| 28 |
+
}
|
app.py
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
|
| 2 |
+
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
| 3 |
+
|
| 4 |
+
# cell
|
| 5 |
+
from fastai.vision.all import *
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
+
def is_cat(x): return x[0].isupper()
|
| 9 |
+
|
| 10 |
+
# cell
|
| 11 |
+
learn = load_learner('model.pkl')
|
| 12 |
+
|
| 13 |
+
# cell
|
| 14 |
+
categories = ('Dog', 'Cat')
|
| 15 |
+
|
| 16 |
+
def classify_image(img):
|
| 17 |
+
preds, idx, probs = learn.predict(img)
|
| 18 |
+
return dict(zip(categories, map(float, probs)))
|
| 19 |
+
|
| 20 |
+
# cell
|
| 21 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 22 |
+
label = gr.outputs.Label()
|
| 23 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 24 |
|
| 25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 26 |
+
intf.launch(inline=False)
|
cat.jpg
ADDED
|
dog.jpg
ADDED
|
dunno.jpg
ADDED
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c564616285b915f15a4a14c2faacd95f9411d696862fc704cb0abf8a83dc8093
|
| 3 |
+
size 47063185
|
model.pkl:Zone.Identifier
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ZoneTransfer]
|
| 2 |
+
ZoneId=3
|
| 3 |
+
HostUrl=about:internet
|