examples icon indicating copy to clipboard operation
examples copied to clipboard

Update pytorch weights_only parameter to False

Open adarshan-intel opened this issue 10 months ago • 1 comments

  • 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

This change is Reviewable

adarshan-intel avatar Feb 04 '25 08:02 adarshan-intel

-- commits line 5 at r2:

Previously, mkow (Michał Kowalczyk) wrote…

What's "direct unpickling" exactly? For me it sounds like the direct one would be with weights_only=False, not True.

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.

adarshan-intel avatar Feb 10 '25 04:02 adarshan-intel