MMDetection-inference

Published by onesixx on

MMDection 설치

– MMCV가 먼저 설치되어 있어야 함 .(pip를 통해 mmcv-full 설치)
– mmdetection.git을 clone 하고, setyp.py를 통해 설치

Inference 수행 (Pretrained 모델을 활용)

이미지

https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb 데모아래 튜토리얼 참조

Config와 Checkpoint(모델) 다운로드

config_file     = './mmdetection/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = './mmdetection/checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'

model = init_detector(
              config_file, 
              checkpoint_file, 
              device='cuda:6'
          )  # Model loading from config and pretrained  

# model.__dict__
# print(model.cfg.pretty_text)
img = './data/rose.jpg'
# img_arr = cv2.imread(img)
# img_arr = cv2.cvtColor(img_arr, cv2.COLOR_BGR2RGB)
result = inference_detector(model, img)   # class 80개에 대한 80 length의 List
# result[39]
# model.CLASSES[39]
show_result_pyplot(model, img, results)   # (class confidence) score threadhold 0.3

list순서에 따른 class 명

비디오

https://github.com/open-mmlab/mmdetection/blob/master/demo/video_demo.py 데모아래 참조

config_file     = './mmdetection/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = './mmdetection/checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:6')  # Model loading from config and pretrained  
# model.__dict__
# print(model.cfg.pretty_text)
# img_arr = cv2.imread(img)
# img_arr = cv2.cvtColor(img_arr, cv2.COLOR_BGR2RGB)
result = inference_detector(model, img)   # class 80개에 대한 80 length의 List
# result[39]
# model.CLASSES[39]
show_result_pyplot(model, img, results)   # (class confidence) score threadhold 0.3
Categories: vision

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x