Spaces:
Sleeping
Sleeping
Kirubel Tadesse
commited on
Commit
•
5be6dbb
1
Parent(s):
45ae6f0
add cat-dog classifyer model
Browse files- .gitignore +1 -0
- app.py +19 -4
- cat.jpeg +0 -0
- dog.jpeg +0 -0
- images.jpeg +0 -0
- model.pkl +3 -0
- requirements.txt +1 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradenv/*
|
app.py
CHANGED
@@ -1,9 +1,24 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
+
from networkx import center
|
4 |
|
5 |
+
def is_cat(x): return x[0].isupper()
|
6 |
|
7 |
+
learn = load_learner('model.pkl')
|
8 |
+
categories = ('Dog', 'Cat')
|
9 |
|
10 |
+
def classify_image(img):
|
11 |
+
pred,idx,probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float,probs)))
|
13 |
|
14 |
+
|
15 |
+
|
16 |
+
demo = gr.Interface(
|
17 |
+
fn=classify_image,
|
18 |
+
inputs=gr.Image(height=224, width=224, label="Upload Image"),
|
19 |
+
outputs=gr.Label(),
|
20 |
+
examples=['dog.jpeg', 'cat.jpeg', 'images.jpeg']
|
21 |
+
)
|
22 |
+
|
23 |
+
# lanuch the interface
|
24 |
+
demo.launch(share=True)
|
cat.jpeg
ADDED
dog.jpeg
ADDED
images.jpeg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2a53685764edf0c265be2c3e02073e7e1aed8d37dffcb87a08b372026dcb116
|
3 |
+
size 47059947
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastbook
|