Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacyΒ© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
ODPure β€” Black-box input-stage purification defense that neutralizes backdoor attacks on object detectors via corruption, diffusion reconstruction, and DBSCAN consensus voting. | Kitploit
Tools/GitHubGitHub/alex66366/odpure
Defensive ToolsDynamic Analysis (Sandboxing)Vulnerability AnalysisMachine LearningPapers & ResearchAI SecurityAdversarial Attack
GitHubalex66366/odpure

ODPure

Black-box input-stage purification defense that neutralizes backdoor attacks on object detectors via corruption, diffusion reconstruction, and DBSCAN consensus voting.

View Repository
1681 month agoNot yet reviewed

Most Popular

View all β†’

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools β†’
Share

ODPure: Backdoor Purification for Object Detection via Ensemble Corruption Consensus

The first input-stage black-box purification defense tailored for object detectors against backdoor attacks.

License: MIT

πŸ“– Overview

ODPure is the first input-stage, black-box purification framework tailored for defending object detectors against backdoor attacks. It operationalizes a novel Corruption-Reconstruction-Selection (CRS) paradigm that:

  1. Corrupts input images with diverse perturbations to disrupt trigger patterns
  2. Reconstructs fine-grained structural features using generative diffusion priors
  3. Selects high-confidence detections via spatial consensus voting

ODPure effectively neutralizes diverse backdoor attacks (reducing Attack Success Rate to as low as 0.0%) while preserving clean detection utility, achieving superior defense-utility trade-offs over existing defenses.

πŸ”‘ Key Features

  • Black-Box Defense: No need for model internals, gradients, or architectures
  • Model-Agnostic: Works with any object detector (YOLO, Faster R-CNN, etc.)
  • Multi-Attack Defense: Handles OMA, ODA, and OGA attack types
  • Zero-Shot: No prior knowledge of trigger patterns required
  • Continuous Perception: Maintains operational stream continuity without discarding data

πŸ“‹ Requirements

System Requirements

  • Python 3.8+
  • CUDA 11.7+ (for GPU acceleration)
  • 16GB+ GPU memory recommended

Python Dependencies

# 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

Conda Environment Setup (Recommended)

# 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

πŸ“¦ Download Pretrained Weights

Before running the Reconstruction module, you need to download the pretrained model weights:

Required Weights

ModelDescriptionDownload
DiffBIR v2.1Main restoration modelHuggingFace
Stable DiffusionLatent diffusion priorsHuggingFace
LLaVAVision-language captionerHuggingFace
RAMRecognition-Aware ModelGitHub Release

Installation Steps

  1. Create the weights directory:
mkdir -p Method/Reconstruction/weights
  1. Download and place the weights following the instructions in the respective model repositories.

  2. Update the config files in Method/Reconstruction/configs/ to point to your downloaded weights.

πŸ—οΈ Project Structure

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

πŸš€ Quick Start

Option A: One-Shot End-to-End Pipeline (Recommended)

The recommended entry point is run_pipeline.sh, which cascades the three CRS stages:

# 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

The script performs:

  1. Stage 1 (Corruption) – generates 45 corrupted variants
  2. Stage 2 (Reconstruction) – DiffBIR v2.1 with LLaVA captioner
  3. Stage 3 (Selection) – DBSCAN spatial consensus voting

Final purified detections are written to <OUTPUT_DIR>/final/.

Option B: Run Each Stage Manually

Use this if you want to inspect / replace intermediate steps.

Stage 1: Corruption

python Method/corruptions/multiprocess_imagecorruption.py \
    --input_dir /path/to/input/images \
    --output_dir /path/to/corrupted/images \
    --num_corruptions 45 \
    --num_workers 8

Stage 2: Reconstruction

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

Stage 3: Selection (DBSCAN Voting)

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

πŸ“Š Evaluation

Step 1: Activate Environment

conda activate odpure

Step 2: Run Detector on Three Splits

# Run on poisoned inputs (before defense)
python evaluation/val_ODA.py \
    --weights runs/train/exp/weights/last.pt \
    --data data/ODA_poison.yaml \
    --img 640 --iou-thres 0.65 --conf-thres 0.5 \
    --save-txt --save-conf \
    --project results/poisoned_val_txt
Download Tool