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

[Feature] Support YOLOX-PAI #8778

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open

Conversation

okotaku
Copy link
Contributor

@okotaku okotaku commented Sep 13, 2022

Motivation

YOLOX-PAI: An Improved YOLOX, Stronger and Faster than YOLOv6
official repo

Related PR

open-mmlab/mmcv#2256
open-mmlab/mmpretrain#1025

Result

Backbone ASFF TOOD box AP
YOLOX-PAI-s N N 42.2
YOLOX-PAI-s Y N 42.9
YOLOX-PAI-s Y Y 43.9

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@okotaku okotaku changed the base branch from master to dev September 13, 2022 06:26
@RangiLyu RangiLyu requested a review from hhaAndroid September 14, 2022 06:07
@RangiLyu RangiLyu added the v-2.x label Sep 14, 2022
@ZwwWayne
Copy link
Collaborator

Hi @okotaku ,
Thanks for your kind PR. It seems that your branch deviates from the dev branch. Could you use git rebase --onto to rebase your modification to dev?

@ZwwWayne ZwwWayne added this to the 2.27.0 milestone Sep 17, 2022
act_cfg=act_cfg,
)

def forward(self, inputs):
Copy link
Contributor

Choose a reason for hiding this comment

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

feat_heigh, feat_height -> feat_high in yolox_asff_pafpn.py and yolox_pafpn.py

@@ -0,0 +1,4 @@
_base_ = './yolox_pai_s_8x8_300e_coco.py'

model = dict(bbox_head=dict(type='YOLOXTOODHead'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this config use neck=dict(type='YOLOXASFFPAFPN')?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a mistake. I fixed base config.

@okotaku okotaku requested review from shinya7y and removed request for hhaAndroid September 20, 2022 00:18
@shinya7y
Copy link
Contributor

It will be better not to remove request for Collaborator reviewers.

@okotaku
Copy link
Contributor Author

okotaku commented Sep 20, 2022

Sorry. When I pushed 'Re-request review', Collaborator reviewers were removed.

@shinya7y
Copy link
Contributor

Maybe we should wait for the announcement of MMYOLO or MMDet-YOLO before further discussion.
https://zhuanlan.zhihu.com/p/565106513
https://ultralytics.com/yolo-vision

@shinya7y
Copy link
Contributor

nn.SiLU vs. mmcv Swish

nn.silu is faster and use less GPU memory, but causes compatibility issues that restrict versions of PyTorch and MMCV.
A possible solution is the following three PRs:
(1) Support SiLU for PyTorch < 1.7 in MMCV, like MMYOLO https://github.com/open-mmlab/mmyolo/blob/84f115c4e57856ab63417fb9b781db88fe10ccf1/mmyolo/models/layers/yolo_bricks.py#L14-L27
(2) Use mmcv Swish in this PR, like other code in MMDetection v2
(3) Replace all mmcv Swish with nn.SiLU in MMDetection v3.0

@okotaku
Copy link
Contributor Author

okotaku commented Sep 22, 2022

1st option looks good. I created PR for mmcv.
open-mmlab/mmcv#2278

@shinya7y
Copy link
Contributor

Are there any plans or ideas to refactor yolox_asff_pafpn.py and support todo: handle len(self.in_channels) > 3?

@okotaku
Copy link
Contributor Author

okotaku commented Sep 26, 2022

Are there any plans or ideas to refactor yolox_asff_pafpn.py and support todo: handle len(self.in_channels) > 3?

Yes. I will implement it soon. Please wait for a few days.

@okotaku
Copy link
Contributor Author

okotaku commented Oct 3, 2022

@shinya7y I pushed refactored codes. Please review it.

mlvl_feats[i],
scale_factor=2**(i - self.level),
mode='nearest')
mlvl_wegiths_v.append(self.mlvl_weights[i](mlvl_feats[i]))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is easier to understand to use F.max_pool2d like:

mlvl_weights_v = []
for i, feat in enumerate(x):
    for _ in range(self.level - i - 1):
        feat = F.max_pool2d(feat, 3, stride=2, padding=1)
    feat = self.mlvl_convs[i](feat)
    if i > self.level:
        feat = F.interpolate(
            feat,
            scale_factor=2**(i - self.level),
            mode='nearest')
    mlvl_weights_v.append(self.mlvl_weights[i](feat))

@okotaku okotaku requested a review from shinya7y October 7, 2022 02:36
@@ -429,6 +430,52 @@ def test_yolox_pafpn():
assert outs[i].shape[2] == outs[i].shape[3] == s // (2**i)


def test_yolox_asff_pafpn():
s = 32
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment # test the case that length of in_channels is 3 before s = 32

@@ -184,6 +184,7 @@ Results and models are available in the [model zoo](docs/en/model_zoo.md).
<li><a href="configs/deformable_detr">Deformable DETR (ICLR'2021)</a></li>
<li><a href="configs/tood">TOOD (ICCV'2021)</a></li>
<li><a href="configs/ddod">DDOD (ACM MM'2021)</a></li>
<li><a href="configs/yoloxpai">YOLOX-PAI (ArXiv'2022)</a></li>
Copy link
Contributor

Choose a reason for hiding this comment

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

Update README_zh-CN.md

@okotaku okotaku requested a review from shinya7y October 10, 2022 02:47
@hhaAndroid
Copy link
Collaborator

hhaAndroid commented Oct 10, 2022

@okotaku Are you interested in adding related features to mmyolo? And if the algorithm is developed based on dev 3.x, it will be more efficient and simpler to implement.

@okotaku
Copy link
Contributor Author

okotaku commented Oct 11, 2022

@hhaAndroid I will try to develop based on dev-3.x. But there may not be time to contribute to mmyolo.

assert len(x) == len(self.in_channels)

mlvl_spatial_importance_map = []
mlvl_feats = []
Copy link
Contributor

Choose a reason for hiding this comment

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

The new variable names are good and discriminable, but could be shorter.

mlvl_feats = []
mlvl_importance = []  # spatial importance map

pip install mmcls>=0.24.0
```

## Usage
Copy link
Contributor

Choose a reason for hiding this comment

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

Either Usage or Note will be sufficient.

@okotaku okotaku requested a review from shinya7y October 12, 2022 03:31
@shinya7y
Copy link
Contributor

LGTM.
@hhaAndroid I would appreciate it if you could proceed with remaining tasks (additional review, discussion for 2.x vs. 3.x, retraining, uploading weights, and updating README.md).

@hhaAndroid
Copy link
Collaborator

OK

@hhaAndroid
Copy link
Collaborator

LGTM. @hhaAndroid I would appreciate it if you could proceed with remaining tasks (additional review, discussion for 2.x vs. 3.x, retraining, uploading weights, and updating README.md).

Ok. But we'd really like you to create PR directly to the dev-3.x branch

@okotaku
Copy link
Contributor Author

okotaku commented Nov 22, 2022

@hhaAndroid
I have already created PR for dev-3.x. Do you want to close this one?
#9255

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

Successfully merging this pull request may close these issues.

5 participants