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
edb8c1bc
Unverified
Commit
edb8c1bc
authored
Jan 12, 2025
by
Sayak Paul
Committed by
GitHub
Jan 12, 2025
Browse files
[Flux] Improve true cfg condition (#10539)
* improve flux true cfg condition * add test
parent
0785dba4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
src/diffusers/pipelines/flux/pipeline_flux.py
src/diffusers/pipelines/flux/pipeline_flux.py
+4
-1
tests/pipelines/flux/test_pipeline_flux.py
tests/pipelines/flux/test_pipeline_flux.py
+11
-0
No files found.
src/diffusers/pipelines/flux/pipeline_flux.py
View file @
edb8c1bc
...
@@ -790,7 +790,10 @@ class FluxPipeline(
...
@@ -790,7 +790,10 @@ class FluxPipeline(
lora_scale
=
(
lora_scale
=
(
self
.
joint_attention_kwargs
.
get
(
"scale"
,
None
)
if
self
.
joint_attention_kwargs
is
not
None
else
None
self
.
joint_attention_kwargs
.
get
(
"scale"
,
None
)
if
self
.
joint_attention_kwargs
is
not
None
else
None
)
)
do_true_cfg
=
true_cfg_scale
>
1
and
negative_prompt
is
not
None
has_neg_prompt
=
negative_prompt
is
not
None
or
(
negative_prompt_embeds
is
not
None
and
negative_pooled_prompt_embeds
is
not
None
)
do_true_cfg
=
true_cfg_scale
>
1
and
has_neg_prompt
(
(
prompt_embeds
,
prompt_embeds
,
pooled_prompt_embeds
,
pooled_prompt_embeds
,
...
...
tests/pipelines/flux/test_pipeline_flux.py
View file @
edb8c1bc
...
@@ -209,6 +209,17 @@ class FluxPipelineFastTests(unittest.TestCase, PipelineTesterMixin, FluxIPAdapte
...
@@ -209,6 +209,17 @@ class FluxPipelineFastTests(unittest.TestCase, PipelineTesterMixin, FluxIPAdapte
output_height
,
output_width
,
_
=
image
.
shape
output_height
,
output_width
,
_
=
image
.
shape
assert
(
output_height
,
output_width
)
==
(
expected_height
,
expected_width
)
assert
(
output_height
,
output_width
)
==
(
expected_height
,
expected_width
)
def
test_flux_true_cfg
(
self
):
pipe
=
self
.
pipeline_class
(
**
self
.
get_dummy_components
()).
to
(
torch_device
)
inputs
=
self
.
get_dummy_inputs
(
torch_device
)
inputs
.
pop
(
"generator"
)
no_true_cfg_out
=
pipe
(
**
inputs
,
generator
=
torch
.
manual_seed
(
0
)).
images
[
0
]
inputs
[
"negative_prompt"
]
=
"bad quality"
inputs
[
"true_cfg_scale"
]
=
2.0
true_cfg_out
=
pipe
(
**
inputs
,
generator
=
torch
.
manual_seed
(
0
)).
images
[
0
]
assert
not
np
.
allclose
(
no_true_cfg_out
,
true_cfg_out
)
@
nightly
@
nightly
@
require_big_gpu_with_torch_cuda
@
require_big_gpu_with_torch_cuda
...
...
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