43
43
now_dir = os .getcwd ()
44
44
tmp = os .path .join (now_dir , "TEMP" )
45
45
shutil .rmtree (tmp , ignore_errors = True )
46
- shutil .rmtree (
47
- "%s/runtime/Lib/site-packages/infer_pack" % (now_dir ), ignore_errors = True
48
- )
46
+ shutil .rmtree ("%s/runtime/Lib/site-packages/infer_pack" % (now_dir ), ignore_errors = True )
49
47
shutil .rmtree ("%s/runtime/Lib/site-packages/uvr5_pack" % (now_dir ), ignore_errors = True )
50
48
os .makedirs (tmp , exist_ok = True )
51
49
os .makedirs (os .path .join (now_dir , "logs" ), exist_ok = True )
@@ -570,21 +568,23 @@ def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
570
568
571
569
572
570
# but2.click(extract_f0,[gpus6,np7,f0method8,if_f0_3,trainset_dir4],[info2])
573
- def extract_f0_feature (gpus , n_p , f0method , if_f0 , exp_dir , version19 ,gpus_rmvpe ):
571
+ def extract_f0_feature (gpus , n_p , f0method , if_f0 , exp_dir , version19 , gpus_rmvpe ):
574
572
gpus = gpus .split ("-" )
575
573
os .makedirs ("%s/logs/%s" % (now_dir , exp_dir ), exist_ok = True )
576
574
f = open ("%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "w" )
577
575
f .close ()
578
576
if if_f0 :
579
- if ( f0method != "rmvpe_gpu" ) :
577
+ if f0method != "rmvpe_gpu" :
580
578
cmd = config .python_cmd + ' extract_f0_print.py "%s/logs/%s" %s %s' % (
581
579
now_dir ,
582
580
exp_dir ,
583
581
n_p ,
584
582
f0method ,
585
583
)
586
584
print (cmd )
587
- p = Popen (cmd , shell = True , cwd = now_dir ) # , stdin=PIPE, stdout=PIPE,stderr=PIPE
585
+ p = Popen (
586
+ cmd , shell = True , cwd = now_dir
587
+ ) # , stdin=PIPE, stdout=PIPE,stderr=PIPE
588
588
###煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
589
589
done = [False ]
590
590
threading .Thread (
@@ -602,7 +602,9 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19,gpus_rmvpe
602
602
sleep (1 )
603
603
if done [0 ]:
604
604
break
605
- with open ("%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r" ) as f :
605
+ with open (
606
+ "%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r"
607
+ ) as f :
606
608
log = f .read ()
607
609
print (log )
608
610
yield log
@@ -612,16 +614,9 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19,gpus_rmvpe
612
614
ps = []
613
615
for idx , n_g in enumerate (gpus_rmvpe ):
614
616
cmd = (
615
- config .python_cmd
616
- + ' extract_f0_rmvpe.py %s %s %s "%s/logs/%s" %s '
617
- % (
618
- leng ,
619
- idx ,
620
- n_g ,
621
- now_dir ,
622
- exp_dir ,
623
- config .is_half
624
- )
617
+ config .python_cmd
618
+ + ' extract_f0_rmvpe.py %s %s %s "%s/logs/%s" %s '
619
+ % (leng , idx , n_g , now_dir , exp_dir , config .is_half )
625
620
)
626
621
print (cmd )
627
622
p = Popen (
@@ -638,12 +633,16 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19,gpus_rmvpe
638
633
),
639
634
).start ()
640
635
while 1 :
641
- with open ("%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r" ) as f :
636
+ with open (
637
+ "%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r"
638
+ ) as f :
642
639
yield (f .read ())
643
640
sleep (1 )
644
641
if done [0 ]:
645
642
break
646
- with open ("%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r" ) as f :
643
+ with open (
644
+ "%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir ), "r"
645
+ ) as f :
647
646
log = f .read ()
648
647
print (log )
649
648
yield log
@@ -1037,7 +1036,8 @@ def train1key(
1037
1036
gpus16 ,
1038
1037
if_cache_gpu17 ,
1039
1038
if_save_every_weights18 ,
1040
- version19 ,gpus_rmvpe
1039
+ version19 ,
1040
+ gpus_rmvpe ,
1041
1041
):
1042
1042
infos = []
1043
1043
@@ -1074,7 +1074,7 @@ def get_info_str(strr):
1074
1074
open (extract_f0_feature_log_path , "w" )
1075
1075
if if_f0_3 :
1076
1076
yield get_info_str ("step2a:正在提取音高" )
1077
- if ( f0method8 != "rmvpe_gpu" ) :
1077
+ if f0method8 != "rmvpe_gpu" :
1078
1078
cmd = config .python_cmd + ' extract_f0_print.py "%s" %s %s' % (
1079
1079
model_log_dir ,
1080
1080
np7 ,
@@ -1088,16 +1088,12 @@ def get_info_str(strr):
1088
1088
leng = len (gpus_rmvpe )
1089
1089
ps = []
1090
1090
for idx , n_g in enumerate (gpus_rmvpe ):
1091
- cmd = (
1092
- config .python_cmd
1093
- + ' extract_f0_rmvpe.py %s %s %s "%s" %s '
1094
- % (
1095
- leng ,
1096
- idx ,
1097
- n_g ,
1098
- model_log_dir ,
1099
- config .is_half
1100
- )
1091
+ cmd = config .python_cmd + ' extract_f0_rmvpe.py %s %s %s "%s" %s ' % (
1092
+ leng ,
1093
+ idx ,
1094
+ n_g ,
1095
+ model_log_dir ,
1096
+ config .is_half ,
1101
1097
)
1102
1098
yield get_info_str (cmd )
1103
1099
p = Popen (
@@ -1318,11 +1314,15 @@ def change_info_(ckpt_path):
1318
1314
traceback .print_exc ()
1319
1315
return {"__type__" : "update" }, {"__type__" : "update" }, {"__type__" : "update" }
1320
1316
1317
+
1321
1318
def change_f0_method (f0method8 ):
1322
- if (f0method8 == "rmvpe_gpu" ):visible = True
1323
- else :visible = False
1319
+ if f0method8 == "rmvpe_gpu" :
1320
+ visible = True
1321
+ else :
1322
+ visible = False
1324
1323
return {"visible" : visible , "__type__" : "update" }
1325
1324
1325
+
1326
1326
def export_onnx (ModelPath , ExportedPath ):
1327
1327
global cpt
1328
1328
cpt = torch .load (ModelPath , map_location = "cpu" )
@@ -1755,10 +1755,12 @@ def export_onnx(ModelPath, ExportedPath):
1755
1755
interactive = True ,
1756
1756
)
1757
1757
gpus_rmvpe = gr .Textbox (
1758
- label = i18n ("rmvpe卡号配置:以-分隔输入使用的不同进程卡号,例如0-0-1使用在卡0上跑2个进程并在卡1上跑1个进程" ),
1759
- value = "%s-%s" % (gpus ,gpus ),
1758
+ label = i18n (
1759
+ "rmvpe卡号配置:以-分隔输入使用的不同进程卡号,例如0-0-1使用在卡0上跑2个进程并在卡1上跑1个进程"
1760
+ ),
1761
+ value = "%s-%s" % (gpus , gpus ),
1760
1762
interactive = True ,
1761
- visible = True
1763
+ visible = True ,
1762
1764
)
1763
1765
but2 = gr .Button (i18n ("特征提取" ), variant = "primary" )
1764
1766
info2 = gr .Textbox (label = i18n ("输出信息" ), value = "" , max_lines = 8 )
@@ -1769,7 +1771,15 @@ def export_onnx(ModelPath, ExportedPath):
1769
1771
)
1770
1772
but2 .click (
1771
1773
extract_f0_feature ,
1772
- [gpus6 , np7 , f0method8 , if_f0_3 , exp_dir1 , version19 ,gpus_rmvpe ],
1774
+ [
1775
+ gpus6 ,
1776
+ np7 ,
1777
+ f0method8 ,
1778
+ if_f0_3 ,
1779
+ exp_dir1 ,
1780
+ version19 ,
1781
+ gpus_rmvpe ,
1782
+ ],
1773
1783
[info2 ],
1774
1784
)
1775
1785
with gr .Group ():
@@ -1894,7 +1904,8 @@ def export_onnx(ModelPath, ExportedPath):
1894
1904
gpus16 ,
1895
1905
if_cache_gpu17 ,
1896
1906
if_save_every_weights18 ,
1897
- version19 ,gpus_rmvpe
1907
+ version19 ,
1908
+ gpus_rmvpe ,
1898
1909
],
1899
1910
info3 ,
1900
1911
)
0 commit comments