by BangguWu

BangguWu / ECANet

Code for ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks

406 Stars 80 Forks Last release: Not found MIT License 24 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

ECA-Net: Efficient Channel Attention

ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks

This is an implementation of ECA-Net(CVPR2020,paper), created by Banggu Wu.



Recently, channel attention mechanism has demonstrated to offer great potential in improving the performance of deep convolutional neuralnetworks (CNNs). However, most existing methods dedicate to developing more sophisticated attention modules for achieving better performance,which inevitably increase model complexity. To overcome the paradox of performance and complexity trade-off, this paper proposes an EfficientChannel Attention (ECA) module, which only involves a handful of parameters while bringing clear performance gain. By dissecting the channelattention module in SENet, we empirically show avoiding dimensionality reduction is important for learning channel attention, and appropriatecross-channel interaction can preserve performance while significantly decreasing model complexity. Therefore, we propose a localcross-channel interaction strategy without dimensionality reduction, which can be efficiently implemented via

convolution. Furthermore,we develop a method to adaptively select kernel size of
convolution, determining coverage of local cross-channel interaction. Theproposed ECA module is efficient yet effective, e.g., the parameters and computations of our modules against backbone of ResNet50 are 80 vs.24.37M and 4.7e-4 GFLOPs vs. 3.86 GFLOPs, respectively, and the performance boost is more than 2\% in terms of Top-1 accuracy. We extensivelyevaluate our ECA module on image classification, object detection and instance segmentation with backbones of ResNets and MobileNetV2. Theexperimental results show our module is more efficient while performing favorably against its counterparts.


   title={ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks},
   author={Qilong Wang, Banggu Wu, Pengfei Zhu, Peihua Li, Wangmeng Zuo and Qinghua Hu},
   booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},


2020/02/26 Upload ECA-Resnet34 model.

2020/03/05 Upload RetinaNet-ecanet50 and RetinaNet-ecanet101 model.

2020/03/24 Update the Introduction and Citation.

2020/03/30 Upload ECA-Resnet18 model.

2020/05/06 Update the poster.

ECA module


Comparison of (a) SE block and (b) our efficient channel attention (ECA) module. Given the aggregated feature using global average pooling (GAP), SE block computes weights using two FC layers. Differently, ECA generates channel weights by performing a fast 1D convolution of size k, where k is adaptively determined via a function of channel dimension C.



  • Python 3.5+
  • PyTorch 1.0+
  • thop

Our environments

  • OS: Ubuntu 16.04
  • CUDA: 9.0/10.0
  • Toolkit: PyTorch 1.0/1.1
  • GPU: GTX 2080Ti/TiTan XP

Start Up

Train with ResNet

You can run the
to train or evaluate as follow:
CUDA_VISIBLE_DEVICES={device_ids} python main -a {model_name} --ksize {eca_kernel_size} {the path of you datasets}

For example:

CUDA_VISIBLE_DEVICES=0,1,2,3 python main -a eca_resnet50 --ksize 3557 ./datasets/ILSVRC2012/images

Train with MobileNet_v2

It is same with above ResNet replace

Compute the parameters and FLOPs

If you have install thop, you can
to compute the parameters and FLOPs of our models. The usage is below:
python -a {model_name}



|Model|Param.|FLOPs|Top-1(%)|Top-5(%)|BaiduDrive(models)|Extract code|GoogleDrive| |:---:|:----:|:---:|:------:|:------:|:----------------:|:----------:|:---------:| |ECA-Net18|11.15M|1.70G|70.92|89.93|ecaresnet18k3577|utsy|ecaresnet18k3577| |ECA-Net34|20.79M|3.43G|74.21|91.83|ecaresnet34k3357|o4dh|ecaresnet34k3357| |ECA-Net50|24.37M|3.86G|77.42|93.62|ecaresnet50k3557|no6u|ecaresnet50k3557| |ECA-Net101|42.49M|7.35G|78.65|94.34|ecaresnet101k3357|iov1|ecaresnet101k3357| |ECA-Net152|57.41M|10.83G|78.92|94.55|ecaresnet152k3357|xaft|ecaresnet152k3357| |ECA-MobileNet_v2|3.34M|319.9M|72.56|90.81|ecamobilenetv2k13|atpt|ecamobilenetv2k13|

COCO 2017

Detection with Faster R-CNN and Mask R-CNN

|Model|Param.|FLOPs|AP|AP50|AP75|Pre trained models|Extract code|GoogleDrive| |:----|:----:|:---:|:--:|:-------:|:-------:|:----------------:|:----------:|:---------:| |FastR-CNNecanet50|41.53M|207.18G|38.0|60.6|40.9|fasterrcnnecanet50k5bs8_lr0.01|divf|fasterrcnnecanet50k5bs8_lr0.01| |FastR-CNNecanet101|60.52M|283.32G|40.3|62.9|44.0|fasterrcnnecanet1013357bs8_lr0.01|d3kd|fasterrcnnecanet1013357bs8_lr0.01| |MaskR-CNNecanet50|44.18M|275.69G|39.0|61.3|42.1|maskrcnnecanet50k3377bs8_lr0.01|xe19|maskrcnnecanet50k3377bs8_lr0.01| |MaskR-CNNecanet101|63.17M|351.83G|41.3|63.1|44.8|maskrcnnecanet101k3357bs8_lr0.01|y5e9|maskrcnnecanet101k3357bs8_lr0.01| |RetinaNetecanet50|37.74M|239.43G|37.3|57.7|39.6|RetinaNetecanet50k3377bs8lr0.01|my44|RetinaNetecanet50k3377bs8lr0.01| |RetinaNetecanet101|56.74M|315.57G|39.1|59.9|41.8|RetinaNetecanet101k3357bs8lr0.01|2eu5|RetinaNetecanet101k3357bs8lr0.01|

Instance segmentation with Mask R-CNN

|Model|Param.|FLOPs|AP|AP50|AP75|Pre trained models|Extract code|GoogleDrive| |:----|:----:|:---:|:--:|:-------:|:-------:|:----------------:|:----------:|:---------:| |MaskR-CNNecanet50|44.18M|275.69G|35.6|58.1|37.7|maskrcnnecanet50k3377bs8_lr0.01|xe19|maskrcnnecanet50k3377bs8_lr0.01| |MaskR-CNNecanet101|63.17M|351.83G|37.4|59.9|39.8|maskrcnnecanet101k3357bs8_lr0.01|y5e9|maskrcnnecanet101k3357bs8_lr0.01| |RetinaNetecanet50|37.74M|239.43G|35.6|58.1|37.7|RetinaNetecanet50k3377bs8lr0.01|my44|RetinaNetecanet50k3377bs8lr0.01| |RetinaNetecanet101|56.74M|315.57G|37.4|59.9|39.8|RetinaNetecanet101k3357bs8lr0.01|2eu5|RetinaNetecanet101k3357bs8lr0.01|

Contact Information

If you have any suggestion or question, you can leave a message here or contact us directly: [email protected] . Thanks for your attention!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.