fix: PyTorch 2.6 compatibility in piper-sample-generator

Fix torch.load compatibility with PyTorch 2.6

Add weights_only=False parameter to torch.load() call in generate_samples.py
to maintain compatibility with PyTorch 2.6, which changed the default value
of weights_only from False to True. This allows loading models with custom
classes like piper_train.vits.models.SynthesizerTrn.

Fixes model loading error: "Weights only load failed" when using PyTorch 2.6+
This commit is contained in:
Praharsh Bhatt 2025-07-29 20:37:38 -04:00 committed by GitHub
parent 9c1019c932
commit fe411ccb2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,7 +73,7 @@ def generate_samples(
_LOGGER.debug("Loading %s", model)
model_path = Path(model)
torch_model = torch.load(model_path)
torch_model = torch.load(model_path, weights_only=False)
torch_model.eval()
_LOGGER.info("Successfully loaded the model")