Spaces:
Runtime error
Runtime error
shravankumar147
commited on
Commit
•
3db1987
1
Parent(s):
dd432fa
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:94a95586fc417b6e28c88273f71000f399149454a01254e0755d0741ba973830
|
3 |
+
size 150
|
4 |
+
import gradio as gr
|
5 |
+
from fastai.vision.all import *
|
6 |
+
|
7 |
+
def is_cat(x): return x[0].isupper()
|
8 |
+
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
11 |
+
categories = ['Dog', 'Cat']
|
12 |
+
|
13 |
+
def classify_img(img):
|
14 |
+
pred, idx, probs = learn.predict(img)
|
15 |
+
return dict(zip(categories, map(float, probs)))
|
16 |
+
|
17 |
+
image = gr.inputs.Image(shape=(192,192))
|
18 |
+
label = gr.outputs.Label()
|
19 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
20 |
+
|
21 |
+
iface = gr.Interface(fn=classify_img, inputs=image, outputs=label)
|
22 |
+
iface.launch()
|