Spaces:
Runtime error
Runtime error
Commit
·
9679546
1
Parent(s):
fe1d000
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
-
import
|
4 |
|
5 |
learn = load_learner('model.pkl')
|
|
|
6 |
|
7 |
-
examples = ['sonic.jpg', 'eggman.jpg']
|
8 |
-
|
9 |
-
|
10 |
-
labels = learn.dls.vocab
|
11 |
def predict(img):
|
12 |
-
img = PILImage.create(img)
|
13 |
pred,pred_idx,probs = learn.predict(img)
|
14 |
-
return
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
title = "Sonic the Hedgehog and Doutor Eggman"
|
17 |
description = "Classificador entre o Sonic e o Doutor Eggman"
|
@@ -19,11 +19,13 @@ examples = ['sonic.jpg', 'eggman.jpg']
|
|
19 |
interpretation='default'
|
20 |
enable_queue=True
|
21 |
|
22 |
-
gr.Interface(fn=predict,
|
23 |
-
inputs=
|
24 |
-
outputs=
|
25 |
title=title,
|
26 |
description=description,
|
27 |
examples=examples,
|
28 |
interpretation=interpretation,
|
29 |
-
enable_queue=enable_queue)
|
|
|
|
|
|
|
|
1 |
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
|
4 |
learn = load_learner('model.pkl')
|
5 |
+
categories = ('Sonic the Hedgehog', 'Doutor Eggman')
|
6 |
|
|
|
|
|
|
|
|
|
7 |
def predict(img):
|
|
|
8 |
pred,pred_idx,probs = learn.predict(img)
|
9 |
+
return dict(zip(categories, map(float, probs)))
|
10 |
+
|
11 |
+
image = gr.Image()
|
12 |
+
label = gr.Label()
|
13 |
+
|
14 |
+
examples = ['sonic.jpg', 'eggman.jpg']
|
15 |
|
16 |
title = "Sonic the Hedgehog and Doutor Eggman"
|
17 |
description = "Classificador entre o Sonic e o Doutor Eggman"
|
|
|
19 |
interpretation='default'
|
20 |
enable_queue=True
|
21 |
|
22 |
+
iface = gr.Interface(fn=predict,
|
23 |
+
inputs=image,
|
24 |
+
outputs=label,
|
25 |
title=title,
|
26 |
description=description,
|
27 |
examples=examples,
|
28 |
interpretation=interpretation,
|
29 |
+
enable_queue=enable_queue)
|
30 |
+
|
31 |
+
iface.launch(inline=False)
|