Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make YOLOv3 neck more flexible #5218

Merged
merged 6 commits into from
Jun 16, 2021
Merged

Conversation

hokmund
Copy link
Contributor

@hokmund hokmund commented May 25, 2021

Motivation

At the moment, YOLOV3Neck only allows to create neck architectures that have out_channels[0] == in_channels[1] and out_channels[1] == i_channels[2]. This is due to this line of code:

        for i in range(1, self.num_scales):
            in_c, out_c = self.in_channels[i], self.out_channels[i]
            self.add_module(f'conv{i}', ConvModule(in_c, out_c, 1, **cfg)) <<<---
            # in_c + out_c : High-lvl feats will be cat with low-lvl feats
            self.add_module(f'detect{i+1}',
                            DetectionBlock(in_c + out_c, out_c, **cfg))

It can be easily fixed to allow more flexible architectures without any backward compatibility issues.

It is convenient when you assemble YOLO-like architecture using some pretrained backbone, e.g. mobilenetv2_100 that has [320, 96, 32] channels in output feature maps. Current implementation enforces you to use very tight neck with [96, 32, X] channels. Less strict implementation will allow you to create a wider neck and increase your model's capacity.

Modification

Change input channels of conv{i} layers in order to accept arbitrary number of output channels from the previous DetectionBlock.

BC-breaking (Optional)

No breaking changes.

@ZwwWayne ZwwWayne requested a review from RangiLyu May 26, 2021 05:16
@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #5218 (ae26378) into master (ade08ba) will decrease coverage by 1.13%.
The diff coverage is 39.80%.

❗ Current head ae26378 differs from pull request most recent head b962b6e. Consider uploading reports for the commit b962b6e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5218      +/-   ##
==========================================
- Coverage   65.39%   64.25%   -1.14%     
==========================================
  Files         276      275       -1     
  Lines       21229    21094     -135     
  Branches     3561     3532      -29     
==========================================
- Hits        13883    13555     -328     
- Misses       6572     6773     +201     
+ Partials      774      766       -8     
Flag Coverage Δ
unittests 64.25% <39.80%> (-1.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmdet/core/export/model_wrappers.py 0.00% <0.00%> (ø)
mmdet/core/export/pytorch2onnx.py 15.68% <ø> (ø)
mmdet/datasets/coco.py 45.84% <ø> (ø)
mmdet/models/dense_heads/anchor_head.py 83.62% <ø> (-3.10%) ⬇️
mmdet/models/dense_heads/cascade_rpn_head.py 22.71% <0.00%> (ø)
mmdet/models/detectors/detr.py 100.00% <ø> (ø)
mmdet/models/roi_heads/point_rend_roi_head.py 19.62% <ø> (ø)
...heads/roi_extractors/single_level_roi_extractor.py 65.38% <0.00%> (-4.01%) ⬇️
mmdet/models/roi_heads/standard_roi_head.py 50.31% <7.31%> (-12.09%) ⬇️
mmdet/models/dense_heads/yolo_head.py 27.11% <18.18%> (-24.05%) ⬇️
... and 89 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d49b7b...b962b6e. Read the comment docs.

Copy link
Member

@RangiLyu RangiLyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@hokmund hokmund mentioned this pull request May 29, 2021
13 tasks
@ZwwWayne ZwwWayne mentioned this pull request Jun 3, 2021
11 tasks
@RangiLyu RangiLyu requested a review from hhaAndroid June 9, 2021 09:44
@RangiLyu RangiLyu requested a review from hhaAndroid June 11, 2021 07:23
@ZwwWayne
Copy link
Collaborator

Can be merged after fixing the docstring format issues.

@OpenMMLab-Coodinator
Copy link

Hi @hokmund !First of all, we want to express our gratitude for your significant PR in this project. Your contribution is highly appreciated, and we are grateful for your efforts in helping improve this open-source project during your personal time. We believe that many developers will benefit from your PR.

We would also like to invite you to join our Special Interest Group (SIG) private channel on Discord, where you can share your experiences, ideas, and build connections with like-minded peers. To join the SIG channel, simply message moderator— OpenMMLab on Discord or briefly share your open-source contributions in the #introductions channel and we will assist you. Look forward to seeing you there! Join us :https://discord.gg/UjgXkPWNqA

If you have WeChat account,welcome to join our community on WeChat. You can add our assistant :openmmlabwx. Please add "mmsig + Github ID" as a remark when adding friends:)
Thank you again for your contribution❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants