Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,16 +14,18 @@ def get_x(r):
|
|
| 14 |
return path/r["fname"]
|
| 15 |
|
| 16 |
learner = from_pretrained_fastai(repo_id)
|
|
|
|
| 17 |
|
| 18 |
def inference(image):
|
| 19 |
label_predict,_,probs = learner.predict(image)
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
gr.Interface(
|
| 23 |
fn=inference,
|
| 24 |
title="Grapevine leave image classification",
|
| 25 |
description = "Predict which type of grapevine leave belong to Ak, Ala_Idris, Buzgulu, Dimnit, Nazli",
|
| 26 |
-
inputs=
|
| 27 |
examples=examples,
|
| 28 |
outputs=gr.Textbox(label='Prediction'),
|
| 29 |
cache_examples=False,
|
|
|
|
| 14 |
return path/r["fname"]
|
| 15 |
|
| 16 |
learner = from_pretrained_fastai(repo_id)
|
| 17 |
+
labels = learner.dls.vocab
|
| 18 |
|
| 19 |
def inference(image):
|
| 20 |
label_predict,_,probs = learner.predict(image)
|
| 21 |
+
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
| 22 |
+
return labels_probs
|
| 23 |
|
| 24 |
gr.Interface(
|
| 25 |
fn=inference,
|
| 26 |
title="Grapevine leave image classification",
|
| 27 |
description = "Predict which type of grapevine leave belong to Ak, Ala_Idris, Buzgulu, Dimnit, Nazli",
|
| 28 |
+
inputs=output = gr.outputs.Label(num_top_classes=3),
|
| 29 |
examples=examples,
|
| 30 |
outputs=gr.Textbox(label='Prediction'),
|
| 31 |
cache_examples=False,
|