Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
4 |
|
5 |
image_processor = ViTImageProcessor.from_pretrained("google/vit-base-patch16-224")
|
6 |
|
@@ -10,8 +10,8 @@ model = AutoModelForImageClassification.from_pretrained("saved_model_files")
|
|
10 |
labels = ['angular_leaf_spot', 'bean_rust', 'healthy']
|
11 |
|
12 |
|
13 |
-
def classify(
|
14 |
-
features = image_processor(
|
15 |
logits = model(features["pixel_values"])[-1]
|
16 |
probability = torch.nn.functional.softmax(logits, dim=-1)
|
17 |
probs = probability[0].detach().numpy()
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from transformers import ViTImageProcessor, AutoFeatureExtractor, AutoModelForImageClassification
|
4 |
|
5 |
image_processor = ViTImageProcessor.from_pretrained("google/vit-base-patch16-224")
|
6 |
|
|
|
10 |
labels = ['angular_leaf_spot', 'bean_rust', 'healthy']
|
11 |
|
12 |
|
13 |
+
def classify(image):
|
14 |
+
features = image_processor(image, return_tensors='pt')
|
15 |
logits = model(features["pixel_values"])[-1]
|
16 |
probability = torch.nn.functional.softmax(logits, dim=-1)
|
17 |
probs = probability[0].detach().numpy()
|