Spaces:
Running
Running
Add Salamandra-2b and Gemma-3-270m to available models
Browse files- optipfair_frontend.py +55 -4
optipfair_frontend.py
CHANGED
|
@@ -18,7 +18,9 @@ AVAILABLE_MODELS = [
|
|
| 18 |
"meta-llama/Llama-3.2-1B",
|
| 19 |
"oopere/pruned40-llama-3.2-1B",
|
| 20 |
"oopere/Fair-Llama-3.2-1B",
|
|
|
|
| 21 |
"google/gemma-3-1b-pt",
|
|
|
|
| 22 |
"Qwen/Qwen3-1.7B",
|
| 23 |
"custom", # Placeholder for custom models
|
| 24 |
]
|
|
@@ -195,7 +197,15 @@ def generate_pca_visualization(
|
|
| 195 |
except requests.exceptions.Timeout:
|
| 196 |
return (
|
| 197 |
None,
|
| 198 |
-
"β **Timeout Error:**\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
"",
|
| 200 |
)
|
| 201 |
|
|
@@ -205,10 +215,35 @@ def generate_pca_visualization(
|
|
| 205 |
"β **Connection Error:**\nCannot connect to the backend. Make sure the FastAPI server is running:\n`uvicorn main:app --reload`",
|
| 206 |
"",
|
| 207 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
except Exception as e:
|
| 210 |
logger.exception("Error in PCA visualization")
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
|
| 214 |
################################################
|
|
@@ -360,7 +395,15 @@ def generate_mean_diff_visualization(
|
|
| 360 |
)
|
| 361 |
|
| 362 |
except requests.exceptions.Timeout:
|
| 363 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
|
| 365 |
except requests.exceptions.ConnectionError:
|
| 366 |
return (
|
|
@@ -559,7 +602,15 @@ def generate_heatmap_visualization(
|
|
| 559 |
except requests.exceptions.Timeout:
|
| 560 |
return (
|
| 561 |
None,
|
| 562 |
-
"β **Timeout Error:**\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
"",
|
| 564 |
)
|
| 565 |
|
|
|
|
| 18 |
"meta-llama/Llama-3.2-1B",
|
| 19 |
"oopere/pruned40-llama-3.2-1B",
|
| 20 |
"oopere/Fair-Llama-3.2-1B",
|
| 21 |
+
"BSC-LT/salamandra-2b",
|
| 22 |
"google/gemma-3-1b-pt",
|
| 23 |
+
"google/gemma-3-270m",
|
| 24 |
"Qwen/Qwen3-1.7B",
|
| 25 |
"custom", # Placeholder for custom models
|
| 26 |
]
|
|
|
|
| 197 |
except requests.exceptions.Timeout:
|
| 198 |
return (
|
| 199 |
None,
|
| 200 |
+
f"β **Timeout Error:**\n"
|
| 201 |
+
f"The request exceeded 5 minutes (300s).\n\n"
|
| 202 |
+
f"**Possible causes:**\n"
|
| 203 |
+
f"1. The model is very large and takes long to load\n"
|
| 204 |
+
f"2. The server is processing many requests\n\n"
|
| 205 |
+
f"**Solutions:**\n"
|
| 206 |
+
f"β’ Use a smaller model (1B parameters)\n"
|
| 207 |
+
f"β’ Wait and try again (model may be caching)\n"
|
| 208 |
+
f"β’ If it persists, run `diagnostic_tool.py` for more information",
|
| 209 |
"",
|
| 210 |
)
|
| 211 |
|
|
|
|
| 215 |
"β **Connection Error:**\nCannot connect to the backend. Make sure the FastAPI server is running:\n`uvicorn main:app --reload`",
|
| 216 |
"",
|
| 217 |
)
|
| 218 |
+
|
| 219 |
+
except MemoryError as e:
|
| 220 |
+
return (
|
| 221 |
+
None,
|
| 222 |
+
f"β **Memory Error:**\n"
|
| 223 |
+
f"The system ran out of RAM.\n\n"
|
| 224 |
+
f"**Solutions:**\n"
|
| 225 |
+
f"β’ Use a smaller model (1B parameters)\n"
|
| 226 |
+
f"β’ Request more RAM in HF Spaces (PRO plan)\n"
|
| 227 |
+
f"β’ Run `diagnostic_tool.py` for detailed analysis",
|
| 228 |
+
"",
|
| 229 |
+
)
|
| 230 |
|
| 231 |
except Exception as e:
|
| 232 |
logger.exception("Error in PCA visualization")
|
| 233 |
+
error_msg = str(e).lower()
|
| 234 |
+
|
| 235 |
+
# Detect hidden memory errors in generic exceptions
|
| 236 |
+
if any(keyword in error_msg for keyword in ["memory", "ram", "oom", "out of memory", "allocation"]):
|
| 237 |
+
return (
|
| 238 |
+
None,
|
| 239 |
+
f"β **Memory Error (detected):**\n"
|
| 240 |
+
f"Error: {str(e)}\n\n"
|
| 241 |
+
f"The system likely ran out of memory.\n"
|
| 242 |
+
f"Run `diagnostic_tool.py` to confirm.",
|
| 243 |
+
"",
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
return None, f"β **Unexpected Error:**\n{str(e)}\n\nCheck server logs for more details.", ""
|
| 247 |
|
| 248 |
|
| 249 |
################################################
|
|
|
|
| 395 |
)
|
| 396 |
|
| 397 |
except requests.exceptions.Timeout:
|
| 398 |
+
return (
|
| 399 |
+
None,
|
| 400 |
+
f"β **Timeout Error:**\n"
|
| 401 |
+
f"The request exceeded 5 minutes (300s).\n\n"
|
| 402 |
+
f"**Solutions:**\n"
|
| 403 |
+
f"β’ Try with a smaller model\n"
|
| 404 |
+
f"β’ Run `diagnostic_tool.py` to diagnose the problem",
|
| 405 |
+
"",
|
| 406 |
+
)
|
| 407 |
|
| 408 |
except requests.exceptions.ConnectionError:
|
| 409 |
return (
|
|
|
|
| 602 |
except requests.exceptions.Timeout:
|
| 603 |
return (
|
| 604 |
None,
|
| 605 |
+
f"β **Timeout Error:**\n"
|
| 606 |
+
f"The request exceeded 5 minutes (300s).\n\n"
|
| 607 |
+
f"**Possible causes:**\n"
|
| 608 |
+
f"1. The model is very large\n"
|
| 609 |
+
f"2. The specified layer requires heavy processing\n\n"
|
| 610 |
+
f"**Solutions:**\n"
|
| 611 |
+
f"β’ Use a smaller model\n"
|
| 612 |
+
f"β’ Try a different layer (0-10 are usually faster)\n"
|
| 613 |
+
f"β’ Run `diagnostic_tool.py` for more information",
|
| 614 |
"",
|
| 615 |
)
|
| 616 |
|