MMDetection is an open source object detection toolbox based on PyTorch.
mmdetection의 적당한 버전을 찾고 설치 가이드라인을 확인한다.
https://github.com/open-mmlab/mmdetection/blob/v2.22.0/docs/en/get_started.md
mmdetection prerequiesites 및 설치할 시스템의 환경(cuda, python version 등)을 고려하여 적당한 버전을 설치하면 된다. pytorch official guideline을 따를 것.
https://pytorch.org/
여기서는 pytorch 1.7.1을 기준으로 설치 진행한다.
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
mmcv 및 기타 Python 패키지를 포함하여 OpenMMLab 프로젝트의 종속성을 자동으로 처리하는 MIM 과 함께 MMDetection을 설치하는 것을 추천함
pip install openmim
mim install mmdet==2.22.0
dependency를 고려하여 자동 설치를 권장하지만
또는 아래와 같이 manual 설치가 가능함
1. install mmcv-full
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
# We can ignore the micro version of PyTorch
pip install mmcv-full==1.4.6 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7/index.html
https://mmcv.readthedocs.io/en/latest/get_started/build.html
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
MMCV_WITH_OPS=1 pip install -e .
pip install mmdet==2.22.0
또는 아래와 같이 repository에서 clone해서 설치가 가능함.
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"
github를 통해 mmdetection code를 받지 않았다면 repo clone을 통해 받고 verification을 위한 checkpoint 및 config 파일을 다운 받는다.
# if there is no mmdetection code in your workspace,
# then you should clone repository of mmdetection to your workspace.
git clone https://github.com/open-mmlab/mmdetection.git
# download config and checkpoint files
mim download mmdet --config faster_rcnn_r50_fpn_1x_coco --dest ./checkpoint/
아래와 같이 동작에 문제가 없는지 데모 파일을 수행한다.
from mmdet.apis import init_detector, inference_detector
config_file = 'mmdetection/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoint/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
inference_detector(model, 'mmdetection/demo/demo.jpg')
https://github.com/open-mmlab/mmdetection#benchmark-and-model-zoo
https://velog.io/@seryoung/2021.09.28-Object-Detection-Library
감사합니다