Fix backend crash when initializing hybrid ML detector

Corrected `main.py` to handle the `ml_analyzer` being `None` when `USE_HYBRID_DETECTOR` is true, preventing an `AttributeError` during startup.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 27f5de5e-5ed6-4ee6-9cc2-a7c448ad2334
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/XSkkaPM
This commit is contained in:
marco370 2025-11-25 07:53:47 +00:00
parent d086b00092
commit 08af108cfb

View File

@ -680,6 +680,15 @@ if __name__ == "__main__":
import uvicorn
# Prova a caricare modello esistente
if USE_HYBRID_DETECTOR:
# Hybrid detector: già caricato all'inizializzazione (riga 69)
if ml_detector and ml_detector.is_trained:
print("[ML] ✓ Hybrid detector models loaded and ready")
else:
print("[ML] ⚠ Hybrid detector initialized but no models found (will train on-demand)")
else:
# Legacy analyzer
if ml_analyzer:
ml_analyzer.load_model()
print("🚀 Starting IDS API on http://0.0.0.0:8000")