d8ahazard / sd_dreambooth_extension

Other
1.86k stars 281 forks source link

[Bug]: TypeError: list indices must be integers or slices, not tuple #1349

Closed NimaMancer closed 11 months ago

NimaMancer commented 11 months ago

Is there an existing issue for this?

What happened?

when Dreambooth is finished generating class images I get the error "TypeError: list indices must be integers or slices, not tuple" full logs provided also I'm a complete noob so I would appreciate caveman terms and solutions <3

Steps to reproduce the problem

  1. Go to Dreambooth extension
  2. create a model
  3. start to train said model

Commit and libraries

Initializing Dreambooth Dreambooth revision: 34690769c2cfb78d5760ba0003fdf55af0faf372 Successfully installed accelerate-0.22.0 fastapi-0.94.1

[!] xformers version 0.0.20 installed. [+] torch version 2.0.1+cu118 installed. [+] torchvision version 0.15.2+cu118 installed. [+] accelerate version 0.22.0 installed. [+] diffusers version 0.20.2 installed. [+] transformers version 4.30.2 installed. [+] bitsandbytes version 0.35.4 installed. Launching Web UI with arguments: --xformers --medvram --autolaunch --no-half-vae --no-half 2023-09-15 12:47:15,445 - ControlNet - INFO - ControlNet v1.1.410 ControlNet preprocessor location: C:\Users\Nima\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads 2023-09-15 12:47:15,644 - ControlNet - INFO - ControlNet v1.1.410 Loading weights [e6bb9ea85b] from C:\Users\Nima\stable-diffusion-webui\models\Stable-diffusion\sdXL_v10VAEFix.safetensors C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\scripts\main.py:261: GradioDeprecationWarning: The style method is deprecated. Please set these arguments in the constructor instead. with gr.Row().style(equal_height=False): CUDA SETUP: Loading binary C:\Users\Nima\stable-diffusion-webui\venv\lib\site-packages\bitsandbytes\libbitsandbytes_cudaall.dll... C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\scripts\main.py:1051: GradioDeprecationWarning: The style method is deprecated. Please set these arguments in the constructor instead. db_gallery = gr.Gallery( C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\scripts\main.py:1051: GradioDeprecationWarning: The 'grid' parameter will be deprecated. Please use 'columns' in the constructor instead. db_gallery = gr.Gallery( Creating model from config: C:\Users\Nima\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch(). Startup time: 66.5s (prepare environment: 52.5s, import torch: 4.0s, import gradio: 1.2s, setup paths: 0.9s, initialize shared: 0.2s, other imports: 1.1s, setup codeformer: 0.2s, load scripts: 3.2s, create ui: 1.9s, gradio launch: 1.1s). Loading VAE weights specified in settings: C:\Users\Nima\stable-diffusion-webui\models\VAE\sdxl_vae.safetensors Applying attention optimization: xformers... done. Model loaded in 69.2s (load weights from disk: 2.6s, create model: 0.8s, apply weights to model: 31.8s, apply float(): 12.7s, load VAE: 3.0s, load weights from state dict: 0.2s, hijack: 0.1s, load textual inversion embeddings: 0.5s, calculate empty prompt: 17.4s).

Command Line Arguments

--no-half --xformers --medvram

Console logs

Extracting config from C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\..\configs\sdxl-training-unfrozen.yaml
Extracting checkpoint from C:\Users\Nima\stable-diffusion-webui\models\Stable-diffusion\sdXL_v10VAEFix.safetensors
Restored system models.
Restored system models.
Duration: 00:05:02
Updating scheduler name to: DDIM
Wizard results:<br>Num Epochs: 150<br>Num instance images per class image: 5
Initializing dreambooth training...
                                                               We need a total of 25 class images.
Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [01:40<00:00, 14.39s/it]
Using scheduler: DEISMultistep   0%|                                                            | 0/25 [00:00<?, ?it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:37<00:00,  3.93s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:30<00:00,  3.77s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:30<00:00,  3.76s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:29<00:00,  3.74s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:29<00:00,  3.73s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:29<00:00,  3.73s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:23<00:00,  3.58s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:27<00:00,  3.70s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.57s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:30<00:00,  3.75s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:22<00:00,  3.56s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:24<00:00,  3.60s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [02:28<00:00,  3.71s/it]
Generating class images 24/25::  96%|███████████████████████████████████████████████████████▋  | 24/25 [00:00<?, ?it/s]Restored system models.s 25/25:: 100%|███████████████████████████████████████████████| 25/25 [00:00<00:00, 25115.59it/s]
                                                                                                                       Init dataset!set:   0%|                                                                           | 0/1 [00:00<?, ?it/s]
Preparing Dataset (With Caching)
                                                                                                                       Traceback (most recent call last):██▌                                                    | 5/30 [00:09<00:39,  1.58s/it]
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dataset\db_dataset.py", line 402, in cache_images
    self.data_cache["sdxl"][img_path] = data_cache["sdxl"][img_path]
KeyError: 'C:\\Users\\Nima\\stable-diffusion-webui\\models\\dreambooth\\BehroozLizard\\classifiers_0\\6fb420023fe4c3b1b4674ae7ffe042ced70cba17.png'
Exception caching: C:\Users\Nima\stable-diffusion-webui\models\dreambooth\BehroozLizard\classifiers_0\6fb420023fe4c3b1b4674ae7ffe042ced70cba17.png: 'C:\\Users\\Nima\\stable-diffusion-webui\\models\\dreambooth\\BehroozLizard\\classifiers_0\\6fb420023fe4c3b1b4674ae7ffe042ced70cba17.png'
Traceback (most recent call last):
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dataset\db_dataset.py", line 402, in cache_images
    self.data_cache["sdxl"][img_path] = data_cache["sdxl"][img_path]
KeyError: 'C:\\Users\\Nima\\stable-diffusion-webui\\models\\dreambooth\\BehroozLizard\\classifiers_0\\6fb420023fe4c3b1b4674ae7ffe042ced70cba17.png'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\ui_functions.py", line 730, in start_training
    result = main(class_gen_method=class_gen_method)
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1792, in main
    return inner_loop()
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\memory.py", line 126, in decorator
    return function(batch_size, grad_size, prof, *args, **kwargs)
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 626, in inner_loop
    train_dataset = generate_dataset(
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\utils\gen_utils.py", line 92, in generate_dataset
    train_dataset.make_buckets_with_caching(vae)
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dataset\db_dataset.py", line 436, in make_buckets_with_caching
    cache_images(class_images, res, self.pbar)
  File "C:\Users\Nima\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dataset\db_dataset.py", line 417, in cache_images
    del self.sample_cache[(img_path, cap, is_prior)]
TypeError: list indices must be integers or slices, not tuple
Duration: 01:12:11
Caching latents...:  17%|██████████▌                                                    | 5/30 [00:13<01:07,  2.69s/it]
Duration: 01:14:00

Additional information

No response

araleza commented 11 months ago

I don't know if it'll help with your problem, but on startup you can see that xformers isn't installed correctly:

[!] xformers version 0.0.20 installed.

You might want to look into that first, and see if your error goes away.

One other thought is that it seems to have crashed 17% of the way through the latents. The training generates one latent per image. I've seen people say that sometimes 'broken' images can crash the training. Maybe try again with just a few images to see if that gets rid of the error, and then try different combinations to see if one (or a few) training images in particular are breaking your run?

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days