Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -404,8 +404,14 @@ async def unified_scan_endpoint(payload: UnifiedRequest):
|
|
| 404 |
except Exception as e:
|
| 405 |
v2_msg = f"V2 Vision Unavailable"
|
| 406 |
|
| 407 |
-
# 4. Calculate the Master Risk Score (
|
| 408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
latency = (time.perf_counter() - start_time) * 1000
|
| 410 |
|
| 411 |
# 5. Return safely serialized JSON to the frontend
|
|
|
|
| 404 |
except Exception as e:
|
| 405 |
v2_msg = f"V2 Vision Unavailable"
|
| 406 |
|
| 407 |
+
# 4. Calculate the Master Risk Score (Dynamic Weights)
|
| 408 |
+
if "Skipped" in v2_msg or "Unavailable" in v2_msg:
|
| 409 |
+
# If CNN times out, re-balance weights so a dummy 0.0 doesn't dilute the risk
|
| 410 |
+
master_score = (v1_score * 0.5) + (v4_score * 0.5)
|
| 411 |
+
else:
|
| 412 |
+
# Standard 40/40/20 split
|
| 413 |
+
master_score = (v1_score * 0.4) + (v4_score * 0.4) + (v2_score * 0.2)
|
| 414 |
+
|
| 415 |
latency = (time.perf_counter() - start_time) * 1000
|
| 416 |
|
| 417 |
# 5. Return safely serialized JSON to the frontend
|