Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,20 +78,30 @@ try:
|
|
| 78 |
print("Processor loaded successfully!")
|
| 79 |
except Exception as proc_error:
|
| 80 |
print(f"Error loading processor from local files: {proc_error}")
|
| 81 |
-
print("Attempting to load
|
| 82 |
|
| 83 |
-
# Try to load processor from
|
| 84 |
try:
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
print("
|
|
|
|
| 90 |
|
| 91 |
-
#
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
# Get labels - handle case where id2label might not exist
|
| 97 |
if hasattr(model.config, 'id2label') and model.config.id2label:
|
|
|
|
| 78 |
print("Processor loaded successfully!")
|
| 79 |
except Exception as proc_error:
|
| 80 |
print(f"Error loading processor from local files: {proc_error}")
|
| 81 |
+
print("Attempting to load just the image processor...")
|
| 82 |
|
| 83 |
+
# Try to load just the image processor from your model
|
| 84 |
try:
|
| 85 |
+
from transformers import SiglipImageProcessor
|
| 86 |
+
processor = SiglipImageProcessor.from_pretrained(MODEL_PATH, local_files_only=True)
|
| 87 |
+
print("Image processor loaded successfully from local files!")
|
| 88 |
+
except Exception as img_proc_error:
|
| 89 |
+
print(f"Error loading local image processor: {img_proc_error}")
|
| 90 |
+
print("Loading image processor from base SigLIP model...")
|
| 91 |
|
| 92 |
+
# Try to load processor from the base SigLIP model
|
| 93 |
+
try:
|
| 94 |
+
from transformers import SiglipImageProcessor
|
| 95 |
+
processor = SiglipImageProcessor.from_pretrained("google/siglip-base-patch16-224")
|
| 96 |
+
print("Image processor loaded from base SigLIP model!")
|
| 97 |
+
except Exception as base_error:
|
| 98 |
+
print(f"Error loading base processor: {base_error}")
|
| 99 |
+
print("Using CLIP processor as fallback...")
|
| 100 |
+
|
| 101 |
+
# As a last resort, try to create a minimal processor
|
| 102 |
+
from transformers import CLIPImageProcessor
|
| 103 |
+
processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
| 104 |
+
print("Using CLIP processor as fallback!")
|
| 105 |
|
| 106 |
# Get labels - handle case where id2label might not exist
|
| 107 |
if hasattr(model.config, 'id2label') and model.config.id2label:
|