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
124ac3e8
Unverified
Commit
124ac3e8
authored
Mar 14, 2025
by
Sayak Paul
Committed by
GitHub
Mar 14, 2025
Browse files
[LoRA] feat: support non-diffusers wan t2v loras. (#11059)
feat: support non-diffusers wan t2v loras.
parent
2f0f281b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
src/diffusers/loaders/lora_conversion_utils.py
src/diffusers/loaders/lora_conversion_utils.py
+10
-7
No files found.
src/diffusers/loaders/lora_conversion_utils.py
View file @
124ac3e8
...
@@ -1355,6 +1355,7 @@ def _convert_non_diffusers_wan_lora_to_diffusers(state_dict):
...
@@ -1355,6 +1355,7 @@ def _convert_non_diffusers_wan_lora_to_diffusers(state_dict):
original_state_dict
=
{
k
[
len
(
"diffusion_model."
)
:]:
v
for
k
,
v
in
state_dict
.
items
()}
original_state_dict
=
{
k
[
len
(
"diffusion_model."
)
:]:
v
for
k
,
v
in
state_dict
.
items
()}
num_blocks
=
len
({
k
.
split
(
"blocks."
)[
1
].
split
(
"."
)[
0
]
for
k
in
original_state_dict
})
num_blocks
=
len
({
k
.
split
(
"blocks."
)[
1
].
split
(
"."
)[
0
]
for
k
in
original_state_dict
})
is_i2v_lora
=
any
(
"k_img"
in
k
for
k
in
original_state_dict
)
and
any
(
"v_img"
in
k
for
k
in
original_state_dict
)
for
i
in
range
(
num_blocks
):
for
i
in
range
(
num_blocks
):
# Self-attention
# Self-attention
...
@@ -1374,13 +1375,15 @@ def _convert_non_diffusers_wan_lora_to_diffusers(state_dict):
...
@@ -1374,13 +1375,15 @@ def _convert_non_diffusers_wan_lora_to_diffusers(state_dict):
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_B.weight"
]
=
original_state_dict
.
pop
(
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_B.weight"
]
=
original_state_dict
.
pop
(
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_B.weight"
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_B.weight"
)
)
for
o
,
c
in
zip
([
"k_img"
,
"v_img"
],
[
"add_k_proj"
,
"add_v_proj"
]):
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_A.weight"
]
=
original_state_dict
.
pop
(
if
is_i2v_lora
:
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_A.weight"
for
o
,
c
in
zip
([
"k_img"
,
"v_img"
],
[
"add_k_proj"
,
"add_v_proj"
]):
)
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_A.weight"
]
=
original_state_dict
.
pop
(
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_B.weight"
]
=
original_state_dict
.
pop
(
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_A.weight"
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_B.weight"
)
)
converted_state_dict
[
f
"blocks.
{
i
}
.attn2.
{
c
}
.lora_B.weight"
]
=
original_state_dict
.
pop
(
f
"blocks.
{
i
}
.cross_attn.
{
o
}
.lora_B.weight"
)
# FFN
# FFN
for
o
,
c
in
zip
([
"ffn.0"
,
"ffn.2"
],
[
"net.0.proj"
,
"net.2"
]):
for
o
,
c
in
zip
([
"ffn.0"
,
"ffn.2"
],
[
"net.0.proj"
,
"net.2"
]):
...
...
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