Spaces:
Sleeping
Sleeping
Commit
·
060ee2c
1
Parent(s):
d3bde7c
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#|export
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def is_cat(x): return x[0].isupper()
|
6 |
+
|
7 |
+
categories = ('Dog', 'Cat')
|
8 |
+
|
9 |
+
|
10 |
+
labels = learn.dls.vocab
|
11 |
+
def classify_image(img):
|
12 |
+
pred, idx, probs = learn.predict(image)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
|
16 |
+
img = gr.inputs.Image((192, 192))
|
17 |
+
label = gr.outputs.Label()
|
18 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
19 |
+
|
20 |
+
intf = gr.Interface(fn=classify_image, inputs=img, outputs=label, examples=examples)
|
21 |
+
intf.launch(inline=False)
|
22 |
+
|
cat.jpg
ADDED
![]() |
dog.jpg
ADDED
![]() |
dunno.jpg
ADDED
![]() |