Download code/tools/make_masks.py from MRBSTUDIO/AGT: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/MRBSTUDIO/AGT/resolve/main/code/tools/make_masks.py
- Command line
-
hf download hf://MRBSTUDIO/AGT/code/tools/make_masks.py
-
curl -L -o make_masks.py https://huggingface.co/MRBSTUDIO/AGT/resolve/main/code/tools/make_masks.py
2.05 kB
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import sys | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| from agt.masks import pipeline | |
| def main(argv=None): | |
| p = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) | |
| p.add_argument("--export", type=Path, required=True, help="clip export directory (tools/prepare_clip.py)") | |
| p.add_argument("--out", type=Path, required=True, help="output mask directory") | |
| p.add_argument("--config", type=Path, default=ROOT / "configs/masks/occluder_v1.yaml") | |
| p.add_argument("--stage", choices=("all", "propose", "verify", "finish"), default="all") | |
| p.add_argument("--sam3-checkpoint", default=None, help="local sam3.pt (default: facebook/sam3 from the Hugging Face hub)") | |
| p.add_argument("--verifier", default=None, help="verifier name (default: config verify.verifier)") | |
| p.add_argument("--verifier-model", default=None, help="verifier weights: hub id or local directory (default: config verify.model)") | |
| p.add_argument("--device", default="cuda") | |
| p.add_argument("--clips", nargs="+", default=None, help="only these clip ids of the export (default: all)") | |
| args = p.parse_args(argv) | |
| config = pipeline.load_config(args.config) | |
| if args.verifier: | |
| config["verify"]["verifier"] = args.verifier | |
| if args.verifier_model: | |
| config["verify"]["model"] = args.verifier_model | |
| if args.stage in ("all", "propose"): | |
| print(json.dumps(pipeline.propose(args.export, args.out, config, args.sam3_checkpoint, args.device, args.clips)), flush=True) | |
| if args.stage in ("all", "verify"): | |
| from agt.masks.verifiers import build_verifier | |
| print(json.dumps(pipeline.verify(args.export, args.out, config, build_verifier(config["verify"], args.device), args.clips)), flush=True) | |
| if args.stage in ("all", "finish"): | |
| print(json.dumps(pipeline.finish(args.export, args.out, config, args.clips)), flush=True) | |
| if __name__ == "__main__": | |
| main() | |