Repository navigation
Closed
Labels
bugSomething isn't working
Description
Describe the bug
I'm trying to train the SDXL with pokemon-blip-captions dataset on the basis of pretrained weight. I have downloaded the whole repo form stabilityai/stable-diffusion-xl-base-1.0, while the ValueError caused by structure mismatch still occurred.
It indicates a mismatch between the unet structure defined by the code and the key-value pairs in the weights. I confirm that the model weight downloaded is complete. Could anyone help?
Reproduction
# path of SDXL
model_name="./models_ckpt/"
# path of VAE
vae_name="./ckpt/sdxl-vae-fp16-fix"
# path of dataset
dataset_name="~/diffusers/data/pokemon-blip-captions/"
python ./examples/text_to_image/train_text_to_image_lora_sdxl.py \
--pretrained_model_name_or_path=$model_name \
--dataset_name=$dataset_name --caption_column="text" \
--resolution=1024 --random_flip \
--train_batch_size=1 \
--num_train_epochs=2 --checkpointing_steps=500 \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--seed=42 \
--output_dir="sd-pokemon-model-lora-sdxl-txt-new" \
--train_text_encoder \
--validation_prompt="cute dragon creature"
Logs
02/28/2024 07:04:40 - INFO - __main__ - Distributed environment: NO
Num processes: 1
Process index: 0
Local process index: 0
Device: cpu
Mixed precision type: no
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
{'dynamic_thresholding_ratio', 'clip_sample_range', 'variance_type', 'rescale_betas_zero_snr', 'thresholding'} was not found in config. Values will be initialized to default values.
{'reverse_transformer_layers_per_block', 'dropout', 'attention_type'} was not found in config. Values will be initialized to default values.
Traceback (most recent call last):
File "/home/cmq/code/diffusers/./examples/text_to_image/train_text_to_image_lora_sdxl.py", line 1266, in <module>
main(args)
File "/home/cmq/code/diffusers/./examples/text_to_image/train_text_to_image_lora_sdxl.py", line 568, in main
unet = UNet2DConditionModel.from_pretrained(
File "/home/cmq/miniconda3/envs/diffuser/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "/home/cmq/diffusers/src/diffusers/models/modeling_utils.py", line 662, in from_pretrained
raise ValueError(
ValueError: Cannot load <class 'diffusers.models.unets.unet_2d_condition.UNet2DConditionModel'> from ./models_ckpt/ because the following keys are missing:
mid_block.attentions.0.transformer_blocks.0.ff.net.0.proj.bias, up_blocks.0.attentions.0.transformer_blocks.8.norm1.weight, down_blocks.2.attentions.0.transformer_blocks.8.norm3.weight, down_blocks.2.attentions.0.transformer_blocks.8.norm2.bias, mid_block.attentions.0.transformer_blocks.9.attn1.to_v.weight, up_blocks.0.attentions.1.transformer_blocks.7.attn2.to_k.weight, down_blocks.1.resnets.0.conv1.bias, down_blocks.2.attentions.0.transformer_blocks.3.ff.net.0.proj.weight, down_blocks.1.attentions.1.transformer_blocks.0.attn1.to_out.0.weight, down_blocks.2.attentions.0.transformer_blocks.4.ff.net.2.weight, down_blocks.1.attentions.0.transformer_blocks.1.attn2.to_q.weight, mid_block.attentions.0.transformer_blocks.3.norm3.weight,
...
...
Please make sure to pass `low_cpu_mem_usage=False` and `device_map=None` if you want to randomly initialize those weights or else make sure your checkpoint file is correct.
### System Info
- linux
- python 3.10
### Who can help?
cc @yiyixuxu @sayakpaul @DN6
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
MengqingCao commentedon Feb 29, 2024
I have found the solution, and I will fix it in a PR.
sayakpaul commentedon Mar 1, 2024
If I pass "stabilityai/stable-diffusion-xl-base-1.0" to
--pretrained_model_name_or_path=$model_name, it works. If I pass "/path/to/local_dir/stable-diffusion-xl-base-1.0" (which has the exact same folder structure as https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) to--pretrained_model_name_or_path=$model_nameit works. I don't really understand the problem.MengqingCao commentedon Mar 2, 2024
Ops, I made the mistake of downloading a checkpoint file into the folder with the same name as unet‘s. Sorry for that and thanks for your reply.