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
6133d98f
Unverified
Commit
6133d98f
authored
Apr 05, 2024
by
YiYi Xu
Committed by
GitHub
Apr 05, 2024
Browse files
[IF| add set_begin_index for all IF pipelines (#7577)
add set_begin_index for all if pipelines
parent
1c60e094
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
7 deletions
+23
-7
src/diffusers/pipelines/deepfloyd_if/pipeline_if.py
src/diffusers/pipelines/deepfloyd_if/pipeline_if.py
+3
-0
src/diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py
src/diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py
+4
-1
src/diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py
...lines/deepfloyd_if/pipeline_if_img2img_superresolution.py
+4
-2
src/diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py
...iffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py
+4
-2
src/diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py
...es/deepfloyd_if/pipeline_if_inpainting_superresolution.py
+4
-2
src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py
...ers/pipelines/deepfloyd_if/pipeline_if_superresolution.py
+3
-0
src/diffusers/pipelines/pipeline_utils.py
src/diffusers/pipelines/pipeline_utils.py
+1
-0
No files found.
src/diffusers/pipelines/deepfloyd_if/pipeline_if.py
View file @
6133d98f
...
...
@@ -691,6 +691,9 @@ class IFPipeline(DiffusionPipeline, LoraLoaderMixin):
self
.
scheduler
.
set_timesteps
(
num_inference_steps
,
device
=
device
)
timesteps
=
self
.
scheduler
.
timesteps
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
0
)
# 5. Prepare intermediate images
intermediate_images
=
self
.
prepare_intermediate_images
(
batch_size
*
num_images_per_prompt
,
...
...
src/diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py
View file @
6133d98f
...
...
@@ -633,12 +633,15 @@ class IFImg2ImgPipeline(DiffusionPipeline, LoraLoaderMixin):
return
image
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusionImg2ImgPipeline.get_timesteps
def
get_timesteps
(
self
,
num_inference_steps
,
strength
):
# get the original timestep using init_timestep
init_timestep
=
min
(
int
(
num_inference_steps
*
strength
),
num_inference_steps
)
t_start
=
max
(
num_inference_steps
-
init_timestep
,
0
)
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
:]
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
*
self
.
scheduler
.
order
:]
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
t_start
*
self
.
scheduler
.
order
)
return
timesteps
,
num_inference_steps
-
t_start
...
...
src/diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py
View file @
6133d98f
...
...
@@ -714,13 +714,15 @@ class IFImg2ImgSuperResolutionPipeline(DiffusionPipeline, LoraLoaderMixin):
return
image
# Copied from diffusers.pipelines.
deepfloyd_if.pipeline_if_img2img.IF
Img2ImgPipeline.get_timesteps
# Copied from diffusers.pipelines.
stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusion
Img2ImgPipeline.get_timesteps
def
get_timesteps
(
self
,
num_inference_steps
,
strength
):
# get the original timestep using init_timestep
init_timestep
=
min
(
int
(
num_inference_steps
*
strength
),
num_inference_steps
)
t_start
=
max
(
num_inference_steps
-
init_timestep
,
0
)
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
:]
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
*
self
.
scheduler
.
order
:]
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
t_start
*
self
.
scheduler
.
order
)
return
timesteps
,
num_inference_steps
-
t_start
...
...
src/diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py
View file @
6133d98f
...
...
@@ -723,13 +723,15 @@ class IFInpaintingPipeline(DiffusionPipeline, LoraLoaderMixin):
return
mask_image
# Copied from diffusers.pipelines.
deepfloyd_if.pipeline_if_img2img.IF
Img2ImgPipeline.get_timesteps
# Copied from diffusers.pipelines.
stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusion
Img2ImgPipeline.get_timesteps
def
get_timesteps
(
self
,
num_inference_steps
,
strength
):
# get the original timestep using init_timestep
init_timestep
=
min
(
int
(
num_inference_steps
*
strength
),
num_inference_steps
)
t_start
=
max
(
num_inference_steps
-
init_timestep
,
0
)
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
:]
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
*
self
.
scheduler
.
order
:]
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
t_start
*
self
.
scheduler
.
order
)
return
timesteps
,
num_inference_steps
-
t_start
...
...
src/diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py
View file @
6133d98f
...
...
@@ -800,13 +800,15 @@ class IFInpaintingSuperResolutionPipeline(DiffusionPipeline, LoraLoaderMixin):
return
mask_image
# Copied from diffusers.pipelines.
deepfloyd_if.pipeline_if_img2img.IF
Img2ImgPipeline.get_timesteps
# Copied from diffusers.pipelines.
stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusion
Img2ImgPipeline.get_timesteps
def
get_timesteps
(
self
,
num_inference_steps
,
strength
):
# get the original timestep using init_timestep
init_timestep
=
min
(
int
(
num_inference_steps
*
strength
),
num_inference_steps
)
t_start
=
max
(
num_inference_steps
-
init_timestep
,
0
)
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
:]
timesteps
=
self
.
scheduler
.
timesteps
[
t_start
*
self
.
scheduler
.
order
:]
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
t_start
*
self
.
scheduler
.
order
)
return
timesteps
,
num_inference_steps
-
t_start
...
...
src/diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py
View file @
6133d98f
...
...
@@ -775,6 +775,9 @@ class IFSuperResolutionPipeline(DiffusionPipeline, LoraLoaderMixin):
self
.
scheduler
.
set_timesteps
(
num_inference_steps
,
device
=
device
)
timesteps
=
self
.
scheduler
.
timesteps
if
hasattr
(
self
.
scheduler
,
"set_begin_index"
):
self
.
scheduler
.
set_begin_index
(
0
)
# 5. Prepare intermediate images
num_channels
=
self
.
unet
.
config
.
in_channels
//
2
intermediate_images
=
self
.
prepare_intermediate_images
(
...
...
src/diffusers/pipelines/pipeline_utils.py
View file @
6133d98f
...
...
@@ -998,6 +998,7 @@ class DiffusionPipeline(ConfigMixin, PushToHubMixin):
all_model_components
=
{
k
:
v
for
k
,
v
in
self
.
components
.
items
()
if
isinstance
(
v
,
torch
.
nn
.
Module
)}
self
.
_all_hooks
=
[]
hook
=
None
for
model_str
in
self
.
model_cpu_offload_seq
.
split
(
"->"
):
model
=
all_model_components
.
pop
(
model_str
,
None
)
...
...
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