논문 링크: arxiv.org/pdf/2304.02643
OUTTA 논문 리뷰 링크: [2025-1] 김경훈 - SAM (Segment Anything Model)
[2025-1] 김경훈 - SAM (Segment Anything Model)
원본 논문 링크 : https://arxiv.org/abs/2304.02643 Segment AnythingWe introduce the Segment Anything (SA) project: a new task, model, and dataset for image segmentation. Using our efficient model in a data collection loop, we built the largest segmen
blog.outta.ai
1. Abstract
- SA-1B: 10M+ images, 1.1B+ segmentation masks로 구성된 가장 큰 segmentation dataset 구축.
- SAM (Segment Anything Model) 제안:
- Zero-shot segmentation 성능을 보이는 foundation model.
- 다양한 segmentation task에 prompt 기반으로 대응 가능.
2. Introduction
- Background
- 웹 스케일 데이터로 학습된 대형 언어 모델(LM)은 강력한 일반화 능력을 가짐 → NLP 혁신.
- Segmentation 분야에서도 이러한 foundation model을 구축하는 것이 목표.
- Three Key Questions
- Zero-shot generalization을 가능하게 하는 task는 무엇인가?
- 해당 model의 architecture는?
- 어떤 dataset이 필요한가?
- Data Engine Approach
- 웹 스케일 segmentation dataset이 없기 때문에 효율적인 모델을 사용하여 데이터를 수집하고, 수집한 데이터를 다시 모델 학습에 활용하는 반복적인 data engine 구축.
3. Segment Anything Task
- NLP의 Prompt Engineering에서 영감
- Segmentation task를 prompt-based 방식으로 정의하여 다양한 downstream task에 적용.
3.1 Promptable Segmentation Task
- Prompt를 입력받아 유효한 segmentation mask를 반환하는 task.
- 기존 supervised segmentation과의 차이점
- NLP의 LM처럼 다양한 segmentation task를 하나의 모델로 수행 가능.
- Zero-shot transfer가 가능 → 추가 fine-tuning 없이 새로운 task에 적용.
3.2 Training Strategy
- Pre-training
- 다양한 prompt를 simulation하여 학습.
- Ambiguous prompts에 대해서도 valid한 mask를 항상 예측하도록 설계.
4. Segment Anything Model (SAM)
- Architecture
- Image Encoder: MAE로 pre-trained된 ViT-H 모델 사용.
- Prompt Encoder:
- Sparse prompt: points, boxes, text 포함.
- Dense prompt: 기존 mask 기반 refinement.
- Mask Decoder:
- DETR(Detection Transformer)와 유사한 구조.
- Ambiguous prompt에 대해 multiple valid masks (3개)를 출력하고, ranking 수행.
4.1 Image Encoder
- ViT-H (pre-trained with MAE) 사용.
- High-resolution image embedding 생성 → 한 번 계산된 embedding은 여러 prompt에서 재사용 가능.
4.2 Prompt Encoder
- Sparse Prompt:
- Points, boxes → 위치 encoding.
- Text → CLIP text encoder 사용 (실험적 적용).
- Dense Prompt:
- 기존 segmentation mask 사용 → CNN으로 feature map에 추가.
4.3 Mask Decoder(SAM Decoder)
- DETR 스타일 Transformer Decoder 사용.
- Output tokens → DETR의 object query처럼 동작하여 segmentation mask를 예측.
4.4 Resolving Ambiguity
- Ambiguous prompt 대응을 위해 multiple masks (3개) 예측.
- Mask ranking을 수행하여 best mask를 선택.
- Loss 계산 시, 가장 정확한 mask에 대해서만 backpropagation 수행.
5. Losses and Training
- Loss Function
- Focal Loss + Dice Loss (DETR과 동일한 방식 사용).
- Interactive Training
- Randomized iterative training (RITM) 적용 → 11 rounds 동안 랜덤 prompt를 샘플링하여 interactive segmentation 환경 시뮬레이션.
6. Segment Anything Data Engine
- Segmentation dataset 구축을 위한 data collection pipeline
- Assisted-manual stage → 전문가 주석
- Semi-automatic stage → 모델+주석자 협력
- Fully automatic stage → 완전 자동화
6.1 Assisted-Manual Stage
- 전문 annotator가 SAM 기반 interactive tool을 사용하여 label 생성.
- Label의 이름이나 설명은 수집하지 않음 (pure segmentation mask 데이터 구축).
- SAM을 지속적으로 재학습 → segmentation mask 품질 향상.
- 120K images, 4.3M masks까지 확장.
6.2 Semi-Automatic Stage
- SAM이 자동으로 mask 예측 후, 누락된 부분을 human annotator가 보완.
- 추가 학습을 통해 mask quality 개선.
- 300K images, 10.2M masks까지 확장.
6.3 Fully Automatic Stage
- SAM 모델이 완전 자동으로 1.1B masks 생성.
- High-confidence masks만 필터링하여 사용.
- 최종적으로 11M images, 1.1B masks로 구성된 SA-1B dataset 완성.
7. Segment Anything Dataset (SA-1B)
- Object-centric spatial distribution을 가지는 대규모 segmentation dataset.
- COCO, LVIS 대비 압도적인 데이터 크기:
- 평균 mask 개수 많음 (COCO 대비 50배 이상).
- mask 크기는 더 작음 → finer-grained segmentation 제공.
8. Zero-Shot Transfer Experiments
8.1 Zero-Shot Segmentation Performance
- 23개 dataset에서 평가 (COCO, Cityscapes, ADE20K 등).
- One-point prompt 기준 mIoU 비교:
- SAM이 기존 interactive segmentation models(RITM, FocalClick)보다 성능 우수.
8.2 Zero-Shot Edge Detection
- BSDS500 dataset에서 Sobel, Canny 등과 비교.
- SAM이 기존 방법 대비 높은 precision & recall 기록.
8.3 Zero-Shot Object Proposal
- LVIS dataset에서 평가.
- SAM이 ViTDet-H(Mask R-CNN 기반)보다 중형/대형 object detection 성능 우수.
8.4 Zero-Shot Instance Segmentation
- COCO & LVIS dataset에서 평가.
- Mask quality는 ViTDet보다 우수하지만, object detection 정확도는 낮음.
8.5 Zero-Shot Text-to-Mask Segmentation
- CLIP을 활용하여 text prompt 기반 segmentation 실험.
- 단독 text prompt 성능은 부족하지만, point prompt 조합 시 성능 개선 가능.
9. Ablation Study
- Dataset Size Comparison
- 1M images(10% subset)만으로도 strong performance 유지.
- Model Size Comparison
- ViT-H (636M parameters)가 가장 우수하지만, ViT-L (308M)도 유사한 성능.
10. Conclusion
- SAM은 prompt-driven segmentation을 수행하는 foundation model.
- Zero-shot transfer를 통해 다양한 segmentation task에 적용 가능.
- SA-1B dataset(11M images, 1.1B masks)은 segmentation 연구의 새로운 milestone.
- Future Directions
- Higher resolution mask prediction.
- Text-driven segmentation 강화.