fix(ceus): 降低长视频内存峰值,快照开跑即写,build 核对 CEUS 运行与交付包
- 内存:prepare_segmentation 改为流式解码,只留分屏和配准的抽样帧,绿框逐帧在两半上找; 分割那一半由 SegmentationInput.target_frames() 到用时再解码,segment_video 边读边写 jpg; MedSAM2 init_state 的读帧换成直接在存放设备上建张量(不改 MedSAM2 源码,结果逐位相同); 传播结果写进预分配数组。帧数最多的一段视频常驻内存峰值 11.2 GiB → 2.3 GiB,分辨率最大的 一段原代码被 OOM 杀掉、现为 4.2 GiB;两段的掩码和全部产物与改前逐字节相同,33 段视频的 第 1–2 步结果与改前一致,29 例配准与 review.csv 一致。 - 快照:ceus_quant 开跑时写 snapshot/(git、ceus.yaml、review.csv、uv.lock、segment.json), 配置和核对表从快照副本读;收尾由新函数 runs.finish_snapshot 只新建 finished.json。 build 与 ceus_align_review 同样改用 finish_snapshot 记结束时间。 - build:summary.json 加 video_sha256;装 CEUS 结果时核对快照里的 delivery_dir、逐例核对 视频 SHA-256 和推注时间,不同就整次停下;新字段做类型检查,不进 tic.json。 来源:主会话任务(问题 1–3 及补充的 delivery_dir 比对)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""B3 green_prompt 绿框提示检测单元测试。
|
||||
|
||||
钉死四件事的关键性质(参考 ``references/ROI/roi_tracking_pipeline.py`` P:241-332/989-1004):
|
||||
钉死这几件事的关键性质(参考 ``references/ROI/roi_tracking_pipeline.py`` P:241-332/989-1004):
|
||||
|
||||
- ``extract_color_prompt``:合成在已知位置画绿色多边形的 BGR 左视图帧 →
|
||||
返回该绿框 bbox(含端点 ``x2=x1+w-1`` / ``y2=y1+h-1``)+ 充满轮廓的布尔 mask;
|
||||
@@ -9,8 +9,6 @@
|
||||
绿框在带外则正常返回。
|
||||
- ``min_area``:按 **bbox 面积 w×h**(findings §3.2,非轮廓面积)过滤——
|
||||
bbox 面积 < min_area 的候选被丢弃。
|
||||
- ``collect_prompt_observations``:对多帧序列返回逐帧观测列表,
|
||||
无绿帧以 ``None`` 占位(``observation.prompt is None``)。
|
||||
- ``prompt_color_mask``:TIC 端"排除绿框色"掩膜——``exclude_prompt_color=False`` 全 False;
|
||||
``prompt_exclude_dilate=1`` 不膨胀(mask == 原始 inRange);增大膨胀核则 mask 更大。
|
||||
|
||||
@@ -24,10 +22,8 @@ from cadx.ceus import (
|
||||
CeusConfig,
|
||||
ColorPrompt,
|
||||
PanSourceConfig,
|
||||
PromptObservation,
|
||||
PromptSourceConfig,
|
||||
TicAnalysisConfig,
|
||||
collect_prompt_observations,
|
||||
extract_color_prompt,
|
||||
prompt_color_mask,
|
||||
)
|
||||
@@ -198,24 +194,6 @@ def test_min_area_picks_largest_bbox_candidate() -> None:
|
||||
assert abs(prompt.bbox_xyxy[1] - 60) <= 3
|
||||
|
||||
|
||||
# Phase 4: collect_prompt_observations —— 多帧观测列表(None 占位)
|
||||
def test_collect_observations_none_placeholder_for_no_green_frames() -> None:
|
||||
frames = [
|
||||
_frame_with_green_rect(120, 200, (40, 40, 120, 90)), # 有绿
|
||||
_gray_frame(120, 200), # 无绿 → None 占位
|
||||
_frame_with_green_rect(120, 200, (50, 40, 130, 95)), # 有绿
|
||||
]
|
||||
observations = collect_prompt_observations(frames, _cfg())
|
||||
assert len(observations) == 3
|
||||
assert all(isinstance(o, PromptObservation) for o in observations)
|
||||
assert [o.frame_index for o in observations] == [0, 1, 2]
|
||||
assert observations[0].prompt is not None
|
||||
assert observations[1].prompt is None # 无绿帧占位
|
||||
assert observations[2].prompt is not None
|
||||
assert observations[1].detected is False
|
||||
assert observations[0].detected is True
|
||||
|
||||
|
||||
# Phase 5: prompt_color_mask —— TIC 端"排除绿框色"掩膜(受 tic_cfg 门控)
|
||||
def test_prompt_color_mask_marks_green_pixels() -> None:
|
||||
frame = _frame_with_green_rect(120, 200, (40, 30, 120, 90))
|
||||
|
||||
Reference in New Issue
Block a user