Skip to content

Commit

Permalink
Merge pull request #939 from d8ahazard/dev
Browse files Browse the repository at this point in the history
Rock and ROLL!
  • Loading branch information
d8ahazard authored Mar 1, 2023
2 parents 43ae9d5 + 9c18904 commit d4e2f7d
Show file tree
Hide file tree
Showing 58 changed files with 5,830 additions and 5,910 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://www.paypal.com/donate/?hosted_button_id=UWE4GTY3JR7GY']
custom: [ 'https://www.paypal.com/donate/?hosted_button_id=UWE4GTY3JR7GY' ]
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ labels: ''
assignees: ''

---

### Kindly read the entire form below and fill it out with the requested information.

**WHAT**
Expand Down
14 changes: 7 additions & 7 deletions .github/autoclose.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Autocloser
on: [issues]
on: [ issues ]
jobs:
autoclose:
runs-on: ubuntu-latest
steps:
- name: Auto-close issues that did not follow issue template
uses: roots/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-close-message: "@${issue.user.login} This issue was automatically closed because you didn't use the template. Go here and try again: https://github.com/d8ahazard/sd_dreambooth_extension/issues/new/choose"
issue-pattern: ".### Kindly read the entire form below and fill it out with the requested information."
- name: Auto-close issues that did not follow issue template
uses: roots/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-close-message: "@${issue.user.login} This issue was automatically closed because you didn't use the template. Go here and try again: https://github.com/d8ahazard/sd_dreambooth_extension/issues/new/choose"
issue-pattern: ".### Kindly read the entire form below and fill it out with the requested information."
239 changes: 239 additions & 0 deletions D8-DreamBooth.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github"
},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/d8ahazard/sd_dreambooth_extension/blob/Torch2/D8-DreamBooth.ipynb)"
]
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"import os\n",
"\n",
"drive.mount(\"/content/gdrive\", force_remount=True)\n",
"\n",
"if not os.path.exists(\"/content/gdrive/MyDrive/sd-db-d8\"):\n",
" os.mkdirs(\"/content/gdrive/MyDrive/sd-db-d8\")\n",
"\n",
"if not os.path.exists(\"/content/working/\"):\n",
" os.mkdirs(\"/content/working/\")\n",
"\n",
"!rm -f /content/working/stable-diffusion-webui\n",
"!ln -s /content/gdrive/MyDrive/sd-db-d8 /content/working/stable-diffusion-webui"
],
"metadata": {
"id": "W4eFr-nSHE85"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Install various packages"
],
"metadata": {
"id": "PLbCegoEyO4M"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "upF9RGj0tTiH"
},
"outputs": [],
"source": [
"# **fast-DreamBooth colab From https://github.com/d8ahazard/sd_dreambooth_extension, modified from https://github.com/camenduru/stable-diffusion-webui-collab**\n",
"!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /content/working/stable-diffusion-webui/\n",
"!wget https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O /content/working/stable-diffusion-webui/scripts/run_n_times.py\n",
"!git clone https://github.com/AlUlkesh/stable-diffusion-webui-images-browser /content/working/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser\n",
"!git clone https://github.com/camenduru/stable-diffusion-webui-huggingface /content/working/stable-diffusion-webui/extensions/stable-diffusion-webui-huggingface\n",
"!git clone https://github.com/camenduru/sd-civitai-browser /content/working/stable-diffusion-webui/extensions/sd-civitai-browser\n",
"!git clone https://github.com/camenduru/sd-webui-additional-networks /content/working/stable-diffusion-webui/extensions/sd-webui-additional-networks\n",
"!git clone -b Torch2 https://github.com/d8ahazard/sd_dreambooth_extension /content/working/stable-diffusion-webui/extensions/sd_dreambooth_extension\n",
"\n",
"%cd /content/working/stable-diffusion-webui\n"
]
},
{
"cell_type": "markdown",
"source": [
"Bump Python Version (RUN ONCE)"
],
"metadata": {
"id": "no--xkmZyJGx"
}
},
{
"cell_type": "code",
"source": [
"\n",
"!wget https://github.com/korakot/kora/releases/download/v0.10/py310.sh\n",
"!bash ./py310.sh -b -f -p /usr/local\n",
"!python -m ipykernel install --name \"py310\" --user\n"
],
"metadata": {
"id": "IJxdOKeBvUGp"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Download the 1.5 Model"
],
"metadata": {
"id": "sQirFY6cyr1O"
}
},
{
"cell_type": "code",
"source": [
"!wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.safetensors -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned.safetensors\n"
],
"metadata": {
"id": "F42Hh4v8yjyB"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"And/Or download the 2.1 Model"
],
"metadata": {
"id": "K0uL_P3OyvC5"
}
},
{
"cell_type": "code",
"source": [
"!wget https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-nonema-pruned.safetensors -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-nonema-pruned.safetensors\n",
"\n",
"!wget https://huggingface.co/ckpt/stable-diffusion-2-1/raw/main/v2-inference-v.yaml -O /content/working/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-nonemaema-pruned.yaml\n"
],
"metadata": {
"id": "FKyzSN7SyfbZ"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Install Dreambooth and Auto1111 dependencies (RUN ONCE)"
],
"metadata": {
"id": "kzh_c4qvyFUs"
}
},
{
"cell_type": "code",
"source": [
"!%cd /content/working/stable-diffusion-webui/\n",
"# Clone Auto1111 repos\n",
"!git clone \"https://github.com/Stability-AI/stablediffusion.git\" \"/content/working/stable-diffusion-webui/repositories/stable-diffusion-stability-ai\" \n",
"!%cd \"/content/working/stable-diffusion-webui/repositories/stable-diffusion-stability-ai\" \n",
"!git checkout \"47b6b607fdd31875c9279cd2f4f16b92e4ea958e\"\n",
"!git clone \"https://github.com/CompVis/taming-transformers.git\" \"/content/working/stable-diffusion-webui/repositories/taming-transformers\" \n",
"!%cd \"/content/working/stable-diffusion-webui/repositories/taming-transformers\" \n",
"!git checkout \"24268930bf1dce879235a7fddd0b2355b84d7ea6\"\n",
"!git clone \"https://github.com/crowsonkb/k-diffusion.git\" \"/content/working/stable-diffusion-webui/repositories/k-diffusion\"\n",
"!%cd \"/content/working/stable-diffusion-webui/repositories/k-diffusion\"\n",
"!git checkout \"5b3af030dd83e0297272d861c19477735d0317ec\"\n",
"!git clone \"https://github.com/sczhou/CodeFormer.git\" \"/content/working/stable-diffusion-webui/repositories/CodeFormer\"\n",
"!%cd \"/content/working/stable-diffusion-webui/repositories/CodeFormer\" \n",
"!git checkout \"c5b4593074ba6214284d6acd5f1719b6c5d739af\"\n",
"!git clone \"https://github.com/salesforce/BLIP.git\" \"/content/working/stable-diffusion-webui/repositories/BLIP\" \n",
"!%cd \"/content/working/stable-diffusion-webui/repositories/BLIP\"\n",
"!git checkout \"48211a1594f1321b00f14c9f7a5b4813144b2fb9\"\n"
],
"metadata": {
"id": "q4-o5-Grx_sw"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Setup VENV"
],
"metadata": {
"id": "_G-NX4mvIv-G"
}
},
{
"cell_type": "code",
"source": [
"# Install PIP stuff\n",
"!%cd /content/working/stable-diffusion-webui/\n",
"!pip install virtualenv\n",
"!virtualenv venv\n",
"!source venv/bin/activate\n",
"# Install Auto1111 PIP packages\n",
"!pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379\n",
"!pip install git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1\n",
"!pip install git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b\n",
"\n",
"# Install Requirements\n",
"!pip install -r /content/working/stable-diffusion-webui/requirements_versions.txt\n",
"!pip install -r /content/working/stable-diffusion-webui./extensions/sd_dreambooth_extension/requirements.txt\n",
"!pip install https://github.com/ArrowM/xformers/releases/download/xformers-0.0.17%2B36e23c5.d20230209-cp310-cu118/xformers-0.0.17+36e23c5.d20230209-cp310-cp310-linux_x86_64.whl\n",
"!pip install https://download.pytorch.org/whl/nightly/cu118/torch-2.0.0.dev20230209%2Bcu118-cp310-cp310-linux_x86_64.whl https://download.pytorch.org/whl/nightly/cu118/torchvision-0.15.0.dev20230209%2Bcu118-cp310-cp310-linux_x86_64.whl\n"
],
"metadata": {
"id": "XIdP81K-Isiw"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Run Auto1111"
],
"metadata": {
"id": "A_AePD55yYeQ"
}
},
{
"cell_type": "code",
"source": [
"!%cd /content/working/stable-diffusion-webui/extensions/sd_dreambooth_extension/\n",
"!git fetch && git pull\n",
"!%cd /content/working/stable-diffusion-webui/ \n",
"!python launch.py --share --xformers --enable-insecure-extension-access --torch2 --skip-install --skip-torch-cuda-test"
],
"metadata": {
"id": "qa5T38izv6CX"
},
"execution_count": null,
"outputs": []
}
]
}
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ We also need a newer version of diffusers, as SD-WebUI uses version 0.3.0, while
having the right diffusers version is the cause of the 'UNet2DConditionModel' object has no attribute '
enable_gradient_checkpointing' error message, as well as safety checker warnings.

## IF YOU ARE HAVING ISSUES WITH REQUIREMENTS AFTER INSTALLING, LOOK BELOW
## IF YOU ARE HAVING ISSUES WITH REQUIREMENTS AFTER INSTALLING, LOOK BELOW

To force sd-web-ui to *only* install one set of requirements and resolve many issues on install, we can specify the command line argument:
To force sd-web-ui to *only* install one set of requirements and resolve many issues on install, we can specify the
command line argument:

set/export REQS_FILE=.\extensions\sd_dreambooth_extension\requirements.txt

Expand Down Expand Up @@ -85,21 +86,21 @@ Generate Samples* - Click this while training to generate samples before the nex

*Model* - The model to use. Training parameters will not be automatically loaded to the UI when changing models.

*Lora Model* - An existing lora checkpoint to load if resuming training, or to merge with the base model if generating a checkpoint.
*Lora Model* - An existing lora checkpoint to load if resuming training, or to merge with the base model if generating a
checkpoint.

*Half Model* - Enable this to save the model using half precision. Results in a smaller checkpoint with little
noticeable difference in image output.

*Save Checkpoint to Subdirectory* - Save the checkpoint to a subdirectory using the model name.


## Training Parameters

*Performance Wizard (WIP)* - Tries to set the optimal training parameters based on the amount of VRAM for your GPU and number of instance images.
*Performance Wizard (WIP)* - Tries to set the optimal training parameters based on the amount of VRAM for your GPU and
number of instance images.

Probably not perfect, but at least a good starting point.


### Intervals

This section contains parameters related to when things happen during training.
Expand All @@ -126,15 +127,15 @@ in seconds.
*Class batch size* - How many classification images to generate simultaneously. Set this to whatever you can safely
process at once using Txt2Image, or just leave it alone.

*Set Gradients to None When Zeroing* - instead of setting to zero, set the grads to None. This will in general have lower memory footprint, and can modestly improve performance.
*Set Gradients to None When Zeroing* - instead of setting to zero, set the grads to None. This will in general have
lower memory footprint, and can modestly improve performance.
https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html

*Gradient Checkpointing* - Enable this to save VRAM at the cost of a bit of speed.
https://arxiv.org/abs/1604.06174v2

*Max Grad Norms* - The maximum number of gradient normalizati


### Learning Rate

This section contains parameters related to the learning rate.
Expand Down Expand Up @@ -215,7 +216,9 @@ to better editability.

*Max Token Length* - raise the tokenizer's default limit above 75. Requires Pad Tokens for > 75.

*AdamW Weight Decay* - The weight decay of the AdamW Optimizer used for training. Values closer to 0 closely match your training dataset, and values closer to 1 generalize more and deviate from your training dataset. Default is 1e-2, values lower than 0.1 are recommended.
*AdamW Weight Decay* - The weight decay of the AdamW Optimizer used for training. Values closer to 0 closely match your
training dataset, and values closer to 1 generalize more and deviate from your training dataset. Default is 1e-2, values
lower than 0.1 are recommended.

## Concepts

Expand Down
Loading

0 comments on commit d4e2f7d

Please sign in to comment.