Spaces:
Runtime error
Runtime error
Update io.py
Browse files
io.py
CHANGED
|
@@ -30,17 +30,10 @@ def load_fsspec(
|
|
| 30 |
cache: bool = True,
|
| 31 |
**kwargs,
|
| 32 |
) -> Any:
|
| 33 |
-
"""Like torch.load but can load from other locations (e.g. s3:// , gs://).
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
Args:
|
| 36 |
-
path: Any path or url supported by fsspec.
|
| 37 |
-
map_location: torch.device or str.
|
| 38 |
-
cache: If True, cache a remote file locally for subsequent calls. It is cached under `get_user_data_dir()/tts_cache`. Defaults to True.
|
| 39 |
-
**kwargs: Keyword arguments forwarded to torch.load.
|
| 40 |
-
|
| 41 |
-
Returns:
|
| 42 |
-
Object stored in path.
|
| 43 |
-
"""
|
| 44 |
is_local = os.path.isdir(path) or os.path.isfile(path)
|
| 45 |
if cache and not is_local:
|
| 46 |
with fsspec.open(
|
|
@@ -53,7 +46,6 @@ def load_fsspec(
|
|
| 53 |
with fsspec.open(path, "rb") as f:
|
| 54 |
return torch.load(f, map_location=map_location, **kwargs)
|
| 55 |
|
| 56 |
-
|
| 57 |
def load_checkpoint(
|
| 58 |
model, checkpoint_path, use_cuda=False, eval=False, cache=False
|
| 59 |
): # pylint: disable=redefined-builtin
|
|
|
|
| 30 |
cache: bool = True,
|
| 31 |
**kwargs,
|
| 32 |
) -> Any:
|
| 33 |
+
"""Like torch.load but can load from other locations (e.g. s3:// , gs://)."""
|
| 34 |
+
if "weights_only" not in kwargs:
|
| 35 |
+
kwargs["weights_only"] = False # 👈 forzar compatibilidad con checkpoints antiguos
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
is_local = os.path.isdir(path) or os.path.isfile(path)
|
| 38 |
if cache and not is_local:
|
| 39 |
with fsspec.open(
|
|
|
|
| 46 |
with fsspec.open(path, "rb") as f:
|
| 47 |
return torch.load(f, map_location=map_location, **kwargs)
|
| 48 |
|
|
|
|
| 49 |
def load_checkpoint(
|
| 50 |
model, checkpoint_path, use_cuda=False, eval=False, cache=False
|
| 51 |
): # pylint: disable=redefined-builtin
|