Zhen Ye Claude Opus 4.6 commited on
Commit
5aec47c
·
1 Parent(s): 64f68de

perf: GPU-resident tensor pipeline for SAM2 video propagation

Browse files

Eliminate all CUDA synchronization from propagate_segment() by keeping
masks, bboxes, and validity flags on GPU in pre-allocated buffers.
CPU materialization is deferred to a single bulk transfer via
SegmentOutput.to_object_dicts() at the consumer.

- Add _bbox_gpu() for zero-sync bounding box computation on GPU
- Add SegmentOutput dataclass for GPU-resident segment results
- Rewrite propagate_segment() with inline bbox + pre-allocated tensors
- Refactor process_video() to reuse propagate_segment()
- Update Phase 4 reconciliation: 3 CUDA syncs per segment vs 100+

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

2 files changed +161 -125
Files changed (2)
inference.py+12-8
models/segmenters/grounded_sam2.py+149-117