""" Download model weights for Hugging Face Spaces deployment. R50_TF, R50_nodown, CLIP-D, P2G and NPR ship their weights via Git LFS. PGC, ForensicConcept and MDMF use the official pre-trained weights and backbones (about 4 GB), which are fetched from their original sources and checksum-verified on first start. """ import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parent REQUIRED = { "PGC": ["checkpoint/pretrained/weights/best.pt", "checkpoint/backbones/dinov2-large/model.safetensors"], "ForensicConcept": ["checkpoint/pretrained/weights/best.pt", "checkpoint/backbones/ViT-L-14.pt", "upstream/codebooks/cleandift_codebook.npy"], "MDMF": ["checkpoint/pretrained/weights/best.pt", "checkpoint/backbones/dinov2-large/config.json"], } def download_all_weights(): for method, files in REQUIRED.items(): base = ROOT / "detectors" / method if all((base / f).exists() for f in files): print(f"✓ {method} weights present") continue print(f"Downloading official weights for {method}...") try: subprocess.run([sys.executable, str(ROOT / "support" / "setup_recent_weights.py"), method], check=True, cwd=ROOT) except Exception as e: print(f"✗ Failed to set up {method}: {e}") if __name__ == "__main__": download_all_weights()