Skip to content

Commit e18cd9a

Browse files
RangiLyuyumion
authored andcommitted
[Feature] Support ConvNeXt-V2 in projects (open-mmlab#9619)
1 parent a13cf6e commit e18cd9a

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

projects/ConvNeXt-V2/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ConvNeXt-V2
2+
3+
> [ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders](http://arxiv.org/abs/2301.00808)
4+
5+
## Abstract
6+
7+
Driven by improved architectures and better representation learning frameworks, the field of visual recognition has enjoyed rapid modernization and performance boost in the early 2020s. For example, modern ConvNets, represented by ConvNeXt \[52\], have demonstrated strong performance in various scenarios. While these models were originally designed for supervised learning with ImageNet labels, they can also potentially benefit from self-supervised learning techniques such as masked autoencoders (MAE) . However, we found that simply combining these two approaches leads to subpar performance. In this paper, we propose a fully convolutional masked autoencoder framework and a new Global Response Normalization (GRN) layer that can be added to the ConvNeXt architecture to enhance inter-channel feature competition. This co-design of self-supervised learning techniques and architectural improvement results in a new model family called ConvNeXt V2, which significantly improves the performance of pure ConvNets on various recognition benchmarks, including ImageNet classification, COCO detection, and ADE20K segmentation. We also provide pre-trained ConvNeXt V2 models of various sizes, ranging from an efficient 3.7Mparameter Atto model with 76.7% top-1 accuracy on Im-ageNet, to a 650M Huge model that achieves a state-of-theart 88.9% accuracy using only public training data.
8+
9+
<div align=center>
10+
<img src="https://user-images.githubusercontent.com/12907710/212588579-02d621d8-5796-4f0d-b4d2-758fe9c2f395.png" width="50%"/>
11+
</div>
12+
13+
## Results and models
14+
15+
| Method | Backbone | Pretrain | Lr schd | Augmentation | Mem (GB) | box AP | mask AP | Config | Download |
16+
| :--------: | :-----------: | :------: | :-----: | :----------: | :------: | :----: | :-----: | :----------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
17+
| Mask R-CNN | ConvNeXt-V2-B | FCMAE | 3x | LSJ | 22.5 | 52.9 | 46.4 | [config](./mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py) | [model](https://download.openmmlab.com/mmdetection/v3.0/convnextv2/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco_20230113_110947-757ee2dd.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/convnextv2/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco_20230113_110947.log.json) |
18+
19+
**Note**:
20+
21+
- This is a pre-release version of ConvNeXt-V2 object detection. The official finetuning setting of ConvNeXt-V2 has not been released yet.
22+
- ConvNeXt backbone needs to install [MMClassification dev-1.x branch](https://github.com/open-mmlab/mmclassification/tree/dev-1.x) first, which has abundant backbones for downstream tasks.
23+
24+
```shell
25+
git clone -b dev-1.x https://github.com/open-mmlab/mmclassification.git
26+
cd mmclassification
27+
pip install -U openmim && mim install -e .
28+
```
29+
30+
## Citation
31+
32+
```bibtex
33+
@article{Woo2023ConvNeXtV2,
34+
title={ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},
35+
author={Sanghyun Woo, Shoubhik Debnath, Ronghang Hu, Xinlei Chen, Zhuang Liu, In So Kweon and Saining Xie},
36+
year={2023},
37+
journal={arXiv preprint arXiv:2301.00808},
38+
}
39+
```
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
_base_ = [
2+
'mmdet::_base_/models/mask-rcnn_r50_fpn.py',
3+
'mmdet::_base_/datasets/coco_instance.py',
4+
'mmdet::_base_/schedules/schedule_1x.py',
5+
'mmdet::_base_/default_runtime.py'
6+
]
7+
8+
# please install the mmclassification dev-1.x branch
9+
# import mmcls.models to trigger register_module in mmcls
10+
custom_imports = dict(imports=['mmcls.models'], allow_failed_imports=False)
11+
checkpoint_file = 'https://download.openmmlab.com/mmclassification/v0/convnext-v2/convnext-v2-base_3rdparty-fcmae_in1k_20230104-8a798eaf.pth' # noqa
12+
image_size = (1024, 1024)
13+
14+
model = dict(
15+
backbone=dict(
16+
_delete_=True,
17+
type='mmcls.ConvNeXt',
18+
arch='base',
19+
out_indices=[0, 1, 2, 3],
20+
# TODO: verify stochastic depth rate {0.1, 0.2, 0.3, 0.4}
21+
drop_path_rate=0.4,
22+
layer_scale_init_value=0., # disable layer scale when using GRN
23+
gap_before_final_norm=False,
24+
use_grn=True, # V2 uses GRN
25+
init_cfg=dict(
26+
type='Pretrained', checkpoint=checkpoint_file,
27+
prefix='backbone.')),
28+
neck=dict(in_channels=[128, 256, 512, 1024]),
29+
test_cfg=dict(
30+
rpn=dict(nms=dict(type='nms')), # TODO: does RPN use soft_nms?
31+
rcnn=dict(nms=dict(type='soft_nms'))))
32+
33+
train_pipeline = [
34+
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
35+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
36+
dict(
37+
type='RandomResize',
38+
scale=image_size,
39+
ratio_range=(0.1, 2.0),
40+
keep_ratio=True),
41+
dict(
42+
type='RandomCrop',
43+
crop_type='absolute_range',
44+
crop_size=image_size,
45+
recompute_bbox=True,
46+
allow_negative_crop=True),
47+
dict(type='FilterAnnotations', min_gt_bbox_wh=(1e-2, 1e-2)),
48+
dict(type='RandomFlip', prob=0.5),
49+
dict(type='PackDetInputs')
50+
]
51+
52+
train_dataloader = dict(
53+
batch_size=4, # total_batch_size 32 = 8 GPUS x 4 images
54+
num_workers=8,
55+
dataset=dict(pipeline=train_pipeline))
56+
57+
max_epochs = 36
58+
train_cfg = dict(max_epochs=max_epochs)
59+
60+
# learning rate
61+
param_scheduler = [
62+
dict(
63+
type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,
64+
end=1000),
65+
dict(
66+
type='MultiStepLR',
67+
begin=0,
68+
end=max_epochs,
69+
by_epoch=True,
70+
milestones=[27, 33],
71+
gamma=0.1)
72+
]
73+
74+
# Enable automatic-mixed-precision training with AmpOptimWrapper.
75+
optim_wrapper = dict(
76+
type='AmpOptimWrapper',
77+
constructor='LearningRateDecayOptimizerConstructor',
78+
paramwise_cfg={
79+
'decay_rate': 0.95,
80+
'decay_type': 'layer_wise', # TODO: sweep layer-wise lr decay?
81+
'num_layers': 12
82+
},
83+
optimizer=dict(
84+
_delete_=True,
85+
type='AdamW',
86+
lr=0.0001,
87+
betas=(0.9, 0.999),
88+
weight_decay=0.05,
89+
))
90+
91+
default_hooks = dict(checkpoint=dict(max_keep_ckpts=1))

0 commit comments

Comments
 (0)