Spaces:
Runtime error
Runtime error
Richard Hsu
commited on
Commit
·
1643eec
1
Parent(s):
c6e892e
updating app
Browse files
app.py
CHANGED
|
@@ -1,7 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
| 3 |
def greet(name):
|
| 4 |
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
from fastai.vision.all import *
|
| 4 |
+
|
| 5 |
def greet(name):
|
| 6 |
return "Hello " + name + "!!"
|
| 7 |
|
| 8 |
+
|
| 9 |
+
categories = ('dog', 'cat')
|
| 10 |
+
def is_cat(x): return x[0].isupper()
|
| 11 |
+
|
| 12 |
+
learner = load_learner("./model.pkl")
|
| 13 |
+
def classify(img):
|
| 14 |
+
pred, idx, probs = learner.predict(img)
|
| 15 |
+
return dict(zip(categories, map(float, probs)))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 20 |
+
label = gr.outputs.Label()
|
| 21 |
+
examples = ['cat.jpeg', 'dog.jpeg', 'Teddy.jpeg']
|
| 22 |
+
demo = gr.Interface(fn=classify, inputs=image, outputs=label)
|
| 23 |
+
demo.launch(inline = False)
|
| 24 |
+
|