일단 구상하고 있는 아이디어에 사용되는 데이터는
모델 : BEiT (https://arxiv.org/pdf/2106.08254.pdf)
데이터 : ADE20K(https://github.com/CSAILVision/ADE20K/tree/main) 이다
BEiT for ADE20K를 사용하기 위해서는 mmsegmentation Framework를 이용하려 한다
이 Backbone을 이용하고 싶어서
MMsegmentation을 이용하고자 한다
conda create -n mmseg python=3.7 -y
conda activate mmseg
https://github.com/open-mmlab/mmsegmentation/blob/main/docs/en/get_started.md
conda install pytorch=1.6.0 torchvision cudatoolkit=10.1 -c pytorch
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
그 다음 mmsegmentation의 공식 github를 clone 해오자
git clone https://github.com/open-mmlab/mmsegmentation.git .
여기에 들어가 보면
beit가 딸려서 온다
예시대로 진행해보자
python tools/model_converters/beit2mmseg.py ${PRETRAIN_PATH} ${STORE_PATH}
에러 슈팅해주고
ModuleNotFoundError: No module named 'mmengine'
pip install mmengine
뭔가 이상해서 직접 pth를 받았다
https://github.com/microsoft/unilm/blob/master/beit/README.md
GitHub - microsoft/unilm: Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities - GitHub - microsoft/unilm: Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
github.com
공식레포인 아래의 링크 를 MMseg로 바꿔준 것이라고 한다
https://github.com/microsoft/unilm/tree/master/beit/semantic_segmentation
그 다음 아래로 트레이닝을 시킨다
tools/dist_train.sh <CONFIG_PATH> <NUM_GPUS> --work-dir <SAVE_PATH> --seed 0 --deterministic --options model.pretrained=<IMAGENET_CHECKPOINT_PATH/URL>
tools/dist_train.sh /configs/beit/beit-base_upernet_8xb2-160k_ade20k-640x640_ms.py 1 --work-dir ./save --seed 0 --deterministic --options model.pretrained=/pretrain/beit_base_patch16_224_pt22k_ft22k.pth
라고 하는데
File "/home/kist/Collabot/semantic_seg/mmseg/__init__.py", line 62, in <module> f'MMCV=={mmcv.__version__} is used but incompatible. ' \ AssertionError: MMCV==1.7.1 is used but incompatible. Please install mmcv>=2.0.0rc4.
이 에러가 나서
mim install 'mmcv >= 2.0.0rc1'
를 해줬더니
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> mmcv
이 에러가 나와가지고
pip install --upgrade pip
한 다음 아래의 링크
https://github.com/open-mmlab/mmdetection/issues/10104에서 하라는 데로
pip install mmcv==2.0.0rc4 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9/index.html
를 통해서 mmcv 문제는 해결했고
이 에러를 해결해 보자
UserWarning: Cannot import torch.fx, `merge_dict` is a simple function to merge multiple dicts warnings.warn('Cannot import torch.fx, `merge_dict` is a simple function ' usage: train.py [-h] [--work-dir WORK_DIR] [--resume] [--amp] [--cfg-options CFG_OPTIONS [CFG_OPTIONS ...]] [--launcher {none,pytorch,slurm,mpi}] [--local_rank LOCAL_RANK] config train.py: error: unrecognized arguments: --seed 0 --deterministic --options model.pretrained=/pretrain/beit_base_patch16_224_pt22k_ft22k.pth Traceback (most recent call last): File "/home/kist/anaconda3/envs/mmseg/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/home/kist/anaconda3/envs/mmseg/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/kist/anaconda3/envs/mmseg/lib/python3.7/site-packages/torch/distributed/launch.py", line 261, in <module> main() File "/home/kist/anaconda3/envs/mmseg/lib/python3.7/site-packages/torch/distributed/launch.py", line 257, in main cmd=cmd) subprocess.CalledProcessError: Command '['/home/kist/anaconda3/envs/mmseg/bin/python', '-u', 'tools/train.py', '--local_rank=0', '/configs/beit/beit-base_upernet_8xb2-160k_ade20k-640x640_ms.py', '--launcher', 'pytorch', '--work-dir', './save', '--seed', '0', '--deterministic', '--options', 'model.pretrained=/pretrain/beit_base_patch16_224_pt22k_ft22k.pth']' returned non-zero exit status 2.
참고자료
https://github.com/open-mmlab/mmsegmentation/tree/master
GitHub - open-mmlab/mmsegmentation: OpenMMLab Semantic Segmentation Toolbox and Benchmark.
OpenMMLab Semantic Segmentation Toolbox and Benchmark. - GitHub - open-mmlab/mmsegmentation: OpenMMLab Semantic Segmentation Toolbox and Benchmark.
github.com
mmdet 설치가 안되네요 ㅠㅠ - 인프런 | 질문 & 답변
먼저 좋은 강의 감사드립니다. 열심히 따라가면서 배우고 있습니다 ^^다만 mmdet 설치가 계속 안되어서.. 질문 드립니다.Colab 이 아닌, 개인 pc 서버로 실습을 해 오고 있었습니다. GPU 는 RTX3090 이구
www.inflearn.com
'AI Track > CV' 카테고리의 다른 글
[Seg] Segmentation 모델(mmsegmentation) 준비 (0) | 2023.06.27 |
---|---|
Custom Diffusion 실습 (0) | 2023.06.21 |
[Seg] Segmentation 데이터셋(ADE20K) 준비 (0) | 2023.06.14 |
[seg] semantic segmentation 예제 연습 (1) | 2023.06.09 |
[Generative] Diffusion에 관하여 (0) | 2023.04.27 |