{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zSM6HuYmkYCt"
},
"source": [
"# [kohya sd-scripts webui](https://github.com/ddPn08/kohya-sd-scripts-webui)\n",
"\n",
"This notebook is for running [sd-scripts](https://github.com/kohya-ss/sd-scripts) by [Kohya](https://github.com/kohya-ss).\n",
"\n",
"このノートブックは[Kohya](https://github.com/kohya-ss)さんによる[sd-scripts](https://github.com/kohya-ss/sd-scripts)を実行するためのものです。\n",
"\n",
"# Repository\n",
"[kohya_ss/sd-scripts](https://github.com/kohya-ss/sd-scripts)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zXcznGdeyb2I"
},
"outputs": [],
"source": [
"! nvidia-smi\n",
"! nvcc -V\n",
"! free -h"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "tj65Tb_oyxtP"
},
"outputs": [],
"source": [
"# @markdown # Mount Google Drive\n",
"mount_gdrive = True # @param {type:\"boolean\"}\n",
"gdrive_preset_path = \"/content/drive/MyDrive/AI/kohya-sd-scripts-webui/presets\" # @param {type:\"string\"}\n",
"\n",
"if mount_gdrive:\n",
" from google.colab import drive\n",
" drive.mount('/content/drive', force_remount=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "FN7UJvSdzBFF"
},
"outputs": [],
"source": [
"# @markdown # Initialize environment\n",
"\n",
"! git clone https://github.com/ddPn08/kohya-sd-scripts-webui.git\n",
"\n",
"import os\n",
"\n",
"if not os.path.exists(gdrive_preset_path):\n",
" os.makedirs(gdrive_preset_path, exist_ok=True)\n",
"\n",
"! rm -f ./kohya-sd-scripts-webui/presets.json\n",
"! ln -s {gdrive_preset_path} ./kohya-sd-scripts-webui/presets\n",
"\n",
"conda_dir = \"/opt/conda\" # @param{type:\"string\"}\n",
"conda_bin = os.path.join(conda_dir, \"bin\", \"conda\")\n",
"\n",
"if not os.path.exists(conda_bin):\n",
" ! curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh\n",
" ! chmod +x Miniconda3-latest-Linux-x86_64.sh\n",
" ! bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p {conda_dir}\n",
" ! rm Miniconda3-latest-Linux-x86_64.sh\n",
"\n",
"def run_script(s):\n",
" ! {s}\n",
"\n",
"def make_args(d):\n",
" arguments = \"\"\n",
" for k, v in d.items():\n",
" if type(v) == bool:\n",
" arguments += f\"--{k} \" if v else \"\"\n",
" elif type(v) == str and v:\n",
" arguments += f\"--{k} \\\"{v}\\\" \"\n",
" elif v:\n",
" arguments += f\"--{k}={v} \"\n",
" return arguments"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "uetu1lShs6aJ"
},
"outputs": [],
"source": [
"# @markdown # Run\n",
"\n",
"# @markdown
\n",
"\n",
"# @markdown ## Optional | Ngrok Tunnel\n",
"# @markdown Get token from [here](https://dashboard.ngrok.com/get-started/your-authtoken)\n",
"\n",
"ngrok_token = \"\" # @param {type:\"string\"}\n",
"ngrok_region = \"us\" # @param [\"us\", \"eu\", \"au\", \"ap\", \"sa\", \"jp\", \"in\"]\n",
"\n",
"arguments = {\n",
" \"ngrok\": ngrok_token,\n",
" \"ngrok-region\": ngrok_region,\n",
" \"share\": ngrok_token is None,\n",
" \"xformers\": True,\n",
" \"enable-console-log\": True\n",
"}\n",
"\n",
"run_script(f\"\"\"\n",
"eval \"$({conda_bin} shell.bash hook)\"\n",
"cd kohya-sd-scripts-webui\n",
"python launch.py {make_args(arguments)}\n",
"\"\"\")"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"include_colab_link": true,
"provenance": []
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}