Reimplementation Self-Supervised Vision Transformers for DINO v2 with Huggingface ๐Ÿค—

July 4, 2025 ยท View on GitHub


  • Pytorch implementation and pretrained models for DINO v2 in remote sensing.
  • See Official Paper and Github for information in detail. [arXiv #1] [arXiv #2] [Github]

Training

This project use the deepspeed interface for multi gpu training with DeepSpeed Zero Stage 3

deepspeed --include localhost:0,1,2,3,4,5,6,7 train.py --deepspeed --deepspeed_config ds_config/ds_z3.json --model-path {model_path} --batch-size {total_batch_size}

Training Dataset for Remote Sensing

Dataset name# of corpusDataset Paper
Million-AID990,666Link
SkyScript5,181,068Link
Total6,171,734

Pretrained Model on Huggingface

ModelEpochTotal ParamsStudent Backbone ParamsStudent DINO Head ParamsStudent iBOT Head ParamsWeight & ConfigLogs
ViT-S/16-e2525132M21M22M22MLinklogs
ViT-S/16-e10025132M21M22M22MLinklogs
ViT-B/16-e2525264M88M21M21MLinklogs
ViT-L/14-e2525837M303M57M57MLinklogs
ViT-L/14-e5050837M303M57M57MLinklogs

Evaluation

The evaluation methods for DINOv2 are k-nn clustering and linear probing. 90% of the data is randomly selected as the training set while the 10% is selected as test set. The k=20 is selected for evaluation with K-NN. The evaluation datasets are including below table. The splited data is stored in linprob_data_lists.

Dataset NameDataset Paper
RESISCRemote Sensing Image Scene Classification: Benchmark and State of the Art
Optimal 31Scene Classification With Recurrent Attention of VHR Remote Sensing Images
MLRSNetMLRSNet: A Multi-label High Spatial Resolution Remote Sensing Dataset for Semantic Scene Understanding
WHU-RS19
EuroSATEuroSAT: A Novel Dataset and Deep Learning Benchmark for Land Use and Land Cover Classification
UC MercedBag-of-visual-words and spatial extensions for land-use classification
Cv-BrCTAiRound and CV-BrCT: Novel Multi-View Datasets for Scene Classification
AiRoundAiRound and CV-BrCT: Novel Multi-View Datasets for Scene Classification
RSI-CB128RSI-CB: A Large Scale Remote Sensing Image Classification Benchmark via Crowdsource Data

Linear Probing Evaluation

# train_textfile = linprob_data_lists/RESISC/train.txt
# test_textfile = linprob_data_lists/RESISC/test.txt

python3 evaluation/linprob.py --model-path {model_registry} \
                              --data-root {data_root} \
                              --train-text {train_textfile} \
                              --test-text {test_textfile}
ModelRESISCOptimal 31MLRSNetWHU-RS19EuroSATUC MercedCv-BrCTAiRoundRSI-CB128Avg
ViT-S/16-e2594.38196.23796.64299.81198.03799.04877.61378.64499.59393.334
ViT-S/16-e10094.38195.16196.349100.0097.70499.04876.91079.40799.53993.167
ViT-B/16-e2595.46098.92597.301100.0097.88998.57179.05880.33999.67594.135
ViT-L/14-e2596.60396.77498.161100.00098.70499.04880.13282.62799.72994.642
ViT-L/14-e5096.76296.77497.511100.0098.40798.57180.46385.50899.70294.855

KNN Evaluation

# train_textfile = linprob_data_lists/RESISC/train.txt
# test_textfile = linprob_data_lists/RESISC/test.txt

python3 evaluation/knn.py --model-path {model_registry} \
                              --data-root {data_root} \
                              --train-text {train_textfile} \
                              --test-text {test_textfile}
ModelRESISCOptimal 31MLRSNetWHU-RS19EuroSATUC MercedCv-BrCTAiRoundRSI-CB128Avg
Official ViT-S/1487.77885.48491.82099.06592.07491.42973.93674.06896.50488.018
Official ViT-B/1490.57189.24791.94896.26290.66792.85774.72175.84796.58588.745
ViT-S/16-e2593.36589.78596.98197.19695.74187.14376.20877.88198.94390.360
ViT-S/16-e10093.74694.62497.08197.19696.22286.66775.96076.69598.80890.778
ViT-B/16-e2594.28690.32397.328100.0095.70487.14376.45677.37399.10690.858
ViT-L/14-e2593.77891.39897.39299.06596.96388.09579.43080.08599.13391.704
ViT-L/14-e5094.06392.47397.511100.0096.70487.61979.84382.20399.07992.116

Property Analysis