Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaoyuHKU committed Mar 29, 2022
1 parent e7e9d8b commit 5ac4525
Showing 1 changed file with 5 additions and 100 deletions.
105 changes: 5 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
# BOAT: Bilateral Local Attention Vision Transformer


This is an unofficial implementation of the paper
We only change ./model/swin_transformer.py to ./model/boat_swin_transformer.py and keep other codes unchanged.


# Start

Please refer to [Start for Swin](https://github.com/microsoft/Swin-Transformer/blob/main/get_started.md) for installing the prerequisite.

# Training

`BOAT-Swin-T`:

```bash
python -m torch.distributed.launch --nproc_per_node 4 --master_port 12345 main.py \
--cfg configs/swin_tiny_patch4_window7_224.yaml --data-path <imagenet-path> --batch-size 256
```

`BOAT-Swin-S`:

```bash
python -m torch.distributed.launch --nproc_per_node 8 --master_port 12345 main.py \
--cfg configs/swin_small_patch4_window7_224.yaml --data-path <imagenet-path> --batch-size 128
```

`BOAT-Swin-B`:

```bash
python -m torch.distributed.launch --nproc_per_node 8 --master_port 12345 main.py \
--cfg configs/swin_base_patch4_window7_224.yaml --data-path <imagenet-path> --batch-size 128 \
```

# Evaluation

To evaluate a pre-trained `BOAT-Swin Transformer` on ImageNet val, run:

```bash
python -m torch.distributed.launch --nproc_per_node <num-of-gpus-to-use> --master_port 12345 main.py --eval \
--cfg <config-file> --resume <checkpoint> --data-path <imagenet-path>
```
This is an unofficial implementation of the paper BOAT: Bilateral Local Attention Vision Transformer.
The [Swin variant](https://github.com/mahaoyuHKU/pytorch-boat/tree/main/Swin) is based on [Swin Transformer](https://github.com/microsoft/Swin-Transformer)
The [CSwin variant](https://github.com/mahaoyuHKU/pytorch-boat/tree/main/CSwin) is based on [CSwin Tranformer](https://github.com/microsoft/CSWin-Transformer)
Please check corresponding folders for more installation instructions.

# Pre-trained models

Expand All @@ -54,69 +19,9 @@ python -m torch.distributed.launch --nproc_per_node <num-of-gpus-to-use> --maste
[BOAT-CSwin-Small](https://www.dropbox.com/s/cnl00d1faxxoi19/cswin_small.pth.tar?dl=0)

[BOAT-CSwin-Base](https://www.dropbox.com/s/92sr8r8zhng1mqg/cswin_base.pth.tar?dl=0)
# CSWin-Transformer

[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/cswin-transformer-a-general-vision/semantic-segmentation-on-ade20k)](https://paperswithcode.com/sota/semantic-segmentation-on-ade20k?p=cswin-transformer-a-general-vision)
[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/cswin-transformer-a-general-vision/semantic-segmentation-on-ade20k-val)](https://paperswithcode.com/sota/semantic-segmentation-on-ade20k-val?p=cswin-transformer-a-general-vision)

This repo is the official implementation of ["CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows"](https://arxiv.org/pdf/2107.00652.pdf).

## Introduction


## Requirements

timm==0.3.4, pytorch>=1.4, opencv, ... , run:

```
bash install_req.sh
```

Apex for mixed precision training is used for finetuning. To install apex, run:

```
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
```

Data prepare: ImageNet with the following folder structure, you can extract imagenet by this [script](https://gist.github.com/BIGBALLON/8a71d225eff18d88e469e6ea9b39cef4).

```
│imagenet/
├──train/
│ ├── n01440764
│ │ ├── n01440764_10026.JPEG
│ │ ├── n01440764_10027.JPEG
│ │ ├── ......
│ ├── ......
├──val/
│ ├── n01440764
│ │ ├── ILSVRC2012_val_00000293.JPEG
│ │ ├── ILSVRC2012_val_00002138.JPEG
│ │ ├── ......
│ ├── ......
```

## Train

Train the three lite variants: CSWin-Tiny, CSWin-Small and CSWin-Base:
```
bash train.sh 8 --data <data path> --model CSWin_64_12211_tiny_224 -b 256 --lr 2e-3 --weight-decay .05 --amp --img-size 224 --warmup-epochs 20 --model-ema-decay 0.99984 --drop-path 0.2
```
```
bash train.sh 8 --data <data path> --model CSWin_64_24322_small_224 -b 256 --lr 2e-3 --weight-decay .05 --amp --img-size 224 --warmup-epochs 20 --model-ema-decay 0.99984 --drop-path 0.4
```
```
bash train.sh 8 --data <data path> --model CSWin_96_24322_base_224 -b 128 --lr 1e-3 --weight-decay .1 --amp --img-size 224 --warmup-epochs 20 --model-ema-decay 0.99992 --drop-path 0.5
```





## Acknowledgement
This is developped based on CSWin Transformer
This is developped based on CSWin Transformer and Swin-transformer


# If you use this code for your research, please consider citing:
Expand Down

0 comments on commit 5ac4525

Please sign in to comment.