Spaces:
Sleeping
Sleeping
Ilija Eftimov
commited on
Commit
·
5e82ea1
1
Parent(s):
d23377f
Improve model response
Browse files
app.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
def classify_image(img):
|
| 5 |
pred, idx, probs = learn.predict(img)
|
| 6 |
return pred
|
| 7 |
-
|
| 8 |
-
learn = load_learner("model.pkl")
|
| 9 |
|
| 10 |
image = gr.inputs.Image(shape=(192,192))
|
| 11 |
label = gr.outputs.Label()
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn = load_learner("model.pkl")
|
| 5 |
+
|
| 6 |
+
labels = learn.dls.vocab
|
| 7 |
def classify_image(img):
|
| 8 |
pred, idx, probs = learn.predict(img)
|
| 9 |
return pred
|
| 10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
|
|
|
| 11 |
|
| 12 |
image = gr.inputs.Image(shape=(192,192))
|
| 13 |
label = gr.outputs.Label()
|