-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
add res2net backbone #2237
add res2net backbone #2237
Conversation
Hi @gasvn |
could you kindly provide coco-pretrained weights for these configs? Thanks |
Once the mmdetection team finish the benchmarking, they will release the pretrained models. |
Hi @gasvn
For other details, you may refer to this guide |
merge from mmdetection
Thanks, @xvjiarui I will follow your advice to integrate Res2Net into MMDetection v2.0 and reopen this pull request once I finish the code. |
@xvjiarui I have integrated Res2Net into the mmdetection v2. Please let me if there are any other requirements, thanks. |
@xvjiarui Currently, the ImageNet pretrained model of res2net for mmdetv2 is hosted on my personal OSS, which may not stable. |
I will upload it. Btw, the model is actually based on ResNetV1d, right? Since it uses |
Yes, it's based on the ResNetV1d, and we name it as Res2Net_v1b. |
mmdet/models/backbones/res2net.py
Outdated
def __init__(self, | ||
inplanes, | ||
planes, | ||
scale=4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to rename it to scales
or num_scales
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the term 'scale' to 'scales'.
mmdet/models/backbones/res2net.py
Outdated
if scale == 1: | ||
self.nums = 1 | ||
else: | ||
self.nums = scale - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name nums
is too ambiguous. Actually we can limit that scales > 1, otherwise it falls back to ResNet.
In this case we can just omit this variable and just use scales-1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nums are removed.
mmdet/models/backbones/res2net.py
Outdated
|
||
if self.scale != 1: | ||
if self.stage_type == 'normal' \ | ||
or self.conv2_stride == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid the backslash, we can write it as follows:
if (self.stage_type == 'normal' or self.conv2_stride == 1)
and let yapf to format it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done as suggested.
mmdet/models/backbones/res2net.py
Outdated
return out | ||
|
||
|
||
class ResLayer(nn.Sequential): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bottleneck is named Bottle2neck
. Maybe we can also name it Res2Layer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done as suggested.
@gasvn Thanks for your contribution to the community. |
@gasvn Hi, I've tried res2net with DCN. However, I found there may be some conflicts with the original code when testing. mmdetection/mmdet/models/backbones/res2net.py Line 100 in c298a0a
Since the author added this line explicitly, I wonder if I can simply remove this line. |
@zehuichen123 The m.conv2 is not used in bottle2neck, so I removed this attribute. I think it's ok to keep this attribute. But if you are going to count parameters, it's possible that the conv2 parts are also included. |
Hi @zehuichen123 |
Thanks for your reply. So If we remove mmdetection/mmdet/models/backbones/resnet.py Line 577 in c298a0a
or overwrite init_weights in res2net backbone.
|
This reverts commit 6730084.
* add res2net backbone * add readme for res2net * simplify res2net file * remove some init in bottle2neck * optimize forward code * change init * update results of res2net * update config and readme * add test and fix small issues
Hello, after my training, I also encountered this problem during the test. I annotated this item according to your method. It can be tested, but this also appears. Is the final result correct?
|
@sky-fly97 you must retrain the network if you comment out this line (delattr(self, 'conv2')), because you change the architecture of the network |
...The long time training is wasted... I‘m falling apart... |
@sky-fly97 you don't need to comment out delattr(self, 'conv2') if self.dcn is not None:
for m in self.modules():
if isinstance(m, Bottleneck) and hasattr(
m.conv2, 'conv_offset'):
constant_init(m.conv2.conv_offset, 0) in the resnet.py |
Thanks, I'll try it now! |
|
No description provided.