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

AttributeError when caching model from command line #37

Open
venzen opened this issue Sep 8, 2024 · 2 comments
Open

AttributeError when caching model from command line #37

venzen opened this issue Sep 8, 2024 · 2 comments

Comments

@venzen
Copy link

venzen commented Sep 8, 2024

I used the following code from this repo's README to cache the stable-diffusion-v1-5-inpainting model from here:

https://huggingface.co/benjamin-paine/stable-diffusion-v1-5-inpainting

from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained("benjamin-paine/stable-diffusion-v1-5-inpainting")
exit()

I had to login with a Huggingface token via command line first and then all files were successfully downloaded. However, while loading pipeline components I got this AttributeError:

  File "/opt/stable-diffusion-webui/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/opt/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 876, in from_pretrained
    loaded_sub_model = load_sub_model(
  File "/opt/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/pipelines/pipeline_loading_utils.py", line 700, in load_sub_model
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "/opt/stable-diffusion-webui/venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2604, in from_pretrained
    state_dict = load_state_dict(resolved_archive_file)
  File "/opt/stable-diffusion-webui/venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 452, in load_state_dict
    if metadata.get("format") not in ["pt", "tf", "flax"]:
AttributeError: 'NoneType' object has no attribute 'get'

Not sure whether this is caused by a bug in modeling_utils.py or something not-normal in the repo.

@Uminosachi
Copy link
Owner

Based on the error message, it seems that the model's safetensors file lacks metadata, leading to a None value being returned. This suggests there may be an issue with the file itself.

@venzen
Copy link
Author

venzen commented Sep 9, 2024

I found this utility to write metadata to a safetensors file:

https://github.com/by321/safetensors_util

Since it'll be difficult to find accurate metadata for this v1.5 inpainting model, I will inject generic made-up metadata to help modeling_utils.py to read the file.

If I do this, will it affect the functioning of Inpaint Anything ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants