Skip to content

xysteve00/Cassandra

Repository files navigation

Cassandra: Detecting Trojaned Networks from Adversarial Perturbations

Requirements

  1. Python 3.6 (Anaconda3):
conda create -n envname python==3.7 anaconda
conda activate envname
  1. Pytorch >=1.4:
conda install pytorch torchvision -c pytorch
  1. Geffnet and scikit-image
pip install geffnet scikit-image

Data

Download NIST-Round0 data from https://data.nist.gov/od/id/mds2-2175 and save it in ./data/

Generate meta data for NIST-Round0 models, run python data_pre.py output is data_meta.txt and then split the data into data_meta_tain.txt and data_meta_test.txt

Training

To train the model(s) in the paper, run these commands

  1. generate l infinity norm bounded adversarial perturbations for training and test set and save them to ./Pert/pert_mb/train_inf and ./Pert/pert_mb/test_inf respectively by running:
python pert_gen.py --meta_file ./data/data_meta_train.txt --pert_loc ./Pert/pert_mb/train_inf --max_iter 5 --p_norm 2
  1. generate l2 norm bounded adversarial perturbations for training and test set and save them to ./Pert/pert_mb/train_l2 and ./Pert/pert_mb/test_l2 respectively by running:
python pert_gen.py --meta_file ./data/data_meta_train.txt --pert_loc ./Pert/pert_mb/train_l2 --max_iter 5 --p_norm 3 --p_value 40
  1. train the model
python train.py

The generated model will be saved in ./models/detector/pretrained/

Evaluation

Run evaluation using

python eval.py

Pre-Trained Models

To evaluate my pretrained model download pretrained model from: Google Drive Link and save it to ./models/detector/pretrained/ before running evaluation.

Results

Model Precision
mobilenetv3_0.95_0.925_mnet.pth 0.95

About

Detecting Trojaned Neural Netowrks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages