Spaces:
Runtime error
Runtime error
TrackLab commited on
Commit ·
eefdc67
1
Parent(s): d0ea057
AnimalClassifier
Browse files- app.py +18 -2
- both.jpg +0 -0
- both.jpgZone.Identifier +4 -0
- cat.jpg +0 -0
- cat.jpgZone.Identifier +4 -0
- dog.jpg +0 -0
- dog.jpgZone.Identifier +4 -0
- model.pkl +3 -0
- model.pklZone.Identifier +3 -0
app.py
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def is_cat(x): return x[0].isupper()
|
| 5 |
+
|
| 6 |
+
learn = load_learner('model.pkl')
|
| 7 |
+
|
| 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 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 15 |
+
label = gr.outputs.Label()
|
| 16 |
+
examples = ['dog.jpg', 'cat.jpg', 'both.jpg']
|
| 17 |
+
|
| 18 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 19 |
+
intf.launch(inline=False)
|
both.jpg
ADDED
|
both.jpgZone.Identifier
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ZoneTransfer]
|
| 2 |
+
ZoneId=3
|
| 3 |
+
ReferrerUrl=https://i.quotev.com/img/q/u/18/12/14/6kvdklhj2h.jpg
|
| 4 |
+
HostUrl=https://i.quotev.com/img/q/u/18/12/14/6kvdklhj2h.jpg
|
cat.jpg
ADDED
|
cat.jpgZone.Identifier
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ZoneTransfer]
|
| 2 |
+
ZoneId=3
|
| 3 |
+
ReferrerUrl=https://pixnio.com/free-images/2017/09/26/2017-09-26-09-28-58-823x825.jpg
|
| 4 |
+
HostUrl=https://pixnio.com/free-images/2017/09/26/2017-09-26-09-28-58-823x825.jpg
|
dog.jpg
ADDED
|
dog.jpgZone.Identifier
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ZoneTransfer]
|
| 2 |
+
ZoneId=3
|
| 3 |
+
ReferrerUrl=https://www.publicdomainpictures.net/pictures/40000/velka/cute-dog-1362593345bn4.jpg
|
| 4 |
+
HostUrl=https://www.publicdomainpictures.net/pictures/40000/velka/cute-dog-1362593345bn4.jpg
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46ad4f27fe07e450c2c1ff42b0ffd8dfec9ccf492660605a7e078aba082b26b7
|
| 3 |
+
size 47061483
|
model.pklZone.Identifier
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ZoneTransfer]
|
| 2 |
+
ZoneId=3
|
| 3 |
+
HostUrl=about:internet
|