Spaces:
Sleeping
Sleeping
Update app.py
Browse files1871 unmodified lines18721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421151871 unmodified linesfiles_in_folder = os.listdir(pretrained_folder)num_files = len(files_in_folder)return num_files >= 2if has_two_files_in_pretrained_folder():print("Pretrained weights are downloaded. Training tab enabled!\n-------------------------------")with gr.TabItem("Train", visible=False):with gr.Row():with gr.Column():exp_dir1 = gr.Textbox(label="Voice Name:", value="My-Voice")sr2 = gr.Radio(label=i18n("目标采样率"),choices=["40k", "48k"],value="40k",interactive=True,visible=False)if_f0_3 = gr.Radio(label=i18n("模型是否带音高指导(唱歌一定要, 语音可以不要)"),choices=[True, False],value=True,interactive=True,visible=False)version19 = gr.Radio(label="RVC version",choices=["v1", "v2"],value="v2",interactive=True,visible=False,)np7 = gr.Slider(minimum=0,maximum=config.n_cpu,step=1,label="# of CPUs for data processing (Leave as it is)",value=config.n_cpu,interactive=True,visible=True)trainset_dir4 = gr.Textbox(label="Path to your dataset (audios, not zip):", value="./dataset")easy_uploader = gr.Files(label='OR Drop your audios here. They will be uploaded in your dataset path above.',file_types=['audio'])but1 = gr.Button("1. Process The Dataset", variant="primary")info1 = gr.Textbox(label="Status (wait until it says 'end preprocess'):", value="")easy_uploader.upload(fn=upload_to_dataset, inputs=[easy_uploader, trainset_dir4], outputs=[info1])but1.click(preprocess_dataset, [trainset_dir4, exp_dir1, sr2, np7], [info1])with gr.Column():spk_id5 = gr.Slider(minimum=0,maximum=4,step=1,label=i18n("请指定说话人id"),value=0,interactive=True,visible=False)with gr.Accordion('GPU Settings', open=False, visible=False):gpus6 = gr.Textbox(label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),value=gpus,interactive=True,visible=False)gpu_info9 = gr.Textbox(label=i18n("显卡信息"), value=gpu_info)f0method8 = gr.Radio(label=i18n("选择音高提取算法:输入歌声可用pm提速,高质量语音但CPU差可用dio提速,harvest质量更好但慢"),choices=["harvest","crepe", "mangio-crepe", "rmvpe"], # Fork feature: Crepe on f0 extraction for training.value="rmvpe",interactive=True,)extraction_crepe_hop_length = gr.Slider(minimum=1,maximum=512,step=1,label=i18n("crepe_hop_length"),value=128,interactive=True,visible=False,)f0method8.change(fn=whethercrepeornah, inputs=[f0method8], outputs=[extraction_crepe_hop_length])but2 = gr.Button("2. Pitch Extraction", variant="primary")info2 = gr.Textbox(label="Status(Check the Colab Notebook's cell output):", value="", max_lines=8)but2.click(extract_f0_feature,[gpus6, np7, f0method8, if_f0_3, exp_dir1, version19, extraction_crepe_hop_length],[info2],)with gr.Row():with gr.Column():total_epoch11 = gr.Slider(minimum=1,maximum=5000,step=10,label="Total # of training epochs (IF you choose a value too high, your model will sound horribly overtrained.):",value=250,interactive=True,)butstop = gr.Button("Stop Training",variant='primary',visible=False,)but3 = gr.Button("3. Train Model", variant="primary", visible=True)but3.click(fn=stoptraining, inputs=[gr.Number(value=0, visible=False)], outputs=[but3, butstop])butstop.click(fn=stoptraining, inputs=[gr.Number(value=1, visible=False)], outputs=[butstop, but3])but4 = gr.Button("4.Train Index", variant="primary")info3 = gr.Textbox(label="Status(Check the Colab Notebook's cell output):", value="", max_lines=10)with gr.Accordion("Training Preferences (You can leave these as they are)", open=False):#gr.Markdown(value=i18n("step3: 填写训练设置, 开始训练模型和索引"))with gr.Column():save_epoch10 = gr.Slider(minimum=1,maximum=200,step=1,label="Backup every X amount of epochs:",value=10,interactive=True,)batch_size12 = gr.Slider(minimum=1,maximum=40,step=1,label="Batch Size (LEAVE IT unless you know what you're doing!):",value=default_batch_size,interactive=True,)if_save_latest13 = gr.Checkbox(label="Save only the latest '.ckpt' file to save disk space.",value=True,interactive=True,)if_cache_gpu17 = gr.Checkbox(label="Cache all training sets to GPU memory. Caching small datasets (less than 10 minutes) can speed up training, but caching large datasets will consume a lot of GPU memory and may not provide much speed improvement.",value=False,interactive=True,)if_save_every_weights18 = gr.Checkbox(label="Save a small final model to the 'weights' folder at each save point.",value=True,interactive=True,)zip_model = gr.Button('5. Download Model')zipped_model = gr.Files(label='Your Model and Index file can be downloaded here:')zip_model.click(fn=zip_downloader, inputs=[exp_dir1], outputs=[zipped_model, info3])with gr.Group():with gr.Accordion("Base Model Locations:", open=False, visible=False):pretrained_G14 = gr.Textbox(label=i18n("加载预训练底模G路径"),value="pretrained_v2/f0G40k.pth",interactive=True,)pretrained_D15 = gr.Textbox(label=i18n("加载预训练底模D路径"),value="pretrained_v2/f0D40k.pth",interactive=True,)gpus16 = gr.Textbox(label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),value=gpus,interactive=True,)sr2.change(change_sr2,[sr2, if_f0_3, version19],[pretrained_G14, pretrained_D15, version19],)version19.change(change_version19,[sr2, if_f0_3, version19],[pretrained_G14, pretrained_D15],)if_f0_3.change(change_f0,[if_f0_3, sr2, version19],[f0method8, pretrained_G14, pretrained_D15],)but5 = gr.Button(i18n("一键训练"), variant="primary", visible=False)but3.click(click_train,[exp_dir1,sr2,if_f0_3,spk_id5,save_epoch10,total_epoch11,batch_size12,if_save_latest13,pretrained_G14,pretrained_D15,gpus16,if_cache_gpu17,if_save_every_weights18,version19,],[info3,butstop,but3,],)but4.click(train_index, [exp_dir1, version19], info3)but5.click(train1key,[exp_dir1,sr2,if_f0_3,trainset_dir4,spk_id5,np7,f0method8,save_epoch10,total_epoch11,batch_size12,if_save_latest13,pretrained_G14,pretrained_D15,gpus16,if_cache_gpu17,if_save_every_weights18,version19,extraction_crepe_hop_length],info3,)else:print("Pretrained weights not downloaded. Disabling training tab.\n""Wondering how to train a voice? Join AI HUB Discord Server! https://discord.gg/aihub\n""-------------------------------\n")app.launch(share=False, quiet=False, max_threads=1022)#endpain1871 unmodified lines1872187318741875187618771878187918801881188218831871 unmodified linesfiles_in_folder = os.listdir(pretrained_folder)num_files = len(files_in_folder)return num_files >= 2print("=" * 50,"Disabling Training, as ZeroGPU only supports a running time of 120 seconds.","Please use a local machine, or colab for training.","=" * 50,)app.launch(share=False, quiet=False, max_threads=1022)#endpain
app.py+6-238