Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
0c47c954
Unverified
Commit
0c47c954
authored
May 09, 2025
by
Sayak Paul
Committed by
GitHub
May 09, 2025
Browse files
[LoRA] support non-diffusers hidream loras (#11532)
* support non-diffusers hidream loras * make fix-copies
parent
7acf8345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
src/diffusers/loaders/lora_conversion_utils.py
src/diffusers/loaders/lora_conversion_utils.py
+8
-0
src/diffusers/loaders/lora_pipeline.py
src/diffusers/loaders/lora_pipeline.py
+5
-1
No files found.
src/diffusers/loaders/lora_conversion_utils.py
View file @
0c47c954
...
@@ -1704,3 +1704,11 @@ def _convert_musubi_wan_lora_to_diffusers(state_dict):
...
@@ -1704,3 +1704,11 @@ def _convert_musubi_wan_lora_to_diffusers(state_dict):
converted_state_dict
[
f
"transformer.
{
key
}
"
]
=
converted_state_dict
.
pop
(
key
)
converted_state_dict
[
f
"transformer.
{
key
}
"
]
=
converted_state_dict
.
pop
(
key
)
return
converted_state_dict
return
converted_state_dict
def
_convert_non_diffusers_hidream_lora_to_diffusers
(
state_dict
,
non_diffusers_prefix
=
"diffusion_model"
):
if
not
all
(
k
.
startswith
(
non_diffusers_prefix
)
for
k
in
state_dict
):
raise
ValueError
(
"Invalid LoRA state dict for HiDream."
)
converted_state_dict
=
{
k
.
removeprefix
(
f
"
{
non_diffusers_prefix
}
."
):
v
for
k
,
v
in
state_dict
.
items
()}
converted_state_dict
=
{
f
"transformer.
{
k
}
"
:
v
for
k
,
v
in
converted_state_dict
.
items
()}
return
converted_state_dict
src/diffusers/loaders/lora_pipeline.py
View file @
0c47c954
...
@@ -43,6 +43,7 @@ from .lora_conversion_utils import (
...
@@ -43,6 +43,7 @@ from .lora_conversion_utils import (
_convert_hunyuan_video_lora_to_diffusers
,
_convert_hunyuan_video_lora_to_diffusers
,
_convert_kohya_flux_lora_to_diffusers
,
_convert_kohya_flux_lora_to_diffusers
,
_convert_musubi_wan_lora_to_diffusers
,
_convert_musubi_wan_lora_to_diffusers
,
_convert_non_diffusers_hidream_lora_to_diffusers
,
_convert_non_diffusers_lora_to_diffusers
,
_convert_non_diffusers_lora_to_diffusers
,
_convert_non_diffusers_lumina2_lora_to_diffusers
,
_convert_non_diffusers_lumina2_lora_to_diffusers
,
_convert_non_diffusers_wan_lora_to_diffusers
,
_convert_non_diffusers_wan_lora_to_diffusers
,
...
@@ -5371,7 +5372,6 @@ class HiDreamImageLoraLoaderMixin(LoraBaseMixin):
...
@@ -5371,7 +5372,6 @@ class HiDreamImageLoraLoaderMixin(LoraBaseMixin):
@
classmethod
@
classmethod
@
validate_hf_hub_args
@
validate_hf_hub_args
# Copied from diffusers.loaders.lora_pipeline.CogVideoXLoraLoaderMixin.lora_state_dict
def
lora_state_dict
(
def
lora_state_dict
(
cls
,
cls
,
pretrained_model_name_or_path_or_dict
:
Union
[
str
,
Dict
[
str
,
torch
.
Tensor
]],
pretrained_model_name_or_path_or_dict
:
Union
[
str
,
Dict
[
str
,
torch
.
Tensor
]],
...
@@ -5465,6 +5465,10 @@ class HiDreamImageLoraLoaderMixin(LoraBaseMixin):
...
@@ -5465,6 +5465,10 @@ class HiDreamImageLoraLoaderMixin(LoraBaseMixin):
logger
.
warning
(
warn_msg
)
logger
.
warning
(
warn_msg
)
state_dict
=
{
k
:
v
for
k
,
v
in
state_dict
.
items
()
if
"dora_scale"
not
in
k
}
state_dict
=
{
k
:
v
for
k
,
v
in
state_dict
.
items
()
if
"dora_scale"
not
in
k
}
is_non_diffusers_format
=
any
(
"diffusion_model"
in
k
for
k
in
state_dict
)
if
is_non_diffusers_format
:
state_dict
=
_convert_non_diffusers_hidream_lora_to_diffusers
(
state_dict
)
return
state_dict
return
state_dict
# Copied from diffusers.loaders.lora_pipeline.CogVideoXLoraLoaderMixin.load_lora_weights
# Copied from diffusers.loaders.lora_pipeline.CogVideoXLoraLoaderMixin.load_lora_weights
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment