single_file_utils.py#load_single_file_model_checkpoint bugs
Describe the bug
Loading a checkpoint from file crashes as it tries to print a warning with unexpected keys because is accessing __name__ on incorrect target (instance instead of class)
https://github.com/huggingface/diffusers/blob/d50baf0c632342b9576a24352244c4235ce8b875/src/diffusers/loaders/single_file_utils.py
f"Some weights of the model checkpoint were not used when initializing {vae.__name__}
f"Some weights of the model checkpoint were not used when initializing {unet.__name__}
f"Some weights of the model checkpoint were not used when initializing {controlnet.__name__}
should be:
[...].__class__.__name__
Reproduction
load a single file checkpoint with extra keys
Logs
No response
System Info
diffusersversion: 0.27.2- Platform: Linux-6.8.8-1-clear-x86_64-with-glibc2.39
- Python version: 3.11.0
- PyTorch version (GPU?): 2.2.0+cu121 (True)
- Huggingface_hub version: 0.23.0
- Transformers version: 4.40.1
- Accelerate version: 0.30.0
Who can help?
@sayakpaul
Please provide a reproducible snippet.
Cc: @DN6
@sayakpaul
Ran:
StableDiffusionPipeline.from_single_file("checkpoint-with-extra-keys.safetensor").
Got:
File ".venv/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/diffusers/loaders/single_file.py", line 289, in from_single_file
components = build_sub_model_components(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/diffusers/loaders/single_file.py", line 75, in build_sub_model_components
vae_components = create_diffusers_vae_model_from_ldm(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/diffusers/loaders/single_file_utils.py", line 1391, in create_diffusers_vae_model_from_ldm
f"Some weights of the model checkpoint were not used when initializing {vae.__name__}: \n {[', '.join(unexpected_keys)]}"
^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/diffusers/models/modeling_utils.py", line 218, in __getattr__
return super().__getattr__(name)
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1688, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'AutoencoderKL' object has no attribute '__name__'
Expected:
Some weights of the model checkpoint were not used when initializing AutoencoderKL: [...]
This is still not fully reproducible.
@knoopx we just merged this PR https://github.com/huggingface/diffusers/pull/7496 can you update the diffusers and try again?
if still not working, please provide a reproducible code example with inputs and checkpoints that accessible to us
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.