Skip to content

Commit

Permalink
pre-release models and logs for det and seg
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupin1998 committed Feb 9, 2023
1 parent cb7ae13 commit 23d17b6
Show file tree
Hide file tree
Showing 28 changed files with 285 additions and 76 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ This project is released under the [Apache 2.0 license](LICENSE).

Our implementation is mainly based on the following codebases. We gratefully thank the authors for their wonderful works.

- [pytorch-image-models](https://github.com/rwightman/pytorch-image-models)
- [PoolFormer](https://github.com/sail-sg/poolformer)
- [MMDetection](https://github.com/open-mmlab/mmdetection)
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation)
- [pytorch-image-models](https://github.com/rwightman/pytorch-image-models).
- [PoolFormer](https://github.com/sail-sg/poolformer): Official PyTorch implementation of MetaFormer.
- [ConvNeXt](https://github.com/facebookresearch/ConvNeXt): Official PyTorch implementation of ConvNeXt.
- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab Detection Toolbox and Benchmark.
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation): OpenMMLab Semantic Segmentation Toolbox and Benchmark.
- [MMPose](https://github.com/open-mmlab/mmpose): OpenMMLab Pose Estimation Toolbox and Benchmark.

## Citation

Expand Down
23 changes: 12 additions & 11 deletions detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ For more details, see [Efficient Multi-order Gated Aggregation Network](https://

## Note

Please note that we just simply follow the hyper-parameters of [PVT](https://github.com/whai362/PVT/tree/v2/detection) which may not be the optimal ones for MogaNet. Feel free to tune the hyper-parameters to get better performance.
Please note that we simply follow the hyper-parameters of [PVT](https://github.com/whai362/PVT/tree/v2/detection) and [ConvNeXt](https://github.com/facebookresearch/ConvNeXt), which may not be the optimal ones for MogaNet. Feel free to tune the hyper-parameters to get better performance.

## Environement Setup

Expand Down Expand Up @@ -47,19 +47,19 @@ Prepare COCO according to the guidelines in [MMDetection](https://github.com/ope
## Results and models on COCO

| Method | Backbone | Pretrain | Params | FLOPs | Lr schd | Aug | box mAP | mask mAP | Config | Download |
|:---:|:---:|:---:|---|---|:---:|:---:|:---:|:---:|:---:|:---:|
| RetinaNet | MogaNet-XT | ImageNet-1K | 12.1M | 167.2G | 1x | No | 38.9 | - | [config](configs/mask_rcnn_moganet_xtiny_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-T | ImageNet-1K | 14.4M | 173.4G | 1x | No | 40.9 | - | [config](configs/mask_rcnn_moganet_tiny_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-S | ImageNet-1K | 35.1M | 253.0G | 1x | No | 45.4 | - | [config](configs/mask_rcnn_moganet_small_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-B | ImageNet-1K | 53.5M | 354.5G | 1x | No | | - | [config](configs/mask_rcnn_moganet_base_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-L | ImageNet-1K | 92.4M | 476.8G | 1x | No | | - | [config](configs/mask_rcnn_moganet_large_fpn_1x_coco.py) | log / model |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| RetinaNet | MogaNet-XT | ImageNet-1K | 12.1M | 167.2G | 1x | No | 39.7 | - | [config](configs/mask_rcnn_moganet_xtiny_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-T | ImageNet-1K | 14.4M | 173.4G | 1x | No | 41.4 | - | [config](configs/mask_rcnn_moganet_tiny_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-S | ImageNet-1K | 35.1M | 253.0G | 1x | No | 45.8 | - | [config](configs/mask_rcnn_moganet_small_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-B | ImageNet-1K | 53.5M | 354.5G | 1x | No | 47.7 | - | [config](configs/mask_rcnn_moganet_base_fpn_1x_coco.py) | log / model |
| RetinaNet | MogaNet-L | ImageNet-1K | 92.4M | 476.8G | 1x | No | 48.7 | - | [config](configs/mask_rcnn_moganet_large_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-XT | ImageNet-1K | 22.8M | 185.4G | 1x | No | 40.7 | 37.6 | [config](configs/retinanet_moganet_xtiny_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-T | ImageNet-1K | 25.0M | 191.7G | 1x | No | 42.6 | 39.1 | [config](configs/retinanet_moganet_tiny_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-S | ImageNet-1K | 45.0M | 271.6G | 1x | No | 46.1 | 41.8 | [config](configs/retinanet_moganet_small_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-B | ImageNet-1K | 63.4M | 373.1G | 1x | No | 48.2 | 43.4 | [config](configs/retinanet_moganet_base_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-L | ImageNet-1K | 102.1M | 495.3G | 1x | No | | | [config](configs/retinanet_moganet_large_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-S | ImageNet-1K | 45.0M | 271.6G | 1x | No | 46.6 | 42.2 | [config](configs/retinanet_moganet_small_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-B | ImageNet-1K | 63.4M | 373.1G | 1x | No | 49.0 | 43.8 | [config](configs/retinanet_moganet_base_fpn_1x_coco.py) | log / model |
| Mask R-CNN | MogaNet-L | ImageNet-1K | 102.1M | 495.3G | 1x | No | 49.4 | 44.2 | [config](configs/retinanet_moganet_large_fpn_1x_coco.py) | log / model |

**Notes**: All the models can also be downloaded by [**Baidu Cloud**](https://pan.baidu.com/s/1d5MTTC66gegehmfZvCQRUA?pwd=z8mf) (z8mf). The params (M) and FLOPs (G) are measured by [get_flops](get_flops.sh) with 1280 $\times$ 800 resolutions.
**Notes**: All the models can also be downloaded by [**Baidu Cloud**](https://pan.baidu.com/s/1d5MTTC66gegehmfZvCQRUA?pwd=z8mf) (z8mf) at `MogaNet/COCO_Detection`. The params (M) and FLOPs (G) are measured by [get_flops](get_flops.sh) with 1280 $\times$ 800 resolutions.
```bash
bash get_flops.sh /path/to/config --shape 1280 800
```
Expand Down Expand Up @@ -97,6 +97,7 @@ Our implementation is mainly based on the following codebases. We gratefully tha

- [MMDetection](https://github.com/open-mmlab/mmdetection)
- [PVT detection](https://github.com/whai362/PVT/tree/v2/detection)
- [ConvNeXt](https://github.com/facebookresearch/ConvNeXt)
- [PoolFormer](https://github.com/sail-sg/poolformer)

<p align="right">(<a href="#top">back to top</a>)</p>
10 changes: 8 additions & 2 deletions detection/configs/moganet/mask_rcnn_moganet_base_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -23,5 +23,11 @@
out_channels=256,
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/mask_rcnn_moganet_large_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_large_sz224_8xbs64_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_large_sz224_8xbs64_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -23,5 +23,11 @@
out_channels=256,
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/mask_rcnn_moganet_small_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_small_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_small_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -23,5 +23,11 @@
out_channels=256,
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/mask_rcnn_moganet_tiny_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_tiny_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_tiny_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -23,5 +23,11 @@
out_channels=256,
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/mask_rcnn_moganet_xtiny_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_xtiny_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_xtiny_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -23,5 +23,11 @@
out_channels=256,
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0002, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/retinanet_moganet_base_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_base_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -25,5 +25,11 @@
add_extra_convs='on_input',
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/retinanet_moganet_large_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_large_sz224_8xbs64_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_large_sz224_8xbs64_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -25,5 +25,11 @@
add_extra_convs='on_input',
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/retinanet_moganet_small_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_small_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_small_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -25,5 +25,11 @@
add_extra_convs='on_input',
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/retinanet_moganet_tiny_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_tiny_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_tiny_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -25,5 +25,11 @@
add_extra_convs='on_input',
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
10 changes: 8 additions & 2 deletions detection/configs/moganet/retinanet_moganet_xtiny_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init_cfg=dict(
type='Pretrained',
checkpoint=\
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_xtiny_sz224_8xbs128_ep300.pth.tar',
'https://github.com/Westlake-AI/MogaNet/releases/download/moganet-in1k-weights/moganet_xtiny_sz224_8xbs128_ep300.pth.tar',
),
),
neck=dict(
Expand All @@ -25,5 +25,11 @@
add_extra_convs='on_input',
num_outs=5))
# optimizer
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.0001)
optimizer = dict(_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'layer_scale': dict(decay_mult=0.),
'scale': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)}))
optimizer_config = dict(grad_clip=None)

checkpoint_config = dict(interval=1, max_keep_ckpts=1)
evaluation = dict(save_best='auto')
9 changes: 6 additions & 3 deletions models/moganet.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ def freeze_patch_emb(self):
def no_weight_decay(self):
return dict()

@torch.jit.ignore
def get_classifier(self):
return self.head

Expand Down Expand Up @@ -750,7 +751,10 @@ def forward_features(self, x):
return outs
else:
# output only the last layer for image classification
return x.mean(dim=[2, 3])
return x

def forward_head(self, x):
return self.head(x.mean(dim=[2, 3]))

def forward(self, x):
x = self.forward_features(x)
Expand All @@ -759,8 +763,7 @@ def forward(self, x):
return x
else:
# for image classification
x = self.head(x)
return x
return self.forward_head(x)


def _cfg(url='', **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions pose_estimation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ For more details, see [Efficient Multi-order Gated Aggregation Network](https://

## Note

Please note that we just simply follow the hyper-parameters of [PVT](https://github.com/whai362/PVT/tree/v2/detection) and [Swin](https://github.com/microsoft/Swin-Transformer) which may not be the optimal ones for MogaNet. Feel free to tune the hyper-parameters to get better performance.
Please note that we simply follow the hyper-parameters of [PVT](https://github.com/whai362/PVT/tree/v2/detection) and [Swin](https://github.com/microsoft/Swin-Transformer) which may not be the optimal ones for MogaNet. Feel free to tune the hyper-parameters to get better performance.

## Environement Setup

Expand All @@ -26,7 +26,7 @@ Prepare COCO according to the guidelines in [MMPose](https://github.com/open-mml

## Results and models on COCO

**Notes**: All the models can also be downloaded by [**Baidu Cloud**](https://pan.baidu.com/s/1d5MTTC66gegehmfZvCQRUA?pwd=z8mf) (z8mf). The params (M) and FLOPs (G) are measured by [get_flops](get_flops.sh) with 256 $\times$ 192 or 384 $\times$ 288 resolutions.
**Notes**: All the models can also be downloaded by [**Baidu Cloud**](https://pan.baidu.com/s/1d5MTTC66gegehmfZvCQRUA?pwd=z8mf) (z8mf) at `MogaNet/COCO_Pose`. The params (M) and FLOPs (G) are measured by [get_flops](get_flops.sh) with 256 $\times$ 192 or 384 $\times$ 288 resolutions.
```bash
bash get_flops.sh /path/to/config --shape 256 192
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
arch="small", # modify 'arch' for various architectures
init_value=1e-5,
frozen_stages=1,
drop_path_rate=0.1,
drop_path_rate=0.2,
stem_norm_cfg=norm_cfg,
conv_norm_cfg=norm_cfg,
out_indices=(0, 1, 2, 3),
Expand Down
Loading

0 comments on commit 23d17b6

Please sign in to comment.