Skip to main content
QUICK REVIEW

[论文解读] Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolution

Mostafa Dehghani, Basil Mustafa|arXiv (Cornell University)|Jul 12, 2023
Advanced Image and Video Retrieval TechniquesComputer Science被引用 15
一句话总结

NaViT (Patch n' Pack) 通过将多个示例打包成一个序列,使视觉变换器能够以原生分辨率和任意纵横比处理图像,从而提高训练效率并在不同分辨率下实现灵活推断。

ABSTRACT

The ubiquitous and demonstrably suboptimal choice of resizing images to a fixed resolution before processing them with computer vision models has not yet been successfully challenged. However, models such as the Vision Transformer (ViT) offer flexible sequence-based modeling, and hence varying input sequence lengths. We take advantage of this with NaViT (Native Resolution ViT) which uses sequence packing during training to process inputs of arbitrary resolutions and aspect ratios. Alongside flexible model usage, we demonstrate improved training efficiency for large-scale supervised and contrastive image-text pretraining. NaViT can be efficiently transferred to standard tasks such as image and video classification, object detection, and semantic segmentation and leads to improved results on robustness and fairness benchmarks. At inference time, the input resolution flexibility can be used to smoothly navigate the test-time cost-performance trade-off. We believe that NaViT marks a departure from the standard, CNN-designed, input and modelling pipeline used by most computer vision models, and represents a promising direction for ViTs.

研究动机与目标

  • 推动摆脱固定分辨率的 CNN 流水线,允许 ViT 处理原生分辨率且保持纵横比的输入。
  • 引入 Patch n’ Pack,将来自不同图像的多个图像块打包到单一序列中,以实现高效训练。
  • 开发支持打包、可变分辨率和令牌丢弃的架构与训练修改,同时不改变核心注意力/MLP 操作。
  • 证明相较于固定形状 ViT,NaViT 在预训练效率、向下游任务的迁移能力,以及鲁棒性/公正性基准方面的提升。

提出的方法

  • 引入 Patch n’ Pack:将多张图像打包为单一序列,以实现原生分辨率输入。
  • 使用掩蔽防止跨样本注意力,并在打包序列中通过掩蔽池化产生每个样本的表示。
  • 采用分解的(绝对和分数量化的)位置嵌入以支持任意分辨率和纵横比。
  • 实现连续令牌丢弃和分辨率采样,以提升训练效率和性能。
  • 将训练扩展到监督分类(JFT-4B)和对比图像-文本预训练(WebLI)。
  • 在打包 setting 下应用固定批量序列的考虑以及分块对比损失,以在大 Emax 下扩展训练规模。

实验结果

研究问题

  • RQ1在不将输入调整为正方形的情况下,Vision Transformer 是否能够在原生分辨率且任意纵横比的图像上进行训练?
  • RQ2在固定计算预算下,Patch n’ Pack 是否在跨任务与模态中提升训练效率和最终性能?
  • RQ3分辨率采样、令牌丢弃和分解位置嵌入如何影响对未知分辨率和纵横比的泛化?
  • RQ4相较于 ViT,NaViT 表征是否能有效迁移到下游任务,如分割、检测和视频分类?
  • RQ5原生纵横比输入对公平性与鲁棒性基准的影响是什么?

主要发现

  • NaViT 在各个尺度上持续优于等算力的 ViT,在预训练中以约 4 倍更少的计算量达到最佳 ViT 的水平。
  • 使用变分辨率和令牌丢弃的训练使 NaViT-L/16 在同一计算预算内能够处理多达五倍于 ViT 的图像数量。
  • NaViT 保留纵横比并支持在多个分辨率上的评估,便于更便宜的适配与推断时的成本‑性能权衡。
  • 分解位置嵌入(尤其是 x 与 y 嵌入的加法组合)在未知分辨率和纵横比上的泛化能力优于基线的二维嵌入。
  • NaViT 在分布外鲁棒性和与公平相关的信号注释表现方面优于 ViT 基线。
  • 迁移到分割与目标检测时,NaViT 提升 LVIS AP(28.3% 对比 ViT-L/14 的 23.3%)和零样本 ImageNet;在原生分辨率处理方面表现更好;在视频分类中 NaViT-L/16 与 ViViT-L/ 在较少的 epoch 下具有竞争力。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。