Harry24k / adversarial-attacks-pytorch

PyTorch implementation of adversarial attacks [torchattacks]
https://adversarial-attacks-pytorch.readthedocs.io/en/latest/index.html
MIT License
1.85k stars 345 forks source link

Errors when downloading models from model zoom #195

Open JAMES-YI opened 1 month ago

JAMES-YI commented 1 month ago

✨ Short description of the bug [tl;dr]

When I tried to run the following: adversarial-attacks-pytorch/demo /White-box Attack on CIFAR10.ipynb, the model file "Standard.pt" does not look right and it has has size of 3kb.

Here is the error reported File "...\anaconda3\envs\PTC2-2-1\Lib\site-packages\robustbench\utils.py", line 135, in load_model checkpoint = torch.load(model_path, map_location=torch.device('cpu')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "...\anaconda3\envs\PTC2-2-1\Lib\site-packages\torch\serialization.py", line 1040, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "...\anaconda3\envs\PTC2-2-1\Lib\site-packages\torch\serialization.py", line 1258, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _pickle.UnpicklingError: invalid load key, '<'.

💬 Detailed code and results

sys.path.insert(0, '..') import robustbench from robustbench.data import load_cifar10 from robustbench.utils import load_model, clean_accuracy

images, labels = load_cifar10(n_examples=5) print('[Data loaded]')

device = "cuda" model = load_model('Standard', norm='Linf').to(device) acc = clean_accuracy(model, images.to(device), labels.to(device)) print('[Model loaded]') print('Acc: %2.2f %%'%(acc*100))

rikonaka commented 1 month ago

Hi, This bug is caused by robustbench, you can refer to this https://github.com/Harry24k/adversarial-attacks-pytorch/issues/166 to use the new test code.