Skip to content

Commit 54a6cca

Browse files
authored
Merge pull request huggingface#668 from rwightman/more_attn
Add Gather-Excite, Global Context, BAT, Non-Local attn modules and refactored all attn modules and factory for improved consistency. EfficientNet / MobileNetV3 backbones able to use a wider variety of attention modules.
2 parents d7bab8a + 02320c3 commit 54a6cca

37 files changed

+1349
-736
lines changed

.github/workflows/tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ jobs:
3636
run: pip install --no-cache-dir torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }}
3737
- name: Install torch on ubuntu
3838
if: startsWith(matrix.os, 'ubuntu')
39-
run: pip install --no-cache-dir torch==${{ matrix.torch }}+cpu torchvision==${{ matrix.torchvision }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
39+
run: |
40+
pip install --no-cache-dir torch==${{ matrix.torch }}+cpu torchvision==${{ matrix.torchvision }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
41+
sudo apt update
42+
sudo apt install -y google-perftools
4043
- name: Install requirements
4144
run: |
4245
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
4346
pip install --no-cache-dir git+https://github.com/mapillary/inplace_abn.git@v1.0.12
4447
- name: Run tests
48+
env:
49+
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
4550
run: |
4651
pytest -vv --durations=0 ./tests

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,24 @@ Several (less common) features that I often utilize in my projects are included.
295295
* SplitBachNorm - allows splitting batch norm layers between clean and augmented (auxiliary batch norm) data
296296
* DropPath aka "Stochastic Depth" (https://arxiv.org/abs/1603.09382)
297297
* DropBlock (https://arxiv.org/abs/1810.12890)
298-
* Efficient Channel Attention - ECA (https://arxiv.org/abs/1910.03151)
299298
* Blur Pooling (https://arxiv.org/abs/1904.11486)
300299
* Space-to-Depth by [mrT23](https://github.com/mrT23/TResNet/blob/master/src/models/tresnet/layers/space_to_depth.py) (https://arxiv.org/abs/1801.04590) -- original paper?
301300
* Adaptive Gradient Clipping (https://arxiv.org/abs/2102.06171, https://github.com/deepmind/deepmind-research/tree/master/nfnets)
301+
* An extensive selection of channel and/or spatial attention modules:
302+
* Bottleneck Transformer - https://arxiv.org/abs/2101.11605
303+
* CBAM - https://arxiv.org/abs/1807.06521
304+
* Effective Squeeze-Excitation (ESE) - https://arxiv.org/abs/1911.06667
305+
* Efficient Channel Attention (ECA) - https://arxiv.org/abs/1910.03151
306+
* Gather-Excite (GE) - https://arxiv.org/abs/1810.12348
307+
* Global Context (GC) - https://arxiv.org/abs/1904.11492
308+
* Halo - https://arxiv.org/abs/2103.12731
309+
* Involution - https://arxiv.org/abs/2103.06255
310+
* Lambda Layer - https://arxiv.org/abs/2102.08602
311+
* Non-Local (NL) - https://arxiv.org/abs/1711.07971
312+
* Squeeze-and-Excitation (SE) - https://arxiv.org/abs/1709.01507
313+
* Selective Kernel (SK) - (https://arxiv.org/abs/1903.06586
314+
* Split (SPLAT) - https://arxiv.org/abs/2004.08955
315+
* Shifted Window (SWIN) - https://arxiv.org/abs/2103.14030
302316

303317
## Results
304318

tests/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
if 'GITHUB_ACTIONS' in os.environ: # and 'Linux' in platform.system():
2525
# GitHub Linux runner is slower and hits memory limits sooner than MacOS, exclude bigger models
2626
EXCLUDE_FILTERS = [
27-
'*efficientnet_l2*', '*resnext101_32x48d', '*in21k', '*152x4_bitm', '*101x3_bitm',
27+
'*efficientnet_l2*', '*resnext101_32x48d', '*in21k', '*152x4_bitm', '*101x3_bitm', '*50x3_bitm',
2828
'*nfnet_f3*', '*nfnet_f4*', '*nfnet_f5*', '*nfnet_f6*', '*nfnet_f7*',
2929
'*resnetrs350*', '*resnetrs420*']
3030
else:

timm/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from .inception_v3 import *
1818
from .inception_v4 import *
1919
from .levit import *
20-
#from .levit import *
2120
from .mlp_mixer import *
2221
from .mobilenetv3 import *
2322
from .nasnet import *

timm/models/byoanet.py

Lines changed: 91 additions & 283 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)