RobustBench / robustbench

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

load model issue using pickle #87

Closed lizaitang closed 2 years ago

lizaitang commented 2 years ago

When I am using python 3.8 to load the image net model , the code reports that File "/home/zaitang/anaconda3/envs/pytorch/lib/python3.9/site-packages/torch/serialization.py", line 762, in _legacy_load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: invalid load key, '<'.

Could you please help to fix it?

fra31 commented 2 years ago

Hi,

this is probably related. Please let me know if that helps to solve it.

lizaitang commented 2 years ago

Sorry, but still not fixed, I have tried the method.

fra31 commented 2 years ago

Could you please try to delete also the previously downloaded checkpoint (if a file with the same name exists it doesn't get downloaded again)?

lizaitang commented 2 years ago

Sorry but I have also tried.

lizaitang commented 2 years ago

Thank you so much, I just solved it, for anyone with same issue, you need to uninstall robustbench first and reinstall with latest version. Thanks again!

fra31 commented 2 years ago

Ok, good!

lizaitang commented 2 years ago

Thanks, another small issue is that I am using a imagenet dataset generated by GAN , to check the accuracy on the load_model , which preprocessing should be implemented?

fra31 commented 2 years ago

I think one usually keeps the same preprocessing used during training. For the models in the Model Zoo we specify for each classifier the preprocessing (see here).

lizaitang commented 2 years ago

Thanks, which means we do not need to do preprocessing by ourselves? Just load the model?

fra31 commented 2 years ago

For the models in the Model Zoo, the preprocessing is done automatically when loading the dataset. If you want to evaluate other models, you can either specify one of the predefined preprocessing methods here or pass a customized one with https://github.com/RobustBench/robustbench/blob/df316217f4bb929e96525044e3aca620238b6f16/robustbench/eval.py#L33 in the benchmark function.