Spaces:
Runtime error
Runtime error
jaypinedabengco
commited on
Commit
·
1215df2
1
Parent(s):
d0cf2eb
Test
Browse files- app.py +14 -5
- instructions.txt +0 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
iface.
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.widgets import *
|
| 3 |
+
# def greet(name):
|
| 4 |
+
# return "Hello " + name + "!!"
|
| 5 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 6 |
+
label = gr.outputs.Label()
|
| 7 |
+
examples = ['grizzly-bear.jpg', 'black-bear.jpg', 'teddy-bear.jpg']
|
| 8 |
|
| 9 |
+
path = Path()
|
| 10 |
+
learn = load_learner(path/'model.pkl')
|
| 11 |
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 14 |
+
return {'Type': pred, 'Probability': f'{probs[pred_idx]:.04f}'}
|
| 15 |
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 18 |
+
iface.launch(inline=False)
|
instructions.txt
DELETED
|
File without changes
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai>=2.0.0
|