Skip to content

Commit 215a3ed

Browse files
committed
fix: remove outdated codes & add weights_only=True
1 parent 34f28d9 commit 215a3ed

File tree

6 files changed

+15
-49
lines changed

6 files changed

+15
-49
lines changed

infer/lib/rvcmd.py

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -198,44 +198,10 @@ def download_all_assets(tmpdir: str, version="0.2.5"):
198198
suffix = "zip" if is_win else "tar.gz"
199199
RVCMD_URL = BASE_URL + f"v{version}/rvcmd_{system_type}_{architecture}.{suffix}"
200200
cmdfile = os.path.join(tmpdir, "rvcmd")
201-
try:
202-
if is_win:
203-
download_and_extract_zip(RVCMD_URL, tmpdir)
204-
cmdfile += ".exe"
205-
else:
206-
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
207-
os.chmod(cmdfile, 0o755)
208-
subprocess.run([cmdfile, "-notui", "-w", "0", "assets/rvc"])
209-
except Exception:
210-
BASE_URL = "https://raw.gitcode.com/u011570312/RVC-Models-Downloader/assets/"
211-
suffix = {
212-
"darwin_amd64": "555",
213-
"darwin_arm64": "556",
214-
"linux_386": "557",
215-
"linux_amd64": "558",
216-
"linux_arm64": "559",
217-
"windows_386": "562",
218-
"windows_amd64": "563",
219-
}[f"{system_type}_{architecture}"]
220-
RVCMD_URL = BASE_URL + suffix
221-
download_dns_yaml(
222-
"https://raw.gitcode.com/u011570312/RVC-Models-Downloader/raw/main/dns.yaml",
223-
tmpdir,
224-
)
225-
if is_win:
226-
download_and_extract_zip(RVCMD_URL, tmpdir)
227-
cmdfile += ".exe"
228-
else:
229-
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
230-
os.chmod(cmdfile, 0o755)
231-
subprocess.run(
232-
[
233-
cmdfile,
234-
"-notui",
235-
"-w",
236-
"0",
237-
"-dns",
238-
os.path.join(tmpdir, "dns.yaml"),
239-
"assets/rvc",
240-
]
241-
)
201+
if is_win:
202+
download_and_extract_zip(RVCMD_URL, tmpdir)
203+
cmdfile += ".exe"
204+
else:
205+
download_and_extract_tar_gz(RVCMD_URL, tmpdir)
206+
os.chmod(cmdfile, 0o755)
207+
subprocess.run([cmdfile, "-notui", "-w", "0", "assets/rvc"])

infer/lib/train/data_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def get_audio(self, filename):
303303
spec_filename = filename.replace(".wav", ".spec.pt")
304304
if os.path.exists(spec_filename):
305305
try:
306-
spec = torch.load(spec_filename)
306+
spec = torch.load(spec_filename, weights_only=True)
307307
except:
308308
logger.warning("%s %s", spec_filename, traceback.format_exc())
309309
spec = spectrogram_torch(

infer/lib/train/process_ckpt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def save_small_model(ckpt, sr, if_f0, name, epoch, version, hps):
5959

6060
def extract_small_model(path, name, author, sr, if_f0, info, version):
6161
try:
62-
ckpt = torch.load(path, map_location="cpu")
62+
ckpt = torch.load(path, map_location="cpu", weights_only=True)
6363
if "model" in ckpt:
6464
ckpt = ckpt["model"]
6565
opt = OrderedDict()
@@ -196,7 +196,7 @@ def extract_small_model(path, name, author, sr, if_f0, info, version):
196196

197197
def change_info(path, info, name):
198198
try:
199-
ckpt = torch.load(path, map_location="cpu")
199+
ckpt = torch.load(path, map_location="cpu", weights_only=True)
200200
ckpt["info"] = info
201201
if name == "":
202202
name = os.path.basename(path)
@@ -229,8 +229,8 @@ def authors(c1, c2):
229229
a2 = "Unknown"
230230
return f"{a1} & {a2}"
231231

232-
ckpt1 = torch.load(path1, map_location="cpu")
233-
ckpt2 = torch.load(path2, map_location="cpu")
232+
ckpt1 = torch.load(path1, map_location="cpu", weights_only=True)
233+
ckpt2 = torch.load(path2, map_location="cpu", weights_only=True)
234234
cfg = ckpt1["config"]
235235
if "model" in ckpt1:
236236
ckpt1 = extract(ckpt1)

infer/modules/uvr5/vr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, agg, model_path, device, is_half, tta=False):
3737
else:
3838
mp = ModelParameters("infer/lib/uvr5_pack/lib_v5/modelparams/4band_v2.json")
3939
model = Nets.CascadedASPPNet(mp.param["bins"] * 2)
40-
cpk = torch.load(model_path, map_location="cpu")
40+
cpk = torch.load(model_path, map_location="cpu", weights_only=True)
4141
model.load_state_dict(cpk)
4242
model.eval()
4343
if is_half:

infer/modules/vc/hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def model_hash_ckpt(cpt):
152152

153153

154154
def model_hash_from(path):
155-
cpt = torch.load(path, map_location="cpu")
155+
cpt = torch.load(path, map_location="cpu", weights_only=True)
156156
h = model_hash_ckpt(cpt)
157157
del cpt
158158
return h

infer/modules/vc/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def show_info(path):
7575
try:
7676
if hasattr(path, "name"):
7777
path = path.name
78-
a = torch.load(path, map_location="cpu")
78+
a = torch.load(path, map_location="cpu", weights_only=True)
7979
txt = show_model_info(a, show_long_id=True)
8080
del a
8181
except:

0 commit comments

Comments
 (0)