Skip to content

Commit 3b55dc3

Browse files
Chrisqcwxfinal-solutioncswbyu
authored
refactor all (#59)
* refactor gans and base * feat: add refactor for plg * feat: add refactor for plg * refactor: location of latents sampler * fix: some error * feat: add some comments * fix some error & add some docs * fix: detach * fix: parallel error * fix: parallel apply error * refactor: image classifier model forward * fix: hook error * fix error of classifier and add train example * fix: example error * refactor: remove some unuse * refactor: position of sampler * refactor attacker * feat: add preprocess datasets * feat: ppa * feat: add bido, vib, ls trainer * fix: some error * fix some error * feat: add constraint * feat: add brep optimization * feat: add rlb & mirror white * fix: out of memory * minor refactor * fix: warning when resize * refactor: reformat * fix: final evaluation * fix: final selection * fix: preprocess dataset error * feat: dataset preprocess * refactor: preprocess data * fix: dataset preprocess * fix: some error in examples * feat: add feature loss & fix: some typo * fix: description error for datasets * fix: typo * fix: typo and programma error * fix: metric batch * refactor lomma gmi * fix: classifier training * fix: train script for classifier * feat: dataset readme * fix: some error * fix: dataset error * fix: dataset * add: original ppa code * fix: remove unused code * add: split files * fix: some bugs * remove datasets * deleted: datasets/READba/README.md deleted: datasets/celeba/celeba_split.py deleted: datasets/hdceleba/README.md deleted: datasets/hdceleba/celeba_split.py renamed: datasets/celeba/split_files/private_test.txt -> src/modelinversion/datasets/split_files/private_test.txt renamed: datasets/celeba/split_files/private_train.txt -> src/modelinversion/datasets/split_files/private_train.txt renamed: datasets/celME.md deleted: datasets/celeeba/split_files/public.txt -> src/modelinversion/datasets/split_files/public.txt * feat: add some deep inversion loss & fix some error * fix: celeba train * remove incv1 * fix:some bugs * fix:log for classfier training * iter in gan training * minor modification * modified: examples/standard/attacks/gmi.py modified: examples/standard/gan_training/gmi.py modified: examples/standard/gan_training/plgmi.py modified: src/modelinversion/sampler/base.py modified: src/modelinversion/utils/hook.py * fix: dataset process in classifier training * modified: examples/standard/attacks/gmi.py * modified: examples/standard/gan_training/gmi.py modified: src/modelinversion/metrics/base.py * fix: acc in trainer * params in gmi * fix:set center crop as true * rename some classes * fix: programma error in loss * rename some classes * remove BaseTargetModel * feat: release some script & repr for loss * fix: generate dataset by generator * fix: reset params to <fill it> * feat: raise exception in torchvision wrapper * substitute Flatten with nn.Flatten * substitute Flatten with nn.Flatten * add ImageImageFolder declaration * fix: typo * fix: add abstract method to BaseImageGenerator * fix: correct a spelling mistake * fix: comments in scores * refactor: dataset & add ffhq * fix: ppa script error * rename GanTrainer * refactor gan * feat: add some comments in utils * add some comments in io.py * add some comments in io.py * add some comments in utils * feat: generator dataset * add acc var * feat: add attack flow * try fix: lokt gan * feat: add register for models * add register utils in __iit__ * feat: config mixin * feat: register for model config * feat: classifier wrapper config * feat: classifier config load successfully * feat: save config after train classifier * feat: config for GAN * feat: config in __init__ * save config in gan training * refactor: location of config * fix: vib config * feat: comments on ConfigMixin * fix: acc std * fix: acc metric * fix classifier * feat: lokt generation * fix: config error * fix: save error * refactor: remove some unuse * fix: metric exception * fix: plg gan * fix: ked gan train & metric; feat: tl training * fix: kedmi256 structure * feat: ked train script * refactor: rename some scripts * fix: deep inversion first bn weight * feat: add resnest * feat: Add BaseOutput for Optimization * fix: metric error * feat: add face dist & fix std error * fix: save metric resule * feat: post metric * refactor attacker * fix: final eval * fix: gather * fix: final selection * fix lomma gmi * fix: final selection * feat: add post evaluation * feat: add top k score optimized in genetic optimization * refactor: remove unuse package * add vmi (#60) * feat: add sampler * modified: examples/standard/attacks/vmi.py * feat: add latent sampler * feat: add optimization * feat: add optimization * feat: add optimization * feat: add loss for vmi * feat: add loss for vmi * feat: prepare for attack * feat: prepare for attack * fix: remove num_range * refactor: prepare single thread * feat: add single thread vmi * feat: add FlowConfig * feat: add multithread training * feat: add metrics * feat: add metrics * feat: add metrics * feat: add metrics * feat: add metrics * feat: add transform * fix: some minor bugs --------- Co-authored-by: final-solution <2507586353@qq.com> * fix: fid * feat: c2f * fix: c2f * feat: defense example * Supplement (#61) * add: parameter management * feat: extend the parameter management in the future * feat: extend the parameter management in the future * fix: new requirements * Update README.md * Update README.md * Update README.md * Update README.md * feat: README for examples/standard * feat: README for examples/standard --------- Co-authored-by: final-solution <2507586353@qq.com> Co-authored-by: Yixiang Qiu <99653938+final-solution@users.noreply.github.com> Co-authored-by: Wenbo Yu <cswbyu@163.com> --------- Co-authored-by: final-solution <2507586353@qq.com> Co-authored-by: Yixiang Qiu <99653938+final-solution@users.noreply.github.com> Co-authored-by: Wenbo Yu <cswbyu@163.com>
1 parent 4569129 commit 3b55dc3

614 files changed

Lines changed: 78035 additions & 75743 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ cache/
109109
*.pt
110110
*.pth
111111
*.tar
112+
*.pkl
113+
*.tar.gz
112114
results/*
115+
/results*
113116
# checkpoints/*/*
114117
dataset/*/*
115118

@@ -122,5 +125,8 @@ nohup.txt
122125
# !dataset/celeba/README.md
123126
/test.py
124127
/test.ipynb
125-
/test
128+
/test*
126129
.vscode
130+
test*.py
131+
test*.sh
132+
checkpoints_v2/

.vscode/settings.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"python.analysis.extraPaths": [
33
"./src"
4-
],
4+
],
55
"[python]": {
6-
"editor.defaultFormatter": "ms-python.black-formatter"
6+
"editor.defaultFormatter": "ms-python.black-formatter",
7+
"editor.formatOnSave": true,
8+
9+
"editor.formatOnType": true
710
},
8-
"python.formatting.provider": "none"
11+
"black-formatter.args": [
12+
"-S"
13+
],
914
}

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🔥Model Inversion Attack ToolBox v1.0🔥
1+
# 🔥Model Inversion Attack ToolBox v2.0🔥
22

33
![Python 3.10](https://img.shields.io/badge/python-3.10-DodgerBlue.svg?style=plastic)
44
![Pytorch 2.0.1](https://img.shields.io/badge/pytorch-2.0.1-DodgerBlue.svg?style=plastic)
@@ -13,23 +13,14 @@
1313
[Xuan Wang](https://faculty.hitsz.edu.cn/wangxuan),
1414
[Shu-Tao Xia](https://www.sigs.tsinghua.edu.cn/xst/main.htm)
1515

16-
Welcome to **MIA**! This repository is a comprehensive open-source Python benchmark for model inversion attacks, which is well-organized and easy to get started. It includes uniform implementations of advanced and representative model inversion methods, formulating a unified and reliable framework for a convenient and fair comparison between different model inversion methods.
16+
Welcome to **MIA**! This repository is a comprehensive open-source Python benchmark for model inversion attacks, which is well-organized and easy to get started. It includes uniform implementations of advanced and representative model inversion methods, formulating a unified and reliable framework for a convenient and fair comparison between different model inversion methods. Our repository is continuously updated in **https://github.com/ffhibnese/Model-Inversion-Attack-ToolBox**.
1717

1818

1919
If you have any concerns about our toolbox, feel free to contact us at qiuyixiang@stu.hit.edu.cn, yuhongyao@stu.hit.edu.cn, and fang-h23@mails.tsinghua.edu.cn.
2020

2121
Also, you are always welcome to contribute and make this repository better!
2222

2323

24-
### :construction: MIA v2.0 is coming soon
25-
We are already in the second development stage where the following updates will be implemented soon.
26-
- More recently emerging attacks
27-
- Representative defense algorithms
28-
- MI attacks on graph and language modalities
29-
- Able to train your generative model
30-
- Better refactor code with `trainer`
31-
- A package that can be installed with pip
32-
3324
## :rocket: Introduction
3425

3526
**Model inversion attack** is an emerging powerful private data theft attack, where a malicious attacker is able to reconstruct data with the same distribution as the training dataset of the target model.
@@ -68,7 +59,6 @@ The reason why we developed this toolbox is that the research line of **MI** suf
6859

6960
|Method|Paper|Publication|Key Characteristics|
7061
|:-:|:-:|:-:|:-:|
71-
|[DPSGD](./src/modelinversion/defense/DP/)|Deep Learning with Differential Privacy|[CCS'2016](https://dl.acm.org/doi/abs/10.1145/2976749.2978318)|add noise on gradient|
7262
|[ViB / MID](./src/modelinversion/defense/Vib/)|Improving Robustness to Model Inversion Attacks via Mutual Information Regularization|[AAAI'2021](https://ojs.aaai.org/index.php/AAAI/article/view/17387)| variational method, mutual information, special loss function|
7363
|[BiDO](./src/modelinversion/defense/BiDO/)|Bilateral Dependency Optimization: Defending Against Model-inversion Attacks|[KDD'2022](https://dl.acm.org/doi/abs/10.1145/3534678.3539376)|special loss function|
7464
|[TL](./src/modelinversion/defense/TL/)|Model Inversion Robustness: Can Transfer Learning Help?|[CVPR'2024](https://openreview.net/forum?id=nW0sCc3LLN&nesting=2&sort=date-desc)|transfer learning|
@@ -88,7 +78,17 @@ conda activate MIA
8878
pip install -r requirements.txt
8979
```
9080

91-
## :page_facing_up: Datasets and Model Checkpoints
81+
## :page_facing_up: Preprocess Datasets and Pre-trained Models
82+
83+
See [here](./docs/datasets.md) for details to preprocess datasets.
84+
85+
We have released pre-trained target models and evaluation models in the `checkpoints_v2.0` of [Google Drive](https://drive.google.com/drive/folders/1ko8zAK1j9lTSF8FMvacO8mCKHY9evG9L?usp=sharing).
86+
87+
<!-- ## :racehorse: Run Examples
88+
89+
See [here](./docs/) for details. -->
90+
91+
<!-- ## :page_facing_up: Datasets and Model Checkpoints
9292
- For datasets, you can download them according to the file with detailed instructions placed in `./dataset/<DATASET_NAME>/README.md`.
9393
- For pre-trained models, we prepare all the related model weights files in the following link.
9494
Download pre-trained models [here](https://drive.google.com/drive/folders/1ko8zAK1j9lTSF8FMvacO8mCKHY9evG9L) and place them in `./checkpoints/`. The detailed file path structure is shown in `./checkpoints_structure.txt`.
@@ -121,7 +121,7 @@ python defense_scripts/<DEFENSE_METHOD>_<ATTACK_METHOD>.py
121121
```
122122
and attack results will be produced in `./results/<DEFENSE_METHOD>_<ATTACK_METHOD>` by default.
123123
124-
For more information, you can read [here](./defense_scripts/README.md).
124+
For more information, you can read [here](./defense_scripts/README.md). -->
125125

126126
## 📔 Citation
127127
**If you find our work helpful for your research, please kindly cite our paper:**

attack_scripts/README.md

Lines changed: 0 additions & 117 deletions
This file was deleted.

attack_scripts/brep.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

attack_scripts/c2fmi.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

attack_scripts/deepinversion.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)