Image Feature Extraction
timm
vision
self-supervised-learning
image-classification
feature-extraction
vit
Instructions to use BooBooWu/visreg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use BooBooWu/visreg with timm:
import timm model = timm.create_model("hf_hub:BooBooWu/visreg", pretrained=True) - Notebooks
- Google Colab
- Kaggle
publish model
Browse files- README.md +113 -0
- visreg-vit-b-inet1k.pth +3 -0
- visreg-vit-l-inet1k.pth +3 -0
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
library_name: timm
|
| 4 |
+
tags:
|
| 5 |
+
- vision
|
| 6 |
+
- self-supervised-learning
|
| 7 |
+
- image-classification
|
| 8 |
+
- feature-extraction
|
| 9 |
+
- vit
|
| 10 |
+
datasets:
|
| 11 |
+
- ILSVRC/imagenet-1k
|
| 12 |
+
pipeline_tag: image-feature-extraction
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
<h1 style="font-size: 2.5em; text-align: center;">VISReg: Variance-Invariance-Sketching Regularization for JEPA training</h1>
|
| 16 |
+
|
| 17 |
+
<p align="center">
|
| 18 |
+
<a href="https://arxiv.org/abs/2511.08544"><img src="https://img.shields.io/badge/arXiv-2511.08544-b31b1b.svg" alt="arXiv"></a>
|
| 19 |
+
<a href="https://haiyuwu.github.io/visreg/"><img src="https://img.shields.io/badge/Project-Page-blue" alt="Project Page"></a>
|
| 20 |
+
<a href="https://github.com/HaiyuWu/visreg"><img src="https://img.shields.io/badge/GitHub-Code-black?logo=github" alt="GitHub"></a>
|
| 21 |
+
</p>
|
| 22 |
+
|
| 23 |
+
**Key results:**
|
| 24 |
+
- 💪 **Strong collapse prevention**: High gradient when embedding collapse
|
| 25 |
+
- ⚡ **Friendly to scale training**: Linear complexity to scaling factors
|
| 26 |
+
- 🧩 **Easy to train**: Similar to LeJEPA, it is a heuristic-free method
|
| 27 |
+
- 🏆 **Best OOD performance**: Achieve the best accuracy on 6 OOD datasets
|
| 28 |
+
- 📉 **Data efficiency**: Achieving a similar average accuracy to DINOv2 with 90% less data
|
| 29 |
+
- 🧬 **Robust to low-quality datasets**: It is robust to long-tailed and sparse datasets
|
| 30 |
+
|
| 31 |
+
<h2 style="font-size: 1.8em;">Available Checkpoints</h2>
|
| 32 |
+
|
| 33 |
+
| File | Architecture | Patch Size | Embed Dim | Params | Pre-training Data |
|
| 34 |
+
|------|-------------|------------|-----------|--------|-------------------|
|
| 35 |
+
| `visreg-vit-b-inet1k.pth` | ViT-Base | 16 | 768 | 86M | ImageNet-1K |
|
| 36 |
+
| `visreg-vit-l-inet1k.pth` | ViT-Large | 14 | 1024 | 304M | ImageNet-1K |
|
| 37 |
+
|
| 38 |
+
<h2 style="font-size: 1.8em;">Usage</h2>
|
| 39 |
+
|
| 40 |
+
<h3 style="font-size: 1.4em;">Load with timm</h3>
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
import timm
|
| 44 |
+
import torch
|
| 45 |
+
|
| 46 |
+
# ViT-Base/16
|
| 47 |
+
model = timm.create_model("vit_base_patch16_224", pretrained=False, num_classes=0, dynamic_img_size=True)
|
| 48 |
+
state_dict = torch.load("visreg-vit-b-inet1k.pth", map_location="cpu")
|
| 49 |
+
model.load_state_dict(state_dict)
|
| 50 |
+
|
| 51 |
+
# ViT-Large/14
|
| 52 |
+
model = timm.create_model("vit_large_patch14_224", pretrained=False, num_classes=0, dynamic_img_size=True)
|
| 53 |
+
state_dict = torch.load("visreg-vit-l-inet1k.pth", map_location="cpu")
|
| 54 |
+
model.load_state_dict(state_dict)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
<h3 style="font-size: 1.4em;">Download with huggingface_hub</h3>
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
from huggingface_hub import hf_hub_download
|
| 61 |
+
|
| 62 |
+
# ViT-Base/16
|
| 63 |
+
path = hf_hub_download(repo_id="BooBooWu/visreg", filename="visreg-vit-b-inet1k.pth")
|
| 64 |
+
|
| 65 |
+
# ViT-Large/14
|
| 66 |
+
path = hf_hub_download(repo_id="BooBooWu/visreg", filename="visreg-vit-l-inet1k.pth")
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
<h3 style="font-size: 1.4em;">Feature extraction</h3>
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from PIL import Image
|
| 73 |
+
from torchvision import transforms
|
| 74 |
+
|
| 75 |
+
transform = transforms.Compose([
|
| 76 |
+
transforms.Resize(256),
|
| 77 |
+
transforms.CenterCrop(224),
|
| 78 |
+
transforms.ToTensor(),
|
| 79 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 80 |
+
])
|
| 81 |
+
|
| 82 |
+
img = transform(Image.open("image.jpg")).unsqueeze(0)
|
| 83 |
+
|
| 84 |
+
with torch.no_grad():
|
| 85 |
+
features = model(img) # [1, embed_dim]
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
<h2 style="font-size: 1.8em;">Evaluation</h2>
|
| 89 |
+
|
| 90 |
+
Full evaluation suite (linear probe, segmentation, fine-tuning) is available in the [GitHub repo](https://github.com/HaiyuWu/visreg):
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
# Linear probe on 10+ datasets
|
| 94 |
+
python downstream/linear_prob/run_evaluation.py \
|
| 95 |
+
--checkpoint visreg-vit-b-inet1k.pth \
|
| 96 |
+
--model vit_b \
|
| 97 |
+
--datasets all
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
<h2 style="font-size: 1.8em;">Citation</h2>
|
| 101 |
+
|
| 102 |
+
```bibtex
|
| 103 |
+
@inproceedings{wu2026visreg,
|
| 104 |
+
title = {VISReg: Variance-Invariance-Sketching Regularization for JEPA training},
|
| 105 |
+
author = {Wu, Haiyu and Balestriero, Randall and LeCun, Yann and Levine, Morgan},
|
| 106 |
+
booktitle = {arXiv},
|
| 107 |
+
year = {2026}
|
| 108 |
+
}
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
<h2 style="font-size: 1.8em;">License</h2>
|
| 112 |
+
|
| 113 |
+
This project (code and pretrained weights) is released under [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) for non-commercial use only.
|
visreg-vit-b-inet1k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be2b3041c1ed08ce85dcd431b4dc9e2d563396465bb77627b626974bb37a61a8
|
| 3 |
+
size 343241635
|
visreg-vit-l-inet1k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61721b6b7f8456a422662dd4548718568491f5ca94eae271d20342a2cd5c349f
|
| 3 |
+
size 1212806915
|