Implementation of Paper "Z. Ye, W, Luo and M. L. Naseem, et al., C2FMI: Corse-to-Fine Black-box Model Inversion Attack", TDSC, 2023.
I have tested on:
- PyTorch 1.13.0
- CUDA 11.0
If you want to use our trained models, including styleGAN, target model, embedding model and inverse model (refer to Fig.4 in our paper):
- download
checkpoint.zip
from https://huggingface.co/MiLab-HITSZ/C2FMI/tree/main. - download
trained_models.zip
from https://huggingface.co/MiLab-HITSZ/C2FMI/tree/main. - unzip and put these 2 folders in your project directory.
- running with command:
python main_attack_antidefense.py
- note that you should create directory
gen_figures/DE_facescrub_mobile_M100_counter/
in your project before running since our code does not automatically generate it. - changing the variables
init_label
andfina_label
inmain_attack_antidefense.py
, attack will start atinit_label
and end atfina_label
.
Or you can train your own models and change the models in script main_attack_antidefense.py
.
If you want to use our trained models, including styleGAN, target model, embedding model and inverse model (refer to Fig.4 in our paper):
- download
checkpoint2.zip
from https://huggingface.co/MiLab-HITSZ/C2FMI/tree/main. - download
trained_models.zip
from https://huggingface.co/MiLab-HITSZ/C2FMI/tree/main. - unzip and put these 2 folders in your project directory.
- running with command:
python main_attack.py
- note that you should create directory
gen_figures/DE_facescrub/
in your project before running since our code does not automatically generate it. - changing the variables
init_label
andfina_label
inmain_attack.py
, attack will start atinit_label
and end atfina_label
.
Or you can train your own models and change the models in script main_attack.py
.
If you have followed the simplest implementation, you can run the following command to evaluate the attack accuracy:
python eva_accuracy.py
- please modify the annotated variables in
eva_accuracy.py
if using your customized dataset and models.
-the settings of variables in eva_knn_dist.py
is same as in eva_accuracy.py
, except for the variable train_txt
, which you can run annotation_face_train.py
to generate it (it is a .txt
file containing the path of all training data). Note that you should modify the datasets_path
in annotation_face_train.py
.