TrojanZoo provides a universal pytorch platform to conduct security researches (especially backdoor attacks/defenses) of image classification in deep learning.
Dear developers:
The way to load the dataset in the example is trojanvision.datasets.create(**kwargs).
I'm trying to load a dataset in ImageFolder format:
The format of the dataset to be loaded is '_{self.folder_path}/{self.name}/{mode}/{class_name}/{imgidx}.png'.
So I adjusted the code to:
dataset = trojanvision.datasets.ImageFolder(**kwargs)
And I set in parameter configuration
--color --verbose 1 --validate_interval 1 --dataset mnist --attack badnet --data_dir /home/ubuntu/xx/datasets - --mark_random_init --epochs 50 --lr 0.01
My program has the following error:
Traceback (most recent call last):
File "/home/ubuntu/lrchang/trojanzoo/examples/backdoor_attack.py", line 25, in
dataset = trojanvision.datasets.ImageFolder(kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanvision/datasets/imagefolder.py", line 79, in init
super().init(kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanvision/datasets/imageset.py", line 146, in init
super().init(**kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 154, in init
self.loader['train'] = self.get_dataloader(mode='train')
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 414, in get_dataloader
batch_size = self.batch_size
File "/home/ubuntu/anaconda3/envs/py310/lib/python3.10/functools.py", line 981, in get
val = self.func(instance)
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 175, in batch_size
return self.__batch_size if self.__batch_size >= 0 else \
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
P{'default': None, 'device': device(type='cuda'), 'seed': 1228, 'data_seed': 1228, 'verbose': 1, 'color': True, 'tqdm': False, 'cudnn_benchmark': False, 'num_gpus': 1, 'world_size': 1}
Dataset Folder Path: None
Process finished with exit code 1
How should I adjust the code to load the expected dataset?
Looking forward to your reply~
Dear developers: The way to load the dataset in the example is
trojanvision.datasets.create(**kwargs)
.I'm trying to load a dataset in ImageFolder format: The format of the dataset to be loaded is '_{self.folder_path}/{self.name}/{mode}/{class_name}/{imgidx}.png'.
![image](https://user-images.githubusercontent.com/90193470/226275695-7380e6a7-0e2e-4900-bb9a-5321fa01e688.png)
So I adjusted the code to:
dataset = trojanvision.datasets.ImageFolder(**kwargs)
And I set in parameter configuration
--color --verbose 1 --validate_interval 1 --dataset mnist --attack badnet --data_dir /home/ubuntu/xx/datasets - --mark_random_init --epochs 50 --lr 0.01
My program has the following error: Traceback (most recent call last): File "/home/ubuntu/lrchang/trojanzoo/examples/backdoor_attack.py", line 25, in
dataset = trojanvision.datasets.ImageFolder(kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanvision/datasets/imagefolder.py", line 79, in init
super().init(kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanvision/datasets/imageset.py", line 146, in init
super().init(**kwargs)
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 154, in init
self.loader['train'] = self.get_dataloader(mode='train')
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 414, in get_dataloader
batch_size = self.batch_size
File "/home/ubuntu/anaconda3/envs/py310/lib/python3.10/functools.py", line 981, in get
val = self.func(instance)
File "/home/ubuntu/lrchang/trojanzoo/trojanzoo/datasets.py", line 175, in batch_size
return self.__batch_size if self.__batch_size >= 0 else \
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
P{'default': None, 'device': device(type='cuda'), 'seed': 1228, 'data_seed': 1228, 'verbose': 1, 'color': True, 'tqdm': False, 'cudnn_benchmark': False, 'num_gpus': 1, 'world_size': 1}
Dataset Folder Path: None
Process finished with exit code 1
How should I adjust the code to load the expected dataset? Looking forward to your reply~