Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single_file_utils.py#load_single_file_model_checkpoint bugs #7889

Open
knoopx opened this issue May 8, 2024 · 4 comments
Open

single_file_utils.py#load_single_file_model_checkpoint bugs #7889

knoopx opened this issue May 8, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@knoopx
Copy link
Contributor

knoopx commented May 8, 2024

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

  • diffusers version: 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

@knoopx knoopx added the bug Something isn't working label May 8, 2024
@sayakpaul
Copy link
Member

Please provide a reproducible snippet.

Cc: @DN6

@knoopx
Copy link
Contributor Author

knoopx commented May 9, 2024

@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: [...]

@sayakpaul
Copy link
Member

This is still not fully reproducible.

@yiyixuxu
Copy link
Collaborator

yiyixuxu commented May 9, 2024

@knoopx
we just merged this PR #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants