76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
"""Debug 入口:Excel I 列时间段替代 ActionFormer,其余 Phase2 与 main.py 一致。"""
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
import argparse
|
|||
|
|
import os
|
|||
|
|
import sys
|
|||
|
|
from pathlib import Path
|
|||
|
|
|
|||
|
|
PACK_ROOT = Path(__file__).resolve().parent
|
|||
|
|
sys.path.insert(0, str(PACK_ROOT / "src"))
|
|||
|
|
|
|||
|
|
from paths import ensure_code_on_path
|
|||
|
|
|
|||
|
|
ensure_code_on_path(PACK_ROOT)
|
|||
|
|
|
|||
|
|
from config import load_run_config
|
|||
|
|
from orchestrator import run_debug_pipeline
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main() -> int:
|
|||
|
|
os.environ.setdefault("OPENCV_FFMPEG_LOGLEVEL", "8")
|
|||
|
|
ap = argparse.ArgumentParser(
|
|||
|
|
description="手术室耗材 Debug 主流程(Excel 时间段 → Phase2,跳过 ActionFormer)"
|
|||
|
|
)
|
|||
|
|
ap.add_argument("--video", type=Path, required=True, help="输入 MP4")
|
|||
|
|
ap.add_argument(
|
|||
|
|
"--excel",
|
|||
|
|
type=Path,
|
|||
|
|
required=True,
|
|||
|
|
help="商品表 Excel(C 列白名单 + I 列时间段 + 产品编码)",
|
|||
|
|
)
|
|||
|
|
ap.add_argument("--out", type=Path, required=True, help="输出 TSV")
|
|||
|
|
ap.add_argument(
|
|||
|
|
"--config",
|
|||
|
|
type=Path,
|
|||
|
|
default=PACK_ROOT / "configs" / "default_config.yaml",
|
|||
|
|
help="继承 weights / phase2 / tear_merge / doctor 的 YAML(忽略 io 与 phase1)",
|
|||
|
|
)
|
|||
|
|
ap.add_argument(
|
|||
|
|
"--time-col-index",
|
|||
|
|
type=int,
|
|||
|
|
default=8,
|
|||
|
|
help="时间段列索引,默认 8 即 Excel I 列;视频2 可用 9(J 列)",
|
|||
|
|
)
|
|||
|
|
ap.add_argument(
|
|||
|
|
"--min-seg-seconds",
|
|||
|
|
type=float,
|
|||
|
|
default=None,
|
|||
|
|
help="最短段时长(秒);默认 0 表示不过滤短段",
|
|||
|
|
)
|
|||
|
|
args = ap.parse_args()
|
|||
|
|
|
|||
|
|
cfg_path = args.config.resolve()
|
|||
|
|
if not cfg_path.is_file():
|
|||
|
|
print("找不到配置:", cfg_path, file=sys.stderr)
|
|||
|
|
return 1
|
|||
|
|
|
|||
|
|
run_cfg = load_run_config(PACK_ROOT, cfg_path)
|
|||
|
|
run_cfg.video = args.video.resolve()
|
|||
|
|
run_cfg.excel = args.excel.resolve()
|
|||
|
|
run_cfg.out = args.out.resolve()
|
|||
|
|
run_cfg.excel_time_col_index = int(args.time_col_index)
|
|||
|
|
if args.min_seg_seconds is not None:
|
|||
|
|
run_cfg.af_min_seg_seconds = float(args.min_seg_seconds)
|
|||
|
|
else:
|
|||
|
|
run_cfg.af_min_seg_seconds = 0.0
|
|||
|
|
|
|||
|
|
run_cfg.merge_adjacent_tear = False
|
|||
|
|
|
|||
|
|
return int(run_debug_pipeline(run_cfg))
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
raise SystemExit(main())
|