Colaboratory を使用して作成しました

This commit is contained in:
w-okada 2022-11-04 06:56:46 +09:00
parent 32ad76ca33
commit b9117f7912

View File

@ -5,7 +5,7 @@
"colab": { "colab": {
"provenance": [], "provenance": [],
"collapsed_sections": [], "collapsed_sections": [],
"authorship_tag": "ABX9TyN7lDdQ3iB8T1SI4BKFzkWz", "authorship_tag": "ABX9TyMeMGMfscotyaoFPcXG8qRY",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@ -74,15 +74,15 @@
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"id": "vV1t7PBRm-o6", "id": "vV1t7PBRm-o6",
"outputId": "2ab5d79e-0fe1-4e48-9fb4-8a61399e0b60" "outputId": "8e212991-8ca0-45bc-c632-40a707e9668e"
}, },
"execution_count": null, "execution_count": 1,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"Sun Oct 30 10:03:39 2022 \n", "Thu Nov 3 21:54:01 2022 \n",
"+-----------------------------------------------------------------------------+\n", "+-----------------------------------------------------------------------------+\n",
"| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n", "| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
"|-------------------------------+----------------------+----------------------+\n", "|-------------------------------+----------------------+----------------------+\n",
@ -91,7 +91,7 @@
"| | | MIG M. |\n", "| | | MIG M. |\n",
"|===============================+======================+======================|\n", "|===============================+======================+======================|\n",
"| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n", "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n",
"| N/A 35C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |\n", "| N/A 42C P0 25W / 70W | 0MiB / 15109MiB | 0% Default |\n",
"| | | N/A |\n", "| | | N/A |\n",
"+-------------------------------+----------------------+----------------------+\n", "+-------------------------------+----------------------+----------------------+\n",
" \n", " \n",
@ -106,57 +106,6 @@
} }
] ]
}, },
{
"cell_type": "markdown",
"source": [
"# 使用するモデルとコンフィグファイルの指定\n",
"\n",
"使用するトレーニング済みのモデルと、トレーニングで使用したコンフィグファイルのパスを指定してください。\n",
"\n",
"多くの場合はGoogle Driveに格納されているファイルを使用すると思います。その場合は、下の(2-2)のセルを実行してドライブをマウントしてください"
],
"metadata": {
"id": "mHvGrgaWnIPA"
}
},
{
"cell_type": "code",
"source": [
"# # (2-1) 使用するモデルとコンフィグファイルの指定\n",
"# CONFIG=\"/content/drive/MyDrive/VoiceChanger/config.json\"\n",
"# MODEL=\"/content/drive/MyDrive/VoiceChanger/G_326000.pth\""
],
"metadata": {
"id": "nSXATMWYb4Ik"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "2wxD-gRSMU5R",
"outputId": "dabd982a-87c7-44d1-b9e8-986691190771"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/drive\n"
]
}
],
"source": [
"# # (2-2) Google Driveのマウント\n",
"# from google.colab import drive\n",
"# drive.mount('/content/drive')"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
@ -170,115 +119,51 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# (3) リポジトリのクローン\n", "# (2) リポジトリのクローン\n",
"!git clone --depth 1 https://github.com/isletennos/MMVC_Trainer.git -b v1.3.1.3 /MMVC_Trainer\n", "!git clone --depth 1 https://github.com/isletennos/MMVC_Trainer.git -b v1.3.1.3 /MMVC_Trainer\n",
"!git clone --depth 1 https://github.com/w-okada/voice-changer.git -b dev\n", "!git clone --depth 1 https://github.com/w-okada/voice-changer.git -b dev\n",
"%cd voice-changer/demo/\n" "%cd voice-changer/demo/\n",
"\n",
"!cp ../template/setting_mmvc_colab.json ../frontend/dist/assets/setting.json"
], ],
"metadata": { "metadata": {
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"id": "86wTFmqsNMnD", "id": "86wTFmqsNMnD",
"outputId": "a52d5b0e-826e-445d-cd3a-4a42cbd52212" "outputId": "a269932d-20e1-4fa0-ce86-00d231d169bd"
}, },
"execution_count": 36, "execution_count": 2,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"fatal: destination path '/MMVC_Trainer' already exists and is not an empty directory.\n", "Cloning into '/MMVC_Trainer'...\n",
"remote: Enumerating objects: 917, done.\u001b[K\n",
"remote: Counting objects: 100% (917/917), done.\u001b[K\n",
"remote: Compressing objects: 100% (828/828), done.\u001b[K\n",
"remote: Total 917 (delta 3), reused 888 (delta 0), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (917/917), 53.02 MiB | 16.78 MiB/s, done.\n",
"Resolving deltas: 100% (3/3), done.\n",
"Note: checking out '39723b3243e0265b8802e020e4d4d90a4b8b65ee'.\n",
"\n",
"You are in 'detached HEAD' state. You can look around, make experimental\n",
"changes and commit them, and you can discard any commits you make in this\n",
"state without impacting any branches by performing another checkout.\n",
"\n",
"If you want to create a new branch to retain commits you create, you may\n",
"do so (now or later) by using -b with the checkout command again. Example:\n",
"\n",
" git checkout -b <new-branch-name>\n",
"\n",
"Cloning into 'voice-changer'...\n", "Cloning into 'voice-changer'...\n",
"remote: Enumerating objects: 88, done.\u001b[K\n", "remote: Enumerating objects: 91, done.\u001b[K\n",
"remote: Counting objects: 100% (88/88), done.\u001b[K\n", "remote: Counting objects: 100% (91/91), done.\u001b[K\n",
"remote: Compressing objects: 100% (74/74), done.\u001b[K\n", "remote: Compressing objects: 100% (79/79), done.\u001b[K\n",
"remote: Total 88 (delta 14), reused 57 (delta 6), pack-reused 0\u001b[K\n", "remote: Total 91 (delta 12), reused 55 (delta 4), pack-reused 0\u001b[K\n",
"Unpacking objects: 100% (88/88), done.\n", "Unpacking objects: 100% (91/91), done.\n",
"/content/voice-changer/demo/voice-changer/demo/voice-changer/demo/voice-changer/demo/voice-changer/demo\n" "/content/voice-changer/demo\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"# ファイルの配置\n",
"アプリケーションの挙動を記した設定ファイルをコピーします(4-1)。(4-2)はコピーした設定ファイルを表示しています。もしかしたらうまく動かないときに役立つかもしれません。"
],
"metadata": {
"id": "jmDY8W_fnuSi"
}
},
{
"cell_type": "code",
"source": [
"# (4-1) 設定ファイルの配置\n",
"!cp ../template/setting_mmvc_colab.json ../frontend/dist/assets/setting.json\n"
],
"metadata": {
"id": "Bn4kV8TgXp8i"
},
"execution_count": 37,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# (4-2) 設定ファイルの確認\n",
"!cat ../frontend/dist/assets/setting.json\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "pjxPsOOaXXTj",
"outputId": "425a36dd-fbdc-4f55-825e-a2c7026f2aab"
},
"execution_count": 38,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"{\n",
" \"app_title\": \"voice-changer\",\n",
" \"majar_mode\": \"colab\",\n",
" \"voice_changer_server_url\": \"/test\",\n",
" \"sample_rate\": 48000,\n",
" \"buffer_size\": 1024,\n",
" \"prefix_chunk_size\": 36,\n",
" \"chunk_size\": 36,\n",
" \"speaker_ids\": [100, 107, 101, 102, 103],\n",
" \"speaker_names\": [\"ずんだもん\", \"user\", \"そら\", \"めたん\", \"つむぎ\"],\n",
" \"src_id\": 107,\n",
" \"dst_id\": 100,\n",
" \"vf_enable\": true,\n",
" \"voice_changer_mode\": \"realtime\",\n",
" \"gpu\": 0,\n",
" \"available_gpus\": [-1, 0, 1, 2, 3, 4],\n",
" \"avatar\": {\n",
" \"enable_avatar\": true, \n",
" \"motion_capture_face\": true,\n",
" \"motion_capture_upperbody\": true,\n",
" \"lip_overwrite_with_voice\": true,\n",
" \"avatar_url\": \"./assets/vrm/zundamon/zundamon.vrm\",\n",
" \"backgournd_image_url\": \"./assets/images/bg_natural_sougen.jpg\",\n",
" \"background_color\": \"#0000dd\",\n",
" \"chroma_key\": \"#0000dd\",\n",
" \"avatar_canvas_size\": [1280, 720],\n",
" \"screen_canvas_size\": [1280, 720]\n",
" },\n",
" \"advance\": {\n",
" \"avatar_draw_skip_rate\": 3,\n",
" \"screen_draw_skip_rate\": 3,\n",
" \"visualizer_draw_skip_rate\": 3,\n",
" \"cross_fade_lower_value\": 0.1,\n",
" \"cross_fade_offset_rate\": 0.3,\n",
" \"cross_fade_end_rate\": 0.6,\n",
" \"cross_fade_type\": 2\n",
" }\n",
"}\n"
] ]
} }
] ]
@ -297,7 +182,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# (5) 設定ファイルの確認\n", "# (3) 設定ファイルの確認\n",
"!apt-get install -y espeak libsndfile1-dev &> /dev/null\n", "!apt-get install -y espeak libsndfile1-dev &> /dev/null\n",
"!pip install unidecode &> /dev/null\n", "!pip install unidecode &> /dev/null\n",
"!pip install phonemizer &> /dev/null\n", "!pip install phonemizer &> /dev/null\n",
@ -312,7 +197,7 @@
"metadata": { "metadata": {
"id": "LwZAAuqxX7yY" "id": "LwZAAuqxX7yY"
}, },
"execution_count": 44, "execution_count": 3,
"outputs": [] "outputs": []
}, },
{ {
@ -320,14 +205,12 @@
"source": [ "source": [
"# サーバの起動\n", "# サーバの起動\n",
"\n", "\n",
"サーバを起動します。(6-1)\n", "サーバを起動します。(4-1)\n",
"\n", "\n",
"サーバの起動状況を確認します。(6-2) \n", "サーバの起動状況を確認します。(4-2) \n",
"\n", "\n",
"このセルは繰り返し実行することになるのでCtrl+Retでセルを実行してください。\n", "このセルは繰り返し実行することになるのでCtrl+Retでセルを実行してください。\n",
"\n", "\n",
"アクセスできるようになるまで、1~2分かかるようです。コーヒーでも飲みに行きましょう。\n",
"\n",
"下記のようなテキストが表示されたら起動完了です。\n", "下記のようなテキストが表示されたら起動完了です。\n",
"\n", "\n",
"**`DEBUG:asyncio:Using selector: EpollSelector`**\n", "**`DEBUG:asyncio:Using selector: EpollSelector`**\n",
@ -349,7 +232,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# (6-1) サーバの起動\n", "# (4-1) サーバの起動\n",
"import random\n", "import random\n",
"PORT = 10000 + random.randint(1, 9999)\n", "PORT = 10000 + random.randint(1, 9999)\n",
"LOG_FILE = f\"LOG_FILE_{PORT}\"\n", "LOG_FILE = f\"LOG_FILE_{PORT}\"\n",
@ -358,27 +241,16 @@
"#print(f\"PORT:{PORT}, LOG_FILE:{LOG_FILE}\")" "#print(f\"PORT:{PORT}, LOG_FILE:{LOG_FILE}\")"
], ],
"metadata": { "metadata": {
"id": "G-nMdPxEW1rc", "id": "G-nMdPxEW1rc"
"outputId": "ed5fc2d9-f1c5-4aa3-df8d-e306de2e2a30",
"colab": {
"base_uri": "https://localhost:8080/"
}
}, },
"execution_count": 40, "execution_count": 4,
"outputs": [ "outputs": []
{
"output_type": "stream",
"name": "stdout",
"text": [
"PORT:19751, LOG_FILE:LOG_FILE_19751\n"
]
}
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# (6-2) サーバの起動確認 (Ctrl+Retで実行)\n", "# (4-2) サーバの起動確認\n",
"!sleep 5\n",
"!tail -20 {LOG_FILE}" "!tail -20 {LOG_FILE}"
], ],
"metadata": { "metadata": {
@ -386,9 +258,9 @@
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
}, },
"id": "chu06KpAjEK6", "id": "chu06KpAjEK6",
"outputId": "e6b67606-1279-49aa-e276-4e2bb83284c1" "outputId": "a1b039dc-8f47-44f4-fb02-be29f26468fd"
}, },
"execution_count": 45, "execution_count": 7,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
@ -399,12 +271,7 @@
"\u001b[32m PHASE1:__main__\u001b[0m\n", "\u001b[32m PHASE1:__main__\u001b[0m\n",
"\u001b[17mStart MMVC SocketIO Server\u001b[0m\n", "\u001b[17mStart MMVC SocketIO Server\u001b[0m\n",
"\u001b[34m CONFIG:None, MODEL:None\u001b[0m\n", "\u001b[34m CONFIG:None, MODEL:None\u001b[0m\n",
"DEBUG:asyncio:Using selector: EpollSelector\n", "DEBUG:asyncio:Using selector: EpollSelector\n"
"\u001b[32m Phase name:MMVCServerSIO\u001b[0m\n",
"\u001b[32m PHASE3:MMVCServerSIO\u001b[0m\n",
"File saved to: G_326000.pth\n",
"Load: config.json, G_326000.pth\n",
"INFO:root:Loaded checkpoint 'model_upload_dir/G_326000.pth' (iteration 1136)\n"
] ]
} }
] ]
@ -426,7 +293,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# (7) プロキシを起動\n", "# (5) プロキシを起動\n",
"from google.colab.output import eval_js\n", "from google.colab.output import eval_js\n",
"proxy = eval_js( \"google.colab.kernel.proxyPort(\" + str(PORT) + \")\" )\n", "proxy = eval_js( \"google.colab.kernel.proxyPort(\" + str(PORT) + \")\" )\n",
"print(f\"{proxy}front/\")" "print(f\"{proxy}front/\")"
@ -437,15 +304,15 @@
"base_uri": "https://localhost:8080/", "base_uri": "https://localhost:8080/",
"height": 34 "height": 34
}, },
"outputId": "bbc830e9-209a-4b71-891d-8cf78cf3077d" "outputId": "37531763-2abd-49e4-d2b7-0a301b9923de"
}, },
"execution_count": 43, "execution_count": 6,
"outputs": [ "outputs": [
{ {
"output_type": "stream", "output_type": "stream",
"name": "stdout", "name": "stdout",
"text": [ "text": [
"https://w6x1mbngbj-496ff2e9c6d22116-19751-colab.googleusercontent.com/front/\n" "https://s1ib44uhknk-496ff2e9c6d22116-19907-colab.googleusercontent.com/front/\n"
] ]
} }
] ]
@ -456,7 +323,7 @@
"metadata": { "metadata": {
"id": "axkt5BjhoiPV" "id": "axkt5BjhoiPV"
}, },
"execution_count": null, "execution_count": 6,
"outputs": [] "outputs": []
} }
] ]