TL;DR
This paper introduces NARAIM, a novel pre-training method for vision transformers that preserves the original aspect ratio of images. By avoiding the common practice of resizing images to squares, NARAIM better preserves spatial context, leading to improved downstream classification performance, especially for images with non-square aspect ratios.
What Problem Does This Paper Address?
Large language models have demonstrated impressive scaling laws, meaning their performance consistently improves with increased data, model size, and compute. Researchers are seeking similar scaling behaviors in computer vision. Autoregressive models, which predict the next element in a sequence, have shown promise in vision tasks, mirroring their success in NLP. However, a common pre-training practice for these vision models involves cropping and resizing images into squares. This process can distort or destroy crucial spatial information within the images, potentially hindering the model's ability to learn robust representations, especially for images that are naturally non-square. This paper aims to address this limitation by proposing a pre-training method that respects the native aspect ratio of images.
Methods
The core contribution of this paper is the NARAIM (Native Aspect Ratio Autoregressive Image Models) approach. NARAIM builds upon existing Autoregressive Image Models (AIM) but modifies the input processing to preserve the native aspect ratio.
Here's a breakdown of the key methodological aspects:
- Native Aspect Ratio Resize: Instead of forcing images into a fixed square resolution (e.g., 224x224), NARAIM resizes images to maintain their original aspect ratio while keeping the total pixel count roughly constant. A crop is then taken from the top-left, ensuring dimensions are multiples of the patch size. This preserves the original spatial layout.
- Patchification: Images are then divided into square patches (e.g., 14x14) using a raster (row-major) ordering.
- Autoregressive Pre-training: Similar to AIM, a Vision Transformer (ViT) backbone is used. A causal attention mask ensures that the model predicts the next image patch based only on preceding patches, fostering strong representation learning.
- Positional Embeddings: The paper explores both absolute and fractional positional embeddings. Fractional embeddings, which use the proportion of a patch's position within the image dimensions, are hypothesized to generalize better to varying aspect ratios.
- Augmentations: To retain regularization benefits while respecting aspect ratios, NARAIM uses random cropping that preserves the native aspect ratio, with a constraint that the crop must contain a minimum number of pixels. Random horizontal flips are also applied.
- Downstream Adaptation: For fine-tuning on downstream tasks like classification, the ViT backbone is frozen, and an attentive classification probe is used. This probe is found to perform better than a linear probe.
Datasets
- ImageNet-1k: This dataset is used for both pre-training and downstream classification tasks. The paper notes that it's a common benchmark for evaluating vision models.
Key Insights and Ideas
- Aspect Ratio Matters for Autoregressive Vision Models: The paper strongly suggests that preserving the native aspect ratio is not just a minor detail but crucial for effective autoregressive pre-training in vision. Distorting images into squares can disrupt patterns that the model needs to learn.
- Fractional Positional Embeddings Generalize Better: The experiments indicate that fractional positional embeddings are more robust to out-of-distribution aspect ratios compared to absolute embeddings. This is because they capture relative positions, which are more invariant to the total number of patches.
- Random Cropping as a Regularizer: The standard random resized crop, while common, can be detrimental. A modified random crop that preserves the native aspect ratio acts as a more effective regularizer, preventing overfitting during pre-training.
- Patch-wise Normalization is Critical: The ablation studies highlight the importance of patch-wise normalization for downstream accuracy. Without it, models might rely on shortcuts, leading to reduced performance.
Key Results
- Improved Classification Accuracy: The best NARAIM model achieved a validation accuracy of 56.8 ± 0.1% on ImageNet-1k, surpassing the original AIM model by over two percentage points (54.7 ± 0.6%).
- Consistent Improvement Across Aspect Ratios: NARAIM models showed higher accuracy than AIM across all tested aspect ratio bins, demonstrating its general applicability.
- Robustness to Non-Square Images: The performance of the AIM model degraded on non-square images, whereas NARAIM maintained or improved performance. The "NARAIM + RandomCrop" variant was particularly stable.
- Ablation Study Findings:
- Fractional embeddings provided a small accuracy increase.
- Random cropping significantly boosted downstream accuracy, suggesting the base NARAIM model was prone to overfitting.
- Patch-wise normalization was found to be very important for downstream accuracy.
Limitations and Future Work
- Limited Scale: The experiments were conducted on a ViT-B/14 backbone (86M parameters) due to resource constraints. The authors plan to scale their model to 600 million parameters to benchmark against the original AIM at scale.
- Downstream Task Breadth: While classification performance is shown to improve, the authors suggest extending downstream evaluation to more tasks.
- Data Augmentation Nuances: While random cropping improved performance, the "NARAIM + Fractional" models showed slightly noisy behavior, possibly due to overfitting on the training set due to a lack of data augmentation. Further exploration of augmentations might be beneficial.
Summary updated