def process_video(in_path: Path, out_path: Path, stride: int = 5): cap = cv2.VideoCapture(str(in_path)) if not cap.isOpened(): raise RuntimeError(f"Cannot open in_path")
# ------------------------------------------------------------------ # 2️⃣ Helper: build the model (adjust to your repo's factory function) # ------------------------------------------------------------------ def build_model(cfg): """ Replace the body of this function with the actual model‑building logic from camshowrecordings. """ from camshowrecordings.models.sam import SamSamantha # Example import model = SamSamantha( backbone=cfg["model"]["backbone"], img_size=cfg["model"]["image_size"], num_classes=cfg["model"]["num_classes"] ) return model camshowrecordings/model/sam_samantha/5
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) def process_video(in_path: Path
parser = argparse.ArgumentParser(description="Run SAM‑Samantha v5 on a frame") parser.add_argument("image_path", type=str, help="Path to an image (or a video frame)") args = parser.parse_args() camshowrecordings/model/sam_samantha/5
# Normalize img_norm = img_rgb.astype(np.float32) / 255.0 mean = np.array(cfg["preprocess"]["mean"]) std = np.array(cfg["preprocess"]["std"]) img_norm = (img_norm - mean) / std
Open config.yaml to verify things like:
# Convert BGR → RGB img_rgb = cv2.cvtColor(img_resized, cv2.COLOR_BGR2RGB)