spaceflow / lib /util /model_revisions.py
multimodalart's picture
multimodalart HF Staff
SpaceFlow demo
43ca9e0 verified
Raw History Blame Contribute Delete
695 Bytes
"""Recorded source revision for TRELLIS's DINOv2 image conditioner."""
import json
from pathlib import Path
import re
MODEL_REVISIONS = Path(__file__).resolve().parents[2] / "requirements/model-revisions.json"
def dinov2_hub_repository(pins_path: Path = MODEL_REVISIONS) -> str:
"""Use an immutable upstream commit instead of PyTorch Hub's moving main."""
record = json.loads(pins_path.read_text())["dinov2"]
if record["repository"] != "facebookresearch/dinov2" or not re.fullmatch(r"[0-9a-f]{40}", record["revision"]):
raise ValueError("DINOv2 requires the recorded upstream repository and a full commit SHA.")
return f"{record['repository']}:{record['revision']}"