/EdgeNAT

code for EdgeNAT

Primary LanguagePythonApache License 2.0Apache-2.0

EdgeNAT: Transformer for Efficient Edge Detection

In this paper, we propose EdgeNAT, a one-stage Transformer-based edge detector that effectively extracts object boundaries and meaningful edges. Our model leverages image global contextual information and detailed local cues by exploiting the multi-scale structure of the backbone network. Here are the code for this paper.

Requirements

pip3 install -r requirements-base.txt  # Installs torch 
pip3 install -r requirements.txt # Installs NATTEN, MMCV, MMSEG, and others

Initial weights

You can download the initial weights from hear. The five .pth files of pre-training should be placed in the folder ./pretrained.

DiNAT-Mini

DiNAT-Tiny

DiNAT-Small

DiNAT-Base

DiNAT-Large

Training

Training on BSDS500:

./tools/dist_train.sh configs/bsds/edgenat_l_320x320_40k_bsds.py 1   # EdgeNAT-L
./tools/dist_train.sh configs/bsds/edgenat_s0_320x320_40k_bsds.py 1  # EdgeNAT-S0
./tools/dist_train.sh configs/bsds/edgenat_s1_320x320_40k_bsds.py 1  # EdgeNAT-S1
./tools/dist_train.sh configs/bsds/edgenat_s2_320x320_40k_bsds.py 1  # EdgeNAT-S2
./tools/dist_train.sh configs/bsds/edgenat_s3_320x320_40k_bsds.py 1  # EdgeNAT-S3

Training on BSDS-VOC (BSDS500 and PASCAL VOC Context):

Step 1: Training on PASCAL VOC Context

./tools/dist_train.sh configs/bsds/edgenat_l_320x320_40k_bsds_pascal.py 1   # EdgeNAT-L
./tools/dist_train.sh configs/bsds/edgenat_s0_320x320_40k_bsds_pascal.py 1  # EdgeNAT-S0
./tools/dist_train.sh configs/bsds/edgenat_s1_320x320_40k_bsds_pascal.py 1  # EdgeNAT-S1
./tools/dist_train.sh configs/bsds/edgenat_s2_320x320_40k_bsds_pascal.py 1  # EdgeNAT-S2
./tools/dist_train.sh configs/bsds/edgenat_s3_320x320_40k_bsds_pascal.py 1  # EdgeNAT-S3

Step 2: Training on BSDS500

./tools/dist_train.sh configs/bsds/edgenat_l_320x320_40k_bsds.py 1 --load-from ./work_dirs/edgenat_l_320x320_40k_bsds_pascal/iter_XX000.pth  # EdgeNAT-L

./tools/dist_train.sh configs/bsds/edgenat_s0_320x320_40k_bsds.py 1 --load-from ./work_dirs/edgenat_s0_320x320_40k_bsds_pascal/iter_XX000.pth # EdgeNAT-S0

./tools/dist_train.sh configs/bsds/edgenat_s1_320x320_40k_bsds.py 1 --load-from ./work_dirs/edgenat_s1_320x320_40k_bsds_pascal/iter_XX000.pth # EdgeNAT-S1

./tools/dist_train.sh configs/bsds/edgenat_s2_320x320_40k_bsds.py 1 --load-from ./work_dirs/edgenat_s2_320x320_40k_bsds_pascal/iter_XX000.pth # EdgeNAT-S2

./tools/dist_train.sh configs/bsds/edgenat_s3_320x320_40k_bsds.py 1 --load-from ./work_dirs/edgenat_s3_320x320_40k_bsds_pascal/iter_XX000.pth # EdgeNAT-S3

Evaluation

The code is evaluated on MATLAB R2018b.

BSDS500:

cd eval
(echo "data_dir = '../output/epoch-x-test'"; cat eval_bsds.m)|matlab -nodisplay -nodesktop -nosplash

NYUDv2:

cd eval
(echo "data_dir = '../output/epoch-x-test'"; cat eval_nyud.m)|matlab -nodisplay -nodesktop -nosplash