Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,8 @@ from transformers import ViTForImageClassification, ViTFeatureExtractor
|
|
4 |
from PIL import Image
|
5 |
|
6 |
# Load model and feature extractor
|
7 |
-
model = ViTForImageClassification.from_pretrained('
|
8 |
-
feature_extractor = ViTFeatureExtractor.from_pretrained('
|
9 |
|
10 |
# Move to GPU if available
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -14,16 +14,8 @@ model.eval()
|
|
14 |
|
15 |
# Class labels (modify according to your model)
|
16 |
class_labels = [
|
17 |
-
"
|
18 |
-
"
|
19 |
-
"Bellpepper",
|
20 |
-
"Carrot",
|
21 |
-
"Cucumber",
|
22 |
-
"Potato",
|
23 |
-
"Tomato",
|
24 |
-
"mango",
|
25 |
-
"oranges",
|
26 |
-
"strawberry"
|
27 |
]
|
28 |
|
29 |
def predict_freshness(image):
|
|
|
4 |
from PIL import Image
|
5 |
|
6 |
# Load model and feature extractor
|
7 |
+
model = ViTForImageClassification.from_pretrained('shahmi0519/mango_artificial', num_labels=10, ignore_mismatched_sizes=True)
|
8 |
+
feature_extractor = ViTFeatureExtractor.from_pretrained('shahmi0519/mango_artificial')
|
9 |
|
10 |
# Move to GPU if available
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
14 |
|
15 |
# Class labels (modify according to your model)
|
16 |
class_labels = [
|
17 |
+
"Artificial",
|
18 |
+
"Natural"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
]
|
20 |
|
21 |
def predict_freshness(image):
|