examples
examples copied to clipboard
Update pytorch weights_only parameter to False
- Updated pytorchexample.py to set the weights_only argument to False when calling torch.load.
- This change resolves the UnpicklingError encountered when loading the pre-trained model. Fixes #113
Previously, mkow (Michał Kowalczyk) wrote…
What's "direct unpickling" exactly? For me it sounds like the direct one would be with
weights_only=False, notTrue.
Direct unpickling loads a serialized object (e.g., a PyTorch model) directly from a file using Python's pickle module, which can execute arbitrary code and pose a security risk if the file is untrusted.
In PyTorch, weights_only=True loads only the model's weights, avoiding potentially harmful code. However, if the model file contains more than just weights (e.g., custom classes or functions), weights_only=True might fail. Using weights_only=False loads the entire model, including any custom components, but is riskier if the source is untrusted.