Spaces:
Paused
Paused
Zhen Ye Claude Opus 4.6 commited on
Commit ·
b17bd6d
1
Parent(s): 5aec47c
perf: enable torch.compile for SAM2 via vos_optimized flag
Browse filesUses Facebook's official SAM2VideoPredictorVOS which compiles all five
model components (image_encoder, memory_encoder, memory_attention,
sam_prompt_encoder, sam_mask_decoder) with torch.compile max-autotune.
First inference has ~30s warmup cost; subsequent frames benefit from
fused kernels and reduced memory round-trips.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
361 unmodified lines362363364365366367368366369370371372361 unmodified lines from sam2.sam2_image_predictor import SAM2ImagePredictor
# Video predictor (for process_video) # vos_optimized=True enables SAM2VideoPredictorVOS which compiles # image_encoder, memory_encoder, memory_attention, sam_prompt_encoder, # and sam_mask_decoder with torch.compile(mode="max-autotune"). self._video_predictor = build_sam2_video_predictor_hf( hf_id, device=self.device hf_id, device=self.device, vos_optimized=True, )
# Image predictor (for single-frame predict)models/segmenters/grounded_sam2.py+4-1