How khoadoan106/backdoor_attacks works
Project Type & Purpose
• This is a specialized ML research project implementing adversarial backdoor attack methods.
• Its main purpose is to generate triggers and inject backdoors into classifier models (using techniques described in NeurIPS2022 and ICCV2021 papers).
Analyzing the File Structure
• Top-Level Directories and Files:
• The “python” directory contains the core code.
• “etc” holds environment and setup scripts (e.g., CUDA and environment setup, notebook runner).
• “requirements.txt” defines the Python dependencies.
• Inside “python”, there are several subdirectories:
• “attack_models” (e.g., autoencoders.py, unet.py): Contains models likely used for generating or processing triggers.
• “classifier_models” (various architecture definitions like densenet, resnet, etc.): This is where different neural network models for classification/regression are defined.
• “networks” and “utils”: Provide building blocks, custom network layers, utility functions for backdoor attack routines (e.g., dataloader management, backdoor utilities, etc.).
• Standalone scripts (e.g., lira_trigger_generation.py, lira_backdoor_injection.py, marksman_conditional_) that act as execution entry points for different stages of the attack (trigger generation vs. injection).
Main Components & Their Relationships
• Environment Setup & Configuration:
• Managed via “etc” scripts (setup_env, setup_cuda, install_torch_cuda_11.0, run_notebook) which prepare the runtime environment.
• Core ML Modules:
• Attack Models: Contains specific architectures (autoencoders, unet) used in formulating backdoor triggers.
• Classifier Models: A collection of pre-defined classifier architectures (VGG, ResNet, etc.) that are vulnerable to backdoor injection.
• Networks: General network components and blocks that might be shared across the above.
• Utils: Contains helper functions for model training, backdoor perturbation, data handling, and more.
• Experiment Pipelines:
• LIRA Pipeline: Split into two main scripts for trigger generation and backdoor injection. This pipeline first learns a trigger from the data, and then uses it to poison or fine-tune classifiers.
• Marksman Pipeline: Focuses on conditional backdoor injection using arbitrary target classes.
• Data and Execution Flow:
• Environment setup (through “etc”) ensures proper CUDA/Python configuration.
• The experimental scripts (in “python”) are executed to perform the following sequence:
1. Trigger Generation – where the attack model (from attack_models) interacts with a selected classifier (from classifier_models).
2. Backdoor Injection – where after trigger generation, the system triggers injection routines to poison classifier performance.
3. Data handling and utility functions (from utils) are used throughout these stages.
Architectural Patterns & Technologies
• Modularity: The code cleanly separates data handling, model definitions, and attack routines.
• Pipeline Pattern: Two-stage pipeline for LIRA (trigger generation and injection).
• Dependency Injection: Use of configuration scripts and arguments in the execution scripts to specify datasets, models, hyperparameters, etc.
• Technologies: Expect use of deep learning frameworks (e.g., PyTorch given the CUDA setup scripts), Python, and possibly external libraries (specified in requirements.txt).