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
298ab6eb
Unverified
Commit
298ab6eb
authored
Oct 26, 2024
by
SahilCarterr
Committed by
GitHub
Oct 25, 2024
Browse files
Added Support of Xlabs controlnet to FluxControlNetInpaintPipeline (#9770)
* added xlabs support
parent
73b59f52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
...ers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
+34
-27
No files found.
src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
View file @
298ab6eb
...
@@ -932,19 +932,22 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -932,19 +932,22 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
)
)
height
,
width
=
control_image
.
shape
[
-
2
:]
height
,
width
=
control_image
.
shape
[
-
2
:]
# vae encode
# xlab controlnet has a input_hint_block and instantx controlnet does not
control_image
=
self
.
vae
.
encode
(
control_image
).
latent_dist
.
sample
()
controlnet_blocks_repeat
=
False
if
self
.
controlnet
.
input_hint_block
is
None
else
True
control_image
=
(
control_image
-
self
.
vae
.
config
.
shift_factor
)
*
self
.
vae
.
config
.
scaling_factor
if
self
.
controlnet
.
input_hint_block
is
None
:
# vae encode
# pack
control_image
=
self
.
vae
.
encode
(
control_image
).
latent_dist
.
sample
()
height_control_image
,
width_control_image
=
control_image
.
shape
[
2
:]
control_image
=
(
control_image
-
self
.
vae
.
config
.
shift_factor
)
*
self
.
vae
.
config
.
scaling_factor
control_image
=
self
.
_pack_latents
(
control_image
,
# pack
batch_size
*
num_images_per_prompt
,
height_control_image
,
width_control_image
=
control_image
.
shape
[
2
:]
num_channels_latents
,
control_image
=
self
.
_pack_latents
(
height_control_image
,
control_image
,
width_control_image
,
batch_size
*
num_images_per_prompt
,
)
num_channels_latents
,
height_control_image
,
width_control_image
,
)
# set control mode
# set control mode
if
control_mode
is
not
None
:
if
control_mode
is
not
None
:
...
@@ -954,7 +957,9 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -954,7 +957,9 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
elif
isinstance
(
self
.
controlnet
,
FluxMultiControlNetModel
):
elif
isinstance
(
self
.
controlnet
,
FluxMultiControlNetModel
):
control_images
=
[]
control_images
=
[]
for
control_image_
in
control_image
:
# xlab controlnet has a input_hint_block and instantx controlnet does not
controlnet_blocks_repeat
=
False
if
self
.
controlnet
.
nets
[
0
].
input_hint_block
is
None
else
True
for
i
,
control_image_
in
enumerate
(
control_image
):
control_image_
=
self
.
prepare_image
(
control_image_
=
self
.
prepare_image
(
image
=
control_image_
,
image
=
control_image_
,
width
=
width
,
width
=
width
,
...
@@ -966,19 +971,20 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -966,19 +971,20 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
)
)
height
,
width
=
control_image_
.
shape
[
-
2
:]
height
,
width
=
control_image_
.
shape
[
-
2
:]
# vae encode
if
self
.
controlnet
.
nets
[
0
].
input_hint_block
is
None
:
control_image_
=
self
.
vae
.
encode
(
control_image_
).
latent_dist
.
sample
()
# vae encode
control_image_
=
(
control_image_
-
self
.
vae
.
config
.
shift_factor
)
*
self
.
vae
.
config
.
scaling_factor
control_image_
=
self
.
vae
.
encode
(
control_image_
).
latent_dist
.
sample
()
control_image_
=
(
control_image_
-
self
.
vae
.
config
.
shift_factor
)
*
self
.
vae
.
config
.
scaling_factor
# pack
height_control_image
,
width_control_image
=
control_image_
.
shape
[
2
:]
# pack
control_image_
=
self
.
_pack_latents
(
height_control_image
,
width_control_image
=
control_image_
.
shape
[
2
:]
control_image_
,
control_image_
=
self
.
_pack_latents
(
batch_size
*
num_images_per_prompt
,
control_image_
,
num_channels_latents
,
batch_size
*
num_images_per_prompt
,
height_control_image
,
num_channels_latents
,
width_control_image
,
height_control_image
,
)
width_control_image
,
)
control_images
.
append
(
control_image_
)
control_images
.
append
(
control_image_
)
...
@@ -1129,6 +1135,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -1129,6 +1135,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
img_ids
=
latent_image_ids
,
img_ids
=
latent_image_ids
,
joint_attention_kwargs
=
self
.
joint_attention_kwargs
,
joint_attention_kwargs
=
self
.
joint_attention_kwargs
,
return_dict
=
False
,
return_dict
=
False
,
controlnet_blocks_repeat
=
controlnet_blocks_repeat
,
)[
0
]
)[
0
]
# compute the previous noisy sample x_t -> x_t-1
# compute the previous noisy sample x_t -> x_t-1
...
...
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