Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Resources--
- Website & Videos:
- Aitrepreneur SUPER Stable diffusion 2.0 Installation - https://www.youtube.com/watch?v=vg8-NSbaWZI
- Aitrepreneur DREAMBOOTH: Train Stable Diffusion With Your Images (cloud install) - https://youtu.be/7m__xadX0z0
- XavierXiao Dreambooth-Stable-Diffusion - https://github.com/XavierXiao/Dreambooth-Stable-Diffusion
- Gammagec Dreambooth-SD-optimized - https://github.com/gammagec/Dreambooth-SD-optimized
- JoePenna Dreambooth-Stable-Diffusion - https://github.com/JoePenna/Dreambooth-Stable-Diffusion
- (JoePenna's github no longer focuses on local running, but still a good resource.
- Automatic1111 Stable-Diffusion-webui - https://github.com/AUTOMATIC1111/stable-diffusion-webui
- Automatic1111 Guide - https://stablediffusionguides.carrd.co/#one
- Spinferno Dreambooth Guide - https://www.reddit.com/r/StableDiffusion/comments/xpoexy/yet_another_dreambooth_post_how_to_train_an_image/
- Hugging Face - https://huggingface.co/
- Birme Bulk Image Resizing - https://www.birme.net/?target_width=512&target_height=512
- Installers:
- Python - https://www.python.org/downloads/release/python-3109/ (During Install "Add Python to PATH")
- Anaconda - https://www.anaconda.com/
- Git - https://gitforwindows.org/
- Downloads:
- Stable Diffusion Model Weights 1.4 - https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt
- GFPGAN Face Correction - https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth
- Regularization dataset examples: man_euler, man_unsplash, person_ddim, woman_ddim (https://github.com/djbielejeski?tab=repositories)
- ----------------------------------------------------------------------------------------------
- Pre-Requirments:
- 1. Install Python (3.10.x).
- During Install CHECK "Add Python to PATH".
- 2. Install Anaconda.
- 3. Install Git.
- 4. Restart PC.
- 5. Create a folder in your user directory, I named mine "AI" (C:\Users\natemac\AI)
- 5b. You will need to update "natemac" to your user name for this guide.
- ----------------------------------------------------------------------------------------------
- Install Stable Diffusion webui:
- (These same steps are also in "Aitrepreneur SUPER Stable diffusion 2.0 Installation" video and "Automatic1111 Guide")
- 1. Launch "Anaconda Prompt" from the Start Menu.
- 2. Go into your new folder [cd AI] (C:\Users\natemac\AI).
- 3. Clone Stable-Diffusion-webui [git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git].
- 4. Download "Stable Diffusion Model Weights 1.4" (You will need a Hugging Face account).
- 5. Rename the file from "sd-v1-4.ckpt" to "model.ckpt".
- 6. Move the "model.ckpt" file to the Stable Diffusion "Models" folder (C:\Users\natemac\AI\stable-diffusion-webui\models).
- 7. Download the GFPGAN File.
- 8. Move the "GFPGANv1.3.pth" file to root Stable Diffusion webui folder (C:\Users\natemac\AI\stable-diffusion-webui)
- 9. Stable Diffusion webui is installed.
- ----------------------------------------------------------------------------------------------
- Running Stable Diffusion webui:
- 1. Run/Double-click on the "webui-user.bat" inside the "stable-diffusion-webui" folder (this will take longer the first time).
- 1b. This is complete once you see the line "To create a public link, set `share=True` in `launch()`." in the Command Prompt.
- 2. Open a web browser and go-to: http://127.0.0.1:7860
- 3. Stable Diffusion is running.
- ----------------------------------------------------------------------------------------------
- Closing Stable Diffusion webui:
- 1. Close the web browser.
- 2. Close the Command Prompt that opened after running "webui-user.bat".
- ----------------------------------------------------------------------------------------------
- Install Dreambooth-SD-optimized:
- (These steps are similar to "Aitrepreneur DREAMBOOTH" video)
- 1. Launch "Anaconda Prompt" from the Start Menu.
- 2. Go into your new folder [cd AI] (C:\Users\natemac\AI).
- 3. Clone Dreambooth-SD-optimized [git clone https://github.com/gammagec/Dreambooth-SD-optimized.git].
- 3b. XavierXiao's version has the same steps, but a different folder name [git clone https://github.com/XavierXiao/Dreambooth-Stable-Diffusion.git].
- ----------------------------------------------------------------------------------------------
- Install Dreambooth-SD-Optimized - Build Environment:
- 1. Open the "environment.yaml" file (in an editor such as notepad) in the Dreambooth-SD-optimized folder (C:\Users\natemac\AI\Dreambooth-SD-optimized).
- 2. Edit the first line (name: ldm) to your choosing "name: SD-Optimized". Save & close.
- 3. Launch "Anaconda Prompt" from the Start Menu.
- 4. Go into your Dreambooth-SD-optimized folder [cd C:\Users\natemac\AI\Dreambooth-SD-optimized].
- 5. Build environment [conda env create -f environment.yaml]
- 5b. To activate environment use [conda activate SD-Optimized]
- 5c. To deactivate an active environment use [conda deactivate]
- ----------------------------------------------------------------------------------------------
- Install Dreambooth-SD-optimized - Copy Files:
- 1. Copy "model.ckpt" from (C:\Users\natemac\AI\stable-diffusion-webui\models) to (C:\Users\natemac\AI\Dreambooth-SD-optimized)
- 2. Activate the environment by typing into the Anaconda Prompt [Conda activate SD-Optimized]
- 3. Dreambooth-SD-optimized is now installed.
- ----------------------------------------------------------------------------------------------
- Pre-Training - Regularization Images:
- 1. Create folder structure in the "Dreambooth-SD-optimized" root-folder (Dreambooth-SD-optimized/outputs/txt2img-samples/samples/) [md outputs\txt2img-samples\samples]
- 2. Go-to this folder in the Anaconda Prompt [cd C:\Users\natemac\AI\Dreambooth-SD-optimized\outputs\txt2img-samples\samples]
- 3. Choose one of the datasets (man_euler, man_unsplash, person_ddim, woman_ddim)
- 4. Replacing DATASET with your choice (https://github.com/djbielejeski/Stable-Diffusion-Regularization-Images-DATASET.git)
- 5. Run your dataset clone [git clone https://github.com/djbielejeski/Stable-Diffusion-Regularization-Images-woman_ddim.git]
- 6. Open your new DATASET folder(Stable-Diffusion-Regularization-Images-woman_ddim).
- 7. Copy your DATASET folder (woman_ddim) to the (samples) folder.
- 8. Delete empty download folder (Stable-Diffusion-Regularization-Images-woman_ddim).
- 9. You should now have 1500 images in the folder (C:\Users\natemac\AI\Dreambooth-SD-optimized\outputs\txt2img-samples\samples\woman_ddim).
- ----------------------------------------------------------------------------------------------
- Pre-Training - Prepping Training Samples:
- 1. Collect your sample images you'd like to use. At least 10.
- 1b. ***THE COLLECTION ON IMAGE MUST BE AN EVEN AMOUNT.***
- 2. Crop images as needed to not have additional info such as another person if you are training it on a single person.
- 3. Use (https://www.birme.net/?target_width=512&target_height=512) to Bulk crop and size images. Download the zip.
- 4. Create a folder in the root (Dreambooth-SD-optimized) folder named "training_samples".
- 5. Create a folder in the (training_samples) of your training set ("C:\Users\natemac\AI\Dreambooth-SD-optimized\training-samples\rhaenyra").
- 6. Copy your finalized Cropped & Sized images into this folder.
- 7. Open the "personalized.py file (in an editor such as notepad) located in ("C:\Users\natemac\AI\Dreambooth-SD-optimized\ldm\data\personalized.py").
- 8. We will be editing and saving line 11 ('photo of a sks {}',) to your training name ('rhaenyra {}',).
- ----------------------------------------------------------------------------------------------
- Training a Model with your Samples:
- 1. Launch "Anaconda Prompt" from the Start Menu.
- 2. Go into your Dreambooth-SD-optimized root folder [cd C:\Users\natemac\AI\Dreambooth-SD-optimized].
- 3. Take note of your TRAINING-SAMPLES-NAME (rhaenyra) your REGULARIZATION-IMAGES-NAME (woman_ddim) & CLASS (woman).
- 4. We will be editing the below code:
- python main.py --base configs/stable-diffusion/v1-finetune_unfrozen.yaml -t --actual_resume model.ckpt --reg_data_root outputs\txt2img-samples\samples\REGULARIZATION-IMAGES-NAME -n TRAINING-SAMPLES-NAME --gpus 0, --data_root training_samples\TRAINING-SAMPLES-NAME --batch_size 2020 --class_word CLASS
- 5. What it should look like:
- python main.py --base configs/stable-diffusion/v1-finetune_unfrozen.yaml -t --actual_resume model.ckpt --reg_data_root outputs\txt2img-samples\samples\woman_ddim -n rhaenyra --gpus 0, --data_root training_samples\rhaenyra --batch_size 2020 --class_word woman
- 6. Training is complete even if you see an error as long as somewhere you see the line "Another one bites the dust..."
- ----------------------------------------------------------------------------------------------
- Pruning & Transfering Samples Model:
- 0. ***If you are running Dreambooth-SD-optimized, you will need to add "prune_ckpt.py" from "XavierXiao Dreambooth-Stable-Diffusion" clone to the "Dreambooth-SD-optimized" root folder.***
- 1. Find the name of the training data folder (C:\Users\natemac\AI\Dreambooth-SD-optimized\logs\) "rhaenyra2022-09-28T11-46-55_rhaenyra".
- 2. Launch "Anaconda Prompt" from the Start Menu.
- 3. Go into your Dreambooth-SD-optimized root folder [cd C:\Users\natemac\AI\Dreambooth-SD-optimized].
- 4. Run the following command with TRAINED-DATA-FOLDER replaced:
- python "prune_ckpt.py" --ckpt "C:\Users\natemac\AI\Dreambooth-SD-optimized\logs\TRAINED-DATA-FOLDER\checkpoints\last.ckpt"
- 5. What it should look like:
- python "prune_ckpt.py" --ckpt "C:\Users\natemac\AI\Dreambooth-SD-optimized\logs\rhaenyra2022-09-28T11-46-55_rhaenyra\checkpoints\last.ckpt"
- 6. There is now a roughly 2GB file named "last-pruned.ckpt" inside the "checkpoints folder (C:\Users\natemac\AI\Dreambooth-SD-optimized\logs\rhaenyra2022-09-28T11-46-55_rhaenyra\checkpoints\). Transfer this file to your Stable Diffusions Models folder (C:\Users\natemac\AI\stable-diffusion-webui\models).
- 7. Rename the "last-pruned.ckpt" file to your TRAINING-SAMPLES-NAME "rhaenyra.ckpt".
- ----------------------------------------------------------------------------------------------
- Running Stable Diffusion webui with Trained data:
- 1. Run/Double-click on the "webui-user.bat" inside the "stable-diffusion-webui" folder.
- 2. Open a web browser and go-to: http://127.0.0.1:7860
- 3. In the browser UI goto "Settings".
- 4. Under the section "Stable Diffusion" you will see a submenu of "Stable Diffusion checkpoint". Choose your newly created Training Model "rhaenyra.ckpt".
- 5. At the top of the page, click "Apply Settings".
- 6. Close the web browser & Close the Command Prompt that opened after running "webui-user.bat".
- 7. Run/Double-click on the "webui-user.bat" inside the "stable-diffusion-webui" folder.
- 8. Open a web browser and go-to: http://127.0.0.1:7860
- ----------------------------------------------------------------------------------------------
- Using Your Trained Data for txt2img:
- 1. Using the TRAINING-SAMPLES-NAME & CLASS Prompts to create your image "Portrait of rhaenyra woman".
Advertisement
Comments
-
- I'm having trouble at line 124. (I installed the optimized version of Dreambooth). I do not find the ''logs'' folder in my root folder. When should the ''logs'' file appear? I might of misssed a step.
-
- My trouble is at line 118 the execution gave me an error "NameError: name 'trainer' is not defined"
-
- I got this error when using a model.ckpt file other than the default. I tried to rename the diffusions model and got this error, went back to the original and it worked.
-
- hello! i cant find prune_ckpt.py" from "XavierXiao Dreambooth-Stable-Diffusion" on github! do you know what i am doing wrong? thanks for the data
-
- https://github.com/JoePenna/Dreambooth-Stable-Diffusion/tree/main/scripts
-
- thanks!
-
- You change the number of steps in the file: configs/stable-diffusion/v1-finetune_unfrozen.yaml
- took me a while to figure that out
-
- what do you mean with change the number of steps? i am just a modest user of windows 10.
-
- the number of training steps
-
- how many do you use?thnks
-
- I am currently stuck on line 117 of the guide
- "4. We will be editing the below code: ..."
- Where do you go to edit the code?
- -also-
- Went to Anaconda Prompt Dreambooth-SD-optimized root folder, but not sure how to run training. Any help would be greatly appreciated!
-
Comment was deleted
-
- Epoch 0: 15%|▏| 500/3232 [10:04<55:04, 1.21s/it, loss=0.311, v_num=0, train/loss_simple_step=0.0769, train/loss_vlb_sC:\Users\Ben\miniconda3\envs\SD-Optimized\lib\site-packages\pytorch_lightning\callbacks\model_checkpoint.py:644: UserWarning: ModelCheckpoint(monitor='val/loss_simple_ema') not found in the returned metrics: ['train/loss_simple', 'train/loss_simple_step', 'train/loss_vlb', 'train/loss_vlb_step', 'train/loss', 'train/loss_step', 'global_step']. HINT: Did you call self.log('val/loss_simple_ema', value) in the LightningModule?
- warning_cache.warn(m)
- Epoch 0, global step 499: val/loss_simple_ema was not in top 1
- I get to 15% then this happens... python then crashes.
-
Comment was deleted
-
- I followed these steps for both Dreambooth-SD-Optimized and for the XavierXiao version. Followed the guide for both, created separate installs for them. Same error both times, just when it's about to start training.
- >Traceback (most recent call last):
- > File "main.py", line 787, in <module>
- > ngpu = len(lightning_config.trainer.gpus.strip(",").split(','))
- >AttributeError: 'int' object has no attribute 'strip'
- Not sure what to do! Any suggestions would be appreciated.
-
- I got this exact same error and had no issues up to this point. How do I fix this?
-
- I have found the answer some machines require --gpus "0," see the corrected script below:
- python main.py --base configs/stable-diffusion/v1-finetune_unfrozen.yaml -t --actual_resume model.ckpt --reg_data_root outputs\txt2img-samples\samples\woman_ddim -n rhaenyra --gpus "0," --data_root training_samples\rhaenyra --batch_size 2020 --class_word woman
-
- Can anyone get this version to work locally? https://github.com/kanewallmann/Dreambooth-Stable-Diffusion
-
- I'm striking out on lines 54/55 - installing torch and torchvision. I've manually gone to the link and I see a bunch of files that look like they meet the needs as they have 1.12.1+cu113 listed in the file name. Any ideas on how to fix this? Below is what shows when I run the webui-user.bat file.
- venv "C:\Users\jdm56\AI\stable-diffusion-webui\venv\Scripts\Python.exe"
- Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
- Commit hash: 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490
- Installing torch and torchvision
- Traceback (most recent call last):
- File "C:\Users\jdm56\AI\stable-diffusion-webui\launch.py", line 294, in <module>
- prepare_environment()
- File "C:\Users\jdm56\AI\stable-diffusion-webui\launch.py", line 206, in prepare_environment
- run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
- File "C:\Users\jdm56\AI\stable-diffusion-webui\launch.py", line 49, in run
- raise RuntimeError(message)
- RuntimeError: Couldn't install torch.
- Command: "C:\Users\jdm56\AI\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
- Error code: 1
- stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113
- stderr: ERROR: Could not find a version that satisfies the requirement torch==1.12.1+cu113 (from versions: none)
- ERROR: No matching distribution found for torch==1.12.1+cu113
-
- Hi! I think this error is due to some crash with GPU, not sure if it is possible to configurate this to be able to continue the training? I'm using a NVIDIA GeForce RTX 3090
- return Variable._execution_engine.run_backward(
- RuntimeError: CUDA out of memory. Tried to allocate 512.00 MiB (GPU 0; 24.00 GiB total capacity; 20.72 GiB already allocated; 0 bytes free; 21.06 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
-
- I have the same issue with a 20xx super, any idea how to fix it?
Add Comment
Please, Sign In to add comment
Advertisement