DPT: Deformable Patch-based Transformer for Visual Recognition

Zhiyang Chen, Yousong Zhu, Chaoyang Zhao, Guosheng Hu, Wei Zeng, Jinqiao Wang, Ming Tang · DOI

Abstract

Vision Transformers (ViTs) typically rely on a rigid, fixed-grid patch embedding that often bisects critical semantic features. We introduce the Deformable Patch-based Transformer (DPT), which replaces this static approach with a learnable DePatch module. By adaptively predicting patch offsets and scales, DPT allows the model to focus on salient object parts, leading to significant performance improvements in image classification and object detection with negligible computational overhead.

Introduction

Most Vision Transformers begin by partitioning an image into a grid of fixed-size square patches (e.g., 16x16 pixels). While computationally simple, this "hard" splitting approach suffers from two major flaws:

  1. Structural Collapse: Fixed grids often cut through important features—such as a bird's beak or a cat's ear—splitting a single semantic unit across multiple patches and complicating the model's ability to re-assemble object meaning.
  2. Geometric Inflexibility: Objects in the real world appear at varying scales and orientations. A fixed grid cannot adapt to these variations, such as a small bird in the distance versus a close-up of a wing.

DPT addresses these issues by introducing a data-driven way to define patches that respect the actual boundaries and scales of objects within a scene.

Methodology: The DePatch Module

The core innovation of DPT is the DePatch (Deformable Patch) module. Instead of assuming every patch is a fixed square at a fixed coordinate, DePatch treats the position and scale of each patch as learnable parameters.

How it Works

  • Predicting Offsets and Scales: For every patch location, the module uses a lightweight linear layer to predict an $(x, y)$ offset and a $(width, height)$ scale based on the local features of the input map.
  • Bilinear Sampling: Since predicted coordinates are often fractional, the model employs bilinear interpolation to sample a $k imes k$ grid of points within the newly defined rectangular region.
  • Architecture Integration: DePatch is integrated into the Pyramid Vision Transformer (PVT) architecture, replacing standard patch embedding layers at the start of Stages 2, 3, and 4.
Comparison between the rigid grid of original patch embedding (a) and the adaptive, semantic-aware patches of the DePatch module (b).

This approach allows the transformer to "reach out" and capture more meaningful chunks of the image, effectively acting as a learnable crop that focuses on salient features like a "claw" or "tail" within a single token.

Experimental Results

The researchers evaluated DPT on two primary benchmarks: ImageNet-1K for classification and MS COCO for object detection and instance segmentation.

  • ImageNet Classification: DPT-Tiny achieved 77.4% top-1 accuracy, a 2.3% improvement over the baseline PVT-Tiny. The DPT-Medium model reached 81.9%, outperforming larger models like PVT-Large.
  • Object Detection: On MS COCO using the RetinaNet framework, DPT-Small achieved 42.5% mAP, beating the standard ResNet50 by 6.2% and the baseline PVT-Small by 2.1%.
  • Efficiency: These gains are achieved with minimal cost; DPT-Small adds only approximately 1.9 million parameters compared to PVT-Small.

Key Insights and Discussion

  • Semantic Preservation: By allowing patches to deform, the model can encapsulate entire object parts within single tokens, simplifying the task for subsequent attention layers and leading to faster convergence.
  • Receptive Field: Increasing the number of sampling points ($k \times k$) within a deformable patch expands the receptive field, capturing more context without a massive increase in parameters.
  • Stage Sensitivity: DePatch is most effective in later stages. In Stage 1 (raw pixels), the lack of high-level semantic information makes it difficult for the model to predict optimal patch movements.

Conclusion

DPT demonstrates that moving away from rigid image partitioning significantly enhances the representative power of Vision Transformers. By making patch embedding a learnable, content-aware process, DPT achieves a better balance of accuracy and efficiency across diverse visual recognition tasks.

Summary updated

BibTeX
@inproceedings{chen2021dpt,
  author = {Zhiyang Chen and Yousong Zhu and Chaoyang Zhao and Guosheng Hu and Wei Zeng and Jinqiao Wang and Ming Tang},
  title = {{DPT: Deformable Patch-based Transformer for Visual Recognition}},
  booktitle = {ACM Multimedia},
  year = {2021},
  doi = {10.1145/3474085.3475467},
}
Figure