Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aca1bbc

Browse files
committed
fix: use weights_only=True for safe PyTorch model loading
Replace unsafe `torch.load(path)` with `torch.load(path, map_location=self.device, weights_only=True)` to prevent pickle deserialization RCE (trailofbits.python.pickles-in-pytorch). weights_only=True disables pickle entirely for model loading, which is the PyTorch-recommended mitigation (available since 1.13). Also adds map_location for correct CPU/GPU device mapping. Closes ruvnet#106 Co-Authored-By: claude-flow <[email protected]>
1 parent 2ad5107 commit aca1bbc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

references/wifi_densepose_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def save_model(self, path):
441441
}, path)
442442

443443
def load_model(self, path):
444-
checkpoint = torch.load(path)
444+
checkpoint = torch.load(path, map_location=self.device, weights_only=True)
445445
self.model.load_state_dict(checkpoint['model_state_dict'])
446446
self.optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
447447

0 commit comments

Comments
 (0)