https://github.com/liulietlee/cdta
Release for CDTA: A Cross-Domain Transfer-Based Attack with Contrastive Learning [AAAI23]
https://github.com/liulietlee/cdta
Last synced: about 2 months ago
JSON representation
Release for CDTA: A Cross-Domain Transfer-Based Attack with Contrastive Learning [AAAI23]
- Host: GitHub
- URL: https://github.com/liulietlee/cdta
- Owner: LiulietLee
- Created: 2022-11-21T11:19:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-25T03:38:35.000Z (almost 2 years ago)
- Last Synced: 2025-03-24T01:14:05.620Z (2 months ago)
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 10
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CDTA
> Release for CDTA: Cross-Domain Transfer-Based Attack with Contrastive Learning [AAAI23]Paper Link: [https://ojs.aaai.org/index.php/AAAI/article/view/25239](https://ojs.aaai.org/index.php/AAAI/article/view/25239)
## Download
### Datasets
Download [birds-400](https://github.com/LiulietLee/CDTA/releases/download/v1.1/birds-400.zip), [food-101](http://data.vision.ee.ethz.ch/cvl/food-101.tar.gz), [comic books](https://www.kaggle.com/datasets/cenkbircanoglu/comic-books-classification), and [oxford 102 flower](https://www.robots.ox.ac.uk/~vgg/data/flowers/102/) datasets. Extract them to the `./dataset` directory.
### Pre-trained target classifiers
Download target classifiers trained on [birds-400](https://github.com/LiulietLee/CDTA/releases/download/v1.0/birds-400.zip), [food-101](https://github.com/LiulietLee/CDTA/releases/download/v1.0/food-101.zip), [comic books](https://github.com/LiulietLee/CDTA/releases/download/v1.0/Comic.Books.zip), and [oxford 102 flower](https://github.com/LiulietLee/CDTA/releases/download/v1.0/Oxford.102.Flower.zip). Extract them to the `./pretrained/target` directory.
### Pre-trained feature extractor
Download the [per-trained feature extractor](https://github.com/LiulietLee/CDTA/releases/download/v1.0/simsiam_bs256_100ep_cst.tar) and put the tar file in the `./pretrained/surrogate` directory.
## Evaluation
```
python eval_cdta.py \
-d '[dataset]' \
-a '[target classifier]' \
--pretrained './pretrained/surrogate/simsiam_bs256_100ep_cst.tar' \
--eps 0.06274509803921569 \
--nb-iter 30 \
--step-size 0.01568627450980392
```- `[dataset]` can be `birds-400`, `food-101`, `comic books`, or `oxford 102 flower`.
- `[target classifier]` can be `resnet34`, `densenet161`, `inception_v3`, or `vgg16_bn`.Or use `eval.sh` to test all target models.
```
bash ./eval.sh
```## Train feature extractor
```
cd cst
``````
python train.py \
-a resnet50 \
-b 256 \
--dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \
--fix-pred-lr \
'[ImageNet path]'
```