diff --git a/MCSkinGen.ipynb b/MCSkinGen.ipynb new file mode 100644 index 0000000..f63329e --- /dev/null +++ b/MCSkinGen.ipynb @@ -0,0 +1,123 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "private_outputs": true, + "provenance": [], + "gpuType": "T4", + "toc_visible": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "In this block of code it will ask for your token from Hugging Face.\n", + "\n", + "If you don't have an account you can make one here: https://huggingface.co/join\n", + "\n", + "Before you can do this you need to accept the license agreement for the model, which you can do here: https://huggingface.co/CompVis/stable-diffusion-v1-4\n", + "\n", + "On the token page select \"new token\" and ask for a \"read\" token (you can name it \"Colab\")." + ], + "metadata": { + "id": "8pkEI3oVt_QD" + } + }, + { + "cell_type": "code", + "source": [ + "!pip install --quiet --upgrade diffusers transformers scipy mediapy accelerate networks lora utils pillow\n", + "!git clone https://github.com/RandomGamingDev/MCSkinsGen\n", + "!huggingface-cli login" + ], + "metadata": { + "id": "GR4vF2bw-sHR" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "from diffusers import PNDMScheduler, DDIMScheduler, LMSDiscreteScheduler\n", + "import mediapy as media\n", + "import torch\n", + "from torch import autocast\n", + "from diffusers import StableDiffusionPipeline\n", + "from safetensors.torch import load_file\n", + "\n", + "scheduler = PNDMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule=\"scaled_linear\", skip_prk_steps=True)\n", + "\n", + "#@markdown Stable Diffusion Model\n", + "model_id = \"runwayml/stable-diffusion-v1-5\" #@param {type:\"string\"}\n", + "#@markdown The Device (this is mostly just for if you're running it on a different machine)\n", + "device = \"cuda\" #@param {type:\"string\"}\n", + "\n", + "pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16, revision=\"fp16\", safety_checker=None, use_auth_token=True)\n", + "pipe = pipe.to(device)\n", + "\n", + "#@markdown LoRA Model\n", + "lora_model = \"mcskins-18.safetensors\" #@param {type:\"string\"}\n", + "\n", + "pipe.load_lora_weights(f\"/MCSkinsGen/models/{ lora_model }\")\n" + ], + "metadata": { + "id": "bG2hkmSEvByV" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Here is where you actually make images. Change the \"prompt\" to whatever you want to try and then change \"num_images\" if you want more than one image generated. You can re-run this cell without having to re-run everything before it." + ], + "metadata": { + "id": "IoTE794luOXD" + } + }, + { + "cell_type": "code", + "source": [ + "import PIL\n", + "\n", + "#@markdown Generation Parameters\n", + "prompt = \"A Alchemist minecraft skin in the tv category. Alchemist with golden hair.\" #@param {type:\"string\"}\n", + "num_images = 2 #@param {type:\"number\"}\n", + "\n", + "prompts = [prompt] * num_images\n", + "\n", + "#@markdown AI Parameters\n", + "guidance_scale = 7.5 #@param {type:\"number\"}\n", + "num_inference_steps = 50 #@param {type:\"number\"}\n", + "#@markdown Recommended values:
\n", + "#@markdown Most Recommended: `guidance_scale=7.5, num_inference_steps=50`
\n", + "#@markdown `guidance_scale=15, num_inference_steps=50 or 100 or 200`
\n", + "#@markdown `guidance_scale=30, num_inference_steps=100`\n", + "\n", + "with autocast(\"cuda\"):\n", + " images = pipe(prompts, guidance_scale=7.5, num_inference_steps=50).images\n", + "\n", + "#@markdown To download the skins simply right click and press `Save As`\n", + "images = [image.resize((64, 64), resample=PIL.Image.Resampling.NEAREST) for image in images]\n", + "media.show_images(images)" + ], + "metadata": { + "id": "AUc4QJfE-uR9", + "cellView": "form" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/MCSkinGenTrainer.ipynb b/MCSkinGenTrainer.ipynb new file mode 100644 index 0000000..3b9a4d4 --- /dev/null +++ b/MCSkinGenTrainer.ipynb @@ -0,0 +1,849 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "rmCPmqFL6hCQ" + }, + "source": [ + "# โญ Minecraft Skin Generator Trainer by RandomGamingDev\n", + "\n", + "This is the work of [Kohya-ss](https://github.com/kohya-ss/sd-scripts) and [Linaqruf](https://colab.research.google.com/github/Linaqruf/kohya-trainer/blob/main/kohya-LoRA-dreambooth.ipynb), but with some modifications to make it suitable for training a Minecraft Skin Generator.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "OglZzI_ujZq-", + "outputId": "9a43ea9c-eb3b-4690-cdc5-95e376ac8d70" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "๐Ÿ“‚ Connecting to Google Drive...\n", + "Mounted at /content/drive\n", + "\n", + "๐Ÿ’ฟ Checking dataset...\n", + "๐Ÿ“MyDrive/Loras/mcskins/dataset\n", + "๐Ÿ“ˆ Found 2429 images with 1 repeats, equaling 2429 steps.\n", + "๐Ÿ“‰ Divide 2429 steps by 2 batch size to get 1214.5 steps per epoch.\n", + "๐Ÿ”ฎ There will be 50 epochs, for around 60725 total training steps.\n", + "๐Ÿ’ฅ Error: Your total steps are too high. You probably made a mistake. Aborting...\n", + "I, RandomGamingdev removed this cause it didn't look like it's a problem.\n", + "\n", + "๐Ÿญ Installing dependencies...\n", + "\n", + "Cloning into '/content/kohya-trainer'...\n", + "remote: Enumerating objects: 4392, done.\u001b[K\n", + "remote: Counting objects: 100% (4392/4392), done.\u001b[K\n", + "remote: Compressing objects: 100% (1324/1324), done.\u001b[K\n", + "remote: Total 4392 (delta 3092), reused 4314 (delta 3062), pack-reused 0\u001b[K\n", + "Receiving objects: 100% (4392/4392), 8.29 MiB | 7.80 MiB/s, done.\n", + "Resolving deltas: 100% (3092/3092), done.\n", + "HEAD is now at e6ad3cb Merge pull request #478 from rockerBOO/patch-1\n", + "19 packages can be upgraded. Run 'apt list --upgradable' to see them.\n", + "The following additional packages will be installed:\n", + " libaria2-0 libc-ares2\n", + "The following NEW packages will be installed:\n", + " aria2 libaria2-0 libc-ares2\n", + "0 upgraded, 3 newly installed, 0 to remove and 19 not upgraded.\n", + "Need to get 1,513 kB of archives.\n", + "After this operation, 5,441 kB of additional disk space will be used.\n", + "Selecting previously unselected package libc-ares2:amd64.\n", + "(Reading database ... 120895 files and directories currently installed.)\n", + "Preparing to unpack .../libc-ares2_1.18.1-1ubuntu0.22.04.2_amd64.deb ...\n", + "Unpacking libc-ares2:amd64 (1.18.1-1ubuntu0.22.04.2) ...\n", + "Selecting previously unselected package libaria2-0:amd64.\n", + "Preparing to unpack .../libaria2-0_1.36.0-1_amd64.deb ...\n", + "Unpacking libaria2-0:amd64 (1.36.0-1) ...\n", + "Selecting previously unselected package aria2.\n", + "Preparing to unpack .../aria2_1.36.0-1_amd64.deb ...\n", + "Unpacking aria2 (1.36.0-1) ...\n", + "Setting up libc-ares2:amd64 (1.18.1-1ubuntu0.22.04.2) ...\n", + "Setting up libaria2-0:amd64 (1.36.0-1) ...\n", + "Setting up aria2 (1.36.0-1) ...\n", + "Processing triggers for man-db (2.10.2-1) ...\n", + "Processing triggers for libc-bin (2.35-0ubuntu3.1) ...\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link\n", + "\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link\n", + "\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link\n", + "\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link\n", + "\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link\n", + "\n", + "/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link\n", + "\n", + " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m191.5/191.5 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m6.3/6.3 MB\u001b[0m \u001b[31m28.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m53.1/53.1 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m123.5/123.5 kB\u001b[0m \u001b[31m12.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m61.8/61.8 MB\u001b[0m \u001b[31m10.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m41.6/41.6 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m503.1/503.1 kB\u001b[0m \u001b[31m43.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m825.8/825.8 kB\u001b[0m \u001b[31m61.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m62.5/62.5 MB\u001b[0m \u001b[31m10.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m54.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m109.1/109.1 MB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", + " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", + " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", + " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m295.0/295.0 kB\u001b[0m \u001b[31m33.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m106.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m805.2/805.2 kB\u001b[0m \u001b[31m62.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h Building wheel for dadaptation (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", + " Building wheel for lycoris_lora (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Building wheel for library (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "\n", + "โœ… Installation finished in 72 seconds.\n", + "\n", + "๐Ÿ”„ Downloading model...\n", + "\u001b[0m\n", + "Download Results:\n", + "gid |stat|avg speed |path/URI\n", + "======+====+===========+=======================================================\n", + "b0c2fd|\u001b[1;32mOK\u001b[0m | 241MiB/s|//content/AnyLoRA_noVae_fp16-pruned.ckpt\n", + "\n", + "Status Legend:\n", + "(OK):download completed.\n", + "\n", + "\n", + "๐Ÿ“„ Config saved to /content/drive/MyDrive/Loras/mcskins/training_config.toml\n", + "๐Ÿ“„ Dataset config saved to /content/drive/MyDrive/Loras/mcskins/dataset_config.toml\n", + "\n", + "โญ Starting trainer...\n", + "\n", + "Loading settings from /content/drive/MyDrive/Loras/mcskins/training_config.toml...\n", + "/content/drive/MyDrive/Loras/mcskins/training_config\n", + "prepare tokenizer\n", + "Downloading (โ€ฆ)olve/main/vocab.json: 100% 961k/961k [00:00<00:00, 4.34MB/s]\n", + "Downloading (โ€ฆ)olve/main/merges.txt: 100% 525k/525k [00:00<00:00, 83.4MB/s]\n", + "Downloading (โ€ฆ)cial_tokens_map.json: 100% 389/389 [00:00<00:00, 2.10MB/s]\n", + "Downloading (โ€ฆ)okenizer_config.json: 100% 905/905 [00:00<00:00, 3.54MB/s]\n", + "update token length: 225\n", + "Load dataset config from /content/drive/MyDrive/Loras/mcskins/dataset_config.toml\n", + "prepare images.\n", + "found directory /content/drive/MyDrive/Loras/mcskins/dataset contains 2429 image files\n", + "\u001b[31mโ•ญโ”€\u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31mโ”€โ•ฎ\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/\u001b[0m\u001b[1;33mtrain_network.py\u001b[0m:\u001b[94m773\u001b[0m in \u001b[92m\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m770 \u001b[0m\u001b[2mโ”‚ \u001b[0margs = parser.parse_args() \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m771 \u001b[0m\u001b[2mโ”‚ \u001b[0margs = train_util.read_config_from_file(args, parser) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m772 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m773 \u001b[2mโ”‚ \u001b[0mtrain(args) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m774 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/\u001b[0m\u001b[1;33mtrain_network.py\u001b[0m:\u001b[94m116\u001b[0m in \u001b[92mtrain\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m113 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m} \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m114 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m115 \u001b[0m\u001b[2mโ”‚ \u001b[0mblueprint = blueprint_generator.generate(user_config, args, tokeni \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m116 \u001b[2mโ”‚ \u001b[0mtrain_dataset_group = config_util.generate_dataset_group_by_bluepr \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m117 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m118 \u001b[0m\u001b[2mโ”‚ \u001b[0mcurrent_epoch = Value(\u001b[33m\"\u001b[0m\u001b[33mi\u001b[0m\u001b[33m\"\u001b[0m, \u001b[94m0\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m119 \u001b[0m\u001b[2mโ”‚ \u001b[0mcurrent_step = Value(\u001b[33m\"\u001b[0m\u001b[33mi\u001b[0m\u001b[33m\"\u001b[0m, \u001b[94m0\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/library/\u001b[0m\u001b[1;33mconfig_util.py\u001b[0m:\u001b[94m375\u001b[0m in \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[92mgenerate_dataset_group_by_blueprint\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m372 \u001b[0m\u001b[2mโ”‚ \u001b[0mdataset_klass = FineTuningDataset \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m373 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m374 \u001b[0m\u001b[2mโ”‚ \u001b[0msubsets = [subset_klass(**asdict(subset_blueprint.params)) \u001b[94mfor\u001b[0m sub \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m375 \u001b[2mโ”‚ \u001b[0mdataset = dataset_klass(subsets=subsets, **asdict(dataset_blueprin \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m376 \u001b[0m\u001b[2mโ”‚ \u001b[0mdatasets.append(dataset) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m377 \u001b[0m\u001b[2m \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m378 \u001b[0m\u001b[2m \u001b[0m\u001b[2m# print info\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/library/\u001b[0m\u001b[1;33mtrain_util.py\u001b[0m:\u001b[94m1114\u001b[0m in \u001b[92m__init__\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1111 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1112 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mcontinue\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1113 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1114 \u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0mimg_paths, captions = load_dreambooth_dir(subset) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1115 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m \u001b[96mlen\u001b[0m(img_paths) < \u001b[94m1\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1116 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[96mprint\u001b[0m(\u001b[33mf\u001b[0m\u001b[33m\"\u001b[0m\u001b[33mignore subset with image_dir=\u001b[0m\u001b[33m'\u001b[0m\u001b[33m{\u001b[0msubset.image_d \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1117 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mcontinue\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/library/\u001b[0m\u001b[1;33mtrain_util.py\u001b[0m:\u001b[94m1086\u001b[0m in \u001b[92mload_dreambooth_dir\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1083 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# ็”ปๅƒใƒ•ใ‚กใ‚คใƒซใ”ใจใซใƒ—ใƒญใƒณใƒ—ใƒˆใ‚’่ชญใฟ่พผใฟใ€ใ‚‚ใ—ใ‚ใ‚Œใฐใใก \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1084 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0mcaptions = [] \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1085 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mfor\u001b[0m img_path \u001b[95min\u001b[0m img_paths: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1086 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0mcap_for_img = read_caption(img_path, subset.caption_e \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1087 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m cap_for_img \u001b[95mis\u001b[0m \u001b[94mNone\u001b[0m \u001b[95mand\u001b[0m subset.class_tokens \u001b[95mis\u001b[0m \u001b[94mNon\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1088 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[96mprint\u001b[0m(\u001b[33mf\u001b[0m\u001b[33m\"\u001b[0m\u001b[33mneither caption file nor class tokens are\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1089 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0mcaptions.append(\u001b[33m\"\u001b[0m\u001b[33m\"\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/content/kohya-trainer/library/\u001b[0m\u001b[1;33mtrain_util.py\u001b[0m:\u001b[94m1066\u001b[0m in \u001b[92mread_caption\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1063 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m os.path.isfile(cap_path): \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1064 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mwith\u001b[0m \u001b[96mopen\u001b[0m(cap_path, \u001b[33m\"\u001b[0m\u001b[33mrt\u001b[0m\u001b[33m\"\u001b[0m, encoding=\u001b[33m\"\u001b[0m\u001b[33mutf-8\u001b[0m\u001b[33m\"\u001b[0m) \u001b[94mas\u001b[0m f: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1065 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1066 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0mlines = f.readlines() \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1067 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mexcept\u001b[0m \u001b[96mUnicodeDecodeError\u001b[0m \u001b[94mas\u001b[0m e: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1068 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[96mprint\u001b[0m(\u001b[33mf\u001b[0m\u001b[33m\"\u001b[0m\u001b[33millegal char in file (not UTF-8) \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1069 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mraise\u001b[0m e \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33mcodecs.py\u001b[0m:\u001b[94m319\u001b[0m in \u001b[92mdecode\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 316 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[2m# and return an (output, length consumed) tuple\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 317 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mraise\u001b[0m \u001b[96mNotImplementedError\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 318 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m 319 \u001b[2mโ”‚ \u001b[0m\u001b[94mdef\u001b[0m \u001b[92mdecode\u001b[0m(\u001b[96mself\u001b[0m, \u001b[96minput\u001b[0m, final=\u001b[94mFalse\u001b[0m): \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 320 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[2m# decode input (taking the buffer into account)\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 321 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0mdata = \u001b[96mself\u001b[0m.buffer + \u001b[96minput\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 322 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m(result, consumed) = \u001b[96mself\u001b[0m._buffer_decode(data, \u001b[96mself\u001b[0m.errors, f \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n", + "\u001b[1;91mKeyboardInterrupt\u001b[0m\n", + "\u001b[31mโ•ญโ”€\u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31mโ”€โ•ฎ\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33msubprocess.py\u001b[0m:\u001b[94m1209\u001b[0m in \u001b[92mwait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1206 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m timeout \u001b[95mis\u001b[0m \u001b[95mnot\u001b[0m \u001b[94mNone\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1207 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0mendtime = _time() + timeout \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1208 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1209 \u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mreturn\u001b[0m \u001b[96mself\u001b[0m._wait(timeout=timeout) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1210 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mexcept\u001b[0m \u001b[96mKeyboardInterrupt\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1211 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# https://bugs.python.org/issue25942\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1212 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# The first keyboard interrupt waits briefly for the chil\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33msubprocess.py\u001b[0m:\u001b[94m1959\u001b[0m in \u001b[92m_wait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1956 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mwith\u001b[0m \u001b[96mself\u001b[0m._waitpid_lock: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1957 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m \u001b[96mself\u001b[0m.returncode \u001b[95mis\u001b[0m \u001b[95mnot\u001b[0m \u001b[94mNone\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1958 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mbreak\u001b[0m \u001b[2m# Another thread waited.\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1959 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m(pid, sts) = \u001b[96mself\u001b[0m._try_wait(\u001b[94m0\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1960 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# Check the pid and loop as waitpid has been \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1961 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# return 0 even without WNOHANG in odd situat\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1962 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# http://bugs.python.org/issue14396.\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33msubprocess.py\u001b[0m:\u001b[94m1917\u001b[0m in \u001b[92m_try_wait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1914 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mdef\u001b[0m \u001b[92m_try_wait\u001b[0m(\u001b[96mself\u001b[0m, wait_flags): \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1915 \u001b[0m\u001b[2;90mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[33m\"\"\"All callers to this function MUST hold self._waitpid_l\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1916 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1917 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m(pid, sts) = os.waitpid(\u001b[96mself\u001b[0m.pid, wait_flags) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1918 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mexcept\u001b[0m \u001b[96mChildProcessError\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1919 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# This happens if SIGCLD is set to be ignored or wait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1920 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[2m# for child processes has otherwise been disabled for\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n", + "\u001b[1;91mKeyboardInterrupt\u001b[0m\n", + "\n", + "\u001b[3mDuring handling of the above exception, another exception occurred:\u001b[0m\n", + "\n", + "\u001b[31mโ•ญโ”€\u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[31mโ”€โ•ฎ\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/local/bin/\u001b[0m\u001b[1;33maccelerate\u001b[0m:\u001b[94m8\u001b[0m in \u001b[92m\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m5 \u001b[0m\u001b[94mfrom\u001b[0m \u001b[4;96maccelerate\u001b[0m\u001b[4;96m.\u001b[0m\u001b[4;96mcommands\u001b[0m\u001b[4;96m.\u001b[0m\u001b[4;96maccelerate_cli\u001b[0m \u001b[94mimport\u001b[0m main \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m6 \u001b[0m\u001b[94mif\u001b[0m \u001b[91m__name__\u001b[0m == \u001b[33m'\u001b[0m\u001b[33m__main__\u001b[0m\u001b[33m'\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m7 \u001b[0m\u001b[2mโ”‚ \u001b[0msys.argv[\u001b[94m0\u001b[0m] = re.sub(\u001b[33mr\u001b[0m\u001b[33m'\u001b[0m\u001b[33m(-script\u001b[0m\u001b[33m\\\u001b[0m\u001b[33m.pyw|\u001b[0m\u001b[33m\\\u001b[0m\u001b[33m.exe)?$\u001b[0m\u001b[33m'\u001b[0m, \u001b[33m'\u001b[0m\u001b[33m'\u001b[0m, sys.argv[\u001b[94m0\u001b[0m]) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m8 \u001b[2mโ”‚ \u001b[0msys.exit(main()) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m9 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/local/lib/python3.10/dist-packages/accelerate/commands/\u001b[0m\u001b[1;33maccelerate_cli.p\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[1;33my\u001b[0m:\u001b[94m45\u001b[0m in \u001b[92mmain\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m42 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0mexit(\u001b[94m1\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m43 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m44 \u001b[0m\u001b[2mโ”‚ \u001b[0m\u001b[2m# Run\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m45 \u001b[2mโ”‚ \u001b[0margs.func(args) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m46 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m47 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m48 \u001b[0m\u001b[94mif\u001b[0m \u001b[91m__name__\u001b[0m == \u001b[33m\"\u001b[0m\u001b[33m__main__\u001b[0m\u001b[33m\"\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/local/lib/python3.10/dist-packages/accelerate/commands/\u001b[0m\u001b[1;33mlaunch.py\u001b[0m:\u001b[94m1104\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m in \u001b[92mlaunch_command\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1101 \u001b[0m\u001b[2mโ”‚ \u001b[0m\u001b[94melif\u001b[0m defaults \u001b[95mis\u001b[0m \u001b[95mnot\u001b[0m \u001b[94mNone\u001b[0m \u001b[95mand\u001b[0m defaults.compute_environment == Com \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1102 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0msagemaker_launcher(defaults, args) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1103 \u001b[0m\u001b[2mโ”‚ \u001b[0m\u001b[94melse\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1104 \u001b[2mโ”‚ โ”‚ \u001b[0msimple_launcher(args) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1105 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1106 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1107 \u001b[0m\u001b[94mdef\u001b[0m \u001b[92mmain\u001b[0m(): \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/local/lib/python3.10/dist-packages/accelerate/commands/\u001b[0m\u001b[1;33mlaunch.py\u001b[0m:\u001b[94m565\u001b[0m in \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[92msimple_launcher\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 562 \u001b[0m\u001b[2mโ”‚ \u001b[0mcurrent_env[\u001b[33m\"\u001b[0m\u001b[33mOMP_NUM_THREADS\u001b[0m\u001b[33m\"\u001b[0m] = \u001b[96mstr\u001b[0m(args.num_cpu_threads_per_pro \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 563 \u001b[0m\u001b[2mโ”‚ \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 564 \u001b[0m\u001b[2mโ”‚ \u001b[0mprocess = subprocess.Popen(cmd, env=current_env) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m 565 \u001b[2mโ”‚ \u001b[0mprocess.wait() \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 566 \u001b[0m\u001b[2mโ”‚ \u001b[0m\u001b[94mif\u001b[0m process.returncode != \u001b[94m0\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 567 \u001b[0m\u001b[2mโ”‚ โ”‚ \u001b[0m\u001b[94mraise\u001b[0m subprocess.CalledProcessError(returncode=process.return \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m 568 \u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33msubprocess.py\u001b[0m:\u001b[94m1222\u001b[0m in \u001b[92mwait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1219 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0msigint_timeout = \u001b[96mself\u001b[0m._sigint_wait_secs \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1220 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[96mself\u001b[0m._sigint_wait_secs = \u001b[94m0\u001b[0m \u001b[2m# nothing else should wait.\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1221 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1222 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[96mself\u001b[0m._wait(timeout=sigint_timeout) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1223 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mexcept\u001b[0m TimeoutExpired: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1224 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mpass\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1225 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mraise\u001b[0m \u001b[2m# resume the KeyboardInterrupt\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2;33m/usr/lib/python3.10/\u001b[0m\u001b[1;33msubprocess.py\u001b[0m:\u001b[94m1953\u001b[0m in \u001b[92m_wait\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1950 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mif\u001b[0m remaining <= \u001b[94m0\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1951 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mraise\u001b[0m TimeoutExpired(\u001b[96mself\u001b[0m.args, timeout) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1952 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0mdelay = \u001b[96mmin\u001b[0m(delay * \u001b[94m2\u001b[0m, remaining, \u001b[94m.05\u001b[0m) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[31mโฑ \u001b[0m1953 \u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0mtime.sleep(delay) \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1954 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94melse\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1955 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mwhile\u001b[0m \u001b[96mself\u001b[0m.returncode \u001b[95mis\u001b[0m \u001b[94mNone\u001b[0m: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ”‚\u001b[0m \u001b[2m1956 \u001b[0m\u001b[2mโ”‚ โ”‚ โ”‚ โ”‚ โ”‚ \u001b[0m\u001b[94mwith\u001b[0m \u001b[96mself\u001b[0m._waitpid_lock: \u001b[31mโ”‚\u001b[0m\n", + "\u001b[31mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n", + "\u001b[1;91mKeyboardInterrupt\u001b[0m\n", + "^C\n" + ] + } + ], + "source": [ + "import os\n", + "import re\n", + "import toml\n", + "import shutil\n", + "import zipfile\n", + "from time import time\n", + "from IPython.display import Markdown, display\n", + "\n", + "# These carry information from past executions\n", + "if \"model_url\" in globals():\n", + " old_model_url = model_url\n", + "else:\n", + " old_model_url = None\n", + "if \"dependencies_installed\" not in globals():\n", + " dependencies_installed = False\n", + "if \"model_file\" not in globals():\n", + " model_file = None\n", + "\n", + "# These may be set by other cells, some are legacy\n", + "if \"custom_dataset\" not in globals():\n", + " custom_dataset = None\n", + "if \"override_dataset_config_file\" not in globals():\n", + " override_dataset_config_file = None\n", + "if \"override_config_file\" not in globals():\n", + " override_config_file = None\n", + "if \"optimizer\" not in globals():\n", + " optimizer = \"AdamW8bit\"\n", + "if \"optimizer_args\" not in globals():\n", + " optimizer_args = None\n", + "if \"continue_from_lora\" not in globals():\n", + " continue_from_lora = \"\"\n", + "if \"weighted_captions\" not in globals():\n", + " weighted_captions = False\n", + "if \"adjust_tags\" not in globals():\n", + " adjust_tags = False\n", + "if \"keep_tokens_weight\" not in globals():\n", + " keep_tokens_weight = 1.0\n", + "\n", + "COLAB = True # low ram\n", + "COMMIT = \"e6ad3cbc66130fdc3bf9ecd1e0272969b1d613f7\"\n", + "BETTER_EPOCH_NAMES = True\n", + "LOAD_TRUNCATED_IMAGES = True\n", + "\n", + "#@title ## ๐Ÿšฉ Start Here\n", + "\n", + "#@markdown ### โ–ถ๏ธ Setup\n", + "#@markdown Your project name will be the same as the folder containing your images. Spaces aren't allowed.\n", + "project_name = \"mcskins\" #@param {type:\"string\"}\n", + "#@markdown The folder structure doesn't matter and is purely for comfort. Make sure to always pick the same one. I like organizing by project.\n", + "folder_structure = \"Organize by project (MyDrive/Loras/project_name/dataset)\" #@param [\"Organize by category (MyDrive/lora_training/datasets/project_name)\", \"Organize by project (MyDrive/Loras/project_name/dataset)\"]\n", + "#@markdown Decide the model that will be downloaded and used for training. These options should produce clean and consistent results. You can also choose your own by pasting its download link.\n", + "training_model = \"AnyLora (AnyLoRA_noVae_fp16-pruned.ckpt)\" #@param [\"Anime (animefull-final-pruned-fp16.safetensors)\", \"AnyLora (AnyLoRA_noVae_fp16-pruned.ckpt)\", \"Stable Diffusion (sd-v1-5-pruned-noema-fp16.safetensors)\"]\n", + "optional_custom_training_model_url = \"\" #@param {type:\"string\"}\n", + "custom_model_is_based_on_sd2 = False #@param {type:\"boolean\"}\n", + "\n", + "if optional_custom_training_model_url:\n", + " model_url = optional_custom_training_model_url\n", + "elif \"AnyLora\" in training_model:\n", + " model_url = \"https://huggingface.co/Lykon/AnyLoRA/resolve/main/AnyLoRA_noVae_fp16-pruned.ckpt\"\n", + "elif \"Anime\" in training_model:\n", + " model_url = \"https://huggingface.co/hollowstrawberry/stable-diffusion-guide/resolve/main/models/animefull-final-pruned-fp16.safetensors\"\n", + "else:\n", + " model_url = \"https://huggingface.co/hollowstrawberry/stable-diffusion-guide/resolve/main/models/sd-v1-5-pruned-noema-fp16.safetensors\"\n", + "\n", + "#@markdown ### โ–ถ๏ธ Processing\n", + "#@markdown Resolution of 512 is standard for Stable Diffusion 1.5. Higher resolution training is much slower but can lead to better details.

\n", + "#@markdown Images will be automatically scaled while training to produce the best results, so you don't need to crop or resize anything yourself.\n", + "resolution = 512 #@param {type:\"slider\", min:512, max:1024, step:128}\n", + "#@markdown This option will train your images both normally and flipped, for no extra cost, to learn more from them. Turn it on specially if you have less than 20 images.

\n", + "#@markdown **Turn it off if you care about asymmetrical elements in your Lora**.\n", + "flip_aug = False #@param {type:\"boolean\"}\n", + "#markdown Leave empty for no captions.\n", + "caption_extension = \".txt\" #param {type:\"string\"}\n", + "#@markdown Shuffling anime tags in place improves learning and prompting. An activation tag goes at the start of every text file and will not be shuffled.\n", + "shuffle_tags = True #@param {type:\"boolean\"}\n", + "shuffle_caption = shuffle_tags\n", + "activation_tags = \"1\" #@param [0,1,2,3]\n", + "keep_tokens = int(activation_tags)\n", + "\n", + "#@markdown ### โ–ถ๏ธ Steps

\n", + "#@markdown Your images will repeat this number of times during training. I recommend that your images multiplied by their repeats is between 200 and 400.\n", + "num_repeats = 1 #@param {type:\"number\"}\n", + "#@markdown Choose how long you want to train for. A good starting point is around 10 epochs or around 2000 steps.

\n", + "#@markdown One epoch is a number of steps equal to: your number of images multiplied by their repeats, divided by batch size.

\n", + "preferred_unit = \"Epochs\" #@param [\"Epochs\", \"Steps\"]\n", + "how_many = 50 #@param {type:\"number\"}\n", + "max_train_epochs = how_many if preferred_unit == \"Epochs\" else None\n", + "max_train_steps = how_many if preferred_unit == \"Steps\" else None\n", + "#@markdown Saving more epochs will let you compare your Lora's progress better.\n", + "save_every_n_epochs = 1 #@param {type:\"number\"}\n", + "keep_only_last_n_epochs = 10 #@param {type:\"number\"}\n", + "if not save_every_n_epochs:\n", + " save_every_n_epochs = max_train_epochs\n", + "if not keep_only_last_n_epochs:\n", + " keep_only_last_n_epochs = max_train_epochs\n", + "#@markdown Increasing the batch size makes training faster, but may make learning worse. Recommended 2 or 3.\n", + "train_batch_size = 2 #@param {type:\"slider\", min:1, max:8, step:1}\n", + "\n", + "#@markdown ### โ–ถ๏ธ Learning\n", + "#@markdown The learning rate is the most important for your results. If you want to train slower with lots of images, or if your dim and alpha are high, move the unet to 2e-4 or lower.

\n", + "#@markdown The text encoder helps your Lora learn concepts slightly better. It is recommended to make it half or a fifth of the unet. If you're training a style you can even set it to 0.\n", + "unet_lr = 2e-4 #@param {type:\"number\"}\n", + "text_encoder_lr = 1e-4 #@param {type:\"number\"}\n", + "#@markdown The scheduler is the algorithm that guides the learning rate. If you're not sure, pick `constant` and ignore the number. I personally recommend `cosine_with_restarts` with 3 restarts.\n", + "lr_scheduler = \"constant\" #@param [\"constant\", \"cosine\", \"cosine_with_restarts\", \"constant_with_warmup\", \"linear\", \"polynomial\"]\n", + "lr_scheduler_number = 3 #@param {type:\"number\"}\n", + "lr_scheduler_num_cycles = lr_scheduler_number if lr_scheduler == \"cosine_with_restarts\" else 0\n", + "lr_scheduler_power = lr_scheduler_number if lr_scheduler == \"polynomial\" else 0\n", + "#@markdown Steps spent \"warming up\" the learning rate during training for efficiency. I recommend leaving it at 5%.\n", + "lr_warmup_ratio = 0.05 #@param {type:\"slider\", min:0.0, max:0.5, step:0.01}\n", + "lr_warmup_steps = 0\n", + "#@markdown New feature that adjusts loss over time, makes learning much more efficient, and training can be done with about half as many epochs. Uses a value of 5.0 as recommended by [the paper](https://arxiv.org/abs/2303.09556).\n", + "min_snr_gamma = True #@param {type:\"boolean\"}\n", + "min_snr_gamma_value = 5.0 if min_snr_gamma else None\n", + "\n", + "#@markdown ### โ–ถ๏ธ Structure\n", + "#@markdown LoRA is the classic type, while LoCon is good with styles. Lycoris require [this extension](https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris) for webui to work like normal loras. More info [here](https://github.com/KohakuBlueleaf/Lycoris).\n", + "lora_type = \"LoRA\" #@param [\"LoRA\", \"LoCon Lycoris\", \"LoHa Lycoris\"]\n", + "\n", + "#@markdown Below are some recommended values for the following settings:\n", + "\n", + "#@markdown | type | network_dim | network_alpha | conv_dim | conv_alpha |\n", + "#@markdown | :---: | :---: | :---: | :---: | :---: |\n", + "#@markdown | LoRA | 32 | 16 | | |\n", + "#@markdown | LoCon | 16 | 8 | 8 | 1 |\n", + "#@markdown | LoHa | 8 | 4 | 4 | 1 |\n", + "\n", + "#@markdown More dim means larger Lora, it can hold more information but more isn't always better. A dim between 8-32 is recommended, and alpha equal to half the dim.\n", + "network_dim = 32 #@param {type:\"slider\", min:1, max:128, step:1}\n", + "network_alpha = 16 #@param {type:\"slider\", min:1, max:128, step:1}\n", + "#@markdown The following values don't affect LoRA. They work like dim/alpha but only for the additional learning layers of Lycoris.\n", + "conv_dim = 8 #@param {type:\"slider\", min:1, max:64, step:1}\n", + "conv_alpha = 1 #@param {type:\"slider\", min:1, max:64, step:1}\n", + "conv_compression = False #@param {type:\"boolean\"}\n", + "\n", + "network_module = \"lycoris.kohya\" if \"Lycoris\" in lora_type else \"networks.lora\"\n", + "network_args = None if lora_type == \"LoRA\" else [\n", + " f\"conv_dim={conv_dim}\",\n", + " f\"conv_alpha={conv_alpha}\",\n", + "]\n", + "if \"Lycoris\" in lora_type:\n", + " network_args.append(f\"algo={'loha' if 'LoHa' in lora_type else 'lora'}\")\n", + " network_args.append(f\"disable_conv_cp={str(not conv_compression)}\")\n", + "\n", + "#markdown ### โ–ถ๏ธ Experimental\n", + "#markdown Save additional data equaling ~1 GB allowing you to resume training later.\n", + "save_state = False #param {type:\"boolean\"}\n", + "#markdown Resume training if a save state is found.\n", + "resume = False #param {type:\"boolean\"}\n", + "\n", + "#@markdown ### โ–ถ๏ธ Ready\n", + "#@markdown You can now run this cell to cook your Lora. Good luck!

\n", + "\n", + "\n", + "# ๐Ÿ‘ฉโ€๐Ÿ’ป Cool code goes here\n", + "\n", + "if optimizer == \"DAdaptation\":\n", + " optimizer_args = [\"decouple=True\",\"weight_decay=0.02\",\"betas=[0.9,0.99]\"]\n", + " unet_lr = 0.5\n", + " text_encoder_lr = 0.5\n", + " lr_scheduler = \"constant_with_warmup\"\n", + " network_alpha = network_dim\n", + "\n", + "root_dir = \"/content\" if COLAB else \"~/Loras\"\n", + "deps_dir = os.path.join(root_dir, \"deps\")\n", + "repo_dir = os.path.join(root_dir, \"kohya-trainer\")\n", + "\n", + "if \"/Loras\" in folder_structure:\n", + " main_dir = os.path.join(root_dir, \"drive/MyDrive/Loras\") if COLAB else root_dir\n", + " log_folder = os.path.join(main_dir, \"_logs\")\n", + " config_folder = os.path.join(main_dir, project_name)\n", + " images_folder = os.path.join(main_dir, project_name, \"dataset\")\n", + " output_folder = os.path.join(main_dir, project_name, \"output\")\n", + "else:\n", + " main_dir = os.path.join(root_dir, \"drive/MyDrive/lora_training\") if COLAB else root_dir\n", + " images_folder = os.path.join(main_dir, \"datasets\", project_name)\n", + " output_folder = os.path.join(main_dir, \"output\", project_name)\n", + " config_folder = os.path.join(main_dir, \"config\", project_name)\n", + " log_folder = os.path.join(main_dir, \"log\")\n", + "\n", + "config_file = os.path.join(config_folder, \"training_config.toml\")\n", + "dataset_config_file = os.path.join(config_folder, \"dataset_config.toml\")\n", + "accelerate_config_file = os.path.join(repo_dir, \"accelerate_config/config.yaml\")\n", + "\n", + "def clone_repo():\n", + " os.chdir(root_dir)\n", + " !git clone https://github.com/kohya-ss/sd-scripts {repo_dir}\n", + " os.chdir(repo_dir)\n", + " if COMMIT:\n", + " !git reset --hard {COMMIT}\n", + " !wget https://raw.githubusercontent.com/hollowstrawberry/kohya-colab/main/requirements.txt -q -O requirements.txt\n", + "\n", + "def install_dependencies():\n", + " clone_repo()\n", + " !apt -y update -qq\n", + " !apt -y install aria2 -qq\n", + " !pip -q install --upgrade -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118\n", + "\n", + " # patch kohya for minor stuff\n", + " if COLAB:\n", + " !sed -i \"s@cpu@cuda@\" library/model_util.py # low ram\n", + " if LOAD_TRUNCATED_IMAGES:\n", + " !sed -i 's/from PIL import Image/from PIL import Image, ImageFile\\nImageFile.LOAD_TRUNCATED_IMAGES=True/g' library/train_util.py # fix truncated jpegs error\n", + " if BETTER_EPOCH_NAMES:\n", + " !sed -i 's/{:06d}/{:02d}/g' library/train_util.py # make epoch names shorter\n", + " !sed -i 's/\".\" + args.save_model_as)/\"-{:02d}.\".format(num_train_epochs) + args.save_model_as)/g' train_network.py # name of the last epoch will match the rest\n", + "\n", + " from accelerate.utils import write_basic_config\n", + " if not os.path.exists(accelerate_config_file):\n", + " write_basic_config(save_location=accelerate_config_file)\n", + "\n", + " os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n", + " os.environ[\"BITSANDBYTES_NOWELCOME\"] = \"1\"\n", + " os.environ[\"SAFETENSORS_FAST_GPU\"] = \"1\"\n", + "\n", + "def validate_dataset():\n", + " global lr_warmup_steps, lr_warmup_ratio, caption_extension, keep_tokens, keep_tokens_weight, weighted_captions, adjust_tags\n", + " supported_types = (\".png\", \".jpg\", \".jpeg\", \".webp\", \".bmp\")\n", + "\n", + " print(\"\\n๐Ÿ’ฟ Checking dataset...\")\n", + " if not project_name.strip() or any(c in project_name for c in \" .()\\\"'\\\\/\"):\n", + " print(\"๐Ÿ’ฅ Error: Please choose a valid project name.\")\n", + " return\n", + "\n", + " if custom_dataset:\n", + " try:\n", + " datconf = toml.loads(custom_dataset)\n", + " datasets = [d for d in datconf[\"datasets\"][0][\"subsets\"]]\n", + " except:\n", + " print(f\"๐Ÿ’ฅ Error: Your custom dataset is invalid or contains an error! Please check the original template.\")\n", + " return\n", + " reg = [d for d in datasets if d.get(\"is_reg\", False)]\n", + " for r in reg:\n", + " print(\"๐Ÿ“\"+r[\"image_dir\"].replace(\"/content/drive/\", \"\") + \" (Regularization)\")\n", + " datasets = [d for d in datasets if d not in reg]\n", + " datasets_dict = {d[\"image_dir\"]: d[\"num_repeats\"] for d in datasets}\n", + " folders = datasets_dict.keys()\n", + " files = [f for folder in folders for f in os.listdir(folder)]\n", + " images_repeats = {folder: (len([f for f in os.listdir(folder) if f.lower().endswith(supported_types)]), datasets_dict[folder]) for folder in folders}\n", + " else:\n", + " folders = [images_folder]\n", + " files = os.listdir(images_folder)\n", + " images_repeats = {images_folder: (len([f for f in files if f.lower().endswith(supported_types)]), num_repeats)}\n", + "\n", + " for folder in folders:\n", + " if not os.path.exists(folder):\n", + " print(f\"๐Ÿ’ฅ Error: The folder {folder.replace('/content/drive/', '')} doesn't exist.\")\n", + " return\n", + " for folder, (img, rep) in images_repeats.items():\n", + " if not img:\n", + " print(f\"๐Ÿ’ฅ Error: Your {folder.replace('/content/drive/', '')} folder is empty.\")\n", + " return\n", + " for f in files:\n", + " if not f.lower().endswith(\".txt\") and not f.lower().endswith(supported_types):\n", + " print(f\"๐Ÿ’ฅ Error: Invalid file in dataset: \\\"{f}\\\". Aborting.\")\n", + " return\n", + "\n", + " if not [txt for txt in files if txt.lower().endswith(\".txt\")]:\n", + " caption_extension = \"\"\n", + " if continue_from_lora and not (continue_from_lora.endswith(\".safetensors\") and os.path.exists(continue_from_lora)):\n", + " print(f\"๐Ÿ’ฅ Error: Invalid path to existing Lora. Example: /content/drive/MyDrive/Loras/example.safetensors\")\n", + " return\n", + "\n", + " pre_steps_per_epoch = sum(img*rep for (img, rep) in images_repeats.values())\n", + " steps_per_epoch = pre_steps_per_epoch/train_batch_size\n", + " total_steps = max_train_steps or int(max_train_epochs*steps_per_epoch)\n", + " estimated_epochs = int(total_steps/steps_per_epoch)\n", + " lr_warmup_steps = int(total_steps*lr_warmup_ratio)\n", + "\n", + " for folder, (img, rep) in images_repeats.items():\n", + " print(\"๐Ÿ“\"+folder.replace(\"/content/drive/\", \"\"))\n", + " print(f\"๐Ÿ“ˆ Found {img} images with {rep} repeats, equaling {img*rep} steps.\")\n", + " print(f\"๐Ÿ“‰ Divide {pre_steps_per_epoch} steps by {train_batch_size} batch size to get {steps_per_epoch} steps per epoch.\")\n", + " if max_train_epochs:\n", + " print(f\"๐Ÿ”ฎ There will be {max_train_epochs} epochs, for around {total_steps} total training steps.\")\n", + " else:\n", + " print(f\"๐Ÿ”ฎ There will be {total_steps} steps, divided into {estimated_epochs} epochs and then some.\")\n", + "\n", + " if total_steps > 10000:\n", + " print(\"๐Ÿ’ฅ Error: Your total steps are too high. You probably made a mistake. Aborting...\")\n", + " print(\"I, RandomGamingdev removed this cause it didn't look like it's a problem.\")\n", + " #return\n", + "\n", + " if adjust_tags:\n", + " print(f\"\\n๐Ÿ“Ž Weighted tags: {'ON' if weighted_captions else 'OFF'}\")\n", + " if weighted_captions:\n", + " print(f\"๐Ÿ“Ž Will use {keep_tokens_weight} weight on {keep_tokens} activation tag(s)\")\n", + " print(\"๐Ÿ“Ž Adjusting tags...\")\n", + " adjust_weighted_tags(folders, keep_tokens, keep_tokens_weight, weighted_captions)\n", + "\n", + " return True\n", + "\n", + "def adjust_weighted_tags(folders, keep_tokens: int, keep_tokens_weight: float, weighted_captions: bool):\n", + " weighted_tag = re.compile(r\"\\((.+?):[.\\d]+\\)(,|$)\")\n", + " for folder in folders:\n", + " for txt in [f for f in os.listdir(folder) if f.lower().endswith(\".txt\")]:\n", + " with open(os.path.join(folder, txt), 'r') as f:\n", + " content = f.read()\n", + " # reset previous changes\n", + " content = content.replace('\\\\', '')\n", + " content = weighted_tag.sub(r'\\1\\2', content)\n", + " if weighted_captions:\n", + " # re-apply changes\n", + " content = content.replace(r'(', r'\\(').replace(r')', r'\\)').replace(r':', r'\\:')\n", + " if keep_tokens_weight > 1:\n", + " tags = [s.strip() for s in content.split(\",\")]\n", + " for i in range(min(keep_tokens, len(tags))):\n", + " tags[i] = f'({tags[i]}:{keep_tokens_weight})'\n", + " content = \", \".join(tags)\n", + " with open(os.path.join(folder, txt), 'w') as f:\n", + " f.write(content)\n", + "\n", + "def create_config():\n", + " global dataset_config_file, config_file, model_file\n", + "\n", + " if resume:\n", + " resume_points = [f.path for f in os.scandir(output_folder) if f.is_dir()]\n", + " resume_points.sort()\n", + " last_resume_point = resume_points[-1] if resume_points else None\n", + " else:\n", + " last_resume_point = None\n", + "\n", + " if override_config_file:\n", + " config_file = override_config_file\n", + " print(f\"\\nโญ• Using custom config file {config_file}\")\n", + " else:\n", + " config_dict = {\n", + " \"additional_network_arguments\": {\n", + " \"unet_lr\": unet_lr,\n", + " \"text_encoder_lr\": text_encoder_lr,\n", + " \"network_dim\": network_dim,\n", + " \"network_alpha\": network_alpha,\n", + " \"network_module\": network_module,\n", + " \"network_args\": network_args,\n", + " \"network_train_unet_only\": True if text_encoder_lr == 0 else None,\n", + " \"network_weights\": continue_from_lora if continue_from_lora else None\n", + " },\n", + " \"optimizer_arguments\": {\n", + " \"learning_rate\": unet_lr,\n", + " \"lr_scheduler\": lr_scheduler,\n", + " \"lr_scheduler_num_cycles\": lr_scheduler_num_cycles if lr_scheduler == \"cosine_with_restarts\" else None,\n", + " \"lr_scheduler_power\": lr_scheduler_power if lr_scheduler == \"polynomial\" else None,\n", + " \"lr_warmup_steps\": lr_warmup_steps if lr_scheduler != \"constant\" else None,\n", + " \"optimizer_type\": optimizer,\n", + " \"optimizer_args\": optimizer_args if optimizer_args else None,\n", + " },\n", + " \"training_arguments\": {\n", + " \"max_train_steps\": max_train_steps,\n", + " \"max_train_epochs\": max_train_epochs,\n", + " \"save_every_n_epochs\": save_every_n_epochs,\n", + " \"save_last_n_epochs\": keep_only_last_n_epochs,\n", + " \"train_batch_size\": train_batch_size,\n", + " \"noise_offset\": None,\n", + " \"clip_skip\": 2,\n", + " \"min_snr_gamma\": min_snr_gamma_value,\n", + " \"weighted_captions\": weighted_captions,\n", + " \"seed\": 42,\n", + " \"max_token_length\": 225,\n", + " \"xformers\": True,\n", + " \"lowram\": COLAB,\n", + " \"max_data_loader_n_workers\": 8,\n", + " \"persistent_data_loader_workers\": True,\n", + " \"save_precision\": \"fp16\",\n", + " \"mixed_precision\": \"fp16\",\n", + " \"output_dir\": output_folder,\n", + " \"logging_dir\": log_folder,\n", + " \"output_name\": project_name,\n", + " \"log_prefix\": project_name,\n", + " \"save_state\": save_state,\n", + " \"save_last_n_epochs_state\": 1 if save_state else None,\n", + " \"resume\": last_resume_point\n", + " },\n", + " \"model_arguments\": {\n", + " \"pretrained_model_name_or_path\": model_file,\n", + " \"v2\": custom_model_is_based_on_sd2,\n", + " \"v_parameterization\": True if custom_model_is_based_on_sd2 else None,\n", + " },\n", + " \"saving_arguments\": {\n", + " \"save_model_as\": \"safetensors\",\n", + " },\n", + " \"dreambooth_arguments\": {\n", + " \"prior_loss_weight\": 1.0,\n", + " },\n", + " \"dataset_arguments\": {\n", + " \"cache_latents\": True,\n", + " },\n", + " }\n", + "\n", + " for key in config_dict:\n", + " if isinstance(config_dict[key], dict):\n", + " config_dict[key] = {k: v for k, v in config_dict[key].items() if v is not None}\n", + "\n", + " with open(config_file, \"w\") as f:\n", + " f.write(toml.dumps(config_dict))\n", + " print(f\"\\n๐Ÿ“„ Config saved to {config_file}\")\n", + "\n", + " if override_dataset_config_file:\n", + " dataset_config_file = override_dataset_config_file\n", + " print(f\"โญ• Using custom dataset config file {dataset_config_file}\")\n", + " else:\n", + " dataset_config_dict = {\n", + " \"general\": {\n", + " \"resolution\": resolution,\n", + " \"shuffle_caption\": shuffle_caption,\n", + " \"keep_tokens\": keep_tokens,\n", + " \"flip_aug\": flip_aug,\n", + " \"caption_extension\": caption_extension,\n", + " \"enable_bucket\": True,\n", + " \"bucket_reso_steps\": 64,\n", + " \"bucket_no_upscale\": False,\n", + " \"min_bucket_reso\": 320 if resolution > 640 else 256,\n", + " \"max_bucket_reso\": 1280 if resolution > 640 else 1024,\n", + " },\n", + " \"datasets\": toml.loads(custom_dataset)[\"datasets\"] if custom_dataset else [\n", + " {\n", + " \"subsets\": [\n", + " {\n", + " \"num_repeats\": num_repeats,\n", + " \"image_dir\": images_folder,\n", + " \"class_tokens\": None if caption_extension else project_name\n", + " }\n", + " ]\n", + " }\n", + " ]\n", + " }\n", + "\n", + " for key in dataset_config_dict:\n", + " if isinstance(dataset_config_dict[key], dict):\n", + " dataset_config_dict[key] = {k: v for k, v in dataset_config_dict[key].items() if v is not None}\n", + "\n", + " with open(dataset_config_file, \"w\") as f:\n", + " f.write(toml.dumps(dataset_config_dict))\n", + " print(f\"๐Ÿ“„ Dataset config saved to {dataset_config_file}\")\n", + "\n", + "def download_model():\n", + " global old_model_url, model_url, model_file\n", + " real_model_url = model_url.strip()\n", + "\n", + " if real_model_url.lower().endswith((\".ckpt\", \".safetensors\")):\n", + " model_file = f\"/content{real_model_url[real_model_url.rfind('/'):]}\"\n", + " else:\n", + " model_file = \"/content/downloaded_model.safetensors\"\n", + " if os.path.exists(model_file):\n", + " !rm \"{model_file}\"\n", + "\n", + " if m := re.search(r\"(?:https?://)?(?:www\\.)?huggingface\\.co/[^/]+/[^/]+/blob\", model_url):\n", + " real_model_url = real_model_url.replace(\"blob\", \"resolve\")\n", + " elif m := re.search(r\"(?:https?://)?(?:www\\.)?civitai\\.com/models/([0-9]+)\", model_url):\n", + " real_model_url = f\"https://civitai.com/api/download/models/{m.group(1)}\"\n", + "\n", + " !aria2c \"{real_model_url}\" --console-log-level=warn -c -s 16 -x 16 -k 10M -d / -o \"{model_file}\"\n", + "\n", + " if model_file.lower().endswith(\".safetensors\"):\n", + " from safetensors.torch import load_file as load_safetensors\n", + " try:\n", + " test = load_safetensors(model_file)\n", + " del test\n", + " except Exception as e:\n", + " #if \"HeaderTooLarge\" in str(e):\n", + " new_model_file = os.path.splitext(model_file)[0]+\".ckpt\"\n", + " !mv \"{model_file}\" \"{new_model_file}\"\n", + " model_file = new_model_file\n", + " print(f\"Renamed model to {os.path.splitext(model_file)[0]}.ckpt\")\n", + "\n", + " if model_file.lower().endswith(\".ckpt\"):\n", + " from torch import load as load_ckpt\n", + " try:\n", + " test = load_ckpt(model_file)\n", + " del test\n", + " except Exception as e:\n", + " return False\n", + "\n", + " return True\n", + "\n", + "def main():\n", + " global dependencies_installed\n", + "\n", + " if COLAB and not os.path.exists('/content/drive'):\n", + " from google.colab import drive\n", + " print(\"๐Ÿ“‚ Connecting to Google Drive...\")\n", + " drive.mount('/content/drive')\n", + "\n", + " for dir in (main_dir, deps_dir, repo_dir, log_folder, images_folder, output_folder, config_folder):\n", + " os.makedirs(dir, exist_ok=True)\n", + "\n", + " if not validate_dataset():\n", + " return\n", + "\n", + " if not dependencies_installed:\n", + " print(\"\\n๐Ÿญ Installing dependencies...\\n\")\n", + " t0 = time()\n", + " install_dependencies()\n", + " t1 = time()\n", + " dependencies_installed = True\n", + " print(f\"\\nโœ… Installation finished in {int(t1-t0)} seconds.\")\n", + " else:\n", + " print(\"\\nโœ… Dependencies already installed.\")\n", + "\n", + " if old_model_url != model_url or not model_file or not os.path.exists(model_file):\n", + " print(\"\\n๐Ÿ”„ Downloading model...\")\n", + " if not download_model():\n", + " print(\"\\n๐Ÿ’ฅ Error: The model you selected is invalid or corrupted, or couldn't be downloaded. You can use a civitai or huggingface link, or any direct download link.\")\n", + " return\n", + " print()\n", + " else:\n", + " print(\"\\n๐Ÿ”„ Model already downloaded.\\n\")\n", + "\n", + " create_config()\n", + "\n", + " print(\"\\nโญ Starting trainer...\\n\")\n", + " os.chdir(repo_dir)\n", + "\n", + " !accelerate launch --config_file={accelerate_config_file} --num_cpu_threads_per_process=1 train_network.py --dataset_config={dataset_config_file} --config_file={config_file}\n", + "\n", + " if not get_ipython().__dict__['user_ns']['_exit_code']:\n", + " display(Markdown(\"### โœ… Done! [Go download your Lora(s) from Google Drive](https://drive.google.com/drive/my-drive)\"))\n", + "\n", + "main()" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "provenance": [], + "gpuType": "T4" + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/models/mcskins-09.safetensors b/models/mcskins-09.safetensors new file mode 100644 index 0000000..4697406 Binary files /dev/null and b/models/mcskins-09.safetensors differ diff --git a/models/mcskins-10.safetensors b/models/mcskins-10.safetensors new file mode 100644 index 0000000..ce04833 Binary files /dev/null and b/models/mcskins-10.safetensors differ diff --git a/models/mcskins-11.safetensors b/models/mcskins-11.safetensors new file mode 100644 index 0000000..0280888 Binary files /dev/null and b/models/mcskins-11.safetensors differ diff --git a/models/mcskins-12.safetensors b/models/mcskins-12.safetensors new file mode 100644 index 0000000..31d29c0 Binary files /dev/null and b/models/mcskins-12.safetensors differ diff --git a/models/mcskins-13.safetensors b/models/mcskins-13.safetensors new file mode 100644 index 0000000..192b0d7 Binary files /dev/null and b/models/mcskins-13.safetensors differ diff --git a/models/mcskins-14.safetensors b/models/mcskins-14.safetensors new file mode 100644 index 0000000..6f5f413 Binary files /dev/null and b/models/mcskins-14.safetensors differ diff --git a/models/mcskins-15.safetensors b/models/mcskins-15.safetensors new file mode 100644 index 0000000..3df3589 Binary files /dev/null and b/models/mcskins-15.safetensors differ diff --git a/models/mcskins-16.safetensors b/models/mcskins-16.safetensors new file mode 100644 index 0000000..6cf2e75 Binary files /dev/null and b/models/mcskins-16.safetensors differ diff --git a/models/mcskins-17.safetensors b/models/mcskins-17.safetensors new file mode 100644 index 0000000..e1225b3 Binary files /dev/null and b/models/mcskins-17.safetensors differ diff --git a/models/mcskins-18.safetensors b/models/mcskins-18.safetensors new file mode 100644 index 0000000..9751980 Binary files /dev/null and b/models/mcskins-18.safetensors differ