This repository contains the code for the paper "Out-of-the-box: Black-box Causal Attacks on Object Detectors" by Melane Navaratnarajah, David A. Kelly, and Hana Chockler. The code is organized into several scripts that allow you to run the attack generation and analysis for object detectors using the ReX framework.
- Clone the repository
- Install the required packages
- Run the pipeline with your dataset path, ReX output path, ReX script path, and dataset info path.
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/coco/test2017/ --run-rex --rex-output fixed-results --rex-script /mnt/data/Documents/ReX/scripts/yolo.py --dataset-info /mnt/data/Documents/coco/test2017/predictions_info.csv - The results will be saved in the specified ReX output path.
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/testing/image_2/ --run-rex --rex-output fixed-kitti-results --rex-script /mnt/data/Documents/ReX/scripts/yolo.py --dataset-info /mnt/data/Documents/testing/image_2/predictions_info.csv --rex-config /mnt/data/Documents/ReX/rex.tomlcoco:
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/coco/test2017/ --dataset-info /mnt/data/Documents/coco/test2017/predictions_info.csv --analyse --rex-output fixed-results --visualise --output-dir attack --visualisekitti:
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/testing/image_2/ --dataset-info /mnt/data/Documents/testing/image_2/predictions_info.csv --analyse --rex-output fixed-kitti-results --visualise --output-dir attack_kitti --visualiseIn this setting, we generate attacks that using the label and the bounding box information only.
coco:
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/coco/test2017/ --dataset-info /mnt/data/Documents/coco/test2017/predictions_info.csv --rex-output fixed-results --output-dir attack --run-attacks --extract-method "noise" --num-images 50coco:
python -m scripts.run_pipeline --dataset-path /mnt/data/Documents/coco/test2017/ --dataset-info /mnt/data/Documents/coco/test2017/predictions_info.csv --rex-output fixed-results --rex-script /mnt/data/Documents/ReX/scripts/yolo.py --output-dir attack --run-attacks --extract-method "greedy" --num-images 50To run the extraction using the bash script, use the following command:
Make sure to replace the paths and parameters as needed and give execute permission to the script using chmod +x run_extraction.sh.
./run_extraction.sh /mnt/data/Documents/coco/test2017/ yolo attack noise_targeted 6000 fixed-results /mnt/data/Documents/ReX/scripts/yolo.py 15To run analysis bash script:
./run_analysis.sh /mnt/data/Documents/coco/test2017/ yolo fixed-results /mnt/data/Documents/ReX/scripts/yolo.py 6000 attack 1 BlackCAtt can be used in-juction with other state-of-the-art methods to generate attacks. In this paper, we focused on Square Attack, Parallel Rectangle Flip Attack (PRFA), and SparseRS. In this setting, the attack generation is done using a provided loss function. Example run:
python square_attack_runner.py --num_images 1000 --eps 0.0156862745 --results attack_coco/results_analysis.csv --output_folder square_yolo_coco_results_change/ --attack_type label_changingIf you use this code in your research, please cite the following paper:
@article{navaratnarajah2025out,
title={Out-of-the-box: Black-box Causal Attacks on Object Detectors},
author={Navaratnarajah, Melane and Kelly, David A and Chockler, Hana},
journal={arXiv preprint arXiv:2512.03730},
year={2025}
}Main Repositories Used: