Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,10 +9,6 @@ from safetensors.torch import load_file # Import safetensors loading function
|
|
| 9 |
# Set up logging
|
| 10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 11 |
|
| 12 |
-
# Define the labels in the correct order as used during training
|
| 13 |
-
labels = ['Leggings', 'Jogger', 'Palazzo', 'Cargo', 'Dresspants', 'Chinos']
|
| 14 |
-
logging.info(f"Labels: {labels}")
|
| 15 |
-
|
| 16 |
# Define the directory containing the model files
|
| 17 |
model_dir = "." # Use current directory
|
| 18 |
|
|
@@ -32,6 +28,10 @@ for path in [model_path, config_path, preprocessor_path]:
|
|
| 32 |
# Load the configuration
|
| 33 |
config = AutoConfig.from_pretrained(config_path)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Load the feature extractor
|
| 36 |
feature_extractor = ViTFeatureExtractor.from_pretrained(preprocessor_path)
|
| 37 |
|
|
|
|
| 9 |
# Set up logging
|
| 10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Define the directory containing the model files
|
| 13 |
model_dir = "." # Use current directory
|
| 14 |
|
|
|
|
| 28 |
# Load the configuration
|
| 29 |
config = AutoConfig.from_pretrained(config_path)
|
| 30 |
|
| 31 |
+
# Ensure the labels are consistent with the model's config
|
| 32 |
+
labels = list(config.id2label.values())
|
| 33 |
+
logging.info(f"Labels: {labels}")
|
| 34 |
+
|
| 35 |
# Load the feature extractor
|
| 36 |
feature_extractor = ViTFeatureExtractor.from_pretrained(preprocessor_path)
|
| 37 |
|