Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Google Drive path mounting on Colab #436

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def launch(self):
ssl_verify=args.ssl_verify,
ssl_keyfile=args.ssl_keyfile,
ssl_keyfile_password=args.ssl_keyfile_password,
ssl_certfile=args.ssl_certfile
ssl_certfile=args.ssl_certfile,
allowed_paths=eval(args.allowed_paths) if args.allowed_paths else None
)

@staticmethod
Expand Down Expand Up @@ -333,6 +334,7 @@ def on_change_models(model_size: str):
parser.add_argument('--colab', type=str2bool, default=False, nargs='?', const=True, help='Is colab user or not')
parser.add_argument('--api_open', type=str2bool, default=False, nargs='?', const=True,
help='Enable api or not in Gradio')
parser.add_argument('--allowed_paths', type=str, default=None, help='Gradio allowed paths')
parser.add_argument('--inbrowser', type=str2bool, default=True, nargs='?', const=True,
help='Whether to automatically start Gradio app or not')
parser.add_argument('--ssl_verify', type=str2bool, default=True, nargs='?', const=True,
Expand Down
44 changes: 40 additions & 4 deletions notebook/whisper-webui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,42 @@
"!pip install git+https://github.com/jhj0517/ultimatevocalremover_api.git"
]
},
{
"cell_type": "code",
"source": [
"#@title # (Optional) Mount Google Drive\n",
"#@markdown Uploading large input files directly via UI may consume alot of time because it has to be uploaded in colab's server.\n",
"#@markdown <br>This section is for using the input file paths from Google Drive to reduce such file uploading time.\n",
"#@markdown <br>And it will mount the output paths to your Google Drive's. This section is optional and can be ignored.\n",
"\n",
"\n",
"# Mount Google Drive\n",
"from google.colab import drive\n",
"import os\n",
"drive.mount('/content/drive')\n",
"\n",
"\n",
"# Symlink Output Paths for Whisper-WebUI\n",
"import os\n",
"\n",
"OUTPUT_DIRECTORY_PATH = '/content/drive/MyDrive/Whisper-WebUI/outputs' # @param {type:\"string\"}\n",
"local_output_path = '/content/Whisper-WebUI/outputs'\n",
"os.makedirs(local_output_path, exist_ok=True)\n",
"os.makedirs(OUTPUT_DIRECTORY_PATH, exist_ok=True)\n",
"\n",
"if os.path.exists(local_output_path):\n",
" !rm -r \"$local_output_path\"\n",
"\n",
"os.symlink(OUTPUT_DIRECTORY_PATH, local_output_path)\n",
"!ls \"$local_output_path\""
],
"metadata": {
"cellView": "form",
"id": "y2DY5oSb9Bol"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
Expand Down Expand Up @@ -93,12 +129,12 @@
"id": "Qosz9BFlGui3",
"cellView": "form"
},
"execution_count": null,
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "PQroYRRZzQiN",
"cellView": "form"
Expand All @@ -108,9 +144,9 @@
"#@title #Run\n",
"#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
"if 'arguments' in locals():\n",
" !python app.py --share --colab{arguments}\n",
" !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\"{arguments}\n",
"else:\n",
" !python app.py --share --colab"
" !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\""
]
}
],
Expand Down
Loading