Chanlefe commited on
Commit
f70931b
·
verified ·
1 Parent(s): 23ad95f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -11
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 processor from base SigLIP model...")
82
 
83
- # Try to load processor from the base SigLIP model
84
  try:
85
- processor = AutoProcessor.from_pretrained("google/siglip-base-patch16-224")
86
- print("Processor loaded from base SigLIP model!")
87
- except Exception as base_error:
88
- print(f"Error loading base processor: {base_error}")
89
- print("Trying alternative processor...")
 
90
 
91
- # As a last resort, try to create a minimal processor
92
- from transformers import CLIPImageProcessor
93
- processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-base-patch32")
94
- print("Using CLIP processor as fallback!")
 
 
 
 
 
 
 
 
 
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: