Skip to content

Latest commit

 

History

History
115 lines (72 loc) · 5.17 KB

README_old.md

File metadata and controls

115 lines (72 loc) · 5.17 KB

Adversarial Attacks on Satellite Vehicle Point Detectors

Adversarial attacks on satellite vehicle detectors, which predict vehicle centers.

Installation

Run the following commands to install the environment:

# Install the basic packages
conda env create -f environment.yaml -n satdet
conda activate satdet

# Install detectron2 following the official guideline
# Detectron2 is required for training and evaluation, so it must be installed
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

Note that detectron2 v0.6 was used in this project. If required, make sure you install that version by using the relevant tag (v0.6) from the detectron2 repository.

Overview

TO DO

Demo

TO DO

Training

This repository uses detectron2 for training and testing models. In order to train a model, you need to follow a typical detectron2 approach for training. We have several predefined config files ready for use in the config/ folder. For example, you can train a RetinaNet-based point detector in the following way:

python train.py --num-gpus 8 --config-file configs/RetinaConfig.yaml OUTPUT_DIR saved_models/demo-model

Running the command above will train a model using 8 GPU-s and will output the training details (model weights, logs, etc.) to saved_models/demo-model. You can specify more training parameters in the command line, or change them in the config file.

See the following training examples:

  1. Train for 10k iterations
python train.py --num-gpus 8 --config-file configs/RetinaConfig.yaml OUTPUT_DIR saved_models/demo-model SOLVER.MAX_ITER 10000
  1. Train for 10k iterations with 2k warmup iterations
python train.py --num-gpus 8 --config-file configs/RetinaConfig.yaml OUTPUT_DIR saved_models/demo-model SOLVER.MAX_ITER 10000 SOLVER.WARMUP_ITERS 2000
  1. Train on a specific dataset
python train.py --num-gpus 8 --config-file configs/RetinaConfig.yaml OUTPUT_DIR saved_models/demo-model DATASETS.TRAIN '("my-dataset-name/train",)'

Note that the script will search for datasets in the directory specified by the datasets_dir variable in the main function in train.py.

TO DO: describe the expected dataset structure.

Evaluation

To run evaluation you need to have trained model weights. To evaluate a trained model, again follow detectron2's approach:

python train.py --eval-only --num-gpus 8 --resume --config-file saved_models/demo-model/config.yaml MODEL.WEIGHTS saved_models/demo-model/model_final.pth DATASETS.TEST '("my-dataset-name/validation",)'

Running the command above will run evaluation on the specified dataset and save the results to the saved_models/demo-model/inference folder unless a different OUTPUT_DIR is specified.

Inference

TO DO

Adversarial attacks

To fully evaluate an adversarial attack you need to perform the following steps:

  1. Train a model
  2. Attack the model
  3. Generate a dataset using adversarial textures/meshes/etc.
  4. Test the attacked model on the adversarial dataset

Follow the steps described below to attack a model and evaluate the attack.

Attacking a model

To attack a model, you need to have trained model weights. Attack script also follows detectron2's approach. See example commands below to attack a trained model:

python attack.py --resume --eval-only --config-file saved_models/demo-model/config.yaml MODEL.WEIGHTS saved_models/demo-model/model_final.pth OUTPUT_DIR saved_models/attack-demo-model attack-config-file configs/AttackerConfig.yaml

Note that the only required parameter in the command above is the attack-config-file parameter. However, you need to supply other parameters from the command above too, otherwise the attack can either go wrong, or some files can be overwritten. For example, not supplying OUTPUT_DIR will result in the attack logs overwriting the training logs for the given model. Not specifying --resume --eval-only will result in model weights not being loaded.

Note that adversarial attacks cannot be distributed among multiple GPU-s.

Generating an adversarial dataset

We also supply a synthetic data generator module, which allows to generate several types of datasets:

  1. Original Generator generates a synthetic satellite images dataset, where vehicles are rendered using PyTorch3D.
  2. Blurred Generator generates a synthetic satellite images dataset, but also introduced vehicle blurring.
  3. Adversarial Generator generates a synthetic satellite images dataset where vehicle textures are replaced with adversarial textures.
  4. Blurred Adversarial Generator generates a synthetic satellite images dataset similar to the Adversarial Generator, however it also blurrs vehicles in the images.

Evaluating a model on an adversarial dataset

To evaluate an attacked model on an adversarial dataset you simply follow the Evaluation approach, i.e.:

python train.py --resume --eval-only --num-gpus 8 --config-file saved_models/demo-model/config.yaml MODEL.WEIGHTS saved_models/demo-model/model_final.pth DATASETS.TEST '("my-adversarial-dataset/validation",)'