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
mask = infer(img)
Topic: camshowrecordings/model/sam_samantha/5 This guide walks you through everything you need to know to locate, load, and work with the SAM‑Samantha model (version 5) that lives inside the camshowrecordings project. It assumes a typical development environment (Linux/macOS/Windows) and a basic familiarity with Python and machine‑learning model handling. 1️⃣ What Is This Path About? | Part of the Path | Meaning | |------------------|---------| | camshowrecordings | Top‑level repository / package that stores camera‑related recordings, utilities, and ML models used for analysis (e.g., object detection, segmentation, activity classification). | | model | Directory that groups all trained models and their supporting files. | | sam_samantha | Specific model family. “SAM” often stands for Segment Anything Model , and “Samantha” is the custom‑trained variant. | | 5 | The version number (v5). Newer releases may appear as 6 , 7 , … and usually contain performance or architecture upgrades. | camshowrecordings/model/sam_samantha/5
# 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:
# Convert BGR → RGB img_rgb = cv2.cvtColor(img_resized, cv2.COLOR_BGR2RGB) python video_segment
# ------------------------------------------------------------------ # 4️⃣ Pre‑process a single frame (example uses OpenCV) # ------------------------------------------------------------------ def preprocess(img: np.ndarray, cfg) -> torch.Tensor: # Resize while keeping aspect ratio (optional) target_sz = cfg["model"]["image_size"] img_resized = cv2.resize(img, (target_sz, target_sz))
frame_idx += 1
fourcc = cv2.VideoWriter_fourcc(*"mp4v") out = cv2.VideoWriter(str(out_path), fourcc, fps, (w, h))