diff --git a/Kaggle_TheBestTrainingWay.ipynb b/Kaggle_TheBestTrainingWay.ipynb new file mode 100644 index 00000000..1c941b30 --- /dev/null +++ b/Kaggle_TheBestTrainingWay.ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":8617806,"sourceType":"datasetVersion","datasetId":5158124}],"dockerImageVersionId":30699,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## 电脑必选Edge或者Chrome\n## Please use Edge or Chrome! Or you couldnt download the file from the Kaggle!!\n## 目的是下载kaggle的blog二进制文件。很少有浏览器能支持大规模的blob传输。\n## 只有上述浏览器才能成功下载保存的zip文件","metadata":{}},{"cell_type":"markdown","source":"# Before training, Do not forget turn on the settings of \"INTERNET\"! And Do not forget choose GPU as your accelerator!(Tesla T2 recommended)\n# 在训练前注意打开internet,将Accelerator改成任意一个GPU(建议T4)\n> You may need verify your phone number to be accessible to GPU if you are new Kaggle user.\n对于新手玩家需要验证一下手机号才能使用GPU。","metadata":{}},{"cell_type":"markdown","source":"# 注意,目前只能使用训练webui,无法使用uvr5,和推理的webui。\n### 解决方法:自己fork一下官方仓库,修改./GPT_SoVITS/inference_webui.py的gradio的share属性为true。同理uvr5也如此,将第一步的原仓库改成你的仓库地址。即可进行推理。输出gradio的public link","metadata":{}},{"cell_type":"markdown","source":"$ C_{n}^{m} = \\frac{n!}{m!(n-m)!} $\n$ \\text{最诚挚的祝福} $","metadata":{}},{"cell_type":"markdown","source":"## 所有提示信息都写在每个代码框的注释里。","metadata":{}},{"cell_type":"markdown","source":"# 1.必要:安装环境(可替换你的fork地址)\n# 1. Important: Install Dep(Always run it first whatever happened)","metadata":{}},{"cell_type":"code","source":"#准备环境,不管以前保没保存环境都必做.\n!git clone --depth=1 https://github.com/RVC-Boss/GPT-SoVITS.git\n%cd GPT-SoVITS\n!apt-get update && apt-get install -y --no-install-recommends tzdata ffmpeg libsox-dev parallel aria2 git git-lfs && git lfs install\n!pip install -r requirements.txt","metadata":{"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"# 2.下载预训练模型\n# 2. Download pre-trained models for following traning.\n### You dont have to run if you have saved your env(check it out through settings, see if it has 10G or more data )","metadata":{}},{"cell_type":"code","source":"#注意! 如果以前保存过环境就没必要进行这个代码框了!直接去下一个代码框!!!!\n#具体点开你右上角菜单,看是否有10G以上的数据存放在里面。或者说在启动的时候加载很慢,提示\n# Loading data之类的。\n!mkdir -p /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models\n!mkdir -p /kaggle/working/GPT-SoVITS/tools/asr/models\n!mkdir -p /kaggle/working/GPT-SoVITS/tools/uvr5\n%cd /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models\n!git clone https://huggingface.co/lj1995/GPT-SoVITS\n%cd /kaggle/working/GPT-SoVITS/tools/asr/models\n!git clone https://www.modelscope.cn/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch.git\n!git clone https://www.modelscope.cn/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch.git\n!git clone https://www.modelscope.cn/damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch.git\n\n# 这里注释掉uvr5模型是因为你用不上它。也是用不了。\n# 除了开头的方式,如果你有更好的内网穿透工具并且知道如何引用,欢迎更新version。\n# 来穿透uvr5 webui端口可以一试。\n\n#%cd /kaggle/working/GPT-SoVITS/tools/uvr5\n#!git clone https://huggingface.co/Delik/uvr5_weights\n#!git config core.sparseCheckout true\n\n!mv /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models/GPT-SoVITS/* /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models/","metadata":{"scrolled":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Webui 启动!","metadata":{}},{"cell_type":"code","source":"#启动webui.py\n# 通过npm插件启动单一端口的内网穿透。不能多开。\n# 也就是只能训练,不能用来云端推理和进行uvr5的降噪\n\n%cd /kaggle/working/GPT-SoVITS/\n!npm install -g localtunnel\nimport subprocess\nimport threading\nimport time\nimport socket\nimport urllib.request\ndef iframe_thread(port):\n while True:\n time.sleep(0.5)\n sock= socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n result = sock.connect_ex(('127.0.0.1', port))\n if result == 0:\n break\n sock.close()\n from colorama import Fore, Style\n print (Fore.GREEN + \"\\nIP: \", Fore. RED, urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"), \"\\n\", Style. RESET_ALL)\n p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n for line in p.stdout:\n print(line.decode(), end='')\nthreading.Thread (target=iframe_thread, daemon=True, args=(9874,)).start()\n!pip install --upgrade gradio\n!python webui.py","metadata":{"scrolled":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2024-06-06T01:32:23.067947Z","iopub.execute_input":"2024-06-06T01:32:23.068317Z","iopub.status.idle":"2024-06-06T02:01:23.162243Z","shell.execute_reply.started":"2024-06-06T01:32:23.068286Z","shell.execute_reply":"2024-06-06T02:01:23.160966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"***执行下一步之前必须要停止webui进程才能继续!***\n\n***When it comes to pack your weights,stop every running cell first.***","metadata":{}},{"cell_type":"code","source":"#打包权重文件到/kaggle/working/GPT-SoVITS文件夹内,点击刷新按钮即可看到大包邮的内容.\n%cd /kaggle/working/GPT-SoVITS/\n!zip AnyName_GPT_packed.zip /kaggle/working/GPT-SoVITS/SoVITS_weights/* /kaggle/working/GPT-SoVITS/GPT_weights/*","metadata":{"execution":{"iopub.status.busy":"2024-06-06T02:02:27.753801Z","iopub.execute_input":"2024-06-06T02:02:27.754514Z","iopub.status.idle":"2024-06-06T02:03:05.450437Z","shell.execute_reply.started":"2024-06-06T02:02:27.754470Z","shell.execute_reply":"2024-06-06T02:03:05.449109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#清理GPU显存\n#当你用到它的时候,大概率没什么用。肯定是webui填写的时候GPU卡号多写了一组,例如0-1,0-1。正确的应该是\n# 0-1.也有可能batch size太高爆显存了,从7拉低到5即可完美解决。\n!nvidia-smi\nfrom numba import cuda\nimport torch\ncuda.select_device(0)\ncuda.close()\ncuda.select_device(1)\ncuda.close()\ntorch.cuda.empty_cache()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 保持neat: 删除所有音频用来下一次训练\n## Keep tidy and neat! the cell below will delete akl cache data for trainibg next character.","metadata":{}},{"cell_type":"code","source":"# 完全重置,用于新的训练。\n%cd /kaggle/working/GPT-SoVITS\n#这部分必须删除,否则会对新模型训练产生不可逆转的影响。\n!rm -rf ./output/slicer_opt/*.wav #删除你的切片文件\n!rm -rf ./output/denoise_opt/* #删除你降噪后的文件\n!rm -rf ./log/* # 删除log会清空训练过程中产生的数据。但不会清空结果生成的权重。\n# 如果你不是想拿它继续训练,就可以删掉它。\n\n# !rm -rf ./*.zip\n\n#注意,为了节省空间,建议将打包的zip文件执行删除!\n#请在执行之前确保你已经下载完权重文件,为避免误操作,已经注释这个功能\n#若不想删除,保持注释上面这一行即可。但是随着训练任务的增多\n#会不知不觉地占用你的空间\n!rm -rf ./output/asr_opt/* #删除生成的文本文件\n!rm -rf ./input/* #删除你的样本未处理文件\n\n#为避免误操作,以下为注释内容。\n# rm -rf ./GPT_SoVITS_weight/*\n# rm -rf ./SoVITS_weight/*","metadata":{"execution":{"iopub.status.busy":"2024-06-06T02:13:54.150604Z","iopub.execute_input":"2024-06-06T02:13:54.151427Z","iopub.status.idle":"2024-06-06T02:13:59.001223Z","shell.execute_reply.started":"2024-06-06T02:13:54.151387Z","shell.execute_reply":"2024-06-06T02:13:58.999297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]} \ No newline at end of file