Skip to content

Commit

Permalink
Support Poolformer (#137)
Browse files Browse the repository at this point in the history
* original implement

* poolformer_model

* Delete mmset and change docstring

* convert weights

* convert pytorch weights

* change .gitignore

* benchmark

* add document

* change docstring

* fix some spell errors

* fix spell error

* add_speed_test

* Update run_speed_test.sh

* add kargs
  • Loading branch information
thinksoso committed Feb 28, 2022
1 parent 3e4f9ad commit e9fcfac
Show file tree
Hide file tree
Showing 6 changed files with 549 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pip install flowvision==0.1.0
<li>Swin Transformer</li>
<li>CSwin Transformer</li>
<li>CrossFormer</li>
<li>PoolFormer</li>
<li>Mlp Mixer</li>
<li>ResMLP</li>
<li>gMLP</li>
Expand Down
11 changes: 11 additions & 0 deletions ci/check/run_speed_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/convnext.py convnext_tiny_224 16x3x224
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/mlp_mixer.py mlp_mixer_b16_224 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/cswin.py cswin_tiny_224 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/crossformer.py crossformer_tiny_patch4_group7_224 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s12 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s24 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s36 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_m36 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_m48 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/res_mlp.py resmlp_12_224 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_base 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_base_ls 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
python3 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_small 16x3x224x224 --no-show-memory --times $TIMES | check_relative_speed 1.01 | write_to_file_and_print
Expand Down Expand Up @@ -69,6 +75,11 @@ python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $M
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/mlp_mixer.py mlp_mixer_b16_224 16x3x224x224 --no-show-memory --times $TIMES --ddp --disable-backward | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/cswin.py cswin_tiny_224 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/crossformer.py crossformer_tiny_patch4_group7_224 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s12 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s24 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_s36 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_m36 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/poolformer.py poolformer_m48 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_base 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_base_ls 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
python3 -m oneflow.distributed.launch --nproc_per_node 2 $COMPARE_SCRIPT_PATH $MODELS_ROOT/uniformer.py uniformer_small 16x3x224x224 --no-show-memory --times $TIMES --ddp | check_relative_speed 0.99 | write_to_file_and_print
Expand Down
13 changes: 13 additions & 0 deletions docs/source/flowvision.models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ architectures for image classification:
- `Swin-Transformer`_
- `CSwin-Transformer`_
- `CrossFormer`_
- `PoolFormer`_
- `Mlp_Mixer`_
- `ResMLP`_
- `gMLP`_
Expand Down Expand Up @@ -65,6 +66,7 @@ architectures for image classification:
.. _Swin-Transformer: https://arxiv.org/abs/2103.14030
.. _CSwin-Transformer: https://arxiv.org/abs/2107.00652
.. _CrossFormer: https://arxiv.org/abs/2108.00154
.. _PoolFormer: https://arxiv.org/abs/2111.11418
.. _Mlp_Mixer: https://arxiv.org/abs/2105.01601
.. _ResMLP: https://arxiv.org/abs/2105.03404
.. _gMLP: https://arxiv.org/abs/2105.08050
Expand Down Expand Up @@ -342,6 +344,17 @@ CrossFormer
crossformer_large_patch4_group7_224,


PoolFormer
-----------
.. automodule:: flowvision.models
:members:
poolformer_s12,
poolformer_s24,
poolformer_s36,
poolformer_m36,
poolformer_m48,


UniFormer
-----------
.. automodule:: flowvision.models
Expand Down
1 change: 1 addition & 0 deletions flowvision/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .efficientnet import *
from .vision_transformer import *
from .convnext import *
from .poolformer import *
from .resnest import *
from .uniformer import *
from .senet import *
Expand Down

0 comments on commit e9fcfac

Please sign in to comment.