/MDE_Toolbox_Others

This is an official implementation of our CVPR 2023 paper "Revealing the Dark Secrets of Masked Image Modeling" on Depth Estimation.

Primary LanguagePythonApache License 2.0Apache-2.0

DDAD/Arogverse/DrivingStereo 데이터셋 학습 셋업

config 파일 수정

KITTI 외에 DDAD, Argovserse, DrivingStereo와 같은 데이터셋으로 학습하고자 하는 경우, 각각의 데이터셋을 정의하는 config 파일을 작성해야 합니다.

특히 데이터셋이 다를 때에는 이미지 크기가 다르므로, 코드 상에서 사이즈를 다루는 값들(코드 상에서 kb crop size, img_scale 등) 수정이 필요합니다.

그 외에는 이미지와 라벨 파일을 정리한 각각에 대한 폴더명, split을 정의하는 txt 파일, max_depth 값 등의 수정이 필요합니다.

저는 총 5곳에서 수정을 진행했습니다.

depth/datasets/ddad.py
depth/datasets/__init__.py
depth/datasets/pipelines/loading.py
configs/bts/bts_r50_ddad_24e.py
configs/_base_/datasets/ddad.py

그 외에도, 사실 Toolbox 원본 코드 자체에서 오류가 하나 있습니다.

depth/models/losses/sigloss.py
Dg = torch.var(g) + 0.15 * torch.pow(torch.mean(g), 2)
Dg = torch.var(g, unbiased=False) + 0.15 * torch.pow(torch.mean(g), 2)

PyTorch에서는 var()의 디폴트 옵션이 unbiased=True인데요, 이 부분은 명시적으로 False로 지정하는 것이 수식적으로 올바릅니다. 이 부분은 KITTI에서는 딱히 차이가 없지만, DDAD 등의 다른 데이터셋에서는 학습의 안정성에서 큰 문제가 됨을 확인했습니다. 이건 제 생각인데요, random crop하면서 학습하니까 valid point 개수 N이 작아지는 케이스가 발생될 때 N으로 나눠주는 var() 함수에서 불안정성이 생기는 것 같습니다.

데이터셋 준비

.
├── argoverse
│   ├── gt_depth
│   ├── input_image
│   ├── train.txt
│   └── val.txt
├── ddad
│   ├── ddad_test.txt
│   ├── ddad_train.txt
│   ├── ddad_val.txt
│   ├── gt_depth
│   └── input_image
├── drst
│   ├── gt_depth
│   ├── input_image
│   ├── test.txt
│   └── train.txt
└── kitti
    ├── gt_depth
    ├── input
    ├── kitti_eigen_test.txt
    └── kitti_eigen_train.txt

이렇게 셋업했습니다. 각각의 데이터셋을 다운받고, 이미지 폴더와 라벨 폴더 각각에 모두 저장합니다. train/val/test split은 .txt 파일로 관리하기 때문에 폴더 구분은 필요하지 않습니다.

학습

셋업이 끝난 후 학습은 이렇게 진행할 수 있습니다.

sh tools/dist_train.sh configs/depthformer/depthformer_swinl_22k_w7_ddad.py 4 --work-dir work_dirs/depthformer_swinl_22k_w7_ddad_n2

Fine-tuning

checkpoint 파일을 갖고 있을 때, 이에 대한 fine-tuning을 수행하고자 하는 경우 아래와 같이 --load-from에 checkpoint 파일의 경로를 지정하여 수행할 수 있습니다.

sh tools/dist_train.sh configs/depthformer/depthformer_swinl_22k_w7_kitti.py 4 --work-dir work_dirs/depthformer_swinl_22k_w7_drst_kitti_n23 --load-from work_dirs/save/depthformer_swinl_22k_w7_drst_n25/latest.pth

아래는 Toolbox의 original readme입니다.

Monocular-Depth-Estimation-Toolbox

Introduction

Monocular-Depth-Estimation-Toolbox is an open source monocular depth estimation toolbox based on PyTorch and MMSegmentation v0.16.0.

It aims to benchmark MonoDepth methods and provides effective supports for evaluating and visualizing results.

Major features

  • Unified benchmark

    Provide a unified benchmark toolbox for various depth estimation methods.

  • Modular design

    Depth estimation frameworks are decomposed into different components. One can easily construct a customized framework by combining different modules.

  • Support of multiple methods out of box

    I would like to reproduce some of the most excellent depth estimation methods based on this toolbox.

  • High efficiency

    It seems that there are few depth estimation benchmarks, so I start this project and hope it is helpful for research.

Thanks to MMSeg, we own these major features. 😊

Benchmark and model zoo

Results and models are available in the model zoo.

Supported backbones (partially release):

  • ResNet (CVPR'2016)
  • EfficientNet (ICML'2019)
  • Vision Transformer (ICLR'2021)
  • Swin Transformer (ICCV'2021)
  • I recommend cross-package import in config, so that you can utilize other backbone in MMcls, MMseg, etc. Refer to introduction. I will add more backbones in the future.

Supported methods:

Supported datasets:

Installation

Please refer to get_started.md for installation and dataset_prepare.md for dataset preparation.

Get Started

We provide train.md and inference.md for the usage of this toolbox.

License

This project is released under the Apache 2.0 license.

Acknowledgement

This repo benefits from awesome works of mmsegmentation, Adabins, BTS. Please also consider citing them.

Cite

@misc{lidepthtoolbox2022,
  title={Monocular Depth Estimation Toolbox},
  author={Zhenyu Li},
  howpublished = {\url{https://github.com/zhyever/Monocular-Depth-Estimation-Toolbox}},
  year={2022}
}

Changelog

  • Jul. 23, 2022: Release codes for BinsFormer. Potential bugs or performance drops can exist, waiting for completion.
  • Jun. 5, 2022: Add support for custom dataset training. Add a warmup interface for sigloss to help convergence as discussed in Issue #20. Enhance the DPT support and fix bugs in provided pre-trained models as reported in Issue #23.
  • Apr. 16, 2022: Finish most of docs and provide all pre-trained parameters. Release codes about BTS, Adabins, DPT, SimIPU, and DepthFormer. Support KITTI, NYU-v2, SUN RGB-D(eval), and CityScapes.

TODO

  • I will complete release of BinsFormer (On going).
  • I would like to include self-supervised depth estimation methods, such as MonoDepth2.