Camshowrecordings/model/sam_samantha/5 (2024)
img = cv2.imread(args.image_path) if img is None: raise FileNotFoundError(f"Cannot read args.image_path")
# ------------------------------------------------------------------ # 5️⃣ Run inference # ------------------------------------------------------------------ def infer(frame: np.ndarray): x = preprocess(frame, cfg) with torch.no_grad(): # The exact call depends on the model; many SAM‑style models return a mask mask = model(x) # → (B, 1, H, W) logits or probabilities # Post‑process: convert logits → binary mask mask = torch.sigmoid(mask) > 0.5 mask_np = mask.squeeze().cpu().numpy().astype(np.uint8) * 255 return mask_np camshowrecordings/model/sam_samantha/5
mask = infer(img)
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("input_video", type=Path) parser.add_argument("output_video", type=Path) parser.add_argument("--stride", type=int, default=5, help="Run inference every N frames (default=5)") args = parser.parse_args() process_video(args.input_video, args.output_video, args.stride) img = cv2
Open config.yaml to verify things like:
python video_segment.py recordings/2024-03-15.mp4 recordings/2024-03-15_segmented.mp4 --stride 3 Adjust stride to balance speed vs. temporal resolution. | Symptom | Likely Cause | Fix | |---------|--------------|-----| | RuntimeError: CUDA out of memory | Batch size > 1 or image size too large for GPU. | Reduce stride , lower image_size in config.yaml , or switch to CPU ( device: cpu ). | | FileNotFoundError on model.ckpt | Wrong relative path or missing checkpoint. | Verify the file exists in camshowrecordings/model/sam_samantha/5/ . If you cloned a shallow repo, run git lfs pull . | | ImportError: cannot import name 'SamSamantha' | Model class location changed. | Look inside the repo’s camshowrecordings/models/ folder for the exact class name; update the import accordingly. | | torch.cuda.is_available() == False even though GPU is present | Missing or mismatched CUDA toolkit / driver. | Install the correct NVIDIA driver + matching CUDA version, then reinstall PyTorch with the appropriate --index-url flag. | | Segmentation masks are all black | Model not switched to evaluation mode or preprocessing mismatch. | Ensure | Reduce stride , lower image_size in config
# 3️⃣ Install dependencies pip install -r requirements.txt If the repo is private, make sure you have the right SSH key or token. 5️⃣ Inspecting the Model Files Navigate to the model folder:














