RobustBench / robustbench

RobustBench: a standardized adversarial robustness benchmark [NeurIPS 2021 Benchmarks and Datasets Track]
https://robustbench.github.io
Other
669 stars 99 forks source link

How can I quickly load all corruptions of Imagenet-C? #129

Closed hooxizz closed 1 year ago

hooxizz commented 1 year ago

Hi there,

I try to load all corruptions of Imagenet-C as below: from robustbench.data import load_imagenetc

corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', 'brightness', 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression']

x_test_all = [] y_test_all = []

for i_c, corruption_type in enumerate(corruptions): # continual adaptation for all corruption print('load:', corruption_type) x_test, y_test = load_imagenetc(n_examples=5000, severity=5, data_dir='./data', shuffle=False, corruptions=[corruption_type]) # x_test, y_test = x_test.cuda(), y_test.cuda() x_test_all.append(x_test) y_test_all.append(y_test)

However, I got the error and set num_workers=0 is useless. RuntimeError: DataLoader worker (pid(s) 29578) exited unexpectedly

Do you have any suggestions? Thanks in advance.