mirror of
https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-06-07 19:40:44 +08:00
fix: no attribute 'FILE_LIKE'' & update instructions
This commit is contained in:
@@ -5,6 +5,8 @@ import os
|
||||
|
||||
import torch
|
||||
|
||||
from rvc.utils import FileLike
|
||||
|
||||
|
||||
def load_pickle(path: str):
|
||||
with open(path, "rb") as f:
|
||||
@@ -16,7 +18,7 @@ def save_pickle(ckpt: dict, save_path: str):
|
||||
pickle.dump(ckpt, f)
|
||||
|
||||
|
||||
def load_inputs(path: torch.serialization.FILE_LIKE, device: str, is_half=False):
|
||||
def load_inputs(path: FileLike, device: str, is_half=False): # type: ignore
|
||||
parm = torch.load(path, map_location=torch.device("cpu"))
|
||||
for key in parm.keys():
|
||||
parm[key] = parm[key].to(device)
|
||||
|
||||
@@ -4,6 +4,7 @@ import torch
|
||||
|
||||
from .layers.synthesizers import SynthesizerTrnMsNSFsid
|
||||
from .jit import load_inputs, export_jit_model, save_pickle
|
||||
from .utils import FileLike
|
||||
|
||||
|
||||
def get_synthesizer(cpt: OrderedDict, device=torch.device("cpu")):
|
||||
@@ -28,7 +29,7 @@ def get_synthesizer(cpt: OrderedDict, device=torch.device("cpu")):
|
||||
|
||||
|
||||
def load_synthesizer(
|
||||
pth_path: torch.serialization.FILE_LIKE, device=torch.device("cpu")
|
||||
pth_path: FileLike, device=torch.device("cpu") # type: ignore
|
||||
):
|
||||
return get_synthesizer(
|
||||
torch.load(pth_path, map_location=torch.device("cpu"), weights_only=True),
|
||||
|
||||
1
rvc/utils/__init__.py
Normal file
1
rvc/utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .io import FileLike
|
||||
10
rvc/utils/io.py
Normal file
10
rvc/utils/io.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
from typing import Union, IO
|
||||
import torch
|
||||
|
||||
if hasattr(torch.serialization, "FILE_LIKE"):
|
||||
FileLike = torch.serialization.FILE_LIKE
|
||||
elif hasattr(torch.types, "FILE_LIKE"):
|
||||
FileLike = torch.types.FileLike
|
||||
else:
|
||||
FileLike = Union[str, os.PathLike, IO[bytes]]
|
||||
Reference in New Issue
Block a user