Spaces:
Sleeping
Sleeping
pushing first DL model to huggingface
Browse files- .DS_Store +0 -0
- CatsClassifier.pkl +3 -0
- ambiguous.jpg +0 -0
- app.py +20 -4
- cat.jpg +0 -0
- dog.jpg +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
CatsClassifier.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5589472f554647dbf4115edfd518b01583038316943b0e699cc031e0038bb71c
|
3 |
+
size 47061355
|
ambiguous.jpg
ADDED
![]() |
app.py
CHANGED
@@ -1,9 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
|
4 |
-
def
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
_all_ = ['is_cat', 'learn', 'classify_image',
|
4 |
+
'categories', 'image', 'label', 'examples', 'intf']
|
5 |
|
6 |
|
7 |
+
def is_cat(x): return x[0].isupper()
|
|
|
8 |
|
9 |
|
10 |
+
learn = load_learner('CatsClassifier.pkl')
|
11 |
+
categories = ("Dog", "Cat")
|
12 |
+
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred, idx, probs = learn.predict(img)
|
16 |
+
return dict(zip(categories, map(float, probs)))
|
17 |
+
|
18 |
+
|
19 |
+
image = gr.inputs.Image(shape=(192, 192))
|
20 |
+
label = gr.outputs.Label()
|
21 |
+
examples = ['dog.jpg', 'cat.jpeg', 'ambiguous.jpg']
|
22 |
+
|
23 |
+
intf = gr.Interface(fn=classify_image, inputs=image,
|
24 |
+
outputs=label, examples=examples)
|
25 |
+
intf.launch(inline=False)
|
cat.jpg
ADDED
![]() |
dog.jpg
ADDED
![]() |