forked from coqui-ai/TTS
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: define torch safe globals for torch.load
Required for loading some models using torch.load(..., weights_only=True). This is only available from Pytorch 2.4
- Loading branch information
Showing
3 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
import _codecs | ||
import importlib.metadata | ||
from collections import defaultdict | ||
|
||
import numpy as np | ||
import torch | ||
|
||
from TTS.config.shared_configs import BaseDatasetConfig | ||
from TTS.tts.configs.xtts_config import XttsConfig | ||
from TTS.tts.models.xtts import XttsArgs, XttsAudioConfig | ||
from TTS.utils.radam import RAdam | ||
|
||
__version__ = importlib.metadata.version("coqui-tts") | ||
|
||
|
||
torch.serialization.add_safe_globals([dict, defaultdict, RAdam]) | ||
|
||
# Bark | ||
torch.serialization.add_safe_globals( | ||
[ | ||
np.core.multiarray.scalar, | ||
np.dtype, | ||
np.dtypes.Float64DType, | ||
_codecs.encode, # TODO: safe by default from Pytorch 2.5 | ||
] | ||
) | ||
|
||
# XTTS | ||
torch.serialization.add_safe_globals([BaseDatasetConfig, XttsConfig, XttsAudioConfig, XttsArgs]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters