Overview
๊ธฐ์กด ๊ฐ์ฒด ํ์ง ๋ชจ๋ธ
- Heuristic proposals, anchors, window centers ๋ฅผ ์ค์ ํ๋ ๋ฐฉ์์ผ๋ก ์์์ bbox ๋ฅผ ์ค์ ํ๋ค.
- Near-duplicate prediction, bbox ๋ค์ด ์๋ก ๋ง์ด ๊ฒน์ณ ์ค๋ณต๋๋ ์์ธก๋ค์ด ๋ง์ด ์์ฑ๋๊ณ , ์ด๋ฅผ NMS ๋ฅผ ํตํด ํ๋์ bbox ๋ก ์ทจํฉํ๋ค.
- bbox ๋ฅผ ํตํด ํ์ง๋ ๊ฐ์ฒด๋ฅผ ๋ถ๋ฅํ๋ค.
- ์ฆ, ๋ค์์ ๋ฐฉ์์ ๊ฐ์ฒด๋ฅผ ์ง์ ์ฐพ๋ ๋ฐฉ์์ด ์๋, ๋ง์ bbox ๋ฅผ ๋ง๋ค์ด ํ์งํ๋ ๊ฐ์ ์ ์ธ ๋ฐฉ์์ด๋ค.
- ๋ค์๊ณผ ๊ฐ์ด ๊ธฐ์กด ๊ฐ์ฒด ํ์ง ๋ชจ๋ธ์ ๊ฒฝ์ฐ ๋ง์ hand-crafted ์์๋ค์ ์ฌ์ฉํด ๊ฐ์ฒด ํ์ง๋ฅผ ํ๊ณ , ์์ ํ end-to-end ๋ชจ๋ธ์ด ์๋์๋ค.
- ๋ค์์ ๊ธฐ์กด ๋ชจ๋ธ๋ค์ DETR ์ CNN ๊ณผ Transformer ๋ฅผ ํตํด ์์ ํ end-to-end ๊ฐ์ฒด ํ์ง ๋ชจ๋ธ์ ๋ง๋ค์ด๋๋ค.
DETR
- DETR ์ CNN ๊ณผ Transformer ๋ฅผ ํตํด ๊ธฐ์กด ๊ฐ์ฒด ํ์ง๊ธฐ๊ฐ ๊ฐ์ง๊ณ ์๋ hand-crafted ๊ตฌ์ฑ๋ค์ ์์ ๊ณ 1 ๋ 1 ๋์์ ํตํด ๊ฐ์ฒด๋ฅผ ํ์งํ๋ ๊ตฌ์กฐ๋ฅผ ์ด๋ฃฌ๋ค.
- ๋ค์ ๊ตฌ์กฐ๋ฅผ ํตํด ๊ธฐ์กด ๊ฐ์ฒด ํ์ง ๋ชจ๋ธ๊ณผ ๊ฒฝ์ํ ๋งํ ๋ฐ์ด๋ ์ฑ๋ฅ์ ๊ฐ์ง๋ค.
Problem of DETR and Transformer
- ํ์ง๋ง, DETR ์ ๋ค์์ ๋ฌธ์ ์ ์ ๊ฐ๋๋ค.
1. DETR ์ ๊ธฐ์กด ๊ฐ์ฒด ํ์ง๊ธฐ๋ณด๋ค ์๋ ดํ๊ธฐ ์ํด ๋ ๋ง์ ํ๋ จ ์๊ฐ์ ํ์๋ก ํ๋ค. ์ด๋ Transformer ๋ก ์ธํด ๋ฐ์ํ๋๋ฐ, Transformer ๊ฐ ๋ ๊ธด ํ๋ จ ์๊ฐ์ ํ์๋ก ํ๋ ์ด์ ๋ 2 ๊ฐ์ง๊ฐ ์๋ค.
- ๋ค์์ Transformer ์์ ์ฌ์ฉ๋๋ multi-head attention ์ ์์ด๋ค.
: Query element : Key element : Input feature map , : Learnable weight : Attention weight : Number of query element : Number of key element : Learnable weight for query : Learnable weight for key - DETR ์ Transformer, self-attention ์ ์ฌ์ฉํ์ฌ ์ฐ์ฐ์ ํ๋ค. ์ฟผ๋ฆฌ, ํค์ ๊ฐ์ ์ฃผ๋ก ํฝ์
๋ก ์ค์ ๋๋ค. ์ ์ ํ ํ๋ผ๋ฏธํฐ ์ด๊ธฐํ๋ฅผ ํ ๊ฒฝ์ฐ ์ฟผ๋ฆฌ, ํค๋ฅผ ๋ง๋๋
, ๋ ํ๊ท ์ด 0, ๋ถ์ฐ์ด 1 ์ธ ๋ถํฌ๋ฅผ ๊ฐ์ง๊ณ , ํฝ์ ์ ์๊ฐ ๋ง์ ์๋ก attention weight ๊ฐ 1/ ์ ๊ฐ๊น์์ง๊ฒ ๋๋ค. ์ฆ, backpropagation ์ ํตํด gradient ๋ฅผ ๊ตฌํ๋๋ผ๋ ๋งค์ฐ ์์ ๊ฐ์ด ๋์ ์ด๊ธฐ ๊ฐ์ค์น ์กฐ์ ์ด ๋๋ฆฌ๊ฒ ๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก๋ ๋ ๋ง์ ํ๋ จ ์๊ฐ์ ํ์๋ก ํ๋ค. - Multi-head attention ์ ๋ฉ๋ชจ๋ฆฌ, ๊ณ์ฐ ๋ณต์ก๋๊ฐ ์ฟผ๋ฆฌ์ ํค์ ๋ฐ๋ผ ๋งค์ฐ ๋์์ง๋ค. ์ด๋ฏธ์ง ๋ถ์ผ์ ๊ฒฝ์ฐ ์ฟผ๋ฆฌ, ํค๊ฐ ๊ฐ ํฝ์ ์ด ๋๊ธฐ ๋๋ฌธ์ ์ฟผ๋ฆฌ ํค ๊ฐ์ด ๋์ ๊ฒฝ์ฐ๊ฐ ๋ง๊ณ ์ด๋ก ์ธํด ๋ณต์ก๋๊ฐ ๋งค์ฐ ๋์ ์๋ ด์ด ๋๋ ค์ง๊ฒ ๋๋ค.
2. DETR ์ ์์ ๊ฐ์ฒด๋ฅผ ํ์งํ๋ ๊ฒ์ ์๋์ ์ผ๋ก ๋ ๋ฎ์ ์ฑ๋ฅ์ ๋ณด์ธ๋ค. ๋ค๋ฅธ ๊ธฐ์กด ๊ฐ์ฒด ํ์ง๊ธฐ์ ๊ฒฝ์ฐ multi-scale ์ ํน์ง๋งต์ ์ฌ์ฉํ๋ ๋ฑ์ ๋ค์ํ ๋ฐฉ์์ ํตํด์ ์ฌ๋ฌ ํฌ๊ธฐ์ ๊ฐ์ฒด๋ฅผ ํ์งํ๋ค. DETR ๋ ์์ ํฌ๊ธฐ์ ๊ฐ์ฒด๋ฅผ ํ์งํ๋ ค๋ฉด CNN ์ ํตํด์ ์ฐ์ถ๋๋ ํน์ง๋งต์ ํฌ๊ธฐ๋ฅผ ํค์ฐ๋ ๋ฐฉ์์ด ์๋ค. ํ์ง๋ง, DETR ์ ์ฐ์ฐ๋์ด quadratic ํ๊ฒ ์ฆ๊ฐํ๊ธฐ ๋๋ฌธ์ ๋ค์ํ ํฌ๊ธฐ์ ํน์ง๋งต์ ์ฌ์ฉํ์ง ๋ชปํ์ฌ ์์ ๊ฐ์ฒด๋ฅผ ํ์งํ๋ ๊ฒ์ ์๋์ ์ผ๋ก ๋ ๋ฎ์ ์ฑ๋ฅ์ ๋ณด์ธ๋ค.
Deformable DETR ์ ๊ฒฝ์ฐ ์์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๊ณ ์๋์๋ค.
Background
Deformable Convolution
- Deformable DETR ์ DETR ์ ์ฐ์ฐ๋ ๋ฌธ์ ์ ์ ํด๊ฒฐํ๊ธฐ ์ํด deformable convolution ์ ์์ด๋์ด๋ฅผ ์ฌ์ฉํ๋ค.
- Deformable convolution ์ ์ ๊ทธ๋ฆผ๊ณผ ๊ฐ๋ค.
- ์ผ๋ฐ์ ์ธ convolution ์ ๊ฒฝ์ฐ ๊ณ ์ ๋ ํํฐ๋ฅผ ์ ์ฉํด ํ๋์ ํน์ง๋งต์ ์ฐ์ถํ๋ค.
- Deformable convolution ์ feature ๋ฅผ ํน์ layer ์ ํ์ sampling point ๋ฅผ ์์ธกํ๊ณ , ํด๋น point ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก convolution ์ ์ํํ๋ค.
- ์ด๋ฅผ ํตํด ํน์ ์์น์ ๊ฐ์ฒด์ ๋ง์ถฐ, sampling ์ด ์ด๋ฃจ์ด์ง๊ณ ๋ณด๋ค ์ ์ฐํ๊ฒ ํน์ง์ ์ถ์ถํ ์ ์๋ค.
Deformable DETR
Architecture
- DETR ์ ๊ตฌ์กฐ๋ ์ ๊ทธ๋ฆผ๊ณผ ๊ฐ๋ค.
- Multi-scale ์ ํน์ง๋งต์ Deformable Attention ์ ํตํด์ reference point ๋ฅผ ๊ธฐ์ค์ผ๋ก ํค๋ฅผ sampling ํ์ฌ ๋๊ฒจ์ค๋ค. ์์ธํ ๊ฒ์ ์๋๋ฅผ ํตํด ํ์ธํด๋ณด์.
Constructing Multi-Scale Feature Maps
- ์ ๋ ฅ ํน์ง๋งต์ ๋ํ multi-scale ํน์ง๋งต์ ์ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด CNN ์ ๊ฐ ์ธต์์ 1x1 Conv ๋ฅผ ์ฌ์ฉํด์ ๋ฝ์๋ด๊ณ ๋งจ ๋ง์ง๋ง๋ง 3x3 Conv ๋ฅผ ์ฌ์ฉํ์ฌ ์ถ์ถํ๋ค.
Deformable Attention Module
- Transformer ๋ ์ด๋ฏธ์ง ํน์ง๋งต์ ๊ฐ๋ฅํ ๋ชจ๋ ๊ณต๊ฐ์ ์ดํด๋ณด๊ธฐ ๋๋ฌธ์ ์ฐ์ฐ๋์ด ํฐ ๋ฌธ์ ๋ฅผ ๊ฐ๋๋ค.
- ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด Deformable Attention Module ์ ์ ์ํ๋ค.
- Deformable Attention Module ์ ๊ธฐ์ค์ ์ฃผ๋ณ ์์ key sampling point ๋ค์๋ง ์ง์คํจ์ผ๋ก์จ ํน์ ์์น๋ง ํ์ธํ๋ ๋ฐฉ์์ ํตํด์ ์ฐ์ฐ๋์ ์ค์ธ๋ค.
: Query element : 2d reference point : Input feature map , : Learnable weight : Attention weight (Normalized by ) : Sampling offset - ์์ ๋ถ์ ๊ทธ๋ฆผ ๊ทธ๋ ค ๋ฃ์ ์์
Multi-scale Deformable Attention Module
: Query element : Normalized 2d reference point : Input feature map , : Learnable weight : Attention weight (Normalized by ) : Sampling offset : Re-scale the normalized coordinated to the input feature map of the l-th levels - Multi-scale Deformable Attention Module ๊ณผ ๊ฐ์ ๊ฒฝ์ฐ Deformable Attention Module ์์ level ์ด ์๊ฒผ๋ค๊ณ ์๊ฐํ๋ฉด ๋๋ค. ์ฆ, ๊ฐ ์ธต์ ๋ํด Deformable Attention ์ ์ ์ฉํ๋ค.
- MSDeformable Attention ๊ณผ ๊ฐ์ ๊ฒฝ์ฐ ๊ฐ ํน์ง๋งต์ ํฌ๊ธฐ๊ฐ ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ ์์น์ ์ธ ์ ๋ณด๋ฅผ ๋ง์ถฐ์ค์ผ ํ๋ค. ๋๋ฌธ์ reference point ๋ฅผ ์ ๊ทํํ์ฌ ์ ๋ฌํ๋ค.
์ ์ ๊ฒฝ์ฐ ์ ๊ทํ๋์ด ์ ๋ฌ๋ reference point ๋ฅผ ์ฐ์ฐํ scale level ์ ๋ง๋๋ก ํฌ๊ธฐ๋ฅผ ํค์ฐ๋ ์ญํ ์ ํ๋ค.
Details
- ์ธ์ฝ๋์ ๊ฒฝ์ฐ ์ฟผ๋ฆฌ๋ multi-scale ํน์ง๋งต์ ํฝ์ ์ด๋ค. ํ์ง๋ง ๋์ฝ๋์ ๊ฒฝ์ฐ object query ๊ฐ ์ฟผ๋ฆฌ๊ฐ ๋๋ค.
Result
- Deformable DETR ์ ์ ์ฉํ์ ๋ DETR ์ ๋นํด ๋์ผ ์ฑ๋ฅ์์ ํจ์ฌ ๋น ๋ฅธ ์๋๋ก ํ์ต๋๋ค๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
- ๋ํ, ์์ ๋ฌผ์ฒด ํ์ง๊ฐ ์ฝํ DETR ์ ๋นํด Deformable DETR ์ Faster R-CNN ๊ณผ์ ๋น๊ต์์๋ ๊ฒฝ์๋ ฅ์ ์ป์ ๋งํผ์ ์ฑ๋ฅ ํฅ์์ ๋ณด์๋ค.
- Single-scale ์ ๋ ฅ ๋์ multi-scale ์ ๋ ฅ์ ์ฌ์ฉํจ์ผ๋ก์จ ๊ธฐ๋ณธ์ ์ธ ํ์ง ์ฑ๋ฅ๊ณผ ์์ ๋ฌผ์ฒด์ ํ์ง ์ฑ๋ฅ์ ํฅ์์ ์ด๋ค๋๋ค.
- MS deformable attention ์ ์ฌ์ฉํ์ฌ ์ถ๊ฐ์ ์ธ ํฅ์์ ์ด๋ค๋๋ค.
- FPN ์ ์ฌ์ฉํ ๊ฒ๊ณผ FPN ์ ์ฌ์ฉํ์ง ์์ ๋ชจ๋ธ์ ๊ฒฝ์ฐ์์ ์์ ํ ๋์ผํ ์ฑ๋ฅ์ ๋ณด์ธ๋ค.
- ์ ์๋ค์ Cross-Attention ์ ํตํด์ multi-scale ๊ฐ์ ํน์ง ๊ตํ์ด ์ด๋ฃจ์ด์ก๊ธฐ ๋๋ฌธ์ FPN ์ ์ถ๊ฐํ๋ ๊ฒ์ ์ฑ๋ฅ ํฅ์์ ์ด๋์ง ๋ชปํ ๊ฒ์ด๋ผ ์ค๋ช ํ๋ค.
Conclusion
Deformable DETR ์ end-to-end ๊ฐ์ฒด ํ์ง๊ธฐ๋ก, DETR ์ ๋๋ฆฐ ์๋ ด, ์์ ๊ฐ์ฒด ํ์ง์ ์ฝํ๋ค๋ ๋จ์ ์ multi-scale deformable attention module ์ ํตํด์ ๋ณด์ํ๋ค๋ ์ ์์ ์์๋ฅผ ๊ฐ๋๋ค.