Skip to content
프로젝트

소개

[ECCV 2024] RoPE-ViT ‘비전 트랜스포머를 위한 회전 위치 임베딩’의 공식 PyTorch 구현

AI 및 머신러닝

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Rotary Position Embedding for Vision Transformer

Byeongho Heo, Song Park, Dongyoon Han, Sangdoo Yun

NAVER AI LAB

Paper Paper Paper

Official PyTorch implementation of RoPE-ViT "Rotary Position Embedding for Vision Transformer" | arxiv, ECCV

Abstract

Rotary Position Embedding (RoPE) performs remarkably on language models, especially for length extrapolation of Transformers. However, the impacts of RoPE on computer vision domains have been underexplored, even though RoPE appears capable of enhancing Vision Transformer (ViT) performance in a way similar to the language domain. This study provides a comprehensive analysis of RoPE when applied to ViTs, utilizing practical implementations of RoPE for 2D vision data. The analysis reveals that RoPE demonstrates impressive extrapolation performance, i.e., maintaining precision while increasing image resolution at inference. It eventually leads to performance improvement for ImageNet-1k, COCO detection, and ADE-20k segmentation. We believe this study provides thorough guidelines to apply RoPE into ViT, promising improved backbone performance with minimal extra computational overhead.

Updates

  • Oct 29, 2025: Training logs released in logs/
  • Oct 16, 2024: Pre-trained weights are uploaded to huggingface hub
  • Apr 16, 2024: Pre-trained weights released
  • Apr 15, 2024: Code released
  • Mar 21, 2024: Arxiv paper was released

Getting Started

You can find RoPE implementations at each folder.

  • deit/ : RoPE on DeiT-III training code "DeiT III: Revenge of the ViT" original repo
  • swin/ : RoPE on Swin Transformer training code "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" original repo
  • models/ : Only RoPE model files that used for DeiT and Swin.
  • self-attn/ : Minimum implementation of RoPE in self-attention layer
  • logs/ : Training logs for deit and swin

Performances

DeiT-III

RoPE-ViT

Swin Transformer

RoPE-ViT

Pre-trained weights

  • You can access the pre-trained weights on our huggingface hub
  • pretrained=True for models in models/ will automatically load pre-trained weights from huggingface hub
    from models import vit_rope
    model = vit_rope.rope_mixed_deit_small_patch16_LS(pretrained=True)
    from models import swin_transformer_rope
    model = swin_transformer_rope.swin_rope_mixed_tiny_patch4_window7_224(pretrained=True)
    
  • For inference with 256x256 images
    from models import vit_rope
    model = vit_rope.rope_mixed_deit_small_patch16_LS(pretrained=True, img_size=256)
    from models import swin_transformer_rope
    model = swin_transformer_rope.swin_rope_mixed_tiny_patch4_window7_224(pretrained=True, img_size=256)
    

DeiT-III (400 epochs)

Model Name Top-1 (224) Top-1 (384) Weights
deit_small_patch16_LS 80.4 79.4 HF hub / Google drive
rope_axial_deit_small_patch16_LS 80.9 80.0 HF hub / Google drive
rope_mixed_deit_small_patch16_LS 80.9 81.8 HF hub / Google drive
rope_axial_ape_deit_small_patch16_LS 80.7 81.2 HF hub / Google drive
rope_mixed_ape_deit_small_patch16_LS 80.9 81.7 HF hub / Google drive
deit_base_patch16_LS 83.4 82.8 HF hub / Google drive
rope_axial_deit_base_patch16_LS 83.6 83.9 HF hub / Google drive
rope_mixed_deit_base_patch16_LS 83.8 84.4 HF hub / Google drive
rope_axial_ape_deit_base_patch16_LS 83.7 83.8 HF hub / Google drive
rope_mixed_ape_deit_base_patch16_LS 83.8 84.3 HF hub / Google drive
deit_large_patch16_LS 84.6 84.2 HF hub / Google drive
rope_axial_deit_large_patch16_LS 84.7 85.1 HF hub / Google drive
rope_mixed_deit_large_patch16_LS 84.8 85.6 HF hub / Google drive
rope_axial_ape_deit_large_patch16_LS 84.7 85.1 HF hub / Google drive
rope_mixed_ape_deit_large_patch16_LS 84.9 85.5 HF hub / Google drive

Swin Transformer (300 epochs)

Model Name Top-1 (224) Top-1 (384) Weights
swin_tiny_patch4_window7_224 81.2 78.9
swin_rope_axial_tiny_patch4_window7_224 81.3 79.2 HF hub / Google drive
swin_rope_mixed_tiny_patch4_window7_224 81.4 79.5 HF hub / Google drive
swin_small_patch4_window7_224 82.9 81.0
swin_rope_axial_small_patch4_window7_224 83.1 80.9 HF hub / Google drive
swin_rope_mixed_small_patch4_window7_224 83.0 81.4 HF hub / Google drive
swin_base_patch4_window7_224 83.3 81.2
swin_rope_axial_base_patch4_window7_224 83.6 81.8 HF hub / Google drive
swin_rope_mixed_base_patch4_window7_224 83.7 82.1 HF hub / Google drive

How to cite

@inproceedings{heo2024ropevit,
    title={Rotary Position Embedding for Vision Transformer},
    author={Heo, Byeongho and Park, Song and Han, Dongyoon and Yun, Sangdoo},
    year={2024},
    booktitle={European Conference on Computer Vision (ECCV)},
}

License

This project is distributed under Apache-2.0,
except for the files below which originated from https://github.com/meta-llama/codellama.

RoPE-ViT
Copyright (c) 2024-present NAVER Cloud Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

관련 프로젝트 살펴보기

불러오는 중…