1
1
import os
2
2
import shutil
3
- import sys
4
-
5
- now_dir = os .getcwd ()
6
- sys .path .append (now_dir )
7
3
import traceback , pdb
8
4
import warnings
9
5
40
36
41
37
logging .getLogger ("numba" ).setLevel (logging .WARNING )
42
38
43
-
39
+ now_dir = os . getcwd ()
44
40
tmp = os .path .join (now_dir , "TEMP" )
45
41
shutil .rmtree (tmp , ignore_errors = True )
46
42
shutil .rmtree (
@@ -156,6 +152,7 @@ def load_hubert():
156
152
if name .endswith (".pth" ) or "onnx" in name :
157
153
uvr5_names .append (name .replace (".pth" , "" ))
158
154
155
+ cpt = None
159
156
160
157
def vc_single (
161
158
sid ,
@@ -172,7 +169,7 @@ def vc_single(
172
169
rms_mix_rate ,
173
170
protect ,
174
171
): # spk_item, input_audio0, vc_transform0,f0_file,f0method0
175
- global tgt_sr , net_g , vc , hubert_model , version
172
+ global tgt_sr , net_g , vc , hubert_model , version , cpt
176
173
if input_audio_path is None :
177
174
return "You need to upload an audio" , None
178
175
f0_up_key = int (f0_up_key )
@@ -429,9 +426,7 @@ def get_vc(sid, to_return_protect0, to_return_protect1):
429
426
else :
430
427
net_g = SynthesizerTrnMs768NSFsid_nono (* cpt ["config" ])
431
428
del net_g , cpt
432
- if torch .cuda .is_available ():
433
- torch .cuda .empty_cache ()
434
- cpt = None
429
+ if torch .cuda .is_available (): torch .cuda .empty_cache ()
435
430
return {"visible" : False , "__type__" : "update" }
436
431
person = "%s/%s" % (weight_root , sid )
437
432
print ("loading %s" % person )
@@ -1253,6 +1248,7 @@ def change_info_(ckpt_path):
1253
1248
1254
1249
1255
1250
def export_onnx (ModelPath , ExportedPath ):
1251
+ global cpt
1256
1252
cpt = torch .load (ModelPath , map_location = "cpu" )
1257
1253
cpt ["config" ][- 3 ] = cpt ["weight" ]["emb_g.weight" ].shape [0 ]
1258
1254
vec_channels = 256 if cpt .get ("version" , "v1" ) == "v1" else 768
0 commit comments