Spaces:
Runtime error
Runtime error
Manuel Araoz
commited on
Commit
•
35092a1
1
Parent(s):
7880578
cat vs dog
Browse files
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env/
|
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 |
import gradio as gr
|
2 |
|
|
|
|
|
3 |
|
4 |
+
from fastai.vision.all import *
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
import pathlib
|
8 |
+
temp = pathlib.PosixPath
|
9 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
10 |
+
|
11 |
+
def is_cat(x): return x[0].isupper()
|
12 |
+
|
13 |
+
learn = load_learner('model.pkl')
|
14 |
+
|
15 |
+
categories = ('Dog', 'Cat')
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
def classify_image(img):
|
20 |
+
pred, idx, probs = learn.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', 'dunno.jpg']
|
26 |
+
|
27 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
28 |
+
intf.launch()
|
cat.jpg
ADDED
dog.jpg
ADDED
dunno.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bfae5f3f50aa28a32430e4f0f7478cf945d855543d71c9a3a4451485b3471d1e
|
3 |
+
size 87564011
|