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
8d386f79
"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "1f4e3a46609df5550789ea681820cd77b186b515"
Unverified
Commit
8d386f79
authored
Dec 02, 2024
by
hlky
Committed by
GitHub
Dec 02, 2024
Browse files
Add `sigmas` to Flux pipelines (#10081)
parent
827b6c25
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
68 deletions
+63
-68
src/diffusers/pipelines/flux/pipeline_flux.py
src/diffusers/pipelines/flux/pipeline_flux.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_control.py
src/diffusers/pipelines/flux/pipeline_flux_control.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_control_img2img.py
...diffusers/pipelines/flux/pipeline_flux_control_img2img.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_controlnet.py
src/diffusers/pipelines/flux/pipeline_flux_controlnet.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py
...pipelines/flux/pipeline_flux_controlnet_image_to_image.py
+7
-6
src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
...ers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
+7
-6
src/diffusers/pipelines/flux/pipeline_flux_fill.py
src/diffusers/pipelines/flux/pipeline_flux_fill.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_img2img.py
src/diffusers/pipelines/flux/pipeline_flux_img2img.py
+7
-8
src/diffusers/pipelines/flux/pipeline_flux_inpaint.py
src/diffusers/pipelines/flux/pipeline_flux_inpaint.py
+7
-8
No files found.
src/diffusers/pipelines/flux/pipeline_flux.py
View file @
8d386f79
...
@@ -554,7 +554,7 @@ class FluxPipeline(
...
@@ -554,7 +554,7 @@ class FluxPipeline(
height
:
Optional
[
int
]
=
None
,
height
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
3.5
,
guidance_scale
:
float
=
3.5
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -585,10 +585,10 @@ class FluxPipeline(
...
@@ -585,10 +585,10 @@ class FluxPipeline(
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -699,7 +699,7 @@ class FluxPipeline(
...
@@ -699,7 +699,7 @@ class FluxPipeline(
)
)
# 5. Prepare timesteps
# 5. Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
latents
.
shape
[
1
]
image_seq_len
=
latents
.
shape
[
1
]
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -712,8 +712,7 @@ class FluxPipeline(
...
@@ -712,8 +712,7 @@ class FluxPipeline(
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_control.py
View file @
8d386f79
...
@@ -621,7 +621,7 @@ class FluxControlPipeline(
...
@@ -621,7 +621,7 @@ class FluxControlPipeline(
height
:
Optional
[
int
]
=
None
,
height
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
3.5
,
guidance_scale
:
float
=
3.5
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -660,10 +660,10 @@ class FluxControlPipeline(
...
@@ -660,10 +660,10 @@ class FluxControlPipeline(
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -799,7 +799,7 @@ class FluxControlPipeline(
...
@@ -799,7 +799,7 @@ class FluxControlPipeline(
)
)
# 5. Prepare timesteps
# 5. Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
latents
.
shape
[
1
]
image_seq_len
=
latents
.
shape
[
1
]
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -812,8 +812,7 @@ class FluxControlPipeline(
...
@@ -812,8 +812,7 @@ class FluxControlPipeline(
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_control_img2img.py
View file @
8d386f79
...
@@ -647,7 +647,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
...
@@ -647,7 +647,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
strength
:
float
=
0.6
,
strength
:
float
=
0.6
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -698,10 +698,10 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
...
@@ -698,10 +698,10 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -805,7 +805,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
...
@@ -805,7 +805,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
)
)
# 4.Prepare timesteps
# 4.Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -818,8 +818,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
...
@@ -818,8 +818,7 @@ class FluxControlImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSin
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_controlnet.py
View file @
8d386f79
...
@@ -602,7 +602,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
...
@@ -602,7 +602,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
height
:
Optional
[
int
]
=
None
,
height
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
control_guidance_end
:
Union
[
float
,
List
[
float
]]
=
1.0
,
control_guidance_end
:
Union
[
float
,
List
[
float
]]
=
1.0
,
...
@@ -638,10 +638,10 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
...
@@ -638,10 +638,10 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -872,7 +872,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
...
@@ -872,7 +872,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
)
)
# 5. Prepare timesteps
# 5. Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
latents
.
shape
[
1
]
image_seq_len
=
latents
.
shape
[
1
]
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -885,8 +885,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
...
@@ -885,8 +885,7 @@ class FluxControlNetPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleF
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py
View file @
8d386f79
...
@@ -646,7 +646,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -646,7 +646,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
strength
:
float
=
0.6
,
strength
:
float
=
0.6
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
control_guidance_end
:
Union
[
float
,
List
[
float
]]
=
1.0
,
control_guidance_end
:
Union
[
float
,
List
[
float
]]
=
1.0
,
...
@@ -685,8 +685,10 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -685,8 +685,10 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
num_inference_steps (`int`, *optional*, defaults to 28):
num_inference_steps (`int`, *optional*, defaults to 28):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timesteps (`List[int]`, *optional*):
sigmas (`List[float]`, *optional*):
Custom timesteps to use for the denoising process.
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
control_mode (`int` or `List[int]`, *optional*):
control_mode (`int` or `List[int]`, *optional*):
...
@@ -858,7 +860,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -858,7 +860,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
control_mode
=
torch
.
tensor
(
control_mode_
).
to
(
device
,
dtype
=
torch
.
long
)
control_mode
=
torch
.
tensor
(
control_mode_
).
to
(
device
,
dtype
=
torch
.
long
)
control_mode
=
control_mode
.
reshape
([
-
1
,
1
])
control_mode
=
control_mode
.
reshape
([
-
1
,
1
])
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -871,8 +873,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -871,8 +873,7 @@ class FluxControlNetImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py
View file @
8d386f79
...
@@ -752,7 +752,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -752,7 +752,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
strength
:
float
=
0.6
,
strength
:
float
=
0.6
,
padding_mask_crop
:
Optional
[
int
]
=
None
,
padding_mask_crop
:
Optional
[
int
]
=
None
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
control_guidance_start
:
Union
[
float
,
List
[
float
]]
=
0.0
,
...
@@ -799,8 +799,10 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -799,8 +799,10 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
num_inference_steps (`int`, *optional*, defaults to 28):
num_inference_steps (`int`, *optional*, defaults to 28):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timesteps (`List[int]`, *optional*):
sigmas (`List[float]`, *optional*):
Custom timesteps to use for the denoising process.
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
control_guidance_start (`float` or `List[float]`, *optional*, defaults to 0.0):
control_guidance_start (`float` or `List[float]`, *optional*, defaults to 0.0):
...
@@ -1009,7 +1011,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -1009,7 +1011,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
# 6. Prepare timesteps
# 6. Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
(
int
(
global_height
)
//
self
.
vae_scale_factor
//
2
)
*
(
image_seq_len
=
(
int
(
global_height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
global_width
)
//
self
.
vae_scale_factor
//
2
int
(
global_width
)
//
self
.
vae_scale_factor
//
2
)
)
...
@@ -1024,8 +1026,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
...
@@ -1024,8 +1026,7 @@ class FluxControlNetInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin, From
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_fill.py
View file @
8d386f79
...
@@ -689,7 +689,7 @@ class FluxFillPipeline(
...
@@ -689,7 +689,7 @@ class FluxFillPipeline(
height
:
Optional
[
int
]
=
None
,
height
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
num_inference_steps
:
int
=
50
,
num_inference_steps
:
int
=
50
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
30.0
,
guidance_scale
:
float
=
30.0
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -735,10 +735,10 @@ class FluxFillPipeline(
...
@@ -735,10 +735,10 @@ class FluxFillPipeline(
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -878,7 +878,7 @@ class FluxFillPipeline(
...
@@ -878,7 +878,7 @@ class FluxFillPipeline(
masked_image_latents
=
torch
.
cat
((
masked_image_latents
,
mask
),
dim
=-
1
)
masked_image_latents
=
torch
.
cat
((
masked_image_latents
,
mask
),
dim
=-
1
)
# 6. Prepare timesteps
# 6. Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
latents
.
shape
[
1
]
image_seq_len
=
latents
.
shape
[
1
]
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -891,8 +891,7 @@ class FluxFillPipeline(
...
@@ -891,8 +891,7 @@ class FluxFillPipeline(
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
num_warmup_steps
=
max
(
len
(
timesteps
)
-
num_inference_steps
*
self
.
scheduler
.
order
,
0
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_img2img.py
View file @
8d386f79
...
@@ -593,7 +593,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
...
@@ -593,7 +593,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
width
:
Optional
[
int
]
=
None
,
width
:
Optional
[
int
]
=
None
,
strength
:
float
=
0.6
,
strength
:
float
=
0.6
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -636,10 +636,10 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
...
@@ -636,10 +636,10 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -742,7 +742,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
...
@@ -742,7 +742,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
)
)
# 4.Prepare timesteps
# 4.Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -755,8 +755,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
...
@@ -755,8 +755,7 @@ class FluxImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin, FromSingleFile
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
...
...
src/diffusers/pipelines/flux/pipeline_flux_inpaint.py
View file @
8d386f79
...
@@ -693,7 +693,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -693,7 +693,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
padding_mask_crop
:
Optional
[
int
]
=
None
,
padding_mask_crop
:
Optional
[
int
]
=
None
,
strength
:
float
=
0.6
,
strength
:
float
=
0.6
,
num_inference_steps
:
int
=
28
,
num_inference_steps
:
int
=
28
,
timesteps
:
List
[
int
]
=
None
,
sigmas
:
Optional
[
List
[
float
]
]
=
None
,
guidance_scale
:
float
=
7.0
,
guidance_scale
:
float
=
7.0
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
num_images_per_prompt
:
Optional
[
int
]
=
1
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
generator
:
Optional
[
Union
[
torch
.
Generator
,
List
[
torch
.
Generator
]]]
=
None
,
...
@@ -753,10 +753,10 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -753,10 +753,10 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
num_inference_steps (`int`, *optional*, defaults to 50):
num_inference_steps (`int`, *optional*, defaults to 50):
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.
expense of slower inference.
timestep
s (`List[
in
t]`, *optional*):
sigma
s (`List[
floa
t]`, *optional*):
Custom
timestep
s to use for the denoising process with schedulers which support a `
timestep
s` argument
Custom
sigma
s to use for the denoising process with schedulers which support a `
sigma
s` argument
in
in
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is
passed
passed
will be used.
Must be in descending order.
will be used.
guidance_scale (`float`, *optional*, defaults to 7.0):
guidance_scale (`float`, *optional*, defaults to 7.0):
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
Guidance scale as defined in [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598).
`guidance_scale` is defined as `w` of equation 2. of [Imagen
`guidance_scale` is defined as `w` of equation 2. of [Imagen
...
@@ -873,7 +873,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -873,7 +873,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
)
)
# 4.Prepare timesteps
# 4.Prepare timesteps
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
sigmas
=
np
.
linspace
(
1.0
,
1
/
num_inference_steps
,
num_inference_steps
)
if
sigmas
is
None
else
sigmas
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
image_seq_len
=
(
int
(
height
)
//
self
.
vae_scale_factor
//
2
)
*
(
int
(
width
)
//
self
.
vae_scale_factor
//
2
)
mu
=
calculate_shift
(
mu
=
calculate_shift
(
image_seq_len
,
image_seq_len
,
...
@@ -886,8 +886,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -886,8 +886,7 @@ class FluxInpaintPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
self
.
scheduler
,
self
.
scheduler
,
num_inference_steps
,
num_inference_steps
,
device
,
device
,
timesteps
,
sigmas
=
sigmas
,
sigmas
,
mu
=
mu
,
mu
=
mu
,
)
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
...
...
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