File size: 12,752 Bytes
39f3704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QTSdqTqGcbyr"
      },
      "source": [
        "# [Retrieval-based-Voice-Conversion-WebUI](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI) Training notebook"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZFFCx5J80SGa"
      },
      "source": [
        "[![RVC v2](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/tools/colab/v2.ipynb)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "GmFP6bN9dvOq"
      },
      "outputs": [],
      "source": [
        "# @title #查看显卡\n",
        "!nvidia-smi"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "jwu07JgqoFON"
      },
      "outputs": [],
      "source": [
        "# @title 挂载谷歌云盘\n",
        "\n",
        "from google.colab import drive\n",
        "\n",
        "drive.mount(\"/content/drive\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "wjddIFr1oS3W"
      },
      "outputs": [],
      "source": [
        "# @title #安装依赖\n",
        "!apt -y install build-essential python3-dev ffmpeg\n",
        "!pip3 install --upgrade setuptools wheel\n",
        "!pip3 install --upgrade pip"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "ge_97mfpgqTm"
      },
      "outputs": [],
      "source": [
        "# @title #克隆仓库\n",
        "\n",
        "!git clone --depth=1 -b v2.2 https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI\n",
        "%cd /content/Retrieval-based-Voice-Conversion-WebUI"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "BLDEZADkvlw1"
      },
      "outputs": [],
      "source": [
        "# @title 安装依赖\n",
        "!pip install -r requirements.txt"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "pqE0PrnuRqI2"
      },
      "outputs": [],
      "source": [
        "# @title 下载安装 RVC-Models-Downloader\n",
        "!wget https://github.com/RVC-Project/RVC-Models-Downloader/releases/download/v0.2.2/rvcmd_linux_amd64.deb\n",
        "!apt install ./rvcmd_linux_amd64.deb"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "UG3XpUwEomUz"
      },
      "outputs": [],
      "source": [
        "# @title 下载所需资源\n",
        "!rvcmd -notrs -w 1 -notui assets/all"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Mwk7Q0Loqzjx"
      },
      "outputs": [],
      "source": [
        "# @title #从谷歌云盘加载打包好的数据集到/content/dataset\n",
        "\n",
        "# @markdown 数据集位置\n",
        "DATASET = \"/content/drive/MyDrive/mydataset.zip\"  # @param {type:\"string\"}\n",
        "\n",
        "!mkdir -p /content/dataset\n",
        "!unzip -d /content/dataset -B {DATASET}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "PDlFxWHWEynD"
      },
      "outputs": [],
      "source": [
        "# @title #重命名数据集中的重名文件\n",
        "!ls -a /content/dataset/\n",
        "!rename 's/(\\w+)\\.(\\w+)~(\\d*)/$1_$3.$2/' /content/dataset/*.*~*"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7vh6vphDwO0b"
      },
      "outputs": [],
      "source": [
        "# @title #启动webui\n",
        "%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",
        "# %load_ext tensorboard\n",
        "# %tensorboard --logdir /content/Retrieval-based-Voice-Conversion-WebUI/logs\n",
        "!python3 infer-web.py --colab --pycmd python3"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "FgJuNeAwx5Y_"
      },
      "outputs": [],
      "source": [
        "# @title #手动将训练后的模型文件备份到谷歌云盘\n",
        "# @markdown #需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
        "\n",
        "# @markdown #模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown #模型epoch\n",
        "MODELEPOCH = 3200  # @param {type:\"integer\"}\n",
        "\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/added_*.index /content/drive/MyDrive/\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/total_*.npy /content/drive/MyDrive/\n",
        "\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "OVQoLQJXS7WX"
      },
      "outputs": [],
      "source": [
        "# @title 从谷歌云盘恢复pth\n",
        "# @markdown 需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
        "\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 模型epoch\n",
        "MODELEPOCH = 3200  # @param {type:\"integer\"}\n",
        "\n",
        "!mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
        "\n",
        "!cp /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
        "!cp /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
        "!cp /content/drive/MyDrive/*.index /content/\n",
        "!cp /content/drive/MyDrive/*.npy /content/\n",
        "!cp /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "ZKAyuKb9J6dz"
      },
      "outputs": [],
      "source": [
        "# @title 手动预处理(不推荐)\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 采样率\n",
        "BITRATE = 48000  # @param {type:\"integer\"}\n",
        "# @markdown 使用的进程数\n",
        "THREADCOUNT = 8  # @param {type:\"integer\"}\n",
        "\n",
        "!python3 trainset_preprocess_pipeline_print.py /content/dataset {BITRATE} {THREADCOUNT} logs/{MODELNAME} True"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "CrxJqzAUKmPJ"
      },
      "outputs": [],
      "source": [
        "# @title 手动提取特征(不推荐)\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 使用的进程数\n",
        "THREADCOUNT = 8  # @param {type:\"integer\"}\n",
        "# @markdown 音高提取算法\n",
        "ALGO = \"harvest\"  # @param {type:\"string\"}\n",
        "\n",
        "!python3 extract_f0_print.py logs/{MODELNAME} {THREADCOUNT} {ALGO}\n",
        "\n",
        "!python3 extract_feature_print.py cpu 1 0 0 logs/{MODELNAME} True"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "IMLPLKOaKj58"
      },
      "outputs": [],
      "source": [
        "# @title 手动训练(不推荐)\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 使用的GPU\n",
        "USEGPU = \"0\"  # @param {type:\"string\"}\n",
        "# @markdown 批大小\n",
        "BATCHSIZE = 32  # @param {type:\"integer\"}\n",
        "# @markdown 停止的epoch\n",
        "MODELEPOCH = 3200  # @param {type:\"integer\"}\n",
        "# @markdown 保存epoch间隔\n",
        "EPOCHSAVE = 100  # @param {type:\"integer\"}\n",
        "# @markdown 采样率\n",
        "MODELSAMPLE = \"48k\"  # @param {type:\"string\"}\n",
        "# @markdown 是否缓存训练集\n",
        "CACHEDATA = 1  # @param {type:\"integer\"}\n",
        "# @markdown 是否仅保存最新的ckpt文件\n",
        "ONLYLATEST = 0  # @param {type:\"integer\"}\n",
        "\n",
        "!python3 train_nsf_sim_cache_sid_load_pretrain.py -e lulu -sr {MODELSAMPLE} -f0 1 -bs {BATCHSIZE} -g {USEGPU} -te {MODELEPOCH} -se {EPOCHSAVE} -pg pretrained/f0G{MODELSAMPLE}.pth -pd pretrained/f0D{MODELSAMPLE}.pth -l {ONLYLATEST} -c {CACHEDATA}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "haYA81hySuDl"
      },
      "outputs": [],
      "source": [
        "# @title 删除其它pth,只留选中的(慎点,仔细看代码)\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 选中模型epoch\n",
        "MODELEPOCH = 3200  # @param {type:\"integer\"}\n",
        "\n",
        "!echo \"备份选中的模型。。。\"\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
        "\n",
        "!echo \"正在删除。。。\"\n",
        "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
        "!rm /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*.pth\n",
        "\n",
        "!echo \"恢复选中的模型。。。\"\n",
        "!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
        "!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
        "\n",
        "!echo \"删除完成\"\n",
        "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "QhSiPTVPoIRh"
      },
      "outputs": [],
      "source": [
        "# @title 清除项目下所有文件,只留选中的模型(慎点,仔细看代码)\n",
        "# @markdown 模型名\n",
        "MODELNAME = \"mymodel\"  # @param {type:\"string\"}\n",
        "# @markdown 选中模型epoch\n",
        "MODELEPOCH = 3200  # @param {type:\"integer\"}\n",
        "\n",
        "!echo \"备份选中的模型。。。\"\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
        "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
        "\n",
        "!echo \"正在删除。。。\"\n",
        "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
        "!rm -rf /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*\n",
        "\n",
        "!echo \"恢复选中的模型。。。\"\n",
        "!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
        "!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
        "\n",
        "!echo \"删除完成\"\n",
        "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "private_outputs": true,
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}