用压缩图像生成补丁,让ViT更快更准
Compress image to patches for Vision Transformer
- 先压缩图像再分块,替代ViT原分块方式
- 补丁数减至1/4,计算量降低63.35%,精度提升3.3%
- 适合追求高效视觉模型的开发者
视觉变压器(ViT)在计算机视觉领域取得显著进展,但随着模型深度和输入图像分辨率增加,其训练与运行的计算成本急剧上升。本文提出一种基于卷积神经网络与视觉变压器的混合模型CI2P-ViT,引入名为CI2P的模块,利用CompressAI编码器压缩图像,并通过一系列卷积生成补丁序列。CI2P可替代ViT中的图像分块嵌入组件,实现与现有ViT模型的无缝集成。相比ViT-B/16,CI2P-ViT将输入自注意力层的补丁数减少至四分之一,显著降低计算开销,同时通过引入CNN的归纳偏置特性有效提升模型精度。在Animals-10数据集上从零开始训练,CI2P-ViT达到92.37%的准确率,较ViT-B/16提升3.3%;浮点运算量(FLOPs)减少63.35%,相同硬件下训练速度提升2倍。
原文摘要 · Abstract (English)
The Vision Transformer (ViT) has made significant strides in the field of computer vision. However, as the depth of the model and the resolution of the input images increase, the computational cost associated with training and running ViT models has surged dramatically. This paper proposes a hybrid model based on CNN and Vision Transformer, named CI2P-ViT. The model incorporates a module called CI2P, which utilizes the CompressAI encoder to compress images and subsequently generates a sequence of patches through a series of convolutions. CI2P can replace the Patch Embedding component in the ViT model, enabling seamless integration into existing ViT models. Compared to ViT-B/16, CI2P-ViT has the number of patches input to the self-attention layer reduced to a quarter of the original. This design not only significantly reduces the computational cost of the ViT model but also effectively enhances the model's accuracy by introducing the inductive bias properties of CNN. The ViT model's precision is markedly enhanced. When trained from the ground up on the Animals-10 dataset, CI2P-ViT achieved an accuracy rate of 92.37%, representing a 3.3% improvement over the ViT-B/16 baseline. Additionally, the model's computational operations, measured in floating-point operations per second (FLOPs), were diminished by 63.35%, and it exhibited a 2-fold increase in training velocity on identical hardware configurations.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。