Datasets:
Download scripts/extract_frames.py from dcowg/wildshadow-video: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/datasets/dcowg/wildshadow-video/resolve/main/scripts/extract_frames.py
- Command line
-
hf download hf://datasets/dcowg/wildshadow-video/scripts/extract_frames.py
-
curl -L -o extract_frames.py https://huggingface.co/datasets/dcowg/wildshadow-video/resolve/main/scripts/extract_frames.py
1.02 kB
| #!/usr/bin/env python3 | |
| """Extract a paired WildShadow MP4 clip to the frame-folder training layout.""" | |
| from __future__ import annotations | |
| import argparse | |
| import subprocess | |
| from pathlib import Path | |
| def extract(video: Path, destination: Path) -> None: | |
| if not video.is_file(): | |
| raise FileNotFoundError(video) | |
| destination.mkdir(parents=True, exist_ok=True) | |
| subprocess.run([ | |
| "ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(video), | |
| "-vsync", "0", "-start_number", "0", str(destination / "rgb_%06d.png"), | |
| ], check=True) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--shadow", required=True, type=Path) | |
| parser.add_argument("--shadow-free", required=True, type=Path) | |
| parser.add_argument("--output", required=True, type=Path) | |
| args = parser.parse_args() | |
| extract(args.shadow, args.output / "origin") | |
| extract(args.shadow_free, args.output / "shadow_free") | |
| if __name__ == "__main__": | |
| main() | |