BackdoorMBTI
BackdoorMBTI is an open source project expanding the unimodal backdoor learning to a multimodal context. We hope that BackdoorMBTI can facilitate the analysis and development of backdoor defense methods within a multimodal context.
main feature:
- poison dataset generateion
- backdoor model generation
- attack training
- defense training
- backdoor evaluation
The framework:
Task Supported
| Task | Dataset | Modality |
|---|---|---|
| Object Classification | CIFAR10 | Image |
| Object Classification | TinyImageNet | Image |
| Traffic Sign Recognition | GTSRB | Image |
| Facial Recognition | CelebA | Image |
| Sentiment Analysis | SST-2 | Text |
| Sentiment Analysis | IMDb | Text |
| Topic Classification | DBpedia | Text |
| Topic Classification | AG’s News | Text |
| Speech Command Recognition | SpeechCommands | Audio |
| Music Genre Classification | GTZAN | Audio |
| Speaker Identification | VoxCeleb1 | Audio |
Backdoor Attacks Supported
Backdoor Defenses Supported
| Defense | Modality | Input | Stage | Output | Paper |
|---|---|---|---|---|---|
| STRIP | Audio,Image and text | backdoor model, clean dataset | post-training | clean dataset | STRIP: A Defence Against Trojan Attacks on Deep Neural Networks |
| AC | Audio,Image and text | backdoor model, clean dataset, poison dataset | post-training | clean model, clean datasest | Detecting Backdoor Attacks on Deep Neural Networks by Activation Clustering |
| FT | Audio,Image and text | backdoor model, clean dataset | in-training | clean model | Fine-Pruning: Defending Against Backdooring Attacks on Deep Neural Networks. |
| FP | Audio,Image and text | backdoor model, clean dataset | post-training | clean model | Fine-Pruning: Defending Against Backdooring Attacks on Deep Neural Networks. |
| ABL | Audio,Image and text | backdoor model, poison dataset | in-training | clean model | Anti-Backdoor Learning: Training Clean Models on Poisoned Data |
| CLP | Audio,Image and text | backdoor model | post-training | clean model | Data-free Backdoor Removal based on Channel Lipschitzness |
| NC | Image | backdoor model, clean dataset | post-training | clean model, trigger pattern | Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural Networks |
Installation
To install the virtual environment:
conda create -n bkdmbti python=3.10
conda activate bkdmbti
pip install -r requirements.txt
Quick Start
Download Data
Download the data if it can not be downloaded automatically. Some data download scripts are provided in scripts folder.
Backdoor Attack
Here we provide an example to quickly start with the attack experiments, and reproduce the BadNets backdoor attack results. We use resnet-18 as the default model, and 0.1 as the default poison ratio.
cd scripts
python atk_train.py --data_type image --dataset cifar10 --attack_name badnet --model resnet18 --pratio 0.1 --num_workers 4 --epochs 100
python atk_train.py --data_type audio --dataset speechcommands --attack_name blend --model audiocnn --pratio 0.1 --num_workers 4 --epochs 100 --add_noise true
python atk_train.py --data_type text --dataset sst2 --attack_name addsent --model bert --pratio 0.1 --num_workers 4 --epochs 100 --mislabel true
Use args --add_noise true and --mislabel true to add perturbations to the data. After the experiment, metrics ACC(Accuracy), ASR(Attack Success Rate) and RA(Robustness Accuracy) are collected in attack phase.
To learn more about the attack command, you can run python atk_train.py -h to see more details.
Backdoor Defense
Here we provide a defense example, it depends on the backdoor model generated in the attack phase, so you should run the corresponding attack experiment before defense phase.
cd scripts
python def_train.py --data_type image --dataset cifar10 --attack_name badnet --pratio 0.1 --defense_name finetune --num_workers 4 --epochs 10
python def_train.py --data_type audio --dataset speechcommands --attack_name blend --model audiocnn --pratio 0.1 --defense_name fineprune --num_workers 4 --epochs 1 --add_noise true
python def_train.py --data_type text --dataset sst2 --attack_name addsent --model bert --pratio 0.1 --defense_name strip --num_workers 4 --epochs 1 --mislabel true
To learn more about the attack command, you can run python def_train.py -h to see more details.
In defense phase, detection accuracy will be collected if the defense is a detection method, and then the sanitized dataset will be used to retrain the model. ACC, ASR and RA metrics are collected after retraining.
Results
More results can be found in: results.md
Metadata
Release files for backdoormbti 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| backdoormbti-0.2.2.tar.gz | 5.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| backdoormbti-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 MB
Release files / backdoormbti-0.2.2.tar.gz
| Download URL | backdoormbti-0.2.2.tar.gz |
|---|---|
| Size | 5.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
889ff7b5b0588d82f6719a3cdfc2afce39fd6baa38791be0078cff1ef66ebeac
|
|
BLAKE2b-256 checksum How to use checksums |
44434b3b50bfede1c9da8b4a48682a1c484c61dc98b8351407714aca47d61690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|
Release files / backdoormbti-0.2.2-py3-none-any.whl
| Download URL | backdoormbti-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d98ee82558f6c4cf0849c1f70f3bf587fef158195fb098789a62999c75537849
|
|
BLAKE2b-256 checksum How to use checksums |
505a6f8ab1bffe775c8caba196711d23fb20c238722da94cf357a1155b58c969
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.15
|