Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import torch
|
2 |
-
from transformers import ViTForImageClassification, ViTFeatureExtractor
|
3 |
import gradio as gr
|
4 |
from PIL import Image
|
5 |
import os
|
@@ -8,7 +8,7 @@ import logging
|
|
8 |
# Set up logging
|
9 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
10 |
|
11 |
-
# Define the class labels as used during training
|
12 |
labels = ['Leggings', 'Jogger', 'Palazzo', 'Cargo', 'Dresspants', 'Chinos']
|
13 |
logging.info(f"Labels: {labels}")
|
14 |
|
@@ -52,9 +52,6 @@ logging.info("Model set to evaluation mode")
|
|
52 |
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k")
|
53 |
logging.info("Feature extractor loaded")
|
54 |
|
55 |
-
|
56 |
-
logging.info("Model and feature extractor loaded successfully")
|
57 |
-
|
58 |
# Define the prediction function
|
59 |
def predict(image):
|
60 |
logging.info("Starting prediction")
|
|
|
1 |
import torch
|
2 |
+
from transformers import ViTForImageClassification, ViTFeatureExtractor
|
3 |
import gradio as gr
|
4 |
from PIL import Image
|
5 |
import os
|
|
|
8 |
# Set up logging
|
9 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
10 |
|
11 |
+
# Define the class labels in the correct order as used during training
|
12 |
labels = ['Leggings', 'Jogger', 'Palazzo', 'Cargo', 'Dresspants', 'Chinos']
|
13 |
logging.info(f"Labels: {labels}")
|
14 |
|
|
|
52 |
feature_extractor = ViTFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k")
|
53 |
logging.info("Feature extractor loaded")
|
54 |
|
|
|
|
|
|
|
55 |
# Define the prediction function
|
56 |
def predict(image):
|
57 |
logging.info("Starting prediction")
|