ain-soph / trojanzoo

TrojanZoo provides a universal pytorch platform to conduct security researches (especially backdoor attacks/defenses) of image classification in deep learning.
https://ain-soph.github.io/trojanzoo
GNU General Public License v3.0
279 stars 63 forks source link

Input aware dynamic backdoor error #176

Closed GorkaAbad closed 2 years ago

GorkaAbad commented 2 years ago

Hi!, I wanted to know if when using the --attack input_aware_dynamic I also should provide some mask parameters. I assume that I don't have to since the trigger should be included throughout the image.

I'm running this: python examples/backdoor_attack.py --color --verbose 1 --dataset cifar100 --model vgg11_bn --attack input_aware_dynamic --save --download --poison_percent 0.001 --epochs 100 --pretrained --output 1 --dataset_normalize --train_mask_epochs 1 --attack_dir res/

But I keep getting this error in /trojanvision/attacks/backdoor/dynamic/input_aware_dynamic.py", line 378, in attack: UnboundLocalError: local variable 'loss_div' referenced before assignment

Thanks in advance.

ain-soph commented 2 years ago

Are you using the most up-to-date code?

GorkaAbad commented 2 years ago

Yes, I think so. I just installed the latest version from GitHub today.

ain-soph commented 2 years ago

Just commit a fix. Could you please try whether it works?

GorkaAbad commented 2 years ago

Thanks for the fast response. Yes, that problem its solved now.

ain-soph commented 2 years ago

Thanks for your report. The error is raised because of the low poison percent and there might be no poisoning data in a batch. I previously didn't take that into consideration.