Instructions to use mgmbiik/image-context-sorter-dinov2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use mgmbiik/image-context-sorter-dinov2 with timm:
import timm model = timm.create_model("hf_hub:mgmbiik/image-context-sorter-dinov2", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Image Context Sorter โ DINOv2 partial fine-tune
Restoration-work photo classifier for ํ์ฐ์ค์บ์น (water-damage restoration). Classifies a single photo into one of 8 work-type / stage categories.
Private / internal โ trained on client work photos; not for redistribution.
Results (locked test set, 8 classes)
| Model | macro-F1 | top-2 |
|---|---|---|
| 518px frozen linear probe (baseline) | 0.601 | 0.830 |
| 224px frozen linear probe (control) | 0.617 | 0.800 |
| 224px partial fine-tune (this model) | 0.737 | 0.895 |
Every class improved over the probe; the previously weakest class (๊ณฐํก์ด์ ๊ฑฐ) rose 0.44 โ 0.67 and its ๊ณฐํก์ด์ ๊ฑฐโ๋์ํ์ง confusion was eliminated.
Model
- Base:
vit_base_patch14_dinov2.lvd142m(timm / Meta DINOv2) - Fine-tune: partial โ the last 4 transformer blocks + final norm + a new 8-class head are unfrozen; the rest of the backbone is frozen. Input 224px (position-embedding interpolation). Discriminative LR (backbone 1e-5 / head 1e-3), AdamW + cosine schedule, float16 autocast (Apple MPS), class-weighted cross-entropy, early stopping on val macro-F1. No vertical-flip augmentation (ceiling/floor structure is a label cue).
- Calibration: temperature scaling, T โ 2.44 (fit on the val split). Apply it to logits before softmax for honest confidence; it does not change argmax/accuracy.
Classes (index order)
0 ์ฒ ๊ฑฐ์ค ยท 1 ๋นํฌ1 ยท 2 ์ ํํฐ ยท 3 ๋ณด์์์
ยท 4 ์๊ณ ๋ณด๋์ค์น ยท 5 ๋์ํ์ง ยท 6 ๋๋ฐฐ์์
ยท 7 ๊ณฐํก์ด์ ๊ฑฐ
How to load
import timm, torch
from torchvision import transforms as T
model = timm.create_model(
"vit_base_patch14_dinov2.lvd142m", pretrained=False, num_classes=8, img_size=224
)
model.load_state_dict(torch.load("finetune.pt", map_location="cpu"))
model.eval()
tf = T.Compose([
T.Resize(224), T.CenterCrop(224), T.ToTensor(),
T.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
])
# logits = model(tf(img).unsqueeze(0))
# probs = torch.softmax(logits / 2.44, dim=1) # temperature-calibrated
License
This is a derivative of Meta's DINOv2 (vit_base_patch14_dinov2.lvd142m).
Use is governed by the DINOv2 model license โ see
https://github.com/facebookresearch/dinov2. Confirm redistribution / commercial
terms before any external distribution.
Notes
- Weights are a raw PyTorch
state_dict(finetune.pt). Consider converting tosafetensorsfor safer, code-free loading. - See
config.jsonfor the exact class list, temperature, and preprocessing.
- Downloads last month
- -