File size: 5,081 Bytes
0163a2c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ddPn08/kohya-sd-scripts-webui/blob/main/kohya-sd-scripts-webui-colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"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 <br>\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
}
|