Abstract
Vision Transformers (ViTs) have demonstrated strong capabilities in capturing global dependencies but often struggle to efficiently represent fine-grained local details. Existing multi-scale approaches alleviate this issue by integrating hierarchical or hybrid features; however, they rely on fixed patch sizes and introduce redundant computation. To address these limitations, we propose Granularity-driven Vision Transformer (Grc-ViT), a dynamic coarse-to-fine framework that adaptively adjusts visual granularity based on image complexity. It comprises two key stages: (1) Coarse Granularity Evaluation module, which assesses visual complexity using edge density, entropy, and frequency-domain cues to estimate suitable patch and window sizes; (2) Fine-grained Refinement module, which refines attention computation according to the selected granularity, enabling efficient and precise feature learning. Two learnable parameters, α and β, are optimized end-to-end to balance global reasoning and local perception. Comprehensive evaluations demonstrate that Grc-ViT enhances fine-grained discrimination while achieving a superior trade-off between accuracy and computational efficiency.
Introduction
Standard Vision Transformers (ViTs) typically process images by partitioning them into fixed-size patches (e.g., 16x16). While effective for capturing global context, this "one-size-fits-all" approach is inherently inefficient. Simple images with large uniform regions, such as a clear sky, do not require the same high-resolution processing as complex scenes with intricate textures. Furthermore, fixed patch sizes often struggle to capture fine-grained local details without significantly increasing computational costs (FLOPs). The authors of Grc-ViT propose a solution: analyze image complexity first, then decide the appropriate granularity for processing.
The Grc-ViT Framework
The Granularity-driven Vision Transformer (Grc-ViT) operates in two main stages to decouple complexity estimation from feature extraction.
1. Coarse Granularity Evaluation
Before heavy feature extraction begins, a lightweight, training-free module analyzes the image. It uses three "cues" to determine visual complexity:
- Edge Density: Using the Canny operator to identify structural detail.
- Information Entropy: Measuring the randomness of pixel intensities.
- Frequency-Domain Variation: Using 2D Fast Fourier Transforms (FFT) to identify high-frequency textures.
These cues are fused into a complexity score, which routes the image into one of three paths: Coarse, Medium, or Fine. The thresholds for this routing (α and β) are learnable parameters optimized during training.
2. Fine-grained Refinement
Instead of building separate models for each path, Grc-ViT uses a shared Transformer backbone based on the Swin architecture. To handle different granularities efficiently, it employs:
- Granularity-specific Adapters: Lightweight layers that map different patch sizes into a unified "attention core."
- Dynamic Scaling: The model adjusts patch and window sizes based on the complexity score. Complex images receive smaller patches to capture intricate details, while simpler images use larger patches to save computational power.
Visualizing Granularity and Attention
The core hypothesis is that different granularities are better suited for different visual tasks. By adaptively adjusting the focus, the model can more accurately pinpoint salient features.
As shown in the attention maps above, coarser granularities provide a broad overview, while finer granularities allow the model to resolve subtle features necessary for distinguishing between similar classes, such as different animal species or aircraft models.
Experimental Results
Grc-ViT was evaluated on foundational datasets (CIFAR-10/100, Tiny-ImageNet) and specialized fine-grained benchmarks (Stanford Dogs, CUB-200-2011).
- Efficiency vs. Accuracy: On Tiny-ImageNet, Grc-ViT reduced computational requirements from 15.14G FLOPs to 6.07G FLOPs while simultaneously improving accuracy from 79.25% to 79.72%.
- Fine-grained Superiority: The model excelled on the Stanford Dogs dataset, outperforming the baseline by over 1%. This confirms that adaptive granularity is particularly effective for tasks requiring subtle discrimination between similar species.
- Inference Speed: By avoiding redundant computations on simple images, Grc-ViT achieved an approximately 18% reduction in inference time compared to non-granular baselines.
Conclusion
Grc-ViT represents a shift away from static image partitioning in Vision Transformers. By adaptively adjusting granularity based on content, the model achieves a superior balance of performance and efficiency. While currently tied to the Swin architecture, the principles of dynamic granularity offer a promising path for making large-scale vision models more viable for real-time and resource-constrained applications.
Summary updated