Update app.py
Browse files
app.py
CHANGED
|
@@ -1872,244 +1872,12 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="pink", secondary_hue="rose")
|
|
| 1872 |
files_in_folder = os.listdir(pretrained_folder)
|
| 1873 |
num_files = len(files_in_folder)
|
| 1874 |
return num_files >= 2
|
| 1875 |
-
|
| 1876 |
-
|
| 1877 |
-
|
| 1878 |
-
|
| 1879 |
-
|
| 1880 |
-
|
| 1881 |
-
exp_dir1 = gr.Textbox(label="Voice Name:", value="My-Voice")
|
| 1882 |
-
sr2 = gr.Radio(
|
| 1883 |
-
label=i18n("目标采样率"),
|
| 1884 |
-
choices=["40k", "48k"],
|
| 1885 |
-
value="40k",
|
| 1886 |
-
interactive=True,
|
| 1887 |
-
visible=False
|
| 1888 |
-
)
|
| 1889 |
-
if_f0_3 = gr.Radio(
|
| 1890 |
-
label=i18n("模型是否带音高指导(唱歌一定要, 语音可以不要)"),
|
| 1891 |
-
choices=[True, False],
|
| 1892 |
-
value=True,
|
| 1893 |
-
interactive=True,
|
| 1894 |
-
visible=False
|
| 1895 |
-
)
|
| 1896 |
-
version19 = gr.Radio(
|
| 1897 |
-
label="RVC version",
|
| 1898 |
-
choices=["v1", "v2"],
|
| 1899 |
-
value="v2",
|
| 1900 |
-
interactive=True,
|
| 1901 |
-
visible=False,
|
| 1902 |
-
)
|
| 1903 |
-
np7 = gr.Slider(
|
| 1904 |
-
minimum=0,
|
| 1905 |
-
maximum=config.n_cpu,
|
| 1906 |
-
step=1,
|
| 1907 |
-
label="# of CPUs for data processing (Leave as it is)",
|
| 1908 |
-
value=config.n_cpu,
|
| 1909 |
-
interactive=True,
|
| 1910 |
-
visible=True
|
| 1911 |
-
)
|
| 1912 |
-
trainset_dir4 = gr.Textbox(label="Path to your dataset (audios, not zip):", value="./dataset")
|
| 1913 |
-
easy_uploader = gr.Files(label='OR Drop your audios here. They will be uploaded in your dataset path above.',file_types=['audio'])
|
| 1914 |
-
but1 = gr.Button("1. Process The Dataset", variant="primary")
|
| 1915 |
-
info1 = gr.Textbox(label="Status (wait until it says 'end preprocess'):", value="")
|
| 1916 |
-
easy_uploader.upload(fn=upload_to_dataset, inputs=[easy_uploader, trainset_dir4], outputs=[info1])
|
| 1917 |
-
but1.click(
|
| 1918 |
-
preprocess_dataset, [trainset_dir4, exp_dir1, sr2, np7], [info1]
|
| 1919 |
-
)
|
| 1920 |
-
with gr.Column():
|
| 1921 |
-
spk_id5 = gr.Slider(
|
| 1922 |
-
minimum=0,
|
| 1923 |
-
maximum=4,
|
| 1924 |
-
step=1,
|
| 1925 |
-
label=i18n("请指定说话人id"),
|
| 1926 |
-
value=0,
|
| 1927 |
-
interactive=True,
|
| 1928 |
-
visible=False
|
| 1929 |
-
)
|
| 1930 |
-
with gr.Accordion('GPU Settings', open=False, visible=False):
|
| 1931 |
-
gpus6 = gr.Textbox(
|
| 1932 |
-
label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),
|
| 1933 |
-
value=gpus,
|
| 1934 |
-
interactive=True,
|
| 1935 |
-
visible=False
|
| 1936 |
-
)
|
| 1937 |
-
gpu_info9 = gr.Textbox(label=i18n("显卡信息"), value=gpu_info)
|
| 1938 |
-
f0method8 = gr.Radio(
|
| 1939 |
-
label=i18n(
|
| 1940 |
-
"选择音高提取算法:输入歌声可用pm提速,高质量语音但CPU差可用dio提速,harvest质量更好但慢"
|
| 1941 |
-
),
|
| 1942 |
-
choices=["harvest","crepe", "mangio-crepe", "rmvpe"], # Fork feature: Crepe on f0 extraction for training.
|
| 1943 |
-
value="rmvpe",
|
| 1944 |
-
interactive=True,
|
| 1945 |
-
)
|
| 1946 |
-
|
| 1947 |
-
extraction_crepe_hop_length = gr.Slider(
|
| 1948 |
-
minimum=1,
|
| 1949 |
-
maximum=512,
|
| 1950 |
-
step=1,
|
| 1951 |
-
label=i18n("crepe_hop_length"),
|
| 1952 |
-
value=128,
|
| 1953 |
-
interactive=True,
|
| 1954 |
-
visible=False,
|
| 1955 |
-
)
|
| 1956 |
-
f0method8.change(fn=whethercrepeornah, inputs=[f0method8], outputs=[extraction_crepe_hop_length])
|
| 1957 |
-
but2 = gr.Button("2. Pitch Extraction", variant="primary")
|
| 1958 |
-
info2 = gr.Textbox(label="Status(Check the Colab Notebook's cell output):", value="", max_lines=8)
|
| 1959 |
-
but2.click(
|
| 1960 |
-
extract_f0_feature,
|
| 1961 |
-
[gpus6, np7, f0method8, if_f0_3, exp_dir1, version19, extraction_crepe_hop_length],
|
| 1962 |
-
[info2],
|
| 1963 |
-
)
|
| 1964 |
-
with gr.Row():
|
| 1965 |
-
with gr.Column():
|
| 1966 |
-
total_epoch11 = gr.Slider(
|
| 1967 |
-
minimum=1,
|
| 1968 |
-
maximum=5000,
|
| 1969 |
-
step=10,
|
| 1970 |
-
label="Total # of training epochs (IF you choose a value too high, your model will sound horribly overtrained.):",
|
| 1971 |
-
value=250,
|
| 1972 |
-
interactive=True,
|
| 1973 |
-
)
|
| 1974 |
-
butstop = gr.Button(
|
| 1975 |
-
"Stop Training",
|
| 1976 |
-
variant='primary',
|
| 1977 |
-
visible=False,
|
| 1978 |
-
)
|
| 1979 |
-
but3 = gr.Button("3. Train Model", variant="primary", visible=True)
|
| 1980 |
-
|
| 1981 |
-
but3.click(fn=stoptraining, inputs=[gr.Number(value=0, visible=False)], outputs=[but3, butstop])
|
| 1982 |
-
butstop.click(fn=stoptraining, inputs=[gr.Number(value=1, visible=False)], outputs=[butstop, but3])
|
| 1983 |
-
|
| 1984 |
-
|
| 1985 |
-
but4 = gr.Button("4.Train Index", variant="primary")
|
| 1986 |
-
info3 = gr.Textbox(label="Status(Check the Colab Notebook's cell output):", value="", max_lines=10)
|
| 1987 |
-
with gr.Accordion("Training Preferences (You can leave these as they are)", open=False):
|
| 1988 |
-
#gr.Markdown(value=i18n("step3: 填写训练设置, 开始训练模型和索引"))
|
| 1989 |
-
with gr.Column():
|
| 1990 |
-
save_epoch10 = gr.Slider(
|
| 1991 |
-
minimum=1,
|
| 1992 |
-
maximum=200,
|
| 1993 |
-
step=1,
|
| 1994 |
-
label="Backup every X amount of epochs:",
|
| 1995 |
-
value=10,
|
| 1996 |
-
interactive=True,
|
| 1997 |
-
)
|
| 1998 |
-
batch_size12 = gr.Slider(
|
| 1999 |
-
minimum=1,
|
| 2000 |
-
maximum=40,
|
| 2001 |
-
step=1,
|
| 2002 |
-
label="Batch Size (LEAVE IT unless you know what you're doing!):",
|
| 2003 |
-
value=default_batch_size,
|
| 2004 |
-
interactive=True,
|
| 2005 |
-
)
|
| 2006 |
-
if_save_latest13 = gr.Checkbox(
|
| 2007 |
-
label="Save only the latest '.ckpt' file to save disk space.",
|
| 2008 |
-
value=True,
|
| 2009 |
-
interactive=True,
|
| 2010 |
-
)
|
| 2011 |
-
if_cache_gpu17 = gr.Checkbox(
|
| 2012 |
-
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.",
|
| 2013 |
-
value=False,
|
| 2014 |
-
interactive=True,
|
| 2015 |
-
)
|
| 2016 |
-
if_save_every_weights18 = gr.Checkbox(
|
| 2017 |
-
label="Save a small final model to the 'weights' folder at each save point.",
|
| 2018 |
-
value=True,
|
| 2019 |
-
interactive=True,
|
| 2020 |
-
)
|
| 2021 |
-
zip_model = gr.Button('5. Download Model')
|
| 2022 |
-
zipped_model = gr.Files(label='Your Model and Index file can be downloaded here:')
|
| 2023 |
-
zip_model.click(fn=zip_downloader, inputs=[exp_dir1], outputs=[zipped_model, info3])
|
| 2024 |
-
with gr.Group():
|
| 2025 |
-
with gr.Accordion("Base Model Locations:", open=False, visible=False):
|
| 2026 |
-
pretrained_G14 = gr.Textbox(
|
| 2027 |
-
label=i18n("加载预训练底模G路径"),
|
| 2028 |
-
value="pretrained_v2/f0G40k.pth",
|
| 2029 |
-
interactive=True,
|
| 2030 |
-
)
|
| 2031 |
-
pretrained_D15 = gr.Textbox(
|
| 2032 |
-
label=i18n("加载预训练底模D路径"),
|
| 2033 |
-
value="pretrained_v2/f0D40k.pth",
|
| 2034 |
-
interactive=True,
|
| 2035 |
-
)
|
| 2036 |
-
gpus16 = gr.Textbox(
|
| 2037 |
-
label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),
|
| 2038 |
-
value=gpus,
|
| 2039 |
-
interactive=True,
|
| 2040 |
-
)
|
| 2041 |
-
sr2.change(
|
| 2042 |
-
change_sr2,
|
| 2043 |
-
[sr2, if_f0_3, version19],
|
| 2044 |
-
[pretrained_G14, pretrained_D15, version19],
|
| 2045 |
-
)
|
| 2046 |
-
version19.change(
|
| 2047 |
-
change_version19,
|
| 2048 |
-
[sr2, if_f0_3, version19],
|
| 2049 |
-
[pretrained_G14, pretrained_D15],
|
| 2050 |
-
)
|
| 2051 |
-
if_f0_3.change(
|
| 2052 |
-
change_f0,
|
| 2053 |
-
[if_f0_3, sr2, version19],
|
| 2054 |
-
[f0method8, pretrained_G14, pretrained_D15],
|
| 2055 |
-
)
|
| 2056 |
-
but5 = gr.Button(i18n("一键训练"), variant="primary", visible=False)
|
| 2057 |
-
but3.click(
|
| 2058 |
-
click_train,
|
| 2059 |
-
[
|
| 2060 |
-
exp_dir1,
|
| 2061 |
-
sr2,
|
| 2062 |
-
if_f0_3,
|
| 2063 |
-
spk_id5,
|
| 2064 |
-
save_epoch10,
|
| 2065 |
-
total_epoch11,
|
| 2066 |
-
batch_size12,
|
| 2067 |
-
if_save_latest13,
|
| 2068 |
-
pretrained_G14,
|
| 2069 |
-
pretrained_D15,
|
| 2070 |
-
gpus16,
|
| 2071 |
-
if_cache_gpu17,
|
| 2072 |
-
if_save_every_weights18,
|
| 2073 |
-
version19,
|
| 2074 |
-
],
|
| 2075 |
-
[
|
| 2076 |
-
info3,
|
| 2077 |
-
butstop,
|
| 2078 |
-
but3,
|
| 2079 |
-
],
|
| 2080 |
-
)
|
| 2081 |
-
but4.click(train_index, [exp_dir1, version19], info3)
|
| 2082 |
-
but5.click(
|
| 2083 |
-
train1key,
|
| 2084 |
-
[
|
| 2085 |
-
exp_dir1,
|
| 2086 |
-
sr2,
|
| 2087 |
-
if_f0_3,
|
| 2088 |
-
trainset_dir4,
|
| 2089 |
-
spk_id5,
|
| 2090 |
-
np7,
|
| 2091 |
-
f0method8,
|
| 2092 |
-
save_epoch10,
|
| 2093 |
-
total_epoch11,
|
| 2094 |
-
batch_size12,
|
| 2095 |
-
if_save_latest13,
|
| 2096 |
-
pretrained_G14,
|
| 2097 |
-
pretrained_D15,
|
| 2098 |
-
gpus16,
|
| 2099 |
-
if_cache_gpu17,
|
| 2100 |
-
if_save_every_weights18,
|
| 2101 |
-
version19,
|
| 2102 |
-
extraction_crepe_hop_length
|
| 2103 |
-
],
|
| 2104 |
-
info3,
|
| 2105 |
-
)
|
| 2106 |
-
|
| 2107 |
-
else:
|
| 2108 |
-
print(
|
| 2109 |
-
"Pretrained weights not downloaded. Disabling training tab.\n"
|
| 2110 |
-
"Wondering how to train a voice? Join AI HUB Discord Server! https://discord.gg/aihub\n"
|
| 2111 |
-
"-------------------------------\n"
|
| 2112 |
-
)
|
| 2113 |
|
| 2114 |
app.launch(share=False, quiet=False, max_threads=1022)
|
| 2115 |
#endpain
|
|
|
|
| 1872 |
files_in_folder = os.listdir(pretrained_folder)
|
| 1873 |
num_files = len(files_in_folder)
|
| 1874 |
return num_files >= 2
|
| 1875 |
+
print(
|
| 1876 |
+
"=" * 50,
|
| 1877 |
+
"Disabling Training, as ZeroGPU only supports a running time of 120 seconds.",
|
| 1878 |
+
"Please use a local machine, or colab for training.",
|
| 1879 |
+
"=" * 50,
|
| 1880 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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