File size: 4,544 Bytes
17c6d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!--Copyright 2022 The HuggingFace Team. All rights reserved.

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.

โš ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# Swin Transformer V2 [[swin-transformer-v2]]

## ๊ฐœ์š” [[overview]]

Swin Transformer V2๋Š”  Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, Furu Wei, Baining Guo๊ฐ€ ์ œ์•ˆํ•œ ๋…ผ๋ฌธ [Swin Transformer V2: Scaling Up Capacity and Resolution](https://arxiv.org/abs/2111.09883)์—์„œ ์†Œ๊ฐœ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋…ผ๋ฌธ์˜ ์ดˆ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

*๋Œ€๊ทœ๋ชจ NLP ๋ชจ๋ธ๋“ค์€ ์–ธ์–ด ์ž‘์—…์—์„œ์˜ ์„ฑ๋Šฅ์„ ํฌ๊ฒŒ ํ–ฅ์ƒํ•˜๋ฉฐ, ์„ฑ๋Šฅ์ด ํฌํ™”ํ•˜๋Š” ์ง•ํ›„๋ฅผ ๋ณด์ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์‚ฌ๋žŒ๊ณผ ์œ ์‚ฌํ•œ few-shot ํ•™์Šต ๋Šฅ๋ ฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ด ๋…ผ๋ฌธ์€ ๋Œ€๊ทœ๋ชจ ๋ชจ๋ธ์„ ์ปดํ“จํ„ฐ ๋น„์ „ ๋ถ„์•ผ์—์„œ ํƒ๊ตฌํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ๋Œ€ํ˜• ๋น„์ „ ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•˜๊ณ  ์ ์šฉํ•˜๋Š” ๋ฐ ์žˆ์–ด ์„ธ ๊ฐ€์ง€ ์ฃผ์š” ๋ฌธ์ œ๋ฅผ ๋‹ค๋ฃน๋‹ˆ๋‹ค: ํ›ˆ๋ จ ๋ถˆ์•ˆ์ •์„ฑ, ์‚ฌ์ „ ํ•™์Šต๊ณผ ํŒŒ์ธํŠœ๋‹ ๊ฐ„์˜ ํ•ด์ƒ๋„ ์ฐจ์ด, ๊ทธ๋ฆฌ๊ณ  ๋ ˆ์ด๋ธ”์ด ๋‹ฌ๋ฆฐ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ๋†’์€ ์š”๊ตฌ์ž…๋‹ˆ๋‹ค. ์„ธ ๊ฐ€์ง€ ์ฃผ์š” ๊ธฐ๋ฒ•์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค: 1) ํ›ˆ๋ จ ์•ˆ์ •์„ฑ์„ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•œ residual-post-norm ๋ฐฉ๋ฒ•๊ณผ cosine attention์˜ ๊ฒฐํ•ฉ; 2) ์ €ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€๋กœ ์‚ฌ์ „ ํ•™์Šต๋œ ๋ชจ๋ธ์„ ๊ณ ํ•ด์ƒ๋„ ์ž…๋ ฅ์œผ๋กœ ์ „์ดํ•  ์ˆ˜ ์žˆ๋Š” log-spaced continuous position bias ๋ฐฉ๋ฒ•; 3) ๋ ˆ์ด๋ธ”์ด ๋‹ฌ๋ฆฐ ๋ฐฉ๋Œ€ํ•œ ์ด๋ฏธ์ง€์˜ ํ•„์š”์„ฑ์„ ์ค„์ด๊ธฐ ์œ„ํ•œ self-supervised ์‚ฌ์ „ ํ•™์Šต ๋ฐฉ๋ฒ•์ธ SimMIM์ž…๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ธฐ๋ฒ•๋“ค์„ ํ†ตํ•ด 30์–ต ๊ฐœ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ง„ Swin Transformer V2 ๋ชจ๋ธ์„ ์„ฑ๊ณต์ ์œผ๋กœ ํ›ˆ๋ จํ•˜์˜€์œผ๋ฉฐ, ์ด๋Š” ํ˜„์žฌ๊นŒ์ง€ ๊ฐ€์žฅ ํฌ๊ณ  ๊ณ ๋ฐ€๋„์˜ ๋น„์ „ ๋ชจ๋ธ๋กœ, ์ตœ๋Œ€ 1,536ร—1,536 ํ•ด์ƒ๋„์˜ ์ด๋ฏธ์ง€๋ฅผ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์€ ImageNet-V2 ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜, COCO ๊ฐ์ฒด ํƒ์ง€, ADE20K ์˜๋ฏธ๋ก ์  ๋ถ„ํ• , Kinetics-400 ๋น„๋””์˜ค ํ–‰๋™ ๋ถ„๋ฅ˜ ๋“ฑ ๋„ค ๊ฐ€์ง€ ๋Œ€ํ‘œ์ ์ธ ๋น„์ „ ์ž‘์—…์—์„œ ์ƒˆ๋กœ์šด ์„ฑ๋Šฅ ๊ธฐ๋ก์„ ์„ธ์› ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์šฐ๋ฆฌ์˜ ํ›ˆ๋ จ์€ Google์˜ billion-level ๋น„์ „ ๋ชจ๋ธ๊ณผ ๋น„๊ตํ•ด 40๋ฐฐ ์ ์€ ๋ ˆ์ด๋ธ”์ด ๋‹ฌ๋ฆฐ ๋ฐ์ดํ„ฐ์™€ 40๋ฐฐ ์ ์€ ํ›ˆ๋ จ ์‹œ๊ฐ„์œผ๋กœ ์ด๋ฃจ์–ด์กŒ๋‹ค๋Š” ์ ์—์„œ ํ›จ์”ฌ ๋” ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.*

์ด ๋ชจ๋ธ์€ [nandwalritik](https://huggingface.co/nandwalritik)์ด ๊ธฐ์—ฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.
์›๋ณธ ์ฝ”๋“œ๋Š” [์—ฌ๊ธฐ](https://github.com/microsoft/Swin-Transformer)์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

## ๋ฆฌ์†Œ์Šค [[resources]]

Swin Transformer v2์˜ ์‚ฌ์šฉ์„ ๋„์šธ ์ˆ˜ ์žˆ๋Š” Hugging Face ๋ฐ ์ปค๋ฎค๋‹ˆํ‹ฐ(๐ŸŒŽ๋กœ ํ‘œ์‹œ)์˜ ๊ณต์‹ ์ž๋ฃŒ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค.


<PipelineTag pipeline="image-classification"/>

- [`Swinv2ForImageClassification`]์€ ์ด [์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification)์™€ [๋…ธํŠธ๋ถ](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb)์„ ํ†ตํ•ด ์ง€์›๋ฉ๋‹ˆ๋‹ค.
- ๊ด€๋ จ ์ž๋ฃŒ: [์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ์ž‘์—… ๊ฐ€์ด๋“œ](../tasks/image_classification)

๋˜ํ•œ:

- [`Swinv2ForMaskedImageModeling`]๋Š” ์ด [์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-pretraining)๋ฅผ ํ†ตํ•ด ์ง€์›๋ฉ๋‹ˆ๋‹ค.

์ƒˆ๋กœ์šด ์ž๋ฃŒ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ์œผ์‹œ๋‹ค๋ฉด, ์–ธ์ œ๋“ ์ง€ Pull Request๋ฅผ ์—ด์–ด์ฃผ์„ธ์š”! ์ €ํฌ๊ฐ€ ๊ฒ€ํ† ํ•ด ๋“œ๋ฆด๊ฒŒ์š”. ์ด๋•Œ, ์ถ”๊ฐ€ํ•˜๋Š” ์ž๋ฃŒ๋Š” ๊ธฐ์กด ์ž๋ฃŒ์™€ ์ค‘๋ณต๋˜์ง€ ์•Š๊ณ  ์ƒˆ๋กœ์šด ๋‚ด์šฉ์„ ๋ณด์—ฌ์ฃผ๋Š” ์ž๋ฃŒ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

## Swinv2Config [[transformers.Swinv2Config]]

[[autodoc]] Swinv2Config

## Swinv2Model [[transformers.Swinv2Model]]

[[autodoc]] Swinv2Model
    - forward

## Swinv2ForMaskedImageModeling [[transformers.Swinv2ForMaskedImageModeling]]

[[autodoc]] Swinv2ForMaskedImageModeling
    - forward

## Swinv2ForImageClassification [[transformers.Swinv2ForImageClassification]]

[[autodoc]] transformers.Swinv2ForImageClassification
    - forward