Created
December 19, 2023 08:03
-
-
Save takada-at/545214ed2ddb68b2c526e25bb0f22e0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.10.4", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"colab": { | |
"provenance": [] | |
} | |
}, | |
"nbformat_minor": 5, | |
"nbformat": 4, | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# @markdown ### Clone repository\n", | |
"%cd /content/\n", | |
"repository_url = \"https://github.com/bmaltais/kohya_ss.git\" # @param {type: \"string\"}\n", | |
"webui_branch = \"master\" # @param {type: \"string\"}\n", | |
"\n", | |
"! git clone {repository_url}\n", | |
"%cd /content/kohya_ss\n", | |
"! git checkout {webui_branch}" | |
], | |
"metadata": { | |
"cellView": "form", | |
"id": "vijBY1XnmQhB" | |
}, | |
"id": "vijBY1XnmQhB", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# @markdown ### Install\n", | |
"%cd /content/kohya_ss\n", | |
"! pip install bitsandbytes\n", | |
"! pip install -r requirements.txt\n", | |
"! pip3 install xformers==0.0.22.post4+cu118 --index-url https://download.pytorch.org/whl/cu118" | |
], | |
"metadata": { | |
"cellView": "form", | |
"id": "epl7L0zPmTOk" | |
}, | |
"id": "epl7L0zPmTOk", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# @markdown ## Create Password\n", | |
"import secrets\n", | |
"import string\n", | |
"\n", | |
"\n", | |
"def create_password(length):\n", | |
" chars = string.ascii_uppercase + string.ascii_lowercase + string.digits\n", | |
" pw = \"\".join([secrets.choice(chars) for _ in range(length)])\n", | |
" return pw\n", | |
"\n", | |
"\n", | |
"account = ! gcloud config get-value account\n", | |
"gradio_auth_username = account[0].split('@')[0]\n", | |
"gradio_auth_password = create_password(10)\n", | |
"print(f\"gradio_auth_username: {gradio_auth_username}\")\n", | |
"print(f\"gradio_auth_password: {gradio_auth_password}\")" | |
], | |
"metadata": { | |
"cellView": "form", | |
"id": "y76TLaVgmdOr" | |
}, | |
"id": "y76TLaVgmdOr", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# @markdown ### Run script\n", | |
"%cd /content/kohya_ss\n", | |
"\n", | |
"timelimit = 1 #@param {type:\"slider\", min:1, max:5, step:1}\n", | |
"timeout = int(3600 * timelimit)\n", | |
"print(f\"gradio_auth_username: {gradio_auth_username}\")\n", | |
"print(f\"gradio_auth_password: {gradio_auth_password}\")\n", | |
"!timeout {timeout} python kohya_gui.py --share --headless --username {gradio_auth_username} --password {gradio_auth_password}\n" | |
], | |
"metadata": { | |
"cellView": "form", | |
"id": "JwTu0gLGmiZd" | |
}, | |
"id": "JwTu0gLGmiZd", | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment