1
1
from multiprocessing import cpu_count
2
2
import threading
3
3
from time import sleep
4
- from subprocess import Popen , PIPE , run as runn
4
+ from subprocess import Popen
5
5
from time import sleep
6
- import torch , pdb , os ,traceback ,sys ,warnings ,shutil ,numpy as np ,faiss
6
+ import torch , os ,traceback ,sys ,warnings ,shutil ,numpy as np
7
+ import faiss
7
8
#判断是否有能用来训练和加速推理的N卡
8
9
ncpu = cpu_count ()
9
10
ngpu = torch .cuda .device_count ()
33
34
from scipy .io import wavfile
34
35
from fairseq import checkpoint_utils
35
36
import gradio as gr
36
- import librosa
37
37
import logging
38
38
from vc_infer_pipeline import VC
39
- import soundfile as sf
40
- from config import is_half ,device ,is_half
39
+ from config import is_half ,device ,is_half ,python_cmd ,listen_port ,iscolab ,noparallel
41
40
from infer_uvr5 import _audio_pre_
42
41
from my_utils import load_audio
43
42
from train .process_ckpt import show_info ,change_info ,merge ,extract_small_model
@@ -222,7 +221,7 @@ def preprocess_dataset(trainset_dir,exp_dir,sr,n_p=ncpu):
222
221
os .makedirs ("%s/logs/%s" % (now_dir ,exp_dir ),exist_ok = True )
223
222
f = open ("%s/logs/%s/preprocess.log" % (now_dir ,exp_dir ), "w" )
224
223
f .close ()
225
- cmd = "python trainset_preprocess_pipeline_print.py %s %s %s %s/logs/%s"% (trainset_dir ,sr ,n_p ,now_dir ,exp_dir )
224
+ cmd = python_cmd + " trainset_preprocess_pipeline_print.py %s %s %s %s/logs/%s "% (trainset_dir ,sr ,n_p ,now_dir ,exp_dir ) + str ( noparallel )
226
225
print (cmd )
227
226
p = Popen (cmd , shell = True )#, stdin=PIPE, stdout=PIPE,stderr=PIPE,cwd=now_dir
228
227
###煞笔gr,popen read都非得全跑完了再一次性读取,不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
@@ -242,7 +241,7 @@ def extract_f0_feature(gpus,n_p,f0method,if_f0,exp_dir):
242
241
f = open ("%s/logs/%s/extract_f0_feature.log" % (now_dir ,exp_dir ), "w" )
243
242
f .close ()
244
243
if (if_f0 == "是" ):
245
- cmd = "python extract_f0_print.py %s/logs/%s %s %s"% (now_dir ,exp_dir ,n_p ,f0method )
244
+ cmd = python_cmd + " extract_f0_print.py %s/logs/%s %s %s"% (now_dir ,exp_dir ,n_p ,f0method )
246
245
print (cmd )
247
246
p = Popen (cmd , shell = True ,cwd = now_dir )#, stdin=PIPE, stdout=PIPE,stderr=PIPE
248
247
###煞笔gr,popen read都非得全跑完了再一次性读取,不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
@@ -266,7 +265,7 @@ def extract_f0_feature(gpus,n_p,f0method,if_f0,exp_dir):
266
265
leng = len (gpus )
267
266
ps = []
268
267
for idx ,n_g in enumerate (gpus ):
269
- cmd = "python extract_feature_print.py %s %s %s %s/logs/%s"% (leng ,idx ,n_g ,now_dir ,exp_dir )
268
+ cmd = python_cmd + " extract_feature_print.py %s %s %s %s/logs/%s"% (leng ,idx ,n_g ,now_dir ,exp_dir )
270
269
print (cmd )
271
270
p = Popen (cmd , shell = True , cwd = now_dir )#, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
272
271
ps .append (p )
@@ -305,8 +304,8 @@ def click_train(exp_dir1,sr2,if_f0_3,spk_id5,save_epoch10,total_epoch11,batch_si
305
304
with open ("%s/filelist.txt" % exp_dir ,"w" )as f :f .write ("\n " .join (opt ))
306
305
print ("write filelist done" )
307
306
#生成config#无需生成config
308
- # cmd = "python train_nsf_sim_cache_sid_load_pretrain.py -e mi-test -sr 40k -f0 1 -bs 4 -g 0 -te 10 -se 5 -pg pretrained/f0G40k.pth -pd pretrained/f0D40k.pth -l 1 -c 0"
309
- cmd = "python train_nsf_sim_cache_sid_load_pretrain.py -e %s -sr %s -f0 %s -bs %s -g %s -te %s -se %s -pg %s -pd %s -l %s -c %s" % (exp_dir1 ,sr2 ,1 if if_f0_3 == "是" else 0 ,batch_size12 ,gpus16 ,total_epoch11 ,save_epoch10 ,pretrained_G14 ,pretrained_D15 ,1 if if_save_latest13 == "是" else 0 ,1 if if_cache_gpu17 == "是" else 0 )
307
+ # cmd = python_cmd + " train_nsf_sim_cache_sid_load_pretrain.py -e mi-test -sr 40k -f0 1 -bs 4 -g 0 -te 10 -se 5 -pg pretrained/f0G40k.pth -pd pretrained/f0D40k.pth -l 1 -c 0"
308
+ cmd = python_cmd + " train_nsf_sim_cache_sid_load_pretrain.py -e %s -sr %s -f0 %s -bs %s -g %s -te %s -se %s -pg %s -pd %s -l %s -c %s" % (exp_dir1 ,sr2 ,1 if if_f0_3 == "是" else 0 ,batch_size12 ,gpus16 ,total_epoch11 ,save_epoch10 ,pretrained_G14 ,pretrained_D15 ,1 if if_save_latest13 == "是" else 0 ,1 if if_cache_gpu17 == "是" else 0 )
310
309
print (cmd )
311
310
p = Popen (cmd , shell = True , cwd = now_dir )
312
311
p .wait ()
@@ -351,7 +350,7 @@ def get_info_str(strr):
351
350
os .makedirs ("%s/logs/%s" % (now_dir ,exp_dir1 ),exist_ok = True )
352
351
#########step1:处理数据
353
352
open ("%s/logs/%s/preprocess.log" % (now_dir ,exp_dir1 ), "w" ).close ()
354
- cmd = "python trainset_preprocess_pipeline_print.py %s %s %s %s/logs/%s"% (trainset_dir4 ,sr_dict [sr2 ],ncpu ,now_dir ,exp_dir1 )
353
+ cmd = python_cmd + " trainset_preprocess_pipeline_print.py %s %s %s %s/logs/%s "% (trainset_dir4 ,sr_dict [sr2 ],ncpu ,now_dir ,exp_dir1 ) + str ( noparallel )
355
354
yield get_info_str ("step1:正在处理数据" )
356
355
yield get_info_str (cmd )
357
356
p = Popen (cmd , shell = True )
@@ -361,7 +360,7 @@ def get_info_str(strr):
361
360
open ("%s/logs/%s/extract_f0_feature.log" % (now_dir , exp_dir1 ), "w" )
362
361
if (if_f0_3 == "是" ):
363
362
yield get_info_str ("step2a:正在提取音高" )
364
- cmd = "python extract_f0_print.py %s/logs/%s %s %s"% (now_dir ,exp_dir1 ,np7 ,f0method8 )
363
+ cmd = python_cmd + " extract_f0_print.py %s/logs/%s %s %s"% (now_dir ,exp_dir1 ,np7 ,f0method8 )
365
364
yield get_info_str (cmd )
366
365
p = Popen (cmd , shell = True ,cwd = now_dir )
367
366
p .wait ()
@@ -373,7 +372,7 @@ def get_info_str(strr):
373
372
leng = len (gpus )
374
373
ps = []
375
374
for idx ,n_g in enumerate (gpus ):
376
- cmd = "python extract_feature_print.py %s %s %s %s/logs/%s"% (leng ,idx ,n_g ,now_dir ,exp_dir1 )
375
+ cmd = python_cmd + " extract_feature_print.py %s %s %s %s/logs/%s"% (leng ,idx ,n_g ,now_dir ,exp_dir1 )
377
376
yield get_info_str (cmd )
378
377
p = Popen (cmd , shell = True , cwd = now_dir )#, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
379
378
ps .append (p )
@@ -399,7 +398,7 @@ def get_info_str(strr):
399
398
opt .append ("%s/%s.wav|%s/%s.npy|%s" % (gt_wavs_dir .replace ("\\ " ,"\\ \\ " ),name ,co256_dir .replace ("\\ " ,"\\ \\ " ),name ,spk_id5 ))
400
399
with open ("%s/filelist.txt" % exp_dir ,"w" )as f :f .write ("\n " .join (opt ))
401
400
yield get_info_str ("write filelist done" )
402
- cmd = "python train_nsf_sim_cache_sid_load_pretrain.py -e %s -sr %s -f0 %s -bs %s -g %s -te %s -se %s -pg %s -pd %s -l %s -c %s" % (exp_dir1 ,sr2 ,1 if if_f0_3 == "是" else 0 ,batch_size12 ,gpus16 ,total_epoch11 ,save_epoch10 ,pretrained_G14 ,pretrained_D15 ,1 if if_save_latest13 == "是" else 0 ,1 if if_cache_gpu17 == "是" else 0 )
401
+ cmd = python_cmd + " train_nsf_sim_cache_sid_load_pretrain.py -e %s -sr %s -f0 %s -bs %s -g %s -te %s -se %s -pg %s -pd %s -l %s -c %s" % (exp_dir1 ,sr2 ,1 if if_f0_3 == "是" else 0 ,batch_size12 ,gpus16 ,total_epoch11 ,save_epoch10 ,pretrained_G14 ,pretrained_D15 ,1 if if_save_latest13 == "是" else 0 ,1 if if_cache_gpu17 == "是" else 0 )
403
402
yield get_info_str (cmd )
404
403
p = Popen (cmd , shell = True , cwd = now_dir )
405
404
p .wait ()
@@ -630,11 +629,7 @@ def change_info_(ckpt_path):
630
629
with gr .TabItem ("点击查看交流、问题反馈群号" ):
631
630
gr .Markdown (value = """xxxxx""" )
632
631
633
- import argparse
634
- parser = argparse .ArgumentParser ()
635
- parser .add_argument ("--colab" , action = 'store_true' , help = "Launch in colab" )
636
- cmd_opts = parser .parse_args ()
637
- if cmd_opts .colab :
632
+ if iscolab :
638
633
app .queue (concurrency_count = 511 , max_size = 1022 ).launch (share = True )
639
634
else :
640
- app .queue (concurrency_count = 511 , max_size = 1022 ).launch (server_name = "0.0.0.0" ,inbrowser = True ,server_port = 7865 ,quiet = True )
635
+ app .queue (concurrency_count = 511 , max_size = 1022 ).launch (server_name = "0.0.0.0" ,inbrowser = True ,server_port = listen_port ,quiet = True )
0 commit comments