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
OpenDAS
diffusers
Commits
3b01d72a
Unverified
Commit
3b01d72a
authored
Jun 27, 2024
by
Álvaro Somoza
Committed by
GitHub
Jun 27, 2024
Browse files
Modify FlowMatch Scale Noise (#8678)
* initial fix * apply suggestion * delete step_index line
parent
e2a4a46e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py
...stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py
+1
-1
src/diffusers/schedulers/scheduling_flow_match_euler_discrete.py
...fusers/schedulers/scheduling_flow_match_euler_discrete.py
+24
-3
No files found.
src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py
View file @
3b01d72a
...
@@ -852,7 +852,7 @@ class StableDiffusion3Img2ImgPipeline(DiffusionPipeline):
...
@@ -852,7 +852,7 @@ class StableDiffusion3Img2ImgPipeline(DiffusionPipeline):
# 4. Prepare timesteps
# 4. Prepare timesteps
timesteps
,
num_inference_steps
=
retrieve_timesteps
(
self
.
scheduler
,
num_inference_steps
,
device
,
timesteps
)
timesteps
,
num_inference_steps
=
retrieve_timesteps
(
self
.
scheduler
,
num_inference_steps
,
device
,
timesteps
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
timesteps
,
num_inference_steps
=
self
.
get_timesteps
(
num_inference_steps
,
strength
,
device
)
latent_timestep
=
timesteps
[:
1
].
repeat
(
batch_size
*
num_i
nference_steps
)
latent_timestep
=
timesteps
[:
1
].
repeat
(
batch_size
*
num_i
mages_per_prompt
)
# 5. Prepare latent variables
# 5. Prepare latent variables
if
latents
is
None
:
if
latents
is
None
:
...
...
src/diffusers/schedulers/scheduling_flow_match_euler_discrete.py
View file @
3b01d72a
...
@@ -126,10 +126,31 @@ class FlowMatchEulerDiscreteScheduler(SchedulerMixin, ConfigMixin):
...
@@ -126,10 +126,31 @@ class FlowMatchEulerDiscreteScheduler(SchedulerMixin, ConfigMixin):
`torch.FloatTensor`:
`torch.FloatTensor`:
A scaled input sample.
A scaled input sample.
"""
"""
if
self
.
step_index
is
None
:
# Make sure sigmas and timesteps have the same device and dtype as original_samples
self
.
_init_step_index
(
timestep
)
sigmas
=
self
.
sigmas
.
to
(
device
=
sample
.
device
,
dtype
=
sample
.
dtype
)
if
sample
.
device
.
type
==
"mps"
and
torch
.
is_floating_point
(
timestep
):
# mps does not support float64
schedule_timesteps
=
self
.
timesteps
.
to
(
sample
.
device
,
dtype
=
torch
.
float32
)
timestep
=
timestep
.
to
(
sample
.
device
,
dtype
=
torch
.
float32
)
else
:
schedule_timesteps
=
self
.
timesteps
.
to
(
sample
.
device
)
timestep
=
timestep
.
to
(
sample
.
device
)
# self.begin_index is None when scheduler is used for training, or pipeline does not implement set_begin_index
if
self
.
begin_index
is
None
:
step_indices
=
[
self
.
index_for_timestep
(
t
,
schedule_timesteps
)
for
t
in
timestep
]
elif
self
.
step_index
is
not
None
:
# add_noise is called after first denoising step (for inpainting)
step_indices
=
[
self
.
step_index
]
*
timestep
.
shape
[
0
]
else
:
# add noise is called before first denoising step to create initial latent(img2img)
step_indices
=
[
self
.
begin_index
]
*
timestep
.
shape
[
0
]
sigma
=
sigmas
[
step_indices
].
flatten
()
while
len
(
sigma
.
shape
)
<
len
(
sample
.
shape
):
sigma
=
sigma
.
unsqueeze
(
-
1
)
sigma
=
self
.
sigmas
[
self
.
step_index
]
sample
=
sigma
*
noise
+
(
1.0
-
sigma
)
*
sample
sample
=
sigma
*
noise
+
(
1.0
-
sigma
)
*
sample
return
sample
return
sample
...
...
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