This contains the implementation of DIET (Dynamic Information Exchange Training), a novel fine-tuning approach that enhances the zero-shot capabilities of pre-trained vision models. DIET uses a specialized training method that combines traditional supervised learning with a secondary objective that encourages models to maintain and improve their representation capabilities.
DIET introduces several key concepts:
Dual Head Architecture: The model uses two classification heads:
Dynamic Loss Weighting: The relative importance of the DIET loss and the probe loss changes during training:
Label Smoothing: The DIET head uses label smoothing to prevent overfitting to the random diet classes.
Zero-Shot Evaluation: The model is evaluated using several zero-shot metrics, including k-NN, k-means clustering, and linear probing.
├── main.py # Main entry point for running experiments
├── checkpoints/ # Saved model checkpoints
├── config/ # Configuration files
│ └── params.py # Hyperparameter configurations
├── datasets/ # Dataset handling
│ └── data_loader.py # Data loading utilities
├── evaluation/ # Evaluation utilities
│ ├── metrics.py # Zero-shot metrics implementation
│ └── experiment_results.py # Results processing
├── models/ # Model implementations
│ ├── dinov2.py # DINOv2 model wrapper
│ ├── mae.py # MAE model wrapper
│ ├── ijepa.py # I-JEPA model wrapper
│ ├── mambavision.py # MambaVision model wrapper
│ └── aim.py # AIM model wrapper
├── results/ # Experiment results
├── training/ # Training utilities
│ ├── trainer.py # DIET Trainer implementation
│ └── config.py # Training configurations
└── utils/ # Utility functions
└── wandb_logger.py # Weights & Biases logging utilities
__ sanity_check.py # Sanity Check
The framework supports multiple state-of-the-art pre-trained vision models:
DINOv2 (Facebook AI): Self-supervised vision transformer with strong zero-shot capabilities
MAE (Masked Autoencoder): Self-supervised vision transformer that learns by reconstructing masked patches
I-JEPA (Joint-Embedding Predictive Architecture): Self-supervised model that predicts features of masked image regions
MambaVision: State-space model for vision tasks with selective state space layers
AIM (Autoregressive Image Models): Autoregressive model for image generation
ResNet50 (Baseline): Standard ResNet50 pre-trained on ImageNet
The framework supports several image classification datasets:
backbone_type: Type of backbone architecture ("resnet50", "dinov2", "mae", "ijepa", "mambavision", "aim")model_size: Size variant of the model ("small", "base", "large", "giant" for DINOv2, etc.)embedding_dim: Feature dimensionality of the model (automatically set based on model type)projection_dim: Dimensionality of the projection head (default: 256)dataset_name: Name of the dataset to usenum_classes: Number of classes in the dataset (set automatically)num_diet_classes: Number of random diet classes (default: 100-200, adjust based on dataset)da_strength: Data augmentation strength (0-3)limit_data: Number of training samples to use (set to np.inf for full dataset)num_epoch: Number of training epochs (default: 30)batch_size: Batch size for training (default: 64-128, adjust based on model and hardware)lr: Learning rate (typically 1e-4 to 5e-4)weight_decay: Weight decay for regularization (default: 0.05)label_smoothing: Label smoothing factor for DIET loss (default: 0.3)device: Device to use for training ("cuda" or "cpu")The DIET training process follows these steps:
Initialization:
Initial Evaluation:
Training Loop:
Periodic Evaluation:
Final Evaluation:
The framework evaluates zero-shot performance using several metrics:
The framework uses Weights & Biases (wandb) for experiment tracking:
Training Metrics:
Zero-Shot Metrics:
Visualizations:
change the parameters within config/params.py to select the parameters that fit your style
Alternatively, you can use the provided Jupyter notebook (Dinov2_Mnist_new_version copy 2.ipynb), which offers an interactive environment for running experiments with detailed visualizations.
The framework includes a sanity checking utility that verifies the zero-shot performance of pre-trained models on CIFAR-10. This helps ensure that the pre-trained models are properly loaded and functioning as expected before applying DIET finetuning.
Shell
55.3%
Python
43.3%
HTML
1.4%
This contains the implementation of DIET (Dynamic Information Exchange Training), a novel fine-tuning approach that enhances the zero-shot capabilities of pre-trained vision models. DIET uses a specialized training method that combines traditional supervised learning with a secondary objective that encourages models to maintain and improve their representation capabilities.
DIET introduces several key concepts:
Dual Head Architecture: The model uses two classification heads:
Dynamic Loss Weighting: The relative importance of the DIET loss and the probe loss changes during training:
Label Smoothing: The DIET head uses label smoothing to prevent overfitting to the random diet classes.
Zero-Shot Evaluation: The model is evaluated using several zero-shot metrics, including k-NN, k-means clustering, and linear probing.
├── main.py # Main entry point for running experiments
├── checkpoints/ # Saved model checkpoints
├── config/ # Configuration files
│ └── params.py # Hyperparameter configurations
├── datasets/ # Dataset handling
│ └── data_loader.py # Data loading utilities
├── evaluation/ # Evaluation utilities
│ ├── metrics.py # Zero-shot metrics implementation
│ └── experiment_results.py # Results processing
├── models/ # Model implementations
│ ├── dinov2.py # DINOv2 model wrapper
│ ├── mae.py # MAE model wrapper
│ ├── ijepa.py # I-JEPA model wrapper
│ ├── mambavision.py # MambaVision model wrapper
│ └── aim.py # AIM model wrapper
├── results/ # Experiment results
├── training/ # Training utilities
│ ├── trainer.py # DIET Trainer implementation
│ └── config.py # Training configurations
└── utils/ # Utility functions
└── wandb_logger.py # Weights & Biases logging utilities
__ sanity_check.py # Sanity Check
The framework supports multiple state-of-the-art pre-trained vision models:
DINOv2 (Facebook AI): Self-supervised vision transformer with strong zero-shot capabilities
MAE (Masked Autoencoder): Self-supervised vision transformer that learns by reconstructing masked patches
I-JEPA (Joint-Embedding Predictive Architecture): Self-supervised model that predicts features of masked image regions
MambaVision: State-space model for vision tasks with selective state space layers
AIM (Autoregressive Image Models): Autoregressive model for image generation
ResNet50 (Baseline): Standard ResNet50 pre-trained on ImageNet
The framework supports several image classification datasets:
backbone_type: Type of backbone architecture ("resnet50", "dinov2", "mae", "ijepa", "mambavision", "aim")model_size: Size variant of the model ("small", "base", "large", "giant" for DINOv2, etc.)embedding_dim: Feature dimensionality of the model (automatically set based on model type)projection_dim: Dimensionality of the projection head (default: 256)dataset_name: Name of the dataset to usenum_classes: Number of classes in the dataset (set automatically)num_diet_classes: Number of random diet classes (default: 100-200, adjust based on dataset)da_strength: Data augmentation strength (0-3)limit_data: Number of training samples to use (set to np.inf for full dataset)num_epoch: Number of training epochs (default: 30)batch_size: Batch size for training (default: 64-128, adjust based on model and hardware)lr: Learning rate (typically 1e-4 to 5e-4)weight_decay: Weight decay for regularization (default: 0.05)label_smoothing: Label smoothing factor for DIET loss (default: 0.3)device: Device to use for training ("cuda" or "cpu")The DIET training process follows these steps:
Initialization:
Initial Evaluation:
Training Loop:
Periodic Evaluation:
Final Evaluation:
The framework evaluates zero-shot performance using several metrics:
The framework uses Weights & Biases (wandb) for experiment tracking:
Training Metrics:
Zero-Shot Metrics:
Visualizations:
change the parameters within config/params.py to select the parameters that fit your style
Alternatively, you can use the provided Jupyter notebook (Dinov2_Mnist_new_version copy 2.ipynb), which offers an interactive environment for running experiments with detailed visualizations.
The framework includes a sanity checking utility that verifies the zero-shot performance of pre-trained models on CIFAR-10. This helps ensure that the pre-trained models are properly loaded and functioning as expected before applying DIET finetuning.
Shell
55.3%
Python
43.3%
HTML
1.4%