fix wrapper

This commit is contained in:
2025-07-26 08:51:48 -07:00
parent 7852303b40
commit d933d6b606

View File

@@ -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}")