ViViT Fine-Tuning for HMDB51 Guide
ViViT Fine-Tuning for HMDB51 Guide
Per-class accuracy tracking plays a critical role in evaluating the model's performance across different action categories. Instead of providing an overall accuracy score, it tracks how accurately the model predicts each class, highlighting any discrepancies in performance among them. This is crucial for identifying classes that the model struggles to recognize, guiding targeted improvements like data augmentation for underperforming classes. It ensures a comprehensive evaluation that goes beyond aggregate accuracy, fostering balanced learning across all action categories in HMDB51 .
A learning rate scheduler adjusts the learning rate during training, which can help avoid issues like weights oscillating or converging too quickly to suboptimal minima. In the ViViT fine-tuning pipeline, common schedulers such as CosineAnnealingLR, ReduceLROnPlateau, or StepLR are used to dynamically modify the learning rate, usually decreasing it over time to help fine-tune the model more precisely. This controlled adjustment improves model performance by ensuring stable convergence and maintaining a balance between exploration and exploitation during training .
The HMDB51 dataset is organized into 51 class folders, each containing multiple video files. This structure allows easy parsing of official train/test split files provided for each class, which are then converted into Python dictionaries. Stratified train/val/test splits, where the dataset is divided so each class is equally represented (typically 70% train, 15% val, 15% test), ensure balanced performance evaluation across all classes. This prevents class imbalance from skewing the results and provides a more reliable assessment of the model's generalization ability to unseen data .
During data preprocessing, transformations such as resizing, cropping, and normalization are applied to standardize frame dimensions, which helps improve the model's performance by making the input data consistent. Furthermore, temporal normalization ensures each video sample has the same number of frames, addressing discrepancies in video length by looping shorter videos and truncating longer ones. Additionally, data augmentation techniques like random horizontal flips, color jitter, rotation, and random crops are used during training to enhance model generalization by simulating real-world variations .
Post-training analyses on the ViViT model involve running it on the test set using the best checkpoint and computing metrics such as confusion matrix, precision, recall, F1 score per class, and mean accuracy. Additionally, training/validation curves for loss and accuracy are plotted, and a confusion matrix heatmap is shown to gain insights into misclassifications. These analyses provide a detailed understanding of model performance, revealing strengths and weaknesses in classifying different actions, informing decisions for further model iterations or tuning .
Inference testing involves loading the exported model and assessing its speed and accuracy on single video samples. This process benefits from adhering to interface contracts, which define the data flow from video files to tensors and batch processing (from video ".avi" to tensor shape (T, H, W, C) to batch shape (B, C, T, H, W)). These contracts ensure consistency and compatibility between the data input/output structures expected by the model and the actual inputs provided during inference testing. This alignment is critical for achieving reliable results and optimizing the model's performance during deployment .
Gradient clipping prevents the issue of exploding gradients during backpropagation by limiting the maximum gradient value (norm). This ensures that the weight updates are not excessively large, maintaining stable learning and facilitating convergence. It's considered optional because not all models suffer from exploding gradients, and utilizations depend on the observed stability issues during training. In ViViT's context, its complex architecture might occasionally benefit from this technique to maintain training stability, particularly when dealing with large models or noisy data .
Mixed precision involves using 16-bit floating-point numbers along with 32-bit ones to reduce memory usage and increase training speed. For large models like ViViT, this optimization is crucial as it allows larger batch sizes or more parameters to fit into the same GPU memory, reducing the time and cost of training while maintaining similar performance to using full precision .
Replacing the classification head of the ViViT model is significant for adapting the pre-trained model to the specific task of HMDB51, which involves action recognition across 51 classes. The original classification layer is replaced with a new fully connected layer matching the number of classes in HMDB51 (from the pre-trained dataset's classes to 51 classes in HMDB51). This customization allows the model to output logits specifically tailored for HMDB51's action categories, adapting learned features from the larger pre-trained dataset to the specific domain of HMDB51 .
Using AMP in the PyTorch CUDA module during ViViT training reduces memory usage significantly because it allows computation in lower precision (16-bit) while maintaining model accuracy. This reduction in memory allows for training with larger batch sizes or more complex models on the same hardware. It also enhances training speed, which is beneficial for large-scale deep learning models, where computational efficiency and reduced training time contribute significantly to the feasibility and scalability of practical AI applications .