GreedyViG: Dynamic Axial Graph Construction for Efficient Vision GNNs

Mustafa Munir, William Avery, Md Mostafijur Rahman, Radu Marculescu · DOI

Abstract

Vision graph neural networks (ViG) offer a new avenue for exploration in computer vision. A major bottleneck in ViGs is the inefficient k-nearest neighbor (KNN) operation used for graph construction. To solve this issue, we propose a new method for designing ViGs, Dynamic Axial Graph Construction (DAGC), which is more efficient than KNN as it limits the number of considered graph connections made within an image. Additionally, we propose a novel CNN-GNN architecture, GreedyViG, which uses DAGC. Extensive experiments show that GreedyViG beats existing ViG, CNN, and ViT architectures in terms of accuracy, GMACs, and parameters on image classification, object detection, instance segmentation, and semantic segmentation tasks. Our smallest model, GreedyViG-S, achieves 81.1% top-1 accuracy on ImageNet-1K, 2.9% higher than Vision GNN and 2.2% higher than Vision HyperGraph Neural Network (ViHGNN), with less GMACs and a similar number of parameters. Our largest model, GreedyViG-B obtains 83.9% top-1 accuracy, 0.2% higher than Vision GNN, with a 66.6% decrease in parameters and a 69% decrease in GMACs.

Introduction

The landscape of computer vision has evolved from the local receptive fields of Convolutional Neural Networks (CNNs) to the global attention mechanisms of Vision Transformers (ViTs). Recently, Vision Graph Neural Networks (ViGs) have emerged as a compelling alternative, representing images as graphs where patches (nodes) are connected based on feature similarity.

However, ViGs face a significant computational bottleneck in graph construction. Traditional dynamic approaches use K-Nearest Neighbors (KNN) to find similar patches, which is content-aware but computationally expensive ($O(N^2)$). Conversely, static approaches use fixed graph structures to maintain efficiency but lose the ability to adapt to specific image content. GreedyViG addresses this "Goldilocks" problem by introducing Dynamic Axial Graph Construction (DAGC), a method that is both content-aware and highly efficient.

Methodology: Dynamic Axial Graph Construction

The core innovation of GreedyViG is the DAGC module. Instead of searching the entire image for neighbors, DAGC operates along horizontal and vertical axes (axial processing). To make these connections dynamic without the cost of full distance matrices, the authors employ a novel statistical distance estimation technique.

The Quadrant Trick

To avoid calculating every possible distance, the model estimates the mean ($\mu$) and standard deviation ($\sigma$) of patch distances by comparing quadrants of the image against their flipped versions. This heuristic provides a global representation of the image's feature distribution at a fraction of the cost of KNN.

The quadrant-flipping heuristic used for efficient statistical distance estimation.

Following this estimation, a dynamic mask is applied: patches are only connected if their Euclidean distance is less than $\mu - \sigma$. This ensures that only highly similar patches are linked, allowing the graph to adapt to the specific objects in the scene while ignoring irrelevant background noise.

GreedyViG Architecture

The GreedyViG architecture is a four-stage hybrid CNN-GNN model. It utilizes MBConv blocks (standard in mobile-optimized CNNs) for local feature extraction in the early stages and DAGC blocks for global graph-based reasoning in the later stages. To provide spatial awareness, which graphs inherently lack, the model incorporates Conditional Positional Encoding (CPE).

Experimental Results

GreedyViG was evaluated on ImageNet-1K for classification, MS COCO 2017 for object detection, and ADE20K for semantic segmentation.

ImageNet-1K Performance

GreedyViG consistently outperforms pure CNNs, ViTs, and previous ViG models across various scales. As shown in the performance comparison, GreedyViG establishes a new state-of-the-art Pareto frontier for accuracy versus parameter count.

Comparison of Top-1 Accuracy vs. Parameters on ImageNet-1K, showing GreedyViG's superior efficiency.
  • GreedyViG-B achieves 83.9% top-1 accuracy, matching the performance of the much heavier ViHGNN-B but with a 66.6% reduction in parameters and a 69% reduction in GMACs.
  • GreedyViG-S hits 81.1% accuracy, surpassing the original Vision GNN by 2.9% while maintaining a lower computational footprint.

Downstream Tasks and Latency

On MS COCO object detection, GreedyViG-B achieved 46.3 $AP^{box}$, outperforming backbones like PoolFormer and MobileViG-B. Crucially, the DAGC graph construction phase is significantly faster than KNN; on an NVIDIA RTX A6000, DAGC took only 0.06 ms compared to 0.38 ms for KNN, representing a 6x speedup in graph generation.

Discussion and Future Work

While DAGC is mathematically efficient, its reliance on "roll" and "mask" operations means that standard deep learning libraries may require custom CUDA kernels to fully realize theoretical speed gains on all hardware. Furthermore, while the axial approach scales better than KNN, extremely high-resolution processing remains a challenge for global stages. Future research may explore more aggressive variations in "hop" distances across different layers to further optimize the balance between local and global processing.

In conclusion, GreedyViG demonstrates that hybrid CNN-GNN architectures, powered by efficient dynamic graph construction, provide a powerful new avenue for designing high-performance, resource-constrained vision models.

Summary updated

BibTeX
@misc{munir2024greedyvig,
  author = {Mustafa Munir and William Avery and Md Mostafijur Rahman and Radu Marculescu},
  title = {{GreedyViG: Dynamic Axial Graph Construction for Efficient Vision GNNs}},
  year = {2024},
  eprint = {2405.06849},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.06849},
}
Figure