Skip to content

(continue to be updated)Note on mmdetection for better usage and understand

License

Liforam/mmdetection-annotated

 
 

Repository files navigation

Notes!!

There are certain difference between present version and offical openlab-mmdetection , such as demo.py file , cfg attribute is integrated to model in the latest version ,so that only 2 passing parameters are necessary compared to the former 3.
I don't think it worth tracing on codebase's updating , present version is sufficient . Thus I won't keep on attaching notes to newer mmdetection codebase.If you insist that the newer ,the better ,this repo also helps as I have checked the difference between two repos ,only to find that no big changes are made in recent codebase .

mmdetection-annotated

Notice : Work finished! And more annotation will be added if necessary.Still to be contunued....I'm back again , and concentrate on it now.Focused on some experiments recently , I may postpone updates on training parts.To be contunued....(well,I promise to finish the rest work before Jul.Blame it on examinations...)

Introduction

Refer to the execllent implemention here:https://github.com/open-mmlab/mmdetection ,and thanks to author Kai Chen.
Open-mmlab project , which contains various models and implementions of latest papers , achieves great results in detection/segmentataion tasks , and is kind enough for rookies in CV field.

Getting started

More information about installation or pre-train model downloads , pls refer to officia mmdetection or blog here

  • Test on images
    You can test on Mask-RCNN demo by running the script demo.py. I have just rewritten the demo file to detect on single image or a folder as follow:
import ipdb
import sys,os,torch,mmcv
from mmcv.runner import load_checkpoint
#下面这句import的时候定位并调用Registry执行了五个模块的注册
from mmdet.models import build_detector	
from mmdet.apis import inference_detector, show_result

if __name__ == '__main__':
	# ipdb.set_trace()
	cfg = mmcv.Config.fromfile('configs/mask_rcnn_r101_fpn_1x.py')
	# cfg = mmcv.Config.fromfile('configs/faster_rcnn_r50_fpn_1x.py')
	cfg.model.pretrained = None		#inference不设置预训练模型
	#inference只传入cfg的model和test配置,其他的都是训练参数
	model = build_detector(cfg.model, test_cfg=cfg.test_cfg)
	_ = load_checkpoint(model, 'weights/mask_rcnn_r101_fpn_1x_20181129-34ad1961.pth')
	# print(model)  # 展开模型

	# test a single image
	img= mmcv.imread('/py/pic/2.jpg')
	result = inference_detector(model, img, cfg)
	show_result(img, result)

	# # test a list of folder
	# path='/py/mmdetection/images/'
	# imgs= os.listdir(path)
	# for i in range(len(imgs)):
	# 	imgs[i]=os.path.join(path,imgs[i])
	# # imgs = ['/py/pic/4.jpg', '/py/pic/5.jpg']
	# for i, result in enumerate(inference_detector(model, imgs, cfg, device='cuda:0')):
	#     print(i, imgs[i])
	#     show_result(imgs[i], result)

  • Debug
    You can debug by setting breakpoint with method of adding ipdb.set_trace()
  • Hook
    If you want to inspect on intermediate variables , hook.py can be a provision served as a reference for your work.

Annotations

Annotations are attached everywhere in the code(surely only the part I have read , and the not finished part will be completed as soon as possible). Beside , annotation folder contains some interpreting documents as well.

  • Model visualization
    Take Mask-RCNN for example , the model can be visualized as follow:(more details refere to model-structure-png)
  • Configuration
    Explicit describtion on config file , take Mask RCNN for example , refer to mask_rcnn_r101_fpn_1x.py
  • MMCV&MMDET
    Specification of mmcv lib and a partial of mmdet(more details about various models will be updated later ).

Detection Results

Test on Mask RCNN model:

Training

dataset

  • You can just use COCO dataset , refer here.
  • If you want to train on your customed dataset labeled by labelme , you need first convert json files to COCO style , this toolbox may help you ;
  • If you want to train on your customed dataset labeled by labelImg , you need first convert xml files to COCO style , this toolbox may also help you .
  • I have tested on these tools recently to make sure them still work well, if questiones still arised , desrcibe on issue please or contact me , thanks.

learning rate

Remember to set lr in config file according to your own GPU_NUM !!!!(eg.1/8 of default lr for 1 GPU)

Future work

Mmdetection performs better than many classical implementions , it's really a excellent work , can be called as ‘Chinese Detectron’ :p .I will update this project with annotations for more details in the future, letting more people make a good use of this great work.You can continue to foucus on this repo.
BTW , this repo is just used for better comprehension , if you ask for better performance or latest paper implementions ,please keep eyes on mmdetection

About

(continue to be updated)Note on mmdetection for better usage and understand

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 82.8%
  • Cuda 11.6%
  • C++ 5.5%
  • Other 0.1%