File size: 695 Bytes
43ca9e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""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']}"