Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- .gitattributes +1 -0
- app.py +21 -0
- cats_dogs.pk1 +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
cats_dogs.pk1 filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = ['is_cat', 'learner_pets', 'categories', 'classify_pet', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
from fastai.vision.all import *
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
def is_cat(x): return x[0].isupper()
|
7 |
+
|
8 |
+
learner_pets = load_learner('cats_dogs.pk1')
|
9 |
+
categories = ['Dog', 'Cat']
|
10 |
+
|
11 |
+
def classify_pet(img):
|
12 |
+
prediction, index, probability = learner_pets.predict(img)
|
13 |
+
return dict(zip(categories, map(float, probability)))
|
14 |
+
|
15 |
+
intf = gr.Interface(fn=classify_pet,
|
16 |
+
inputs=gr.Image(shape=(192, 192)),
|
17 |
+
outputs=gr.Label(),
|
18 |
+
examples=['dog.jpeg', 'cat.png', 'not_sure.jpeg'])
|
19 |
+
intf.launch(inline=False)
|
20 |
+
|
21 |
+
|
cats_dogs.pk1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7503282d639e3546ac7aceef1c955a087f9a70c3477460dae690c837fdae130
|
3 |
+
size 47065195
|