Blane187 commited on
Commit
6a38a00
1 Parent(s): fafd9bc

Update web.py

Browse files
Files changed (1) hide show
  1. web.py +0 -912
web.py CHANGED
@@ -799,915 +799,3 @@ def change_f0_method(f0method8):
799
  return {"visible": visible, "__type__": "update"}
800
 
801
 
802
- with gr.Blocks(title="RVC WebUI") as app:
803
- gr.Markdown("## RVC WebUI")
804
- gr.Markdown(
805
- value=i18n(
806
- "This software is open source under the MIT license. The author does not have any control over the software. Users who use the software and distribute the sounds exported by the software are solely responsible. <br>If you do not agree with this clause, you cannot use or reference any codes and files within the software package. See the root directory <b>Agreement-LICENSE.txt</b> for details."
807
- )
808
- )
809
- with gr.Tabs():
810
- with gr.TabItem(i18n("Model Inference")):
811
- with gr.Row():
812
- sid0 = gr.Dropdown(
813
- label=i18n("Inferencing voice"), choices=sorted(names)
814
- )
815
- with gr.Column():
816
- refresh_button = gr.Button(
817
- i18n("Refresh voice list and index path"), variant="primary"
818
- )
819
- clean_button = gr.Button(
820
- i18n("Unload model to save GPU memory"), variant="primary"
821
- )
822
- spk_item = gr.Slider(
823
- minimum=0,
824
- maximum=2333,
825
- step=1,
826
- label=i18n("Select Speaker/Singer ID"),
827
- value=0,
828
- visible=False,
829
- interactive=True,
830
- )
831
- clean_button.click(
832
- fn=clean, inputs=[], outputs=[sid0], api_name="infer_clean"
833
- )
834
- modelinfo = gr.Textbox(label=i18n("Model info"), max_lines=8)
835
- with gr.TabItem(i18n("Single inference")):
836
- with gr.Row():
837
- with gr.Column():
838
- vc_transform0 = gr.Number(
839
- label=i18n(
840
- "Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12)"
841
- ),
842
- value=0,
843
- )
844
- input_audio0 = gr.Audio(
845
- label=i18n("The audio file to be processed"),
846
- type="filepath",
847
- )
848
- file_index2 = gr.Dropdown(
849
- label=i18n(
850
- "Auto-detect index path and select from the dropdown"
851
- ),
852
- choices=sorted(index_paths),
853
- interactive=True,
854
- )
855
- file_index1 = gr.File(
856
- label=i18n(
857
- "Path to the feature index file. Leave blank to use the selected result from the dropdown"
858
- ),
859
- )
860
- with gr.Column():
861
- f0method0 = gr.Radio(
862
- label=i18n(
863
- "Select the pitch extraction algorithm ('pm': faster extraction but lower-quality speech; 'harvest': better bass but extremely slow; 'crepe': better quality but GPU intensive), 'rmvpe': best quality, and little GPU requirement"
864
- ),
865
- choices=(
866
- ["pm", "dio", "harvest", "crepe", "rmvpe", "fcpe"]
867
- ),
868
- value="rmvpe",
869
- interactive=True,
870
- )
871
- resample_sr0 = gr.Slider(
872
- minimum=0,
873
- maximum=48000,
874
- label=i18n(
875
- "Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling"
876
- ),
877
- value=0,
878
- step=1,
879
- interactive=True,
880
- )
881
- rms_mix_rate0 = gr.Slider(
882
- minimum=0,
883
- maximum=1,
884
- label=i18n(
885
- "Adjust the volume envelope scaling. Closer to 0, the more it mimicks the volume of the original vocals. Can help mask noise and make volume sound more natural when set relatively low. Closer to 1 will be more of a consistently loud volume"
886
- ),
887
- value=0.25,
888
- interactive=True,
889
- )
890
- protect0 = gr.Slider(
891
- minimum=0,
892
- maximum=0.5,
893
- label=i18n(
894
- "Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy"
895
- ),
896
- value=0.33,
897
- step=0.01,
898
- interactive=True,
899
- )
900
- filter_radius0 = gr.Slider(
901
- minimum=0,
902
- maximum=7,
903
- label=i18n(
904
- "If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness."
905
- ),
906
- value=3,
907
- step=1,
908
- interactive=True,
909
- )
910
- index_rate1 = gr.Slider(
911
- minimum=0,
912
- maximum=1,
913
- label=i18n("Feature searching ratio"),
914
- value=0.75,
915
- interactive=True,
916
- )
917
- f0_file = gr.File(
918
- label=i18n(
919
- "F0 curve file (optional). One pitch per line. Replaces the default F0 and pitch modulation"
920
- ),
921
- visible=False,
922
- )
923
- but0 = gr.Button(i18n("Convert"), variant="primary")
924
- vc_output2 = gr.Audio(
925
- label=i18n(
926
- "Export audio (click on the three dots in the lower right corner to download)"
927
- )
928
- )
929
-
930
- refresh_button.click(
931
- fn=change_choices,
932
- inputs=[],
933
- outputs=[sid0, file_index2],
934
- api_name="infer_refresh",
935
- )
936
-
937
- vc_output1 = gr.Textbox(label=i18n("Output information"))
938
-
939
- but0.click(
940
- vc.vc_single,
941
- [
942
- spk_item,
943
- input_audio0,
944
- vc_transform0,
945
- f0_file,
946
- f0method0,
947
- file_index1,
948
- file_index2,
949
- # file_big_npy1,
950
- index_rate1,
951
- filter_radius0,
952
- resample_sr0,
953
- rms_mix_rate0,
954
- protect0,
955
- ],
956
- [vc_output1, vc_output2],
957
- api_name="infer_convert",
958
- )
959
- with gr.TabItem(i18n("Batch inference")):
960
- gr.Markdown(
961
- value=i18n(
962
- "Batch conversion. Enter the folder containing the audio files to be converted or upload multiple audio files. The converted audio will be output in the specified folder (default: 'opt')."
963
- )
964
- )
965
- with gr.Row():
966
- with gr.Column():
967
- vc_transform1 = gr.Number(
968
- label=i18n(
969
- "Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12)"
970
- ),
971
- value=0,
972
- )
973
- dir_input = gr.Textbox(
974
- label=i18n(
975
- "Enter the path of the audio folder to be processed (copy it from the address bar of the file manager)"
976
- ),
977
- placeholder="C:\\Users\\Desktop\\input_vocal_dir",
978
- )
979
- inputs = gr.File(
980
- file_count="multiple",
981
- label=i18n(
982
- "Multiple audio files can also be imported. If a folder path exists, this input is ignored."
983
- ),
984
- )
985
- opt_input = gr.Textbox(
986
- label=i18n("Specify output folder"), value="opt"
987
- )
988
- file_index4 = gr.Dropdown(
989
- label=i18n(
990
- "Auto-detect index path and select from the dropdown"
991
- ),
992
- choices=sorted(index_paths),
993
- interactive=True,
994
- )
995
- file_index3 = gr.File(
996
- label=i18n(
997
- "Path to the feature index file. Leave blank to use the selected result from the dropdown"
998
- ),
999
- )
1000
-
1001
- refresh_button.click(
1002
- fn=lambda: change_choices()[1],
1003
- inputs=[],
1004
- outputs=file_index4,
1005
- api_name="infer_refresh_batch",
1006
- )
1007
- # file_big_npy2 = gr.Textbox(
1008
- # label=i18n("特征文件路径"),
1009
- # value="E:\\codes\\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1010
- # interactive=True,
1011
- # )
1012
-
1013
- with gr.Column():
1014
- f0method1 = gr.Radio(
1015
- label=i18n(
1016
- "Select the pitch extraction algorithm ('pm': faster extraction but lower-quality speech; 'harvest': better bass but extremely slow; 'crepe': better quality but GPU intensive), 'rmvpe': best quality, and little GPU requirement"
1017
- ),
1018
- choices=(
1019
- ["pm", "harvest", "crepe", "rmvpe"]
1020
- if config.dml == False
1021
- else ["pm", "harvest", "rmvpe"]
1022
- ),
1023
- value="rmvpe",
1024
- interactive=True,
1025
- )
1026
- resample_sr1 = gr.Slider(
1027
- minimum=0,
1028
- maximum=48000,
1029
- label=i18n(
1030
- "Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling"
1031
- ),
1032
- value=0,
1033
- step=1,
1034
- interactive=True,
1035
- )
1036
- rms_mix_rate1 = gr.Slider(
1037
- minimum=0,
1038
- maximum=1,
1039
- label=i18n(
1040
- "Adjust the volume envelope scaling. Closer to 0, the more it mimicks the volume of the original vocals. Can help mask noise and make volume sound more natural when set relatively low. Closer to 1 will be more of a consistently loud volume"
1041
- ),
1042
- value=1,
1043
- interactive=True,
1044
- )
1045
- protect1 = gr.Slider(
1046
- minimum=0,
1047
- maximum=0.5,
1048
- label=i18n(
1049
- "Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy"
1050
- ),
1051
- value=0.33,
1052
- step=0.01,
1053
- interactive=True,
1054
- )
1055
- filter_radius1 = gr.Slider(
1056
- minimum=0,
1057
- maximum=7,
1058
- label=i18n(
1059
- "If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness."
1060
- ),
1061
- value=3,
1062
- step=1,
1063
- interactive=True,
1064
- )
1065
- index_rate2 = gr.Slider(
1066
- minimum=0,
1067
- maximum=1,
1068
- label=i18n("Feature searching ratio"),
1069
- value=1,
1070
- interactive=True,
1071
- )
1072
- format1 = gr.Radio(
1073
- label=i18n("Export file format"),
1074
- choices=["wav", "flac", "mp3", "m4a"],
1075
- value="wav",
1076
- interactive=True,
1077
- )
1078
- but1 = gr.Button(i18n("Convert"), variant="primary")
1079
- vc_output3 = gr.Textbox(label=i18n("Output information"))
1080
-
1081
- but1.click(
1082
- vc.vc_multi,
1083
- [
1084
- spk_item,
1085
- dir_input,
1086
- opt_input,
1087
- inputs,
1088
- vc_transform1,
1089
- f0method1,
1090
- file_index3,
1091
- file_index4,
1092
- # file_big_npy2,
1093
- index_rate2,
1094
- filter_radius1,
1095
- resample_sr1,
1096
- rms_mix_rate1,
1097
- protect1,
1098
- format1,
1099
- ],
1100
- [vc_output3],
1101
- api_name="infer_convert_batch",
1102
- )
1103
- sid0.change(
1104
- fn=vc.get_vc,
1105
- inputs=[sid0, protect0, protect1, file_index2, file_index4],
1106
- outputs=[
1107
- spk_item,
1108
- protect0,
1109
- protect1,
1110
- file_index2,
1111
- file_index4,
1112
- modelinfo,
1113
- ],
1114
- api_name="infer_change_voice",
1115
- )
1116
- with gr.TabItem(
1117
- i18n("Vocals/Accompaniment Separation & Reverberation Removal")
1118
- ):
1119
- gr.Markdown(
1120
- value=i18n(
1121
- "Batch processing for vocal accompaniment separation using the UVR5 model.<br>Example of a valid folder path format: D:\\path\\to\\input\\folder (copy it from the file manager address bar).<br>The model is divided into three categories:<br>1. Preserve vocals: Choose this option for audio without harmonies. It preserves vocals better than HP5. It includes two built-in models: HP2 and HP3. HP3 may slightly leak accompaniment but preserves vocals slightly better than HP2.<br>2. Preserve main vocals only: Choose this option for audio with harmonies. It may weaken the main vocals. It includes one built-in model: HP5.<br>3. De-reverb and de-delay models (by FoxJoy):<br>  (1) MDX-Net: The best choice for stereo reverb removal but cannot remove mono reverb;<br>&emsp;(234) DeEcho: Removes delay effects. Aggressive mode removes more thoroughly than Normal mode. DeReverb additionally removes reverb and can remove mono reverb, but not very effectively for heavily reverberated high-frequency content.<br>De-reverb/de-delay notes:<br>1. The processing time for the DeEcho-DeReverb model is approximately twice as long as the other two DeEcho models.<br>2. The MDX-Net-Dereverb model is quite slow.<br>3. The recommended cleanest configuration is to apply MDX-Net first and then DeEcho-Aggressive."
1122
- )
1123
- )
1124
- with gr.Row():
1125
- with gr.Column():
1126
- dir_wav_input = gr.Textbox(
1127
- label=i18n(
1128
- "Enter the path of the audio folder to be processed"
1129
- ),
1130
- placeholder="C:\\Users\\Desktop\\todo-songs",
1131
- )
1132
- wav_inputs = gr.File(
1133
- file_count="multiple",
1134
- label=i18n(
1135
- "Multiple audio files can also be imported. If a folder path exists, this input is ignored."
1136
- ),
1137
- )
1138
- with gr.Column():
1139
- model_choose = gr.Dropdown(label=i18n("Model"), choices=uvr5_names)
1140
- agg = gr.Slider(
1141
- minimum=0,
1142
- maximum=20,
1143
- step=1,
1144
- label="人声提取激进程度",
1145
- value=10,
1146
- interactive=True,
1147
- visible=False, # 先不开放调整
1148
- )
1149
- opt_vocal_root = gr.Textbox(
1150
- label=i18n("Specify the output folder for vocals"),
1151
- value="opt",
1152
- )
1153
- opt_ins_root = gr.Textbox(
1154
- label=i18n("Specify the output folder for accompaniment"),
1155
- value="opt",
1156
- )
1157
- format0 = gr.Radio(
1158
- label=i18n("Export file format"),
1159
- choices=["wav", "flac", "mp3", "m4a"],
1160
- value="flac",
1161
- interactive=True,
1162
- )
1163
- but2 = gr.Button(i18n("Convert"), variant="primary")
1164
- vc_output4 = gr.Textbox(label=i18n("Output information"))
1165
- but2.click(
1166
- uvr,
1167
- [
1168
- model_choose,
1169
- dir_wav_input,
1170
- opt_vocal_root,
1171
- wav_inputs,
1172
- opt_ins_root,
1173
- agg,
1174
- format0,
1175
- ],
1176
- [vc_output4],
1177
- api_name="uvr_convert",
1178
- )
1179
- with gr.TabItem(i18n("Train")):
1180
- gr.Markdown(
1181
- value=i18n(
1182
- "### Step 1. Fill in the experimental configuration.\nExperimental data is stored in the 'logs' folder, with each experiment having a separate folder. Manually enter the experiment name path, which contains the experimental configuration, logs, and trained model files."
1183
- )
1184
- )
1185
- with gr.Row():
1186
- exp_dir1 = gr.Textbox(
1187
- label=i18n("Enter the experiment name"), value="mi-test"
1188
- )
1189
- author = gr.Textbox(label=i18n("Model Author (Nullable)"))
1190
- np7 = gr.Slider(
1191
- minimum=0,
1192
- maximum=config.n_cpu,
1193
- step=1,
1194
- label=i18n(
1195
- "Number of CPU processes used for pitch extraction and data processing"
1196
- ),
1197
- value=int(np.ceil(config.n_cpu / 1.5)),
1198
- interactive=True,
1199
- )
1200
- with gr.Row():
1201
- sr2 = gr.Radio(
1202
- label=i18n("Target sample rate"),
1203
- choices=["40k", "48k"],
1204
- value="40k",
1205
- interactive=True,
1206
- )
1207
- if_f0_3 = gr.Radio(
1208
- label=i18n(
1209
- "Whether the model has pitch guidance (required for singing, optional for speech)"
1210
- ),
1211
- choices=[i18n("Yes"), i18n("No")],
1212
- value=i18n("Yes"),
1213
- interactive=True,
1214
- )
1215
- version19 = gr.Radio(
1216
- label=i18n("Version"),
1217
- choices=["v1", "v2"],
1218
- value="v2",
1219
- interactive=True,
1220
- visible=True,
1221
- )
1222
- gr.Markdown(
1223
- value=i18n(
1224
- "### Step 2. Audio processing. \n#### 1. Slicing.\nAutomatically traverse all files in the training folder that can be decoded into audio and perform slice normalization. Generates 2 wav folders in the experiment directory. Currently, only single-singer/speaker training is supported."
1225
- )
1226
- )
1227
- with gr.Row():
1228
- with gr.Column():
1229
- trainset_dir4 = gr.Textbox(
1230
- label=i18n("Enter the path of the training folder"),
1231
- )
1232
- spk_id5 = gr.Slider(
1233
- minimum=0,
1234
- maximum=4,
1235
- step=1,
1236
- label=i18n("Please specify the speaker/singer ID"),
1237
- value=0,
1238
- interactive=True,
1239
- )
1240
- but1 = gr.Button(i18n("Process data"), variant="primary")
1241
- with gr.Column():
1242
- info1 = gr.Textbox(label=i18n("Output information"), value="")
1243
- but1.click(
1244
- preprocess_dataset,
1245
- [trainset_dir4, exp_dir1, sr2, np7],
1246
- [info1],
1247
- api_name="train_preprocess",
1248
- )
1249
- gr.Markdown(
1250
- value=i18n(
1251
- "#### 2. Feature extraction.\nUse CPU to extract pitch (if the model has pitch), use GPU to extract features (select GPU index)."
1252
- )
1253
- )
1254
- with gr.Row():
1255
- with gr.Column():
1256
- gpu_info9 = gr.Textbox(
1257
- label=i18n("GPU Information"),
1258
- value=gpu_info,
1259
- visible=F0GPUVisible,
1260
- )
1261
- gpus6 = gr.Textbox(
1262
- label=i18n(
1263
- "Enter the GPU index(es) separated by '-', e.g., 0-1-2 to use GPU 0, 1, and 2"
1264
- ),
1265
- value=gpus,
1266
- interactive=True,
1267
- visible=F0GPUVisible,
1268
- )
1269
- gpus_rmvpe = gr.Textbox(
1270
- label=i18n(
1271
- "Enter the GPU index(es) separated by '-', e.g., 0-0-1 to use 2 processes in GPU0 and 1 process in GPU1"
1272
- ),
1273
- value="%s-%s" % (gpus, gpus),
1274
- interactive=True,
1275
- visible=F0GPUVisible,
1276
- )
1277
- f0method8 = gr.Radio(
1278
- label=i18n(
1279
- "Select the pitch extraction algorithm: when extracting singing, you can use 'pm' to speed up. For high-quality speech with fast performance, but worse CPU usage, you can use 'dio'. 'harvest' results in better quality but is slower. 'rmvpe' has the best results and consumes less CPU/GPU"
1280
- ),
1281
- choices=["pm", "harvest", "dio", "rmvpe", "rmvpe_gpu"],
1282
- value="rmvpe_gpu",
1283
- interactive=True,
1284
- )
1285
- with gr.Column():
1286
- but2 = gr.Button(i18n("Feature extraction"), variant="primary")
1287
- info2 = gr.Textbox(label=i18n("Output information"), value="")
1288
- f0method8.change(
1289
- fn=change_f0_method,
1290
- inputs=[f0method8],
1291
- outputs=[gpus_rmvpe],
1292
- )
1293
- but2.click(
1294
- extract_f0_feature,
1295
- [
1296
- gpus6,
1297
- np7,
1298
- f0method8,
1299
- if_f0_3,
1300
- exp_dir1,
1301
- version19,
1302
- gpus_rmvpe,
1303
- ],
1304
- [info2],
1305
- api_name="train_extract_f0_feature",
1306
- )
1307
- gr.Markdown(
1308
- value=i18n(
1309
- "### Step 3. Start training.\nFill in the training settings and start training the model and index."
1310
- )
1311
- )
1312
- with gr.Row():
1313
- with gr.Column():
1314
- save_epoch10 = gr.Slider(
1315
- minimum=1,
1316
- maximum=50,
1317
- step=1,
1318
- label=i18n("Save frequency (save_every_epoch)"),
1319
- value=5,
1320
- interactive=True,
1321
- )
1322
- total_epoch11 = gr.Slider(
1323
- minimum=2,
1324
- maximum=1000,
1325
- step=1,
1326
- label=i18n("Total training epochs (total_epoch)"),
1327
- value=20,
1328
- interactive=True,
1329
- )
1330
- batch_size12 = gr.Slider(
1331
- minimum=1,
1332
- maximum=40,
1333
- step=1,
1334
- label=i18n("Batch size per GPU"),
1335
- value=default_batch_size,
1336
- interactive=True,
1337
- )
1338
- if_save_latest13 = gr.Radio(
1339
- label=i18n(
1340
- "Save only the latest '.ckpt' file to save disk space"
1341
- ),
1342
- choices=[i18n("Yes"), i18n("No")],
1343
- value=i18n("No"),
1344
- interactive=True,
1345
- )
1346
- if_cache_gpu17 = gr.Radio(
1347
- label=i18n(
1348
- "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"
1349
- ),
1350
- choices=[i18n("Yes"), i18n("No")],
1351
- value=i18n("No"),
1352
- interactive=True,
1353
- )
1354
- if_save_every_weights18 = gr.Radio(
1355
- label=i18n(
1356
- "Save a small final model to the 'weights' folder at each save point"
1357
- ),
1358
- choices=[i18n("Yes"), i18n("No")],
1359
- value=i18n("No"),
1360
- interactive=True,
1361
- )
1362
- with gr.Column():
1363
- pretrained_G14 = gr.Textbox(
1364
- label=i18n("Load pre-trained base model G path"),
1365
- value="assets/pretrained_v2/f0G40k.pth",
1366
- interactive=True,
1367
- )
1368
- pretrained_D15 = gr.Textbox(
1369
- label=i18n("Load pre-trained base model D path"),
1370
- value="assets/pretrained_v2/f0D40k.pth",
1371
- interactive=True,
1372
- )
1373
- gpus16 = gr.Textbox(
1374
- label=i18n(
1375
- "Enter the GPU index(es) separated by '-', e.g., 0-1-2 to use GPU 0, 1, and 2"
1376
- ),
1377
- value=gpus,
1378
- interactive=True,
1379
- )
1380
- sr2.change(
1381
- change_sr2,
1382
- [sr2, if_f0_3, version19],
1383
- [pretrained_G14, pretrained_D15],
1384
- )
1385
- version19.change(
1386
- change_version19,
1387
- [sr2, if_f0_3, version19],
1388
- [pretrained_G14, pretrained_D15, sr2],
1389
- )
1390
- if_f0_3.change(
1391
- change_f0,
1392
- [if_f0_3, sr2, version19],
1393
- [f0method8, gpus_rmvpe, pretrained_G14, pretrained_D15],
1394
- )
1395
-
1396
- but3 = gr.Button(i18n("Train model"), variant="primary")
1397
- but4 = gr.Button(i18n("Train feature index"), variant="primary")
1398
- but5 = gr.Button(i18n("One-click training"), variant="primary")
1399
- with gr.Row():
1400
- info3 = gr.Textbox(label=i18n("Output information"), value="")
1401
- but3.click(
1402
- click_train,
1403
- [
1404
- exp_dir1,
1405
- sr2,
1406
- if_f0_3,
1407
- spk_id5,
1408
- save_epoch10,
1409
- total_epoch11,
1410
- batch_size12,
1411
- if_save_latest13,
1412
- pretrained_G14,
1413
- pretrained_D15,
1414
- gpus16,
1415
- if_cache_gpu17,
1416
- if_save_every_weights18,
1417
- version19,
1418
- author,
1419
- ],
1420
- info3,
1421
- api_name="train_start",
1422
- )
1423
- but4.click(train_index, [exp_dir1, version19], info3)
1424
- but5.click(
1425
- train1key,
1426
- [
1427
- exp_dir1,
1428
- sr2,
1429
- if_f0_3,
1430
- trainset_dir4,
1431
- spk_id5,
1432
- np7,
1433
- f0method8,
1434
- save_epoch10,
1435
- total_epoch11,
1436
- batch_size12,
1437
- if_save_latest13,
1438
- pretrained_G14,
1439
- pretrained_D15,
1440
- gpus16,
1441
- if_cache_gpu17,
1442
- if_save_every_weights18,
1443
- version19,
1444
- gpus_rmvpe,
1445
- author,
1446
- ],
1447
- info3,
1448
- api_name="train_start_all",
1449
- )
1450
-
1451
- with gr.TabItem(i18n("ckpt Processing")):
1452
- gr.Markdown(
1453
- value=i18n(
1454
- "### Model comparison\n> You can get model ID (long) from `View model information` below.\n\nCalculate a similarity between two models."
1455
- )
1456
- )
1457
- with gr.Row():
1458
- with gr.Column():
1459
- id_a = gr.Textbox(label=i18n("ID of model A (long)"), value="")
1460
- id_b = gr.Textbox(label=i18n("ID of model B (long)"), value="")
1461
- with gr.Column():
1462
- butmodelcmp = gr.Button(i18n("Calculate"), variant="primary")
1463
- infomodelcmp = gr.Textbox(
1464
- label=i18n("Similarity (from 0 to 1)"),
1465
- value="",
1466
- max_lines=1,
1467
- )
1468
- butmodelcmp.click(
1469
- hash_similarity,
1470
- [
1471
- id_a,
1472
- id_b,
1473
- ],
1474
- infomodelcmp,
1475
- api_name="ckpt_merge",
1476
- )
1477
-
1478
- gr.Markdown(
1479
- value=i18n("### Model fusion\nCan be used to test timbre fusion.")
1480
- )
1481
- with gr.Row():
1482
- with gr.Column():
1483
- ckpt_a = gr.Textbox(
1484
- label=i18n("Path to Model A"), value="", interactive=True
1485
- )
1486
- ckpt_b = gr.Textbox(
1487
- label=i18n("Path to Model B"), value="", interactive=True
1488
- )
1489
- alpha_a = gr.Slider(
1490
- minimum=0,
1491
- maximum=1,
1492
- label=i18n("Weight (w) for Model A"),
1493
- value=0.5,
1494
- interactive=True,
1495
- )
1496
- with gr.Column():
1497
- sr_ = gr.Radio(
1498
- label=i18n("Target sample rate"),
1499
- choices=["40k", "48k"],
1500
- value="40k",
1501
- interactive=True,
1502
- )
1503
- if_f0_ = gr.Radio(
1504
- label=i18n("Whether the model has pitch guidance"),
1505
- choices=[i18n("Yes"), i18n("No")],
1506
- value=i18n("Yes"),
1507
- interactive=True,
1508
- )
1509
- info__ = gr.Textbox(
1510
- label=i18n("Model information to be placed"),
1511
- value="",
1512
- max_lines=8,
1513
- interactive=True,
1514
- )
1515
- with gr.Column():
1516
- name_to_save0 = gr.Textbox(
1517
- label=i18n("Saved model name (without extension)"),
1518
- value="",
1519
- max_lines=1,
1520
- interactive=True,
1521
- )
1522
- version_2 = gr.Radio(
1523
- label=i18n("Model architecture version"),
1524
- choices=["v1", "v2"],
1525
- value="v1",
1526
- interactive=True,
1527
- )
1528
- but6 = gr.Button(i18n("Fusion"), variant="primary")
1529
- with gr.Row():
1530
- info4 = gr.Textbox(label=i18n("Output information"), value="")
1531
- but6.click(
1532
- merge,
1533
- [
1534
- ckpt_a,
1535
- ckpt_b,
1536
- alpha_a,
1537
- sr_,
1538
- if_f0_,
1539
- info__,
1540
- name_to_save0,
1541
- version_2,
1542
- ],
1543
- info4,
1544
- api_name="ckpt_merge",
1545
- ) # def merge(path1,path2,alpha1,sr,f0,info):
1546
-
1547
- gr.Markdown(
1548
- value=i18n(
1549
- "### Modify model information\n> Only supported for small model files extracted from the 'weights' folder."
1550
- )
1551
- )
1552
- with gr.Row():
1553
- with gr.Column():
1554
- ckpt_path0 = gr.Textbox(
1555
- label=i18n("Path to Model"), value="", interactive=True
1556
- )
1557
- info_ = gr.Textbox(
1558
- label=i18n("Model information to be modified"),
1559
- value="",
1560
- max_lines=8,
1561
- interactive=True,
1562
- )
1563
- name_to_save1 = gr.Textbox(
1564
- label=i18n("Save file name (default: same as the source file)"),
1565
- value="",
1566
- max_lines=1,
1567
- interactive=True,
1568
- )
1569
- with gr.Column():
1570
- but7 = gr.Button(i18n("Modify"), variant="primary")
1571
- info5 = gr.Textbox(label=i18n("Output information"), value="")
1572
- but7.click(
1573
- change_info,
1574
- [ckpt_path0, info_, name_to_save1],
1575
- info5,
1576
- api_name="ckpt_modify",
1577
- )
1578
-
1579
- gr.Markdown(
1580
- value=i18n(
1581
- "### View model information\n> Only supported for small model files extracted from the 'weights' folder."
1582
- )
1583
- )
1584
- with gr.Row():
1585
- with gr.Column():
1586
- ckpt_path1 = gr.File(label=i18n("Path to Model"))
1587
- but8 = gr.Button(i18n("View"), variant="primary")
1588
- with gr.Column():
1589
- info6 = gr.Textbox(label=i18n("Output information"), value="")
1590
- but8.click(show_info, [ckpt_path1], info6, api_name="ckpt_show")
1591
-
1592
- gr.Markdown(
1593
- value=i18n(
1594
- "### Model extraction\n> Enter the path of the large file model under the 'logs' folder.\n\nThis is useful if you want to stop training halfway and manually extract and save a small model file, or if you want to test an intermediate model."
1595
- )
1596
- )
1597
- with gr.Row():
1598
- with gr.Column():
1599
- ckpt_path2 = gr.Textbox(
1600
- label=i18n("Path to Model"),
1601
- value="E:\\codes\\py39\\logs\\mi-test_f0_48k\\G_23333.pth",
1602
- interactive=True,
1603
- )
1604
- save_name = gr.Textbox(
1605
- label=i18n("Save name"), value="", interactive=True
1606
- )
1607
- with gr.Row():
1608
- sr__ = gr.Radio(
1609
- label=i18n("Target sample rate"),
1610
- choices=["32k", "40k", "48k"],
1611
- value="40k",
1612
- interactive=True,
1613
- )
1614
- if_f0__ = gr.Radio(
1615
- label=i18n(
1616
- "Whether the model has pitch guidance (1: yes, 0: no)"
1617
- ),
1618
- choices=["1", "0"],
1619
- value="1",
1620
- interactive=True,
1621
- )
1622
- version_1 = gr.Radio(
1623
- label=i18n("Model architecture version"),
1624
- choices=["v1", "v2"],
1625
- value="v2",
1626
- interactive=True,
1627
- )
1628
- info___ = gr.Textbox(
1629
- label=i18n("Model information to be placed"),
1630
- value="",
1631
- max_lines=8,
1632
- interactive=True,
1633
- )
1634
- extauthor = gr.Textbox(
1635
- label=i18n("Model Author"),
1636
- value="",
1637
- max_lines=1,
1638
- interactive=True,
1639
- )
1640
- with gr.Column():
1641
- but9 = gr.Button(i18n("Extract"), variant="primary")
1642
- info7 = gr.Textbox(label=i18n("Output information"), value="")
1643
- ckpt_path2.change(
1644
- change_info_, [ckpt_path2], [sr__, if_f0__, version_1]
1645
- )
1646
- but9.click(
1647
- extract_small_model,
1648
- [
1649
- ckpt_path2,
1650
- save_name,
1651
- extauthor,
1652
- sr__,
1653
- if_f0__,
1654
- info___,
1655
- version_1,
1656
- ],
1657
- info7,
1658
- api_name="ckpt_extract",
1659
- )
1660
-
1661
- with gr.TabItem(i18n("Export Onnx")):
1662
- with gr.Row():
1663
- ckpt_dir = gr.Textbox(
1664
- label=i18n("RVC Model Path"), value="", interactive=True
1665
- )
1666
- with gr.Row():
1667
- onnx_dir = gr.Textbox(
1668
- label=i18n("Onnx Export Path"), value="", interactive=True
1669
- )
1670
- with gr.Row():
1671
- infoOnnx = gr.Label(label="info")
1672
- with gr.Row():
1673
- butOnnx = gr.Button(i18n("Export Onnx Model"), variant="primary")
1674
- butOnnx.click(
1675
- export_onnx, [ckpt_dir, onnx_dir], infoOnnx, api_name="export_onnx"
1676
- )
1677
-
1678
- tab_faq = i18n("FAQ (Frequently Asked Questions)")
1679
- with gr.TabItem(tab_faq):
1680
- try:
1681
- if tab_faq == "FAQ (Frequently Asked Questions)":
1682
- with open("docs/cn/faq.md", "r", encoding="utf8") as f:
1683
- info = f.read()
1684
- else:
1685
- with open("docs/en/faq_en.md", "r", encoding="utf8") as f:
1686
- info = f.read()
1687
- gr.Markdown(value=info)
1688
- except:
1689
- gr.Markdown(traceback.format_exc())
1690
-
1691
- try:
1692
- import signal
1693
-
1694
- def cleanup(signum, frame):
1695
- signame = signal.Signals(signum).name
1696
- print(f"Got signal {signame} ({signum})")
1697
- app.close()
1698
- sys.exit(0)
1699
-
1700
- signal.signal(signal.SIGINT, cleanup)
1701
- signal.signal(signal.SIGTERM, cleanup)
1702
- if config.global_link:
1703
- app.queue(max_size=1022).launch(share=True, max_threads=511)
1704
- else:
1705
- app.queue(max_size=1022).launch(
1706
- max_threads=511,
1707
- server_name="0.0.0.0",
1708
- inbrowser=not config.noautoopen,
1709
- server_port=config.listen_port,
1710
- quiet=True,
1711
- )
1712
- except Exception as e:
1713
- logger.error(str(e))
 
799
  return {"visible": visible, "__type__": "update"}
800
 
801