Download cli.py from hdcli/copyrightgpt-v1: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/cli.py
- Command line
-
hf download hf://datasets/hdcli/copyrightgpt-v1/cli.py
-
curl -L -o cli.py https://huggingface.co/datasets/hdcli/copyrightgpt-v1/resolve/main/cli.py
1.69 kB
| import argparse | |
| import json | |
| import storage | |
| from ingest import ingest_video | |
| from match import check_video | |
| def main(): | |
| parser = argparse.ArgumentParser(prog="copyrightgpt", description="Video dataset + copyright match checker") | |
| sub = parser.add_subparsers(dest="command", required=True) | |
| p_ingest = sub.add_parser("ingest", help="Add a video to the dataset") | |
| p_ingest.add_argument("path") | |
| p_ingest.add_argument("--title", default=None) | |
| p_ingest.add_argument("--rate", type=float, default=1.0, help="samples per second") | |
| p_ingest.add_argument("--id", default=None, help="append a new patch to this existing video id") | |
| p_check = sub.add_parser("check", help="Check a video against the dataset") | |
| p_check.add_argument("path") | |
| p_check.add_argument("--rate", type=float, default=1.0, help="samples per second") | |
| p_check.add_argument("--threshold", type=float, default=0.5, help="match ratio to call it a match (0-1)") | |
| sub.add_parser("list", help="List videos in the dataset") | |
| args = parser.parse_args() | |
| if args.command == "ingest": | |
| meta = ingest_video(args.path, title=args.title, samples_per_second=args.rate, video_id=args.id) | |
| print(json.dumps(meta, indent=2)) | |
| elif args.command == "check": | |
| result = check_video(args.path, match_ratio_threshold=args.threshold, samples_per_second=args.rate) | |
| print(json.dumps(result, indent=2)) | |
| elif args.command == "list": | |
| for meta in storage.list_videos(): | |
| print(f"{meta['id']} {meta['duration_seconds']:>8.1f}s {meta['total_hashes']:>4} hashes {meta['num_patches']} patch(es) {meta['title']}") | |
| if __name__ == "__main__": | |
| main() | |