Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,7 +110,8 @@ MODEL_CATALOG = {
|
|
| 110 |
"config_filename": "AnatomyFlaws-v15.5_dinov3_7b_bnb_fl.config.json",
|
| 111 |
"head_filename": "AnatomyFlaws-v15.5_dinov3_7b_bnb_fl_s4K.safetensors",
|
| 112 |
# Explicitly define the vision model repo ID to prevent errors
|
| 113 |
-
"vision_model_repo_id": "Enferlain/dinov3-vit7b16-pretrain-lvd1689m-8bit"
|
|
|
|
| 114 |
},
|
| 115 |
"AnatomyFlaws-v14.7 (SigLIP naflex)": {
|
| 116 |
"repo_id": "Enferlain/lumi-classifier",
|
|
@@ -137,7 +138,6 @@ class ModelManager:
|
|
| 137 |
repo_id = model_info["repo_id"]
|
| 138 |
config_filename = model_info["config_filename"]
|
| 139 |
head_filename = model_info["head_filename"]
|
| 140 |
-
# --- NEW: Use the reliable repo ID from our catalog ---
|
| 141 |
vision_model_repo_id = model_info["vision_model_repo_id"]
|
| 142 |
|
| 143 |
try:
|
|
@@ -146,15 +146,21 @@ class ModelManager:
|
|
| 146 |
|
| 147 |
print(f"Loading vision model: {vision_model_repo_id}")
|
| 148 |
|
| 149 |
-
# Load processor and model using our trusted repo ID
|
| 150 |
self.hf_processor = AutoProcessor.from_pretrained(vision_model_repo_id, trust_remote_code=True)
|
| 151 |
|
| 152 |
-
|
| 153 |
-
if
|
| 154 |
-
|
| 155 |
-
else:
|
| 156 |
self.vision_model = AutoModel.from_pretrained(
|
| 157 |
-
vision_model_repo_id,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
).to(DEVICE).eval()
|
| 159 |
|
| 160 |
# The rest of the function continues as before
|
|
|
|
| 110 |
"config_filename": "AnatomyFlaws-v15.5_dinov3_7b_bnb_fl.config.json",
|
| 111 |
"head_filename": "AnatomyFlaws-v15.5_dinov3_7b_bnb_fl_s4K.safetensors",
|
| 112 |
# Explicitly define the vision model repo ID to prevent errors
|
| 113 |
+
# "vision_model_repo_id": "Enferlain/dinov3-vit7b16-pretrain-lvd1689m-8bit"
|
| 114 |
+
"vision_model_repo_id": "Enferlain/dinov3-vit7b16-pretrain-lvd1689m-int4",
|
| 115 |
},
|
| 116 |
"AnatomyFlaws-v14.7 (SigLIP naflex)": {
|
| 117 |
"repo_id": "Enferlain/lumi-classifier",
|
|
|
|
| 138 |
repo_id = model_info["repo_id"]
|
| 139 |
config_filename = model_info["config_filename"]
|
| 140 |
head_filename = model_info["head_filename"]
|
|
|
|
| 141 |
vision_model_repo_id = model_info["vision_model_repo_id"]
|
| 142 |
|
| 143 |
try:
|
|
|
|
| 146 |
|
| 147 |
print(f"Loading vision model: {vision_model_repo_id}")
|
| 148 |
|
|
|
|
| 149 |
self.hf_processor = AutoProcessor.from_pretrained(vision_model_repo_id, trust_remote_code=True)
|
| 150 |
|
| 151 |
+
# --- NEW: Correct loading logic for INT4 vs. standard models ---
|
| 152 |
+
if "int4" in vision_model_repo_id.lower():
|
| 153 |
+
print("INT4 model detected. Loading for CPU.")
|
|
|
|
| 154 |
self.vision_model = AutoModel.from_pretrained(
|
| 155 |
+
vision_model_repo_id,
|
| 156 |
+
torch_dtype=torch.float32,
|
| 157 |
+
device_map="cpu", # Force to CPU
|
| 158 |
+
trust_remote_code=True
|
| 159 |
+
).eval()
|
| 160 |
+
else: # Standard model loading (for SigLIP or GPU environments)
|
| 161 |
+
self.vision_model = AutoModel.from_pretrained(
|
| 162 |
+
vision_model_repo_id,
|
| 163 |
+
torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32
|
| 164 |
).to(DEVICE).eval()
|
| 165 |
|
| 166 |
# The rest of the function continues as before
|