Spaces:
Sleeping
Sleeping
File size: 1,426 Bytes
a479aa5 c55595d a479aa5 c55595d a479aa5 c55595d a479aa5 c55595d a479aa5 c55595d a479aa5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """
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()
|