본문 바로가기

ML-Computer Vision/MMdetection

(7)
[mmdetection] 모델 학습과정에서 wanDB 연동방법 이번에 mmdetection에서 제공하는 Instance Segmentation Network들의 성능을 비교해보려 합니다. 위와같이 mmdetection은 2022년 12월 03일 기준 13개의 Instance Segmentation Network를 툴박스에서 제공합니다. 거두절미하고 학습 시각화를 위한 wegiht&bias를 mmdetection에 연동하는 과정을 설명하겠습니다. 2022년 12월 현재 mmdetection github의 master branch가 2.26.0버전을 제공하므로 이를 기준으로 설명하겠습니다. 1. Prerequirement 설치 # pytorch 설치 for cuda 11.3 conda install pytorch==1.11.0 torchvision==0.12.0 tor..
[mmdetection] roi_head 변경방법 기존 mask rcnn model에서 pointRend model로 mask_head를 변경하려고 하였는데 다음과 같은 오류가 발생하였다. AssertionError: The `num_classes` (80) in MaskPointHead of MMDataParallel does not matches the length of `CLASSES` 1) in VOCDataset 해당 오류는 2가지의 이유로 발생할 수 있는데 먼저, 해결방법 1 mmdetection-master 디렉토리에는 python 파일이 일부만 존재하는데, 실제로 프로그램이 실행될 때 환경에서 소스 파일을 직접 수정하기 때문에 환경의 소스 파일은 계속 실행됩니다. 내 conda 환경의 이름이 conda_env_name이라고 가정하고 다음 ..
[mmdetection] custom training 방법 (개선) 1. config file들 새로 만들기 config의 대분류는 datasets, model, scedule, runtime 이다. 이번에 만들 config file들도 이렇게 구성된다. 1-1 mmdetection/configs 폴더 안에 새로운 폴더 생성 ex) smartfarm 1-2 새로만든 폴더안에 dataset.py 생성 해당 파일은 config/_base_/coco_instance.py 를 복붙하고 주석처리한 부분만 수정한다. # dataset settings dataset_type = 'CocoDataset' data_root = '/scratch/dohyeon/mmdetection/coco_output/' #dataset이 저장된 root위치 classes = ('chicken') # _..
[mmdetection] custom dataset 학습방법 오늘은 custom dataset(육계 데이터셋)을 이용해 mmdetection model을 training하는 방법을 정리하고자 한다. 1. training.py file 생성 from mmdet.apis import init_detector, inference_detector import mmcv import torch import cv2 from mmdet.datasets.builder import DATASETS from mmdet.datasets.coco import CocoDataset from mmcv import Config print(f"Setup complete. Using torch {torch.__version__} ({torch.cuda.get_device_properties(0)..
[mmdetection] 탐지 개체수 설정방법 mmdetection에는 이미지 하나당 감지될 수 있는 개체수가 정해져있다. (default 100) 내가 다루는 데이터의 경우 하나의 이미지에 보통 2~300개의 instance가 존재하므로 위 설정을 바꿀 필요가 있었다. 변경방법은 다음과 같다. mmdetection/configs/_base_/models/mask_rcnn_r50_fpn.py 위 파일에서 맨 아래부분의 test_cfg 부분을 살펴보면 rcnn 내부에 max_per_img 이 변수가 하나의 이미지에서 탐지할 수 있는 최대 개체수 파라미터다. 해당 파라미터를 1000으로 변경하면 최대 1000개까지 instance를 탐지할 수 있다. test_cfg=dict( rpn=dict( nms_pre=1000, max_per_img=1000, n..
[mmdetection] bbox title 변경방법 오늘은 실험실에서 mmdetection 툴박스에서 제공하는 Mask R-CNN으로 추론하던 중 추론결과 표시되는 bbox title을 변경하는 task가 주어졌다. 위 문제를 해결하는 방법을 정리해보려 한다. 원본코드를 이용한 추론결과는 위와 같다. mmdetection Mask R-CNN코드는 다음 순서에 따라 동작한다. 1. config, checkpoint file을 불러오기 2. init_detector를 이용해 detector model 생성 3. 추론하고자 하는 image를 불러들여 inference_detector(model, image_name) 함수를 이용해 추론 4. show_result 함수를 이용해 추론된 결과를 원본 이미지 위에 그려주고 저장 # config 파일을 설정하고, ma..
[mmdetection] 초기 환경세팅 정보 기본환경 OS: ubuntu 18.04 cuda: 10.2 cudnn 8.3.0 for cuda-10.2 python: 3.7.13 pytorch : 1.8.1 for cuda 10.2 mmdetection 설치 pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.1/index.html pip install mmdet APOLLO Workstation python : 3.8.13 pytorch: 1.10.0 cuda: 11.3 cudnn: 8.2.1 for cuda 11.x mmdet: 2.25.0 mmcv-full: 1.47 + git이 설치되어 있지 않으면 mim install로 mmdet 설치 불가능하다