Spaces:
Runtime error
Runtime error
chamarak
commited on
Commit
•
0bce2af
1
Parent(s):
286bb97
modified codes
Browse files- app.py +24 -4
- images/cat.jpg +0 -0
- images/dog.jpg +0 -0
- images/pitbull.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,7 +1,27 @@
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
1 |
+
import pathlib
|
2 |
+
temp = pathlib.PosixPath
|
3 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
4 |
+
from fastai.vision.all import *
|
5 |
import gradio as gr
|
6 |
|
7 |
+
def is_pitbull(x): return 'american_pit_bull' in x.lower()
|
8 |
+
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
pathlib.PosixPath = temp
|
11 |
+
|
12 |
+
categories = ('not a Pitbull','a Pitbull')
|
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 |
+
|
22 |
+
|
23 |
+
examples = ['images\pitbull.jpg','images\cat.jpg','images\dog.jpg']
|
24 |
+
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|
27 |
|
|
|
|
images/cat.jpg
ADDED
![]() |
images/dog.jpg
ADDED
![]() |
images/pitbull.jpg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5282f116070110c9c90be6c7b9bd98e13a2ee046afb6e48c8d1a24487e4ec442
|
3 |
+
size 47063121
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
gradio==3.50
|