Coder Social home page Coder Social logo

liangjiubujiu / mmdetection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-mmlab/mmdetection

0.0 1.0 0.0 14.32 MB

OpenMMLab Detection Toolbox and Benchmark

Home Page: https://mmdetection.readthedocs.io

License: Apache License 2.0

Shell 0.09% Python 99.88% Dockerfile 0.03%

mmdetection's Introduction

Benchmark and model zoo

Results and models are available in the model zoo.

Supported backbones:

  • ResNet
  • ResNeXt
  • VGG
  • HRNet
  • RegNet
  • Res2Net
  • ResNeSt

Supported methods:

Some other methods are also supported in projects using MMDetection.

Installation

Please refer to get_started.md for installation.

Traning your own dataset

  1. prepare your dataset. boshi/boshi/yaqi/tooth
tooth
  |_train
    |_**********.png
    ...
    |_annotation_train.json
  |_val
    |_*********.png
    ...
    |_annotation_val.json
  1. config configs/base/coco_instance.py
2      data_root = 'tooth/'

33     train=dict(
        type=dataset_type,
        ann_file=data_root + 'train/annotation_coco.json',
        img_prefix=data_root + 'train/',
        pipeline=train_pipeline),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'val/annotation_coco.json',
        img_prefix=data_root + 'val/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'val/annotation_coco.json',
        img_prefix=data_root + 'val/',
        pipeline=test_pipeline))
  1. configs/base/models/maskrcc_r50_fpn.py
num_classes=3# not include background
  1. configs/base/schedules/schedule_1x.py
optimizer = dict(type='SGD', lr=0.006, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=500,
    warmup_ratio=0.001,
    step=[8, 11])
total_epochs = 500
  1. configs/default_run_time.py, set saved interval.
checkpoint_config = dict(interval=20)
# yapf:disable
log_config = dict(
    interval=50,
    hooks=[
        dict(type='TextLoggerHook'),
        # dict(type='TensorboardLoggerHook')
    ])
  1. mmdet/core/class_names.py
67 def coco_classes():
      # return [
      #     'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train',
      #     'truck', 'boat', 'traffic_light', 'fire_hydrant', 'stop_sign',
      #     'parking_meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep',
      #     'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella',
      #     'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard',
      #     'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard',
      #     'surfboard', 'tennis_racket', 'bottle', 'wine_glass', 'cup', 'fork',
      #     'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange',
      #     'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'chair',
      #     'couch', 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv',
      #     'laptop', 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave',
      #     'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
      #     'scissors', 'teddy_bear', 'hair_drier', 'toothbrush'
      # ]

      return ['R','G','B']
  1. mmdet/datasets/coco.py
29 class CocoDataset(CustomDataset):

    # CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
    #            'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
    #            'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog',
    #            'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
    #            'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
    #            'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat',
    #            'baseball glove', 'skateboard', 'surfboard', 'tennis racket',
    #            'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
    #            'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot',
    #            'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
    #            'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop',
    #            'mouse', 'remote', 'keyboard', 'cell phone', 'microwave',
    #            'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock',
    #            'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush')
    CLASSES=('R','G','B')
  1. trainning your maskrcnn.

7.1 create configs/tooth and copy .py from config/maskrcnn.

tooth  
  |_mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_tooth.py
  |_mask_rcnn_r50_fpn_1x_coco.py

7.2 run

python /tools/train.py  configs/tooth/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_tooth.py
  1. testing the trained maskrcnn.
python /demo/mydemo.py configs/tooth/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_tooth.py    work_dirs/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_tooth/epoch_500.pth   --show

9.change other parameters in model. For example, add data augmentation alub in train_pipeline. 9.1 change config file in work_dirs/cascade_rcnn_r50_sac_1x_coco/cascade_rcnn_r50_sac_1x_coco.py, rename work_dirs for now model.

190 albu_train_transforms = [
    dict(
        type='ShiftScaleRotate',
        shift_limit=0.0625,
        scale_limit=0.0,
        rotate_limit=180,
        interpolation=1,
        p=0.5)
]
212 dict(
        type='Albu',
        transforms=[
            dict(
                type='ShiftScaleRotate',
                shift_limit=0.0625,
                scale_limit=0.0,
                rotate_limit=180,
                interpolation=1,
                p=0.5)
        ],
336 work_dir = './work_dirs/cascade_rcnn_r50_sac_1x_coco_albu'

9.2 Train the new model with the modified config in 9.1

python tools/train.py work_dirs/cascade_rcnn_r50_sac_1x_coco/cascade_rcnn_r50_sac_1x_coco.py

9.3 change demo/mydemo.py

51     parser.add_argument('--config', default='work_dirs/cascade_rcnn_r50_sac_1x_coco_albu/cascade_rcnn_r50_sac_1x_coco.py',help='test config file path')
    parser.add_argument('--checkpoint', default='work_dirs/cascade_rcnn_r50_sac_1x_coco_albu/epoch_60.pth',help='checkpoint file')
    parser.add_argument('--out', default='result/cascade_rcnn_r50_sac_1x_coco_albu.pkl', help='output result file in pickle format')
    

9.4 Test the new model

python demo/mydemo.py

9.5 Find the new test results in 'result/cascade_rcnn_r50_sac_1x_coco_albu.pkl', and change the config file 'work_dirs/cascade_rcnn_r50_sac_1x_coco_albu/cascade_rcnn_r50_sac_1x_coco.py in tools/eval_metric.py.

19  parser.add_argument('--config', default='work_dirs/cascade_rcnn_r50_sac_1x_coco_albu/cascade_rcnn_r50_sac_1x_coco.py',help='Config of the model')
    parser.add_argument('--pkl_results', default='result/cascade_rcnn_r50_sac_1x_coco_albu.pkl',help='Results in pickle format')
    

9.6 Open plot function and Visualize the Precision-Recall curve in mmdet/datasets/coco.py.

548-572 open todo plot pr curve
549   change the third dimention into 0/1/2 for three classes.          
                pr_array1 = cocoEval.eval['precision'][0, :, 0, 0, 2]
                pr_array2 = cocoEval.eval['precision'][6, :, 0, 0, 2]
                pr_array3 = cocoEval.eval['precision'][7, :, 0, 0, 2]
                pr_array4 = cocoEval.eval['precision'][8, :, 0, 0, 2]
                pr_array5 = cocoEval.eval['precision'][9, :, 0, 0, 2]

9.7 Run tools/eval_metric.py.

python tools/eval_metric.py

10 Show mAP during trainning.

python tools/analyze_logs.py plot_curve /home/liangjiubujiu/Project/mmdetection-master/work_dirs/cascade_rcnn_r50_sac_1x_coco/20201214_144511.log.json /home/liangjiubujiu/Project/mmdetection-master/work_dirs/cascade_rcnn_r50_rfp_1x_coco/20201213_235433.log.json /home/liangjiubujiu/Project/mmdetection-master/work_dirs/detectors_cascade_rcnn_r50_1x_coco/20201215_033344.log.json /home/liangjiubujiu/Project/mmdetection-master/work_dirs/cascade_rcnn_r50_sac_1x_coco_albu/20201216_115552.log.json --keys bbox_mAP --legend sac rfp detectors sac+albu

Getting Started

Please see get_started.md for the basic usage of MMDetection. We provide colab tutorial, and full guidance for quick run with existing dataset and with new dataset for beginners. There are also tutorials for finetuning models, adding new dataset, designing data pipeline, customizing models, customizing runtime settings and useful tools.

Please refer to FAQ for frequently asked questions.

Contributing

We appreciate all contributions to improve MMDetection. Please refer to CONTRIBUTING.md for the contributing guideline.

Acknowledgement

MMDetection is an open source project that is contributed by researchers and engineers from various colleges and companies. We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks. We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new detectors.

Citation

If you use this toolbox or benchmark in your research, please cite this project.

@article{mmdetection,
  title   = {{MMDetection}: Open MMLab Detection Toolbox and Benchmark},
  author  = {Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and
             Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and
             Liu, Ziwei and Xu, Jiarui and Zhang, Zheng and Cheng, Dazhi and
             Zhu, Chenchen and Cheng, Tianheng and Zhao, Qijie and Li, Buyu and
             Lu, Xin and Zhu, Rui and Wu, Yue and Dai, Jifeng and Wang, Jingdong
             and Shi, Jianping and Ouyang, Wanli and Loy, Chen Change and Lin, Dahua},
  journal= {arXiv preprint arXiv:1906.07155},
  year={2019}
}

Contact

This repo is currently maintained by Kai Chen (@hellock), Yuhang Cao (@yhcao6), Wenwei Zhang (@ZwwWayne), Jiarui Xu (@xvjiarui). Other core developers include Jiangmiao Pang (@OceanPang) and Jiaqi Wang (@myownskyW7).

mmdetection's People

Contributors

aemikachow avatar chrisfsj2051 avatar daavoo avatar erotemic avatar gt9505 avatar hellock avatar innerlee avatar johnson-wang avatar jshilong avatar korabelnikov avatar liangjiubujiu avatar liaopeiyuan avatar lindahua avatar melikovk avatar michaelisc avatar mxbonn avatar myownskyw7 avatar oceanpang avatar runningleon avatar ryanxli avatar shinya7y avatar thangvubk avatar tianyuandu avatar v-qjqs avatar wangruohui avatar wswday avatar xvjiarui avatar yhcao6 avatar yuzhj avatar zwwwayne avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.