
Black-Box-Eingangsstufen-Reinigungsverteidigung, die Backdoor-Angriffe auf Objektdetektoren durch Korruption, Diffusionsrekonstruktion und DBSCAN-Konsensabstimmung neutralisiert.
Die erste Black-Box-Bereinigungsverteidigung auf Eingabeebene, die speziell für Objektdetektoren gegen Backdoor-Angriffe entwickelt wurde.
ODPure ist das erste Black-Box-Bereinigungsframework auf Eingabeebene, das speziell für die Verteidigung von Objektdetektoren gegen Backdoor-Angriffe entwickelt wurde. Es operationalisiert ein neuartiges Corruption-Reconstruction-Selection (CRS)-Paradigma, das:
ODPure neutralisiert effektiv verschiedene Backdoor-Angriffe (reduziert die Angriffserfolgsrate auf bis zu 0,0%) und bewahrt gleichzeitig den sauberen Erkennungsnutzen, wodurch überlegene Verteidigungs-Nutzen-Kompromisse im Vergleich zu bestehenden Verteidigungen erzielt werden.
# Core dependencies
torch>=1.13.0
torchvision>=0.14.0
numpy>=1.21.0
Pillow>=9.0.0
opencv-python>=4.5.0
# Diffusion models
diffusers>=0.14.0
transformers>=4.25.0
accelerate>=0.20.0
# Evaluation
scikit-learn>=1.2.0 # For DBSCAN clustering
scipy>=1.9.0
# Data processing
pyyaml>=6.0
tqdm>=4.64.0
# Create conda environment
conda create -n odpure python=3.9 -y
conda activate odpure
# Install PyTorch with CUDA
conda install pytorch torchvision pytorch-cuda=11.7 -c pytorch -c nvidia
# Install other dependencies
pip install -r requirements.txt
Bevor Sie das Rekonstruktionsmodul ausführen, müssen Sie die vortrainierten Modellgewichte herunterladen:
| Modell | Beschreibung | Download |
|---|---|---|
| DiffBIR v2.1 | Haupt-Restaurierungsmodell | HuggingFace |
| Stable Diffusion | Latente Diffusions-Priors | HuggingFace |
| LLaVA | Vision-Sprache-Captioner | HuggingFace |
| RAM | Recognition-Aware Model | GitHub Release |
mkdir -p Method/Reconstruction/weights
Laden Sie die Gewichte herunter und platzieren Sie sie gemäß den Anweisungen in den jeweiligen Modell-Repositories.
Aktualisieren Sie die Konfigurationsdateien in Method/Reconstruction/configs/, um auf Ihre heruntergeladenen Gewichte zu verweisen.
ODPure/
├── attack_script/ # Backdoor attack implementations
│ ├── COCO_chessboard_29x29_OMA.py # Object Misclassification (Chessboard)
│ ├── COCO_chessboard_29x29_ODA.py # Object Disappearance Attack (Chessboard)
│ ├── COCO_chessboard_9x9_OGA.py # Object Generation Attack (Chessboard)
│ ├── COCO_poke_15x15_OMA.py # OMA (Poké Ball)
│ ├── COCO_poke_15x15_ODA.py # ODA (Poké Ball)
│ ├── COCO_poke_15x15_OGA.py # OGA (Poké Ball)
│ ├── COCO_white_15x15_OMA.py # OMA (Solid White)
│ ├── COCO_white_15x15_ODA.py # ODA (Solid White)
│ └── COCO_white_15x15_OGA.py # OGA (Solid White)
│
├── Method/ # Core defense methodology
│ ├── corruptions/ # Image corruption module
│ │ ├── imagecorruption.py # Corruption functions
│ │ └── multiprocess_imagecorruption.py # Parallel processing
│ │
│ ├── Reconstruction/ # Diffusion-based restoration
│ │ ├── inference.py # Main inference script
│ │ ├── diffbir/ # DiffBIR model implementation
│ │ ├── llava/ # LLaVA captioner
│ │ ├── ram/ # Recognition-Aware Model
│ │ ├── configs/ # Model configurations
│ │ └── weights/ # Model weights (download separately)
│ │
│ └── dbscan_vote_new.py # DBSCAN clustering & voting
│
├── evaluation/ # Evaluation metrics
│ ├── OMA_ASR_new.py # OMA Attack Success Rate
│ ├── OMA_mAP.py # OMA Mean Average Precision
│ ├── ODA_ASR_new.py # ODA Attack Success Rate
│ ├── ODA_mAP.py # ODA Mean Average Precision
│ ├── OGA_ASR_new.py # OGA Attack Success Rate
│ ├── OGA_mAP.py # OGA Mean Average Precision
│ ├── val_OMA.py # YOLO validation for OMA
│ ├── val_ODA.py # YOLO validation for ODA
│ └── val_OGA.py # YOLO validation for OGA
│
├── data_format_conversion/ # Data format utilities
│ ├── voc2yolo.py # VOC to YOLO format conversion
│ ├── cocotoyolo.py # COCO to YOLO format conversion
│ └── select_coco_val_attack_information.py
│
├── ablation_study/ # Ablation experiments
│ ├── multiprocess_imagecorruption.py
│ ├── random_select_corruption.py
│ └── select_specific_corruption.py
│
├── run_pipeline.sh # One-shot CRS pipeline runner
└── README.md # This file
Der empfohlene Einstiegspunkt ist run_pipeline.sh, das die drei CRS-Stufen kaskadiert:
# Defaults: GPU=0, INPUT=inputs/demo/bid, OUTPUT=results/v2.1_demo_bid, ATTACK=ODA
bash run_pipeline.sh
# Custom arguments: GPU_ID INPUT_DIR OUTPUT_DIR ATTACK
bash run_pipeline.sh 0 inputs/coco_oda results/oda ODA
bash run_pipeline.sh 1 inputs/coco_oma results/oma OMA
bash run_pipeline.sh 2 inputs/coco_oga results/oga OGA
Das Skript führt Folgendes aus:
Die endgültigen bereinigten Detektionen werden in <OUTPUT_DIR>/final/ geschrieben.
Verwenden Sie dies, wenn Sie Zwischenschritte überprüfen / ersetzen möchten.
python Method/corruptions/multiprocess_imagecorruption.py \
--input_dir /path/to/input/images \
--output_dir /path/to/corrupted/images \
--num_corruptions 45 \
--num_workers 8
python Method/Reconstruction/inference.py \
--task denoise \
--upscale 2 \
--version v2.1 \
--captioner llava \
--cfg_scale 6 \
--noise_aug 1 \
--input /path/to/corrupted/images \
--output /path/to/restored/images \
--batch_size 32 \
--device cuda
python Method/dbscan_vote_new.py \
--folder_purs /path/to/restored/detections \
--temp /path/to/temp \
--output_path /path/to/final/detections \
--eps 0.5 \
--min_samples 10
conda activate odpure