Skip to content

Commit

Permalink
fixup! Set weights_only=False when loading models from a trusted source
Browse files Browse the repository at this point in the history
Signed-off-by: Adarsh Anand <[email protected]>
  • Loading branch information
adarshan-intel committed Feb 6, 2025
1 parent f05c57f commit c87149e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pytorch/pytorchexample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from torchvision import models
import torch

# Load the model from a file (This file is from a trusted source)
# Load the model from a file (ensure this file is from a trusted source)
# Note: For PyTorch 2.6 and later, direct unpickling with weights_only=True (which was made the default)
# can fail if the model file contains more than just the weights and includes classes or functions that are not allowlisted.
alexnet = torch.load("alexnet-pretrained.pt", weights_only=False)

# Prepare a transform to get the input image into a format (e.g., x,y dimensions) the classifier
Expand Down

0 comments on commit c87149e

Please sign in to comment.