Skip to content

Conversation

@hlky
Copy link
Contributor

@hlky hlky commented Apr 13, 2025

What does this PR do?

In single file loading the CLIP config can be incorrect for checkpoints using something like LongCLIP due to the increased max_position_embeddings.

This PR detects the CLIP checkpoint's true max_position_embeddings and overrides the config then reinitializes the model if the detected value does not match.

Reproduction

huggingface-cli download opendiffusionai/xllsd-alpha0  --local-dir G:/xllsd-alpha0
python scripts/convert_diffusers_to_original_stable_diffusion.py --use_safetensors --model_path G:/xllsd-alpha0 --checkpoint_path G:/xllsd-alpha0.safetensors
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_single_file("G:/xllsd-alpha0.safetensors")

Fixes #11285

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@hlky hlky requested a review from DN6 April 13, 2025 08:57
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍🏽

@hlky hlky closed this Apr 15, 2025
@hlky hlky deleted the single-file-clip-num-position-embeds branch April 15, 2025 09:12
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

Successfully merging this pull request may close these issues.

value errors in convert to/from diffusers from original stable diffusion

3 participants