All Projects → moskomule → Senet.pytorch

moskomule / Senet.pytorch

Licence: mit
PyTorch implementation of SENet

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Senet.pytorch

CBAM-tensorflow-slim
CBAM implementation on TensorFlow Slim
Stars: ✭ 104 (-94.21%)
Mutual labels:  senet
Ensemble-of-Multi-Scale-CNN-for-Dermatoscopy-Classification
Fully supervised binary classification of skin lesions from dermatoscopic images using an ensemble of diverse CNN architectures (EfficientNet-B6, Inception-V3, SEResNeXt-101, SENet-154, DenseNet-169) with multi-scale input.
Stars: ✭ 25 (-98.61%)
Mutual labels:  senet
deep utils
An open-source toolkit which is full of handy functions, including the most used models and utilities for deep-learning practitioners!
Stars: ✭ 73 (-95.94%)
Mutual labels:  senet
Mxnet2Caffe-Tensor-RT-SEnet
Mxnet2Caffe_Tensor RT
Stars: ✭ 18 (-99%)
Mutual labels:  senet
Tensorrtx
Implementation of popular deep learning networks with TensorRT network definition API
Stars: ✭ 3,456 (+92.32%)
Mutual labels:  senet
Senet
Squeeze-and-Excitation Networks
Stars: ✭ 2,850 (+58.6%)
Mutual labels:  senet

SENet.pytorch

An implementation of SENet, proposed in Squeeze-and-Excitation Networks by Jie Hu, Li Shen and Gang Sun, who are the winners of ILSVRC 2017 classification competition.

Now SE-ResNet (18, 34, 50, 101, 152/20, 32) and SE-Inception-v3 are implemented.

  • python cifar.py runs SE-ResNet20 with Cifar10 dataset.

  • python imagenet.py and python -m torch.distributed.launch --nproc_per_node=${NUM_GPUS} imagenet.py run SE-ResNet50 with ImageNet(2012) dataset,

    • You need to prepare dataset by yourself in ~/.torch/data or set an enviroment variable IMAGENET_ROOT=${PATH_TO_YOUR_IMAGENET}
    • First download files and then follow the instruction.
    • The number of workers and some hyper parameters are fixed so check and change them if you need.
    • This script uses all GPUs available. To specify GPUs, use CUDA_VISIBLE_DEVICES variable. (e.g. CUDA_VISIBLE_DEVICES=1,2 to use GPU 1 and 2)

For SE-Inception-v3, the input size is required to be 299x299 as the original Inception.

Pre-requirements

The codebase is tested on the following setting.

  • Python>=3.8
  • PyTorch>=1.6.0
  • torchvision>=0.7

For training

To run cifar.py or imagenet.py, you need

hub

You can use some SE-ResNet (se_resnet{20, 56, 50, 101}) via torch.hub.

import torch.hub
hub_model = torch.hub.load(
    'moskomule/senet.pytorch',
    'se_resnet20',
    num_classes=10)

Also, a pretrained SE-ResNet50 model is available.

import torch.hub
hub_model = torch.hub.load(
    'moskomule/senet.pytorch',
    'se_resnet50',
    pretrained=True,)

Results

SE-ResNet20/Cifar10

python cifar.py [--baseline]

Note that the CIFAR-10 dataset expected to be under ~/.torch/data.

ResNet20 SE-ResNet20 (reduction 4 or 8)
max. test accuracy 92% 93%

SE-ResNet50/ImageNet

python [-m torch.distributed.launch --nproc_per_node=${NUM_GPUS}] imagenet.py

The option [-m ...] is for distributed training. Note that the Imagenet dataset is expected to be under ~/.torch/data or specified as IMAGENET_ROOT=${PATH_TO_IMAGENET}.

The initial learning rate and mini-batch size are different from the original version because of my computational resource .

ResNet SE-ResNet
max. test accuracy(top1) 76.15 %(*) 77.06% (**)
# !wget https://github.com/moskomule/senet.pytorch/releases/download/archive/seresnet50-60a8950a85b2b.pkl

senet = se_resnet50(num_classes=1000)
senet.load_state_dict(torch.load("seresnet50-60a8950a85b2b.pkl"))

Contribution

I cannot maintain this repository actively, but any contributions are welcome. Feel free to send PRs and issues.

References

paper

authors' Caffe implementation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].