쫑쫑JJONG
끄적끄적 오후5시37분
쫑쫑JJONG
전체 방문자
오늘
어제
  • 분류 전체보기 (198)
    • Paper Reading (5)
    • Math (5)
    • Data Science (13)
      • SQL (12)
      • Data Analyst (1)
    • AI Track (32)
      • CV (21)
      • CV Remind (2)
      • NLP (1)
      • AI Basic (8)
    • Python (1)
      • Basic (8)
      • Application (5)
    • Robotics (31)
      • ROS (15)
      • Collabot_proj (16)
    • NaverBoost Camp 4기 (45)
      • 부스트일지 (13)
      • [P stage] Image Classificat.. (4)
      • [P stage] Object Detection (12)
      • [P stage] Semantic Segmenta.. (6)
      • [P stage] Final Project (5)
      • CV (1)
      • DL BASIC (4)
    • Excel (1)
    • Git (8)
      • Git (8)
    • Network (3)
      • 통신 (3)
    • 코테준비 (14)
      • Programmers (11)
      • 기타 (3)
    • 환경설정 (19)
    • etc (7)
      • 활동 (2)
      • TIP (3)
      • 잡동사니 (2)
    • 금융관련 (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • 포트폴리오

인기 글

태그

  • ros
  • N
  • transformer
  • Monte Carlo Sampling
  • GIT
  • diffusion
  • 논문분석
  • Data Scraping
  • Arduino
  • error
  • Confusion Matrix
  • robotics
  • mmdetection
  • SQL
  • 이고잉
  • segmentation
  • python
  • CV
  • 환경설정
  • collabot
  • NLP

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
쫑쫑JJONG

끄적끄적 오후5시37분

[Seg] Segmentation 모델(mmsegmentation) 준비
AI Track/CV

[Seg] Segmentation 모델(mmsegmentation) 준비

2023. 6. 21. 13:30
728x90

일단 구상하고 있는 아이디어에 사용되는 데이터는

모델 : 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

https://www.inflearn.com/questions/614994/mmdet-%EC%84%A4%EC%B9%98%EA%B0%80-%EC%95%88%EB%90%98%EB%84%A4%EC%9A%94-%E3%85%A0%E3%85%A0

 

mmdet 설치가 안되네요 ㅠㅠ - 인프런 | 질문 & 답변

먼저 좋은 강의 감사드립니다. 열심히 따라가면서 배우고 있습니다 ^^다만 mmdet 설치가 계속 안되어서.. 질문 드립니다.Colab 이 아닌, 개인 pc 서버로 실습을 해 오고 있었습니다. GPU 는 RTX3090 이구

www.inflearn.com

 

728x90
저작자표시 비영리 변경금지 (새창열림)

'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
    'AI Track/CV' 카테고리의 다른 글
    • [Seg] Segmentation 모델(mmsegmentation) 준비
    • Custom Diffusion 실습
    • [Seg] Segmentation 데이터셋(ADE20K) 준비
    • [seg] semantic segmentation 예제 연습
    쫑쫑JJONG
    쫑쫑JJONG
    connect : tmdwhd619@naver.com

    티스토리툴바