# Next-ViT

**카테고리:** 하이브리드 · **코드:** [`timm/models/nextvit.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/nextvit.py) · **아키텍처:** 3 · **프리트레인드 가중치:** 12 (ImageNet-1k 결과 포함 12개)

Next-ViT는 효율적인 배포를 위한 CNN / transformer 하이브리드로, Next Convolution Blocks(NCB)와 Next Transformer Blocks(NTB)를 적층합니다.

## 논문

* [Next-ViT: 현실적인 산업 시나리오에서 효율적인 배포를 위한 차세대 Vision Transformer](https://arxiv.org/abs/2207.05501)

## 사용

사전 학습된 가중치 로드, 이미지 전처리 및 파인튜닝에 대해서는 [Quickstart](../quickstart)를, 모델을 백본으로 사용하는 방법에 대해서는 [Feature Extraction](../feature_extraction)을 참고하세요.

```py
>>> import timm
>>> model = timm.create_model('nextvit_small.bd_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)
```

## 모델 API 지원

| 기능 | `NextViT` |
|---|---|
| [`features_only=True` feature map](../model_api#intermediate-features) | ✓ (strides 4, 8, 16, 32) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [입력 크기 무관, 변경 불필요](../model_api#input-size) | ✓ |
| [`set_input_size()`](../model_api#input-size) | – |
| [`dynamic_img_size=True`](../model_api#input-size) | – |
| [`set_grad_checkpointing()`](../model_api#training-hooks) | ✓ |
| [레이어별 LR 감쇠(`group_matcher()`)](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#classifier) | ✓ |

✓ 지원됨, ✓ (정사각형) 정사각형 크기만 작동, ✗ 미지원, – 필요 없음(모델이 이미 모든 입력 크기를 허용). 무작위로 초기화된 모델(`NextViT`의 `nextvit_small`, 224)에서 각 기능을 실행하여 확인했으며, 같은 클래스의 다른 아키텍처도 동일한 동작을 하는 것으로 예상됩니다. 자세한 내용은 [Model API](../model_api) 페이지를 참조하세요.

## 아키텍처

| 아키텍처 | 매개변수 (M) | GMAC | 입력 크기 | 사전 학습된 가중치 |
|---|---:|---:|---:|---:|
| `nextvit_base` | 44.79 | 8.29 | 224 | 4 |
| `nextvit_large` | 57.83 | 10.77 | 224 | 4 |
| `nextvit_small` | 31.74 | 5.80 | 224 | 4 |

GMACs와 매개변수 수는 각 아키텍처의 기본 입력 크기 및 분류기를 기준으로 하며, [벤치마크 결과](https://github.com/huggingface/pytorch-image-models/tree/main/results)에서 가져온 값입니다.

## 사전 학습된 가중치

Top-1은 [`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/results-imagenet.csv)에 나열된 평가 크기에서 측정된 ImageNet-1k 검증 정확도이며, 해당 가중치에 ImageNet-1k 결과가 없는 경우(예: 사전 학습 또는 이미지-텍스트 가중치)에는 '-'로 표시됩니다. Classes는 사전 학습된 분류기의 크기를 나타내며, 분류기가 없는 가중치의 경우 해당 값이 없습니다.

| 가중치 | 입력 크기 | Top-1(%) | 평가 크기 | 클래스 | 라이선스 | Hub |
|---|---:|---:|---:|---:|---|---|
| `nextvit_base.bd_in1k` | 224 | 83.498 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_base.bd_in1k) |
| `nextvit_base.bd_in1k_384` | 384 | 84.706 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_base.bd_in1k_384) |
| `nextvit_base.bd_ssld_6m_in1k` | 224 | 85.186 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_base.bd_ssld_6m_in1k) |
| `nextvit_base.bd_ssld_6m_in1k_384` | 384 | 86.372 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_base.bd_ssld_6m_in1k_384) |
| `nextvit_large.bd_in1k` | 224 | 83.654 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_large.bd_in1k) |
| `nextvit_large.bd_in1k_384` | 384 | 84.930 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_large.bd_in1k_384) |
| `nextvit_large.bd_ssld_6m_in1k` | 224 | 85.514 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_large.bd_ssld_6m_in1k) |
| `nextvit_large.bd_ssld_6m_in1k_384` | 384 | 86.544 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_large.bd_ssld_6m_in1k_384) |
| `nextvit_small.bd_in1k` | 224 | 82.626 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_small.bd_in1k) |
| `nextvit_small.bd_in1k_384` | 384 | 84.036 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_small.bd_in1k_384) |
| `nextvit_small.bd_ssld_6m_in1k` | 224 | 84.872 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_small.bd_ssld_6m_in1k) |
| `nextvit_small.bd_ssld_6m_in1k_384` | 384 | 85.966 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/nextvit_small.bd_ssld_6m_in1k_384) |

