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
fengzch-das
nunchaku
Commits
e302ec32
Unverified
Commit
e302ec32
authored
Jun 08, 2025
by
Muyang Li
Committed by
GitHub
Jun 08, 2025
Browse files
fix: handling single nunchaku LoRA composition (#446)
parent
c8134a6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
nunchaku/lora/flux/compose.py
nunchaku/lora/flux/compose.py
+8
-1
No files found.
nunchaku/lora/flux/compose.py
View file @
e302ec32
...
@@ -5,12 +5,19 @@ import torch
...
@@ -5,12 +5,19 @@ import torch
from
safetensors.torch
import
save_file
from
safetensors.torch
import
save_file
from
.diffusers_converter
import
to_diffusers
from
.diffusers_converter
import
to_diffusers
from
.utils
import
is_nunchaku_format
from
.utils
import
is_nunchaku_format
,
load_state_dict_in_safetensors
def
compose_lora
(
def
compose_lora
(
loras
:
list
[
tuple
[
str
|
dict
[
str
,
torch
.
Tensor
],
float
]],
output_path
:
str
|
None
=
None
loras
:
list
[
tuple
[
str
|
dict
[
str
,
torch
.
Tensor
],
float
]],
output_path
:
str
|
None
=
None
)
->
dict
[
str
,
torch
.
Tensor
]:
)
->
dict
[
str
,
torch
.
Tensor
]:
if
len
(
loras
)
==
1
:
if
is_nunchaku_format
(
loras
[
0
][
0
])
and
(
loras
[
0
][
1
]
-
1
)
<
1e-5
:
if
isinstance
(
loras
[
0
][
0
],
str
):
return
load_state_dict_in_safetensors
(
loras
[
0
][
0
],
device
=
"cpu"
)
else
:
return
loras
[
0
][
0
]
composed
=
{}
composed
=
{}
for
lora
,
strength
in
loras
:
for
lora
,
strength
in
loras
:
assert
not
is_nunchaku_format
(
lora
)
assert
not
is_nunchaku_format
(
lora
)
...
...
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