Spaces:
Runtime error
Runtime error
Dev Patel commited on
Commit ·
08b90ae
1
Parent(s): bcc3395
fix: add cat sample images
Browse files- .gitignore +2 -0
- app.py +44 -4
- images/cat1.jpg +0 -0
- images/cat2.jpg +0 -0
- images/cat3.jpg +0 -0
- images/db.jpg +0 -0
- images/dog1.jpg +0 -0
- images/dog2.jpg +0 -0
- images/dog3.jpg +0 -0
- images/dog4.jpg +0 -0
- images/pug1.jpg +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.pkl
|
| 2 |
+
model/
|
app.py
CHANGED
|
@@ -1,9 +1,49 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
|
|
|
|
|
|
| 8 |
if __name__ == "__main__":
|
| 9 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
def is_cat(x):
|
| 6 |
+
if x[0].isupper():
|
| 7 |
+
return 'cat'
|
| 8 |
+
else:
|
| 9 |
+
return 'dog'
|
| 10 |
+
|
| 11 |
+
learn_inference = load_learner('./model/is_Cat_resnet.pkl')
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def image_mod(image):
|
| 16 |
+
detect, _, predict = learn_inference.predict(image)
|
| 17 |
+
return detect
|
| 18 |
|
| 19 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 20 |
+
label = gr.outputs.Label()
|
| 21 |
+
examples=[
|
| 22 |
+
"images/db.jpg",
|
| 23 |
+
"images/dog2.jpg",
|
| 24 |
+
"images/cat3.jpg",
|
| 25 |
+
"images/dog4.jpg",
|
| 26 |
+
"images/pug1.jpg",
|
| 27 |
+
"images/cat2.jpg",
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# examples=[
|
| 31 |
+
# os.path.join(os.path.dirname(__file__), "images/db.jpg"),
|
| 32 |
+
# os.path.join(os.path.dirname(__file__), "images/dog1.jpg"),
|
| 33 |
+
# os.path.join(os.path.dirname(__file__), "images/dog2.jpg"),
|
| 34 |
+
# os.path.join(os.path.dirname(__file__), "images/dog3.jpg"),
|
| 35 |
+
# os.path.join(os.path.dirname(__file__), "images/dog4.jpg"),
|
| 36 |
+
# os.path.join(os.path.dirname(__file__), "images/pug1.jpg"),
|
| 37 |
+
# ]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
demo = gr.Interface(
|
| 41 |
+
image_mod,
|
| 42 |
+
inputs = image,
|
| 43 |
+
outputs = label,
|
| 44 |
+
examples = examples
|
| 45 |
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
if __name__ == "__main__":
|
| 49 |
+
demo.launch()
|
images/cat1.jpg
ADDED
|
images/cat2.jpg
ADDED
|
images/cat3.jpg
ADDED
|
images/db.jpg
ADDED
|
images/dog1.jpg
ADDED
|
images/dog2.jpg
ADDED
|
images/dog3.jpg
ADDED
|
images/dog4.jpg
ADDED
|
images/pug1.jpg
ADDED
|