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

SDXL LoRA key not loaded "lora_te2_text_projection.*" (LoRA from OneTrainer) #8237

Closed
tin2tin opened this issue May 23, 2024 · 5 comments · Fixed by #8242
Closed

SDXL LoRA key not loaded "lora_te2_text_projection.*" (LoRA from OneTrainer) #8237

tin2tin opened this issue May 23, 2024 · 5 comments · Fixed by #8242
Labels
bug Something isn't working

Comments

@tin2tin
Copy link

tin2tin commented May 23, 2024

Describe the bug

When trying to use a LoRA in Diffusers, created in OneTrainer:

These keys are not loaded:

Python\Python311\site-packages\diffusers\loaders\lora_conversion_utils.py", line 273, in _convert_kohya_lora_to_diffusers
    raise ValueError(f"The following keys have not been correctly be renamed: \n\n {', '.join(state_dict.keys())}")
ValueError: The following keys have not been correctly be renamed:

 lora_te2_text_projection.lora_down.weight, lora_te2_text_projection.lora_up.weight

Reading up on the topic here: Nerogar/OneTrainer#47 reveals that it is not considered a OneTrainer bug, and something which should be fixed externally.

This is how the bug is described:
image

So the question is: can the attempt to load the extra text encoder, also be ignored, if not found, so we can use OneTrainer LoRAs in Diffusers?

Reproduction

Import a SDXL LoRA from OneTrainer into Diffusers.
(The one I've got is far too big to share)

Logs

No response

System Info

Windows 11, Diffusers latest alpha version.

Who can help?

@sayakpaul

@tin2tin tin2tin added the bug Something isn't working label May 23, 2024
@tin2tin
Copy link
Author

tin2tin commented May 23, 2024

Crosspost: Nerogar/OneTrainer#314

@sayakpaul
Copy link
Member

You have to provide a fully reproducible code snippet for us to look into this further.

@tin2tin
Copy link
Author

tin2tin commented May 23, 2024

from diffusers import DiffusionPipeline
import torch

pipe_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = DiffusionPipeline.from_pretrained(pipe_id, torch_dtype=torch.float16).to("cuda")
pipe.load_lora_weights("C:/Users/user_name/Downloads/LORA/", weight_name="lora.safetensors", adapter_name="engraving")
lora_scale= 0.9
prompt = "Engravings Henri Meyer"
image = pipe(
    prompt, num_inference_steps=30, cross_attention_kwargs={"scale": lora_scale}, generator=torch.manual_seed(0)
).images[0]
image

The LoRA file: https://filetransfer.io/data-package/SKG6lXd3#link

@sayakpaul
Copy link
Member

If at all possible, please also host the LoRA file on the Hub so that is easily retrievable.

@tin2tin
Copy link
Author

tin2tin commented May 29, 2024

Thank you to all involved for prioritizing and resolving this issue superfast!

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

Successfully merging a pull request may close this issue.

2 participants