Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
|
3 |
+
# def greet(name):
|
4 |
+
# return "Hello " + name + "!!"
|
5 |
+
|
6 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
# iface.launch()
|
8 |
+
|
9 |
+
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
10 |
+
|
11 |
import gradio as gr
|
12 |
+
from fastai.vision.all import *
|
13 |
+
|
14 |
+
|
15 |
+
def is_cat(x): return x[0].isupper()
|
16 |
+
|
17 |
+
learn = load_learner('model.pkl')
|
18 |
+
|
19 |
+
categories = ('Dog', 'Cat')
|
20 |
+
|
21 |
+
def classify_image(img):
|
22 |
+
pred, idx, probs =learn.predict(img)
|
23 |
+
return dict(zip(categories, map(float,probs)))
|
24 |
|
25 |
+
image= gr.inputsImage(shape=(192, 192))
|
26 |
+
label = gr.outputs.Label()
|
27 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
28 |
|
29 |
+
intf = gr.Interface(fr=classify_image, inputs=image, outputs=label, examples=examples)
|
30 |
+
intf.launch(inline=False)
|