Spaces:
Runtime error
Runtime error
shamita
commited on
Commit
•
f89b49d
1
Parent(s):
b2c0b70
dog v cat
Browse files- app.py +25 -4
- catdog.jpg +0 -0
- catjpg +0 -0
- dog.jpg +0 -0
- model.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from doctest import Example
|
2 |
import gradio as gr
|
3 |
+
from fastai.vision.all import *
|
4 |
|
|
|
|
|
5 |
|
6 |
+
# def greet(name):
|
7 |
+
# return "Hello " + name + "!!"
|
8 |
+
|
9 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
10 |
+
# iface.launch()
|
11 |
+
|
12 |
+
|
13 |
+
def is_cat(x): return x[0].isupper()
|
14 |
+
|
15 |
+
learner = load_learner('model.pkl')
|
16 |
+
|
17 |
+
categories = ('Dog', 'Cat')
|
18 |
+
|
19 |
+
def classify_image(img):
|
20 |
+
pred, idx, probs = learner.predict(img)
|
21 |
+
return dict(zip(categories, map(float, probs)))
|
22 |
+
|
23 |
+
image = gr.inputs.Image(shape=(192, 192))
|
24 |
+
label = gr.outputs.Label
|
25 |
+
examples = ['dog.jpg', 'cat.jpg', 'catdog.jpg']
|
26 |
+
|
27 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
28 |
+
intf.launch(inline=False)
|
catdog.jpg
ADDED
catjpg
ADDED
Binary file (104 kB). View file
|
|
dog.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d21abaae5ec269f772eef6ce016ba050a031f3ccfd406b0f5408a86301e69c1
|
3 |
+
size 47065259
|