Spaces:
Sleeping
Sleeping
srishti-hf1110
commited on
Commit
·
9e49044
1
Parent(s):
32fcae2
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,13 @@ Original file is located at
|
|
8 |
"""
|
9 |
|
10 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
interface = gr.Interface(classify, inputs='image', outputs='label', title='Bean plant disease classifier', description='Detect diseases in beans leaves using their images.')
|
13 |
|
|
|
8 |
"""
|
9 |
|
10 |
import gradio as gr
|
11 |
+
def classify(im):
|
12 |
+
features = feature_extractor(im, return_tensors='pt')
|
13 |
+
logits = model(features["pixel_values"])[-1]
|
14 |
+
probability = torch.nn.functional.softmax(logits, dim=-1)
|
15 |
+
probs = probability[0].detach().numpy()
|
16 |
+
confidences = {label: float(probs[i]) for i, label in enumerate(labels)}
|
17 |
+
return confidences
|
18 |
|
19 |
interface = gr.Interface(classify, inputs='image', outputs='label', title='Bean plant disease classifier', description='Detect diseases in beans leaves using their images.')
|
20 |
|