Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
# demo.launch()
|
| 8 |
+
|
| 9 |
+
__all__=['is_cat','learn','classify_image','categories','image','label','examples','intf']
|
| 10 |
+
|
| 11 |
+
from fastai.vision.all import *
|
| 12 |
import gradio as gr
|
| 13 |
+
def is_cat(x): return x[0].isupper()
|
| 14 |
+
|
| 15 |
+
learn=load_learner('model.pkl')
|
| 16 |
+
|
| 17 |
+
categories=('Dog','Cat')
|
| 18 |
+
|
| 19 |
+
def classify_images(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.png','cat.png']
|
| 26 |
|
| 27 |
+
intf=gr.Interface(fn=classify_image,inputs=image,outputs=label,exampes=examples)
|
| 28 |
+
intf.launch(inline=Fale)
|