Colab を使用して作成されました

This commit is contained in:
w-okada 2024-06-23 19:59:09 +09:00
parent 61f4f2a4a7
commit 95a7f0e9a4

View File

@ -61,11 +61,10 @@
"source": [ "source": [
"#=================Updated=================\n", "#=================Updated=================\n",
"# @title **[1]** Clone repository and install dependencies\n", "# @title **[1]** Clone repository and install dependencies\n",
"# @markdown This first step will download the latest version of Voice Changer and install the dependencies. **It can take some time to complete.**\n", "# @markdown This first step will download the latest version of Voice Changer and install the dependencies. **It can take some time to complete.(~10min)**\n",
"\n", "\n",
"#@markdown ---\n", "#@markdown ---\n",
"# @title **[Optional]** Connect to Google Drive\n", "# @markdown By using Google Drive, you can avoid re-downloading already downloaded versions.\n",
"# @markdown Using Google Drive will automatically save your uploaded models for later use.\n",
"\n", "\n",
"\n", "\n",
"import os\n", "import os\n",
@ -80,6 +79,10 @@
"Run_Cell=0\n", "Run_Cell=0\n",
"Use_Drive=True #@param {type:\"boolean\"}\n", "Use_Drive=True #@param {type:\"boolean\"}\n",
"\n", "\n",
"current_version_hash=None\n",
"latest_version_hash=None\n",
"\n",
"\n",
"notebook_env=0\n", "notebook_env=0\n",
"if os.path.exists('/content'):\n", "if os.path.exists('/content'):\n",
" notebook_env=1\n", " notebook_env=1\n",
@ -95,11 +98,6 @@
"\n", "\n",
"from IPython.display import clear_output, Javascript\n", "from IPython.display import clear_output, Javascript\n",
"\n", "\n",
"print(\"Installing libportaudio2... \",end=\"\")\n",
"!sudo apt-get install -y libportaudio2 > /dev/null 2>&1\n",
"!pip install pyngrok > /dev/null 2>&1\n",
"print(\"done.\")\n",
"\n",
"if notebook_env==1 and Use_Drive==True:\n", "if notebook_env==1 and Use_Drive==True:\n",
" work_dir = \"/content/drive/MyDrive/vcclient\"\n", " work_dir = \"/content/drive/MyDrive/vcclient\"\n",
" if not os.path.exists('/content/drive'):\n", " if not os.path.exists('/content/drive'):\n",
@ -124,20 +122,32 @@
" print(f\"hash not match -> download latest version\")\n", " print(f\"hash not match -> download latest version\")\n",
"\n", "\n",
" latest_hash_path=f'{work_dir}/latest_hash.txt'\n", " latest_hash_path=f'{work_dir}/latest_hash.txt'\n",
" !curl -L https://huggingface.co/wok000/vcclient000_colab/resolve/main/vcclient_latest_for_colab -o {work_dir}/vcclient_latest_for_colab\n", " !curl -L https://huggingface.co/wok000/vcclient000_colab/resolve/main/vcclient_latest_for_colab.zip -o {work_dir}/vcclient_latest_for_colab.zip\n",
" !cp latest_hash.txt {latest_hash_path}\n", " !cp latest_hash.txt {latest_hash_path}\n",
" print(\"Download is done.\")\n",
" else:\n", " else:\n",
" print(\"hash matched. skip download\")\n", " print(\"hash matched. skip download\")\n",
"\n", "\n",
"else:\n", "else:\n",
" work_dir = \"/content\"\n", " work_dir = \"/content\"\n",
" print(\"Downloading the latest vcclient... \")\n", " print(\"Downloading the latest vcclient... \")\n",
" !curl -L https://huggingface.co/wok000/vcclient000_colab/resolve/main/vcclient_latest_for_colab -o {work_dir}/vcclient_latest_for_colab\n", " !curl -s -L https://huggingface.co/wok000/vcclient000_colab/resolve/main/latest_hash.txt -o latest_hash.txt\n",
" print(\"done.\")\n", " latest_version_hash = open('latest_hash.txt').read().strip()\n",
" !curl -L https://huggingface.co/wok000/vcclient000_colab/resolve/main/vcclient_latest_for_colab.zip -o {work_dir}/vcclient_latest_for_colab.zip\n",
" print(\"Download is done.\")\n",
"\n", "\n",
"%cd {work_dir}\n", "if current_version_hash != latest_version_hash:\n",
"!chmod 0700 vcclient_latest_for_colab\n", " print(f\"Unzip vcclient to {latest_version_hash} ... \")\n",
"!ls -lha vcclient_latest_for_colab\n", " !cd {work_dir} && unzip -q vcclient_latest_for_colab.zip -d {latest_version_hash}\n",
" print(f\"Unzip is done.\")\n",
"\n",
"%cd {work_dir}/{latest_version_hash}/main\n",
"!chmod 0700 main\n",
"\n",
"print(\"Installing modules... \",end=\"\")\n",
"!sudo apt-get install -y libportaudio2 > /dev/null 2>&1\n",
"!pip install pyngrok > /dev/null 2>&1\n",
"print(\"Install is done.\")\n",
"\n", "\n",
"Run_Cell=1\n" "Run_Cell=1\n"
] ]
@ -164,7 +174,7 @@
"# @markdown **1** - Create a <font color=green>**free**</font> account at [ngrok](https://dashboard.ngrok.com/signup) or **login with Google/Github account**\\\n", "# @markdown **1** - Create a <font color=green>**free**</font> account at [ngrok](https://dashboard.ngrok.com/signup) or **login with Google/Github account**\\\n",
"# @markdown **2** - If you didn't logged in with Google/Github, you will need to **verify your e-mail**!\\\n", "# @markdown **2** - If you didn't logged in with Google/Github, you will need to **verify your e-mail**!\\\n",
"# @markdown **3** - Click [this link](https://dashboard.ngrok.com/get-started/your-authtoken) to get your auth token, and place it here:\n", "# @markdown **3** - Click [this link](https://dashboard.ngrok.com/get-started/your-authtoken) to get your auth token, and place it here:\n",
"Token = 'TOKEN' # @param {type:\"string\"}\n", "Token = '' # @param {type:\"string\"}\n",
"# @markdown **4** - *(optional)* Change to a region near to you or keep at United States if increase latency\\\n", "# @markdown **4** - *(optional)* Change to a region near to you or keep at United States if increase latency\\\n",
"# @markdown `Default Region: ap - Asia/Pacific (Singapore)`\n", "# @markdown `Default Region: ap - Asia/Pacific (Singapore)`\n",
"Region = \"jp - Japan (Tokyo)\" # @param [\"ap - Asia/Pacific (Singapore)\", \"au - Australia (Sydney)\",\"eu - Europe (Frankfurt)\", \"in - India (Mumbai)\",\"jp - Japan (Tokyo)\",\"sa - South America (Sao Paulo)\", \"us - United States (Ohio)\"]\n", "Region = \"jp - Japan (Tokyo)\" # @param [\"ap - Asia/Pacific (Singapore)\", \"au - Australia (Sydney)\",\"eu - Europe (Frankfurt)\", \"in - India (Mumbai)\",\"jp - Japan (Tokyo)\",\"sa - South America (Sao Paulo)\", \"us - United States (Ohio)\"]\n",
@ -211,17 +221,24 @@
"# @markdown This cell will start the server, the first time that you run it will download the models, so it can take a while (~1-2 minutes)\n", "# @markdown This cell will start the server, the first time that you run it will download the models, so it can take a while (~1-2 minutes)\n",
"\n", "\n",
"# @markdown When you see the message \"running...\", please launch the application from the link above.\n", "# @markdown When you see the message \"running...\", please launch the application from the link above.\n",
"!LD_LIBRARY_PATH=/usr/lib64-nvidia:/usr/lib/x86_64-linux-gnu ./vcclient_latest_for_colab cui --port {PORT} --no_cui true\n", "!LD_LIBRARY_PATH=/usr/lib64-nvidia:/usr/lib/x86_64-linux-gnu ./main cui --port {PORT} --no_cui true\n",
"\n" "\n"
] ]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "iv9OixP6rCEP"
},
"execution_count": null,
"outputs": []
} }
], ],
"metadata": { "metadata": {
"accelerator": "GPU",
"colab": { "colab": {
"gpuType": "T4",
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyNnHjYET1tXcVALa6o6IPRp", "authorship_tag": "ABX9TyNWJR74GxLHE/fMfDb7IR0J",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {