fix: address verify findings - add visualize subcommand, curl healthcheck, IoU in JSON, 50KB threshold
This commit is contained in:
+25
-1
@@ -11,7 +11,7 @@ from ts_anomaly_td.schema import setup_schema
|
||||
from ts_anomaly_td.io_csv import read_csv
|
||||
from ts_anomaly_td.detection import detect_all_algos, ALL_ALGOS
|
||||
from ts_anomaly_td.forecast import forecast_anomaly
|
||||
from ts_anomaly_td.visualize import render_contrast
|
||||
from ts_anomaly_td.visualize import render_contrast, _compute_iou
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -94,7 +94,31 @@ def run_e2e(args):
|
||||
"anomaly_count": fc_anom_count,
|
||||
},
|
||||
"png": str(png_path),
|
||||
"iou": None,
|
||||
}
|
||||
|
||||
# 计算 GT windows(从 labels 提取)
|
||||
gt_windows_for_iou = []
|
||||
in_anom = False
|
||||
anom_start = None
|
||||
for i, l in enumerate(labels):
|
||||
if l == 1 and not in_anom:
|
||||
in_anom = True
|
||||
anom_start = ts[i]
|
||||
elif l == 0 and in_anom:
|
||||
in_anom = False
|
||||
gt_windows_for_iou.append((anom_start, ts[i]))
|
||||
if in_anom:
|
||||
gt_windows_for_iou.append((anom_start, ts[-1]))
|
||||
|
||||
# 收集检测 windows
|
||||
all_det_windows = []
|
||||
for r in det_results.values():
|
||||
if not r.get("error"):
|
||||
all_det_windows.extend(r.get("windows", []))
|
||||
|
||||
iou = _compute_iou(gt_windows_for_iou, all_det_windows)
|
||||
ds_summary["iou"] = round(iou, 3)
|
||||
for algo, r in det_results.items():
|
||||
ds_summary["algorithms"][algo] = {
|
||||
"window_count": len(r["windows"]),
|
||||
|
||||
Reference in New Issue
Block a user