Skip to content

boostcampaitech4lv23cv2/level2_semanticsegmentation_cv-level2-cv-09

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

51 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ†์žฌํ™œ์šฉ ํ’ˆ๋ชฉ ๋ถ„๋ฅ˜๋ฅผ ์œ„ํ•œ Semantic Segmentation ๐Ÿ†


๐Ÿ”ฅMember

์ •์Šน์œค ๊น€์ฃผํฌ ์‹ ํ˜„์ˆ˜ ์ด์šฐํƒ ์ดํ•ด์šฑ

Index


๐Ÿ…Project Summary

- ํ”„๋กœ์ ํŠธ ์ฃผ์ œ

์“ฐ๋ ˆ๊ธฐ ์ด๋ฏธ์ง€์—์„œ Semantic Segmentation์„ ํ™œ์šฉํ•˜์—ฌ 10์ข…๋ฅ˜ ํด๋ž˜์Šค์˜ ์“ฐ๋ ˆ๊ธฐ๋กœ ์ถ”์ธกํ•  ์ˆ˜ ์žˆ๋‹ค. ์นด๋ฉ”๋ผ๋ฅผ ์ด์šฉํ•œ ๋ถ„๋ฆฌ์ˆ˜๊ฑฐ ํŒ๋ณ„์„ ํ†ตํ•ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ถ„๋ฆฌ์ˆ˜๊ฑฐ๊ฐ€ ๋˜์–ด ์žˆ๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

- ๊ฐœ์š” ๋ฐ ๊ธฐ๋Œ€ํšจ๊ณผ

Semantic Segmentation Task ๋Œ€ํšŒ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ EDA, Modeling, Ensemble ๋“ฑ ๋‹ค์–‘ํ•œ ํ…Œ์Šคํฌ๋ฅผ ๊ฒฝํ—˜ํ•ด๋ณผ ์ˆ˜ ์žˆ๊ณ  ์ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ฉด์„œ Semantic Segmentation์— ๋Œ€ํ•œ ์ดํ•ด๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค. ๊ธฐ๋Œ€ ํšจ๊ณผ๋กœ๋Š” ์“ฐ๋ ˆ๊ธฐ์žฅ์— ์„ค์น˜๋˜์–ด ์ •ํ™•ํ•œ ๋ถ„๋ฆฌ์ˆ˜๊ฑฐ๋ฅผ ๋•๊ฑฐ๋‚˜, ์–ด๋ฆฐ์•„์ด๋“ค์˜ ๋ถ„๋ฆฌ์ˆ˜๊ฑฐ ๊ต์œก ๋“ฑ์— ํ™œ์šฉ

- ํ™œ์šฉ ์žฅ๋น„ ๋ฐ ์žฌ๋ฃŒ

์„œ๋ฒ„: V100 GPU
๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ: MMSegmentation, Segmentation Models Pytorch(SMP)
๊ฐœ๋ฐœ ๋ฐ ํ˜‘์—… ํˆด: Git, Slack, Zoom, Visual Studio Code

- ๋ฐ์ดํ„ฐ ์…‹์˜ ๊ตฌ์กฐ๋„

  • ๋ฐ์ดํ„ฐ์…‹ ํ†ต๊ณ„
  • ์ „์ฒด ์ด๋ฏธ์ง€ ๊ฐœ์ˆ˜ : 3272์žฅ
  • 11 class : Background ,General trash, Paper, Paper pack, Metal, Glass, Plastic, Styrofoam, Plastic bag, Battery, Clothing
  • ์ด๋ฏธ์ง€ ํฌ๊ธฐ : (512, 512)
  • ๋ฐ์ดํ„ฐ์…‹ ํ˜•ํƒœ : COCO Dataset
  • images :
    • id : ํŒŒ์ผ ์•ˆ์—์„œ image ๊ณ ์œ  id, ex) 1
    • height : 512
    • width : 512
    • filename : ex) batch01_vt/002.jpg

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งTeam Roles

  • ์ด์šฐํƒ: SMP์—์„œ ๋ชจ๋ธ ์‹คํ—˜ ์ง„ํ–‰, ๋‹ค์–‘ํ•œ augmentation ๊ธฐ๋ฒ• ํ™œ์šฉ
  • ์ •์Šน์œค: MMsegmentation segformer ํ•™์Šต, inference file ๊ตฌํ˜„, ensemble file ๊ตฌํ˜„
  • ๊น€์ฃผํฌ: Wandb Setting, Fiftyone, transfer dataset for MMSeg, Albumentation ์ถ”๊ฐ€, UperNet Swin_Large/Tiny ๋ชจ๋ธ ํ•™์Šต
  • ์ดํ•ด์šฑ: SMP์—์„œ ๋ชจ๋ธ ์‹คํ—˜ ์ง„ํ–‰, Swin-L encoder ์ถ”๊ฐ€, AMP(Mixed-Precision) ์ถ”๊ฐ€, UNet ResNet101 / PAN Swin_Large ๋ชจ๋ธ ํ•™์Šต
  • ์‹ ํ˜„์ˆ˜: EDA, Wandb Setting, SMP์—์„œ ๋ชจ๋ธ ์‹คํ—˜ ์ง„ํ–‰, DiceFocalLoss, CDB Loss ๊ตฌํ˜„ ๋ฐ ํ•™์Šต

๐Ÿ—ƒ๏ธProcedures

[2022.12.19 ~ 2022.12.23]

  • Baseline ์ฝ”๋“œ setting
    • ๊ณตํ†ต
      • Fiftyone ์‹œ๊ฐํ™”
    • mmseg
      • MMsegmentation install ๋ฐ ํ™˜๊ฒฝ ์„ค์ •
      • inference file ๊ตฌํ˜„
    • Baseline Code
      • SMP ํ™˜๊ฒฝ ์„ค์ •
      • inference file ๊ตฌํ˜„
    • ๊ฐ์ž ๋ชจ๋ธ ์„ ์ •
      • ์ฃผํฌ: MMSeg, UperNet Swin_Large/Tiny
      • ์Šน์œค: MMSeg, Segformer B5
      • ํ•ด์šฑ: SMP, UNet ResNet101 / PAN Swin_Large
      • ์šฐํƒ: SMP, PAN Swin_Large
      • ํ˜„์ˆ˜: SMP, PAN Swin_Large

[2022.12.24 ~ 2022.12.27]

  • Augmentation ์‹คํ—˜
    • ๊ฐ์ž ์„ ์ •ํ•œ ๋ชจ๋ธ๋“ค์„ ์„ ์ •ํ•˜์—ฌ ๊ฐ ๋ชจ๋ธ์— ๋งž๋Š” Augmentation ์‹คํ—˜ ์ง„ํ–‰

[2022.12.28 ~ 2023.01.01]

  • Refresh Day

[2023.01.02 ~ 2023.01.04]

  • Augmentation์„ ํ† ๋Œ€๋กœ ์„ ์ •ํ•œ ๋ชจ๋ธ ํ•™์Šต
  • Model ensemble file ๊ตฌํ˜„

[2023.01.05]

  • ๋ชจ๋ธ ensemble ๋ฐ ๋Œ€ํšŒ ๋งˆ๋ฌด๋ฆฌ
  • Git merge ๋ฐ Readme ์ž‘์„ฑ
  • Wrap-Up Report ์ž‘์„ฑ

๐ŸŒฟFeatures

feat/fiftyone: FiftyOne์„ ํ†ตํ•œ ๋ฐ์ดํ„ฐ์‹œ๊ฐํ™”
feat/upernet: UperNet Swin ๋ชจ๋ธ ์‹คํ—˜
feat/segformer: Segformer ์‹คํ—˜ ๋ฐ ensemble ํŒŒ์ผ ์ž‘์„ฑ
feat/inferencer: MMsegmentation inference ํŒŒ์ผ ์ž‘์„ฑ
feat-losses: Custom Criterion ์ถ”๊ฐ€
feat-baseline_setting: baseline update
feat-SMP: Baseline Code์— SMP ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ชจ๋ธ ์ถ”๊ฐ€
feat/SMP-AMP: SMP Code์— AMP(Mixed-Precision) ์ถ”๊ฐ€
feat/SMP-swin: SMP Code์— Swin ๋ชจ๋ธ ์ถ”๊ฐ€


๐Ÿ“ŠResult

ํƒ์ƒ‰์  ๋ถ„์„(EDA) ๋ฐ ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ

  • Class ๋‹น Annotation ๋ถ„ํฌ
  • ์ด๋ฏธ์ง€ ๋‹น Annotation ์ˆ˜
  • ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๊ฐ€ ๊ฐ€์ง€๋Š” class ์ˆ˜ ๋ถ„ํฌ
  • Annotation์˜ ํฌ๊ธฐ ๋ถ„ํฌ
  • Class๋ณ„ Annotation์˜ ํฌ๊ธฐ ๋ถ„ํฌ

๋ชจ๋ธ ๊ฐœ์š”

  • ์‚ฌ์šฉํ•œ ๋ชจ๋ธ
    SMP : Swin-L + PAN + ImageNet(pretrained)
    MSeg : Upernet Swin-L(Pretrained)

  • Metric : MIoU

SMP MMSeg
Loss Cross Entropty Cross Entropy
Optimizer AdamW SGD
Schedulers CosineAnneling IterBased

Data Augmentation

Base: UperNet Swin_Tiny
Iteration: 160000

Augmentation MIoU
Base 0.5837
+RandMosaic 0.5908
+CutOut 0.5953
+Rotate 0.5952
+GaussNoise 0.5912
+Mblur 0.6138

Result
Model: UperNet Swin_Large Iteration: 160000 MIoU: 0.6961

Base: Segformer_B0
Iteration: 120000

Augmentation MIoU
Base 0.5837
+Optical distortion 0.5958
+Mosaic 0.5967
+Blur 0.6033
+Flip 0.6058

Result
Model: Segformer B5 Iteration: 160000 MIoU: 0.6526

Base: PAN Swin Large

Augmentation MIoU
Base 0.6798
+Flip +RandomSizedCrop 0.6754
+MaskDropOut 0.6980
+RandomBrightness Contrast 0.6697
+GaussNoise 0.5912
+Mblur 0.6138

Ensemble

๋ชจ๋ธ ๋ณ„ mIoU๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ๊ฐ€์ค‘์น˜๋ฅผ ๋ถ€์—ฌํ•˜์—ฌ ํ”ฝ์…€๋ณ„ Hard voting์„ ํ†ตํ•œ ์•™์ƒ๋ธ”

Model1 Model2 Model3 Ensemble
0.7234 0.7143 0.6961 0.7342

Model1 : (SMP) PAN Swin Large 1
Model2 : (SMP) PAN Swin Large 2
Model3 : (MMSeg) UperNet Swin Large

์‹œ์—ฐ๊ฒฐ๊ณผ

์ง€๊ธˆ๊นŒ์ง€ ํ•™์Šตํ•œ ๋ชจ๋ธ์„ ์ตœ์ข… ์•™์ƒ๋ธ”ํ•ด์„œ ์ œ์ถœ

MIoU
0.7264

๐Ÿ‘จโ€๐Ÿ’ปConclusion

์ž˜ํ•œ ์ ๋“ค

  1. baseline model setting์ด ๋งค์šฐ ๋นจ๋ž๊ณ  ์ด๋ฅผ ํ†ตํ•ด ๋น ๋ฅธ ์‹คํ—˜ ์‹œ์ž‘์ด ๊ฐ€๋Šฅํ–ˆ๋‹ค
  2. augmentation์„ ์œ„ํ•ด Albumentation์—๋งŒ ๊ตญํ•œ๋œ ๊ฒƒ์ด ์•„๋‹Œ, ๋‹ค๋ฅธ library๋ฅผ ํƒ์ƒ‰ํ•˜๊ณ  ๊ณต๋ถ€ํ•ด๋ณด๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์กŒ๋‹ค
  3. SMP์™€ MMSegmentation ๋‘ library๋ฅผ ์ด์šฉํ•ด ๋‹ค์–‘ํ•œ ์‹คํ—˜์„ ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

์•„์‰ฌ์šด ์ ๋“ค

  1. ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ๋ฅผ ํ•ด๋ณด์ง€ ๋ชปํ–ˆ๋‹ค.
  2. DenseCRF, TTA, model soup๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ์— ๋„์›€์ด ๋ ๋งŒํ•œ ๊ธฐ๋ฒ•๋“ค์„ ์‹œ๋„ํ•ด ๋ณด์•˜์œผ๋‚˜ ํฐ ํšจ๊ณผ๋ฅผ ์–ป์ง€ ๋ชปํ•˜์˜€๋‹ค.
  3. Optuna ๋“ฑ์˜ library๋ฅผ ์‚ฌ์šฉํ•œ Hyperparameter tuning์„ ์‹œ๋„ํ•ด๋ณด์ง€ ๋ชปํ–ˆ๋‹ค.
  4. Copy-Paste augmentation์„ ์ ์šฉํ•˜์ง€ ๋ชปํ–ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ๋ฅผ ํ†ตํ•ด ๋ฐฐ์šด์ 

  1. Semantic Segmentation์— ๋Œ€ํ•œ ์ด๋ก  ๋ฐ ๋ชจ๋ธ ํ•™์Šต
  2. ๋‹ค์–‘ํ•œ Loss Function, Optimizer, Scheduler์— ๋Œ€ํ•œ ์ดํ•ด ๋ฐ ์‹คํ—˜

๐Ÿ’ปRequirements

MMSeg

conda install pytorch=1.7.1 cudatoolkit=11.0 torchvision -c pytorch  
pip install openmim  
mim install mmseg  

SMP

pip install -r requirements.txt
pip install segmentation-models-pytorch

To use fiftyone

pip install fiftyone
mkdir fiftyone
chmod ... fiftyone
export FIFTYONE_DATABASE_DIR fiftyone

๐Ÿ—๏ธFolder Structure

โ”œโ”€โ”€ code (SMP)
โ”‚    โ”œโ”€โ”€ ๐Ÿ“‚models
โ”‚    โ”‚      โ”œโ”€โ”€ ๐Ÿ“build.py
โ”‚    โ”‚      โ””โ”€โ”€ ๐Ÿ“swin.py
โ”‚    โ”œโ”€โ”€ ๐Ÿ“‚submission
โ”‚    โ”œโ”€โ”€ ๐Ÿ“SMP_dataset.py
โ”‚    โ”œโ”€โ”€ ๐Ÿ“SMP_train.py
โ”‚    โ”œโ”€โ”€ ๐Ÿ“SMP_inference.py
โ”‚    โ”œโ”€โ”€ ๐Ÿ“custom_scheduler.py
โ”‚    โ”œโ”€โ”€ ๐Ÿ“losses.py
โ”‚    โ””โ”€โ”€ ...
โ”‚   
โ””โ”€โ”€ mmsegmentation 
     โ”œโ”€โ”€ ๐Ÿ“‚segformer_trash
     โ”œโ”€โ”€ ๐Ÿ“‚upernet_swin_trash  
     โ””โ”€โ”€ ... 

About

level2_semanticsegmentation_cv-level2-cv-09 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published