Spaces:
Runtime error
Runtime error
Commit ·
cf7c19e
1
Parent(s): 3f36e3e
initial commit
Browse files
app.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
sample_images=[['https://s3.amazonaws.com/moonup/production/uploads/1663933284359-611f9702593efbee33a4f7c9.png'],
|
| 4 |
['https://s3.amazonaws.com/moonup/production/uploads/1663933284374-611f9702593efbee33a4f7c9.png'],
|
|
@@ -6,7 +14,7 @@ sample_images=[['https://s3.amazonaws.com/moonup/production/uploads/166393328435
|
|
| 6 |
|
| 7 |
title = 'Bean Leaf Classifier'
|
| 8 |
description = 'This model is trained for beans leaf classification but might give a false result on other leaves'
|
| 9 |
-
interface = gr.Interface(gr.Image(shape=(200, 200)), 'label',
|
| 10 |
title = title,
|
| 11 |
description = description,
|
| 12 |
examples=sample_images)
|
|
|
|
| 1 |
+
def classify(im):
|
| 2 |
+
features = feature_extractor(im, return_tensors='pt')
|
| 3 |
+
logits = model(features["pixel_values"])[-1]
|
| 4 |
+
probability = torch.nn.functional.softmax(logits, dim=-1)
|
| 5 |
+
probs = probability[0].detach().numpy()
|
| 6 |
+
confidences = {label: float(probs[i]) for i, label in enumerate(labels)}
|
| 7 |
+
return confidences
|
| 8 |
+
|
| 9 |
+
import gradio as gr
|
| 10 |
|
| 11 |
sample_images=[['https://s3.amazonaws.com/moonup/production/uploads/1663933284359-611f9702593efbee33a4f7c9.png'],
|
| 12 |
['https://s3.amazonaws.com/moonup/production/uploads/1663933284374-611f9702593efbee33a4f7c9.png'],
|
|
|
|
| 14 |
|
| 15 |
title = 'Bean Leaf Classifier'
|
| 16 |
description = 'This model is trained for beans leaf classification but might give a false result on other leaves'
|
| 17 |
+
interface = gr.Interface(classify, gr.Image(shape=(200, 200)), 'label',
|
| 18 |
title = title,
|
| 19 |
description = description,
|
| 20 |
examples=sample_images)
|