Skip to content

PyTorch Code for BAM: Botteneck Attention Module and CBAM: Convolutional Block Attention Module

License

Notifications You must be signed in to change notification settings

haruishi43/bam-cbam

Repository files navigation

BAM and CBAM

A fork of BAM and CBAM.

  • update for newer version of PyTorch
  • cleaned up code, organized directory
  • debugged and updated training script
  • Added training for other tasks
  • development (black, pytest, etc)

Prerequisites

  • Python >= 3.6
  • PyTorch >= 1.5
  • Detectron2 >= 0.21
  • fvcore (comes with Detectron2)

If you don't have detectron2, you can either install it yourself, or use:

git clone --recursive git@github.com:haruishi43/bam-cbam.git
cd third/detectron2
pip install .

Classification

CIFAR10 and CIFAR100

python classification/train_cifar.py --data <path/to/dataset/root> --prefix cifar_run_1
  • Train CIFAR100 using --cifar100.
  • See other arguments inside the parse_args() function @ train_cifar.py.

ImageNet

python classification/train_imagenet.py --data <path/to/dataset/root> --prefix imagenet_run_1

Detection

COCO

Orgaize COCO dataset (see detectron2's guide for more information).

export DETECTRON2_DATASETS=/path/to/datasets  # else detectron2 will use ./datasets
python detection/train_coco.py --num-gpus 8 \
  --config-file detection/configs/COCO-Detection/faster_rcnn_R_50_CBAM_1x.yaml

The original configuration are for using 8 gpus, you might need to change parameters for single gpu:

CUDA_VISIBLE_DEVICES=0, python detection/train_coco.py --ngpu 1 \
  --config-file detection/configs/COCO-Detection/faster_rcnn_R_50_CBAM_1x.yaml \
  SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025

Pascal VOC

About

PyTorch Code for BAM: Botteneck Attention Module and CBAM: Convolutional Block Attention Module

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages