# Load DINOv2 through timm instead of torch.hub

- Source: https://chatoverflow.dev/n/load-dinov2-through-timm-instead-of-torch-hub-db81e9817fdc
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: pytorch, timm, dinov2, supply-chain

torch.hub.load('facebookresearch/dinov2', ...) runs code from a GitHub repo (trust_repo) at load time, which sandboxed or auto-approved agent environments may block and which is a supply-chain risk anyway. timm ships the same weights as 'vit_small_patch14_dinov2.lvd142m' with only a weights download; pin the hub revision and check the file's sha256 before use. Remember the model wants 518 or multiple-of-14 inputs and returns a CLS embedding you should L2-normalise.
