Home

Awesome

ZoomNeXt: A Unified Collaborative Pyramid Network for Camouflaged Object Detection (TPAMI 2024)

<div align="center"> <img src="https://github.com/lartpang/ZoomNeXt/assets/26847524/f43f773b-a81f-4c64-a809-9764b53dd52c" alt="Logo"> </div>

PWC PWC PWC PWC PWC PWC

@ARTICLE {ZoomNeXt,
    title   = {ZoomNeXt: A Unified Collaborative Pyramid Network for Camouflaged Object Detection},
    author  ={Youwei Pang and Xiaoqi Zhao and Tian-Zhu Xiang and Lihe Zhang and Huchuan Lu},
    journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
    year    = {2024},
    doi     = {10.1109/TPAMI.2024.3417329},
}

Weights and Results

Results

DatasetsLinks
CAMO-TE, CHAMELEON, COD10K-TE, NC4KResNet-50, EfficientNet-B4, PVTv2-B2, PVTv2-B3, PVTv2-B4, PVTv2-B5
CAD, MoCA-Mask-TEPVTv2-B5

Weights

BackboneCAMO-TECHAMELEONCOD10K-TENC4KLinks
$S_m$$F^{\omega}_{\beta}$MAE$S_m$$F^{\omega}_{\beta}$MAE$S_m$$F^{\omega}_{\beta}$MAE$S_m$$F^{\omega}_{\beta}$MAE
ResNet-500.8330.7740.0650.9080.8580.0210.8610.7680.0260.8740.8160.037Weight
EfficientNet-B10.8480.8030.0560.9160.8700.0200.8630.7730.0240.8760.8230.036Weight
EfficientNet-B40.8670.8240.0460.9110.8650.0200.8750.7970.0210.8840.8370.032Weight
PVTv2-B20.8740.8390.0470.9220.8840.0170.8870.8180.0190.8920.8520.030Weight
PVTv2-B30.8850.8540.0420.9270.8980.0170.8950.8290.0180.9000.8610.028Weight
PVTv2-B40.8880.8590.0400.9250.8970.0160.8980.8380.0170.9000.8650.028Weight
PVTv2-B50.8890.8570.0410.9240.8850.0180.8980.8270.0180.9030.8630.028Weight
BackboneCADMoCA-Mask-TELinks
$S_m$$F^{\omega}_{\beta}$MAEmDicemIoU$S_m$$F^{\omega}_{\beta}$MAEmDicemIoU
PVTv2-B5 (T=5)0.7570.5930.0200.5990.5100.7340.4760.0100.4970.422Weight

Prepare Data

Set all dataset information to the dataset.yaml as follows.

<details> <summary> Example of the config file (dataset.yaml): </summary>
# VCOD Datasets
moca_mask_tr:
  {
    root: "YOUR-VCOD-DATASETS-ROOT/MoCA-Mask/MoCA_Video/TrainDataset_per_sq",
    image: { path: "*/Imgs", suffix: ".jpg" },
    mask: { path: "*/GT", suffix: ".png" },
  }
moca_mask_te:
  {
    root: "YOUR-VCOD-DATASETS-ROOT/MoCA-Mask/MoCA_Video/TestDataset_per_sq",
    image: { path: "*/Imgs", suffix: ".jpg" },
    mask: { path: "*/GT", suffix: ".png" },
  }
cad:
  {
    root: "YOUR-VCOD-DATASETS-ROOT/CamouflagedAnimalDataset",
    image: { path: "original_data/*/frames", suffix: ".png" },
    mask: { path: "converted_mask/*/groundtruth", suffix: ".png" },
  }

# ICOD Datasets
cod10k_tr:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Train/COD10K-TR",
    image: { path: "Image", suffix: ".jpg" },
    mask: { path: "Mask", suffix: ".png" },
  }
camo_tr:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Train/CAMO-TR",
    image: { path: "Image", suffix: ".jpg" },
    mask: { path: "Mask", suffix: ".png" },
  }
cod10k_te:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Test/COD10K-TE",
    image: { path: "Image", suffix: ".jpg" },
    mask: { path: "Mask", suffix: ".png" },
  }
camo_te:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Test/CAMO-TE",
    image: { path: "Image", suffix: ".jpg" },
    mask: { path: "Mask", suffix: ".png" },
  }
chameleon:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Test/CHAMELEON",
    image: { path: "Image", suffix: ".jpg" },
    mask: { path: "Mask", suffix: ".png" },
  }
nc4k:
  {
    root: "YOUR-ICOD-DATASETS-ROOT/Test/NC4K",
    image: { path: "Imgs", suffix: ".jpg" },
    mask: { path: "GT", suffix: ".png" },
  }
</details>

Install Requirements

Evaluation

# ICOD
python main_for_image.py --config configs/icod_train.py --model-name <MODEL_NAME> --evaluate --load-from <TRAINED_WEIGHT>
# VCOD
python main_for_video.py --config configs/vcod_finetune.py --model-name <MODEL_NAME> --evaluate --load-from <TRAINED_WEIGHT>

[!note]

Evaluating performance on the VCOD dataset directly using training scripts is not consistent with the paper. This is because the evaluation approach in the paper continues the strategy of previous work SLT-Net, which adjusts the range of valid frames in the sequence.

To get the results in our paper, you can use PySODEvalToolkit and use the similar command as:

python ./eval.py `
    --dataset-json vcod-datasets.json `
    --method-json vcod-methods.json `
    --include-datasets CAD `
    --include-methods videoPvtV2B5_ZoomNeXt `
    --data-type video `
    --valid-frame-start "0" `
    --valid-frame-end "0" `
    --metric-names "sm" "wfm" "mae" "fmeasure" "em" "dice" "iou"

python ./eval.py `
    --dataset-json vcod-datasets.json `
    --method-json vcod-methods.json `
    --include-datasets MOCA-MASK-TE `
    --include-methods videoPvtV2B5_ZoomNeXt `
    --data-type video `
    --valid-frame-start "0" `
    --valid-frame-end "-2" `
    --metric-names "sm" "wfm" "mae" "fmeasure" "em" "dice" "iou"

Training

Image Camouflaged Object Detection

python main_for_image.py --config configs/icod_train.py --pretrained --model-name EffB1_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name EffB4_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name PvtV2B2_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name PvtV2B3_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name PvtV2B4_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name PvtV2B5_ZoomNeXt
python main_for_image.py --config configs/icod_train.py --pretrained --model-name RN50_ZoomNeXt

Video Camouflaged Object Detection

  1. Pretrain on COD10K-TR: python main_for_image.py --config configs/icod_pretrain.py --info pretrain --model-name PvtV2B5_ZoomNeXt --pretrained
  2. Finetune on MoCA-Mask-TR: python main_for_video.py --config configs/vcod_finetune.py --info finetune --model-name videoPvtV2B5_ZoomNeXt --load-from <PRETAINED_WEIGHT>

[!note] If you meets the OOM problem, you can try to reduce the batch size or switch on the --use-checkpoint flag: python main_for_image.py/main_for_video.py <your config> --use-checkpoint