diff --git a/vr180_matting/sam2_wrapper.py b/vr180_matting/sam2_wrapper.py index f393c82..d2134ad 100644 --- a/vr180_matting/sam2_wrapper.py +++ b/vr180_matting/sam2_wrapper.py @@ -57,22 +57,13 @@ class SAM2VideoMatting: if sam2_repo_path.exists(): checkpoint_path = str(sam2_repo_path) - # Use the config path as-is (should be relative to SAM2 package) - # Example: "configs/sam2.1/sam2.1_hiera_l.yaml" + # Use SAM2's build_sam2_video_predictor which returns the predictor directly + # The predictor IS the model - no .model attribute needed self.predictor = build_sam2_video_predictor( - model_cfg, - checkpoint_path, + config_file=model_cfg, + ckpt_path=checkpoint_path, device=self.device ) - - # Enable memory optimizations - if self.memory_offload: - # SAM2 has different memory optimization options - pass # Memory offloading is handled by SAM2 internally - - if self.fp16 and self.device == "cuda": - # SAM2 handles FP16 internally, no need to manually convert - pass except Exception as e: raise RuntimeError(f"Failed to load SAM2 model: {e}")