Skip to content

Commit 2656a78

Browse files
committed
fix: deprecate use of init_image in all pipelines
1 parent c9ebcbe commit 2656a78

10 files changed

+46
-3
lines changed

examples/community/imagic_stable_diffusion.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
1818
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
1919
from diffusers.schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
20-
from diffusers.utils import logging
20+
from diffusers.utils import deprecate, logging
2121

2222
# TODO: remove and import from diffusers.utils when the new version of diffusers is released
2323
from packaging import version
@@ -184,6 +184,10 @@ def train(
184184
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
185185
(nsfw) content, according to the `safety_checker`.
186186
"""
187+
message = "Please use `image` instead of `init_image`."
188+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
189+
image = init_image or image
190+
187191
accelerator = Accelerator(
188192
gradient_accumulation_steps=1,
189193
mixed_precision="fp16",

examples/community/lpw_stable_diffusion.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ def __call__(
648648
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
649649
(nsfw) content, according to the `safety_checker`.
650650
"""
651+
message = "Please use `image` instead of `init_image`."
652+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
653+
image = init_image or image
651654

652655
if isinstance(prompt, str):
653656
batch_size = 1

examples/community/lpw_stable_diffusion_onnx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from diffusers.pipeline_utils import DiffusionPipeline
1111
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
1212
from diffusers.schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
13-
from diffusers.utils import logging
13+
from diffusers.utils import deprecate, logging
1414

1515
# TODO: remove and import from diffusers.utils when the new version of diffusers is released
1616
from packaging import version
@@ -533,6 +533,9 @@ def __call__(
533533
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
534534
(nsfw) content, according to the `safety_checker`.
535535
"""
536+
message = "Please use `image` instead of `init_image`."
537+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
538+
image = init_image or image
536539

537540
if isinstance(prompt, str):
538541
batch_size = 1

src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ def __call__(
484484
return_dict: bool = True,
485485
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
486486
callback_steps: Optional[int] = 1,
487+
**kwargs,
487488
):
488489
r"""
489490
Function invoked when calling the pipeline for generation.
@@ -540,6 +541,10 @@ def __call__(
540541
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
541542
(nsfw) content, according to the `safety_checker`.
542543
"""
544+
message = "Please use `image` instead of `init_image`."
545+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
546+
image = init_image or image
547+
543548
# 1. Check inputs
544549
self.check_inputs(prompt, strength, callback_steps)
545550

src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion_superresolution.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
LMSDiscreteScheduler,
1818
PNDMScheduler,
1919
)
20-
from ...utils import PIL_INTERPOLATION
20+
from ...utils import PIL_INTERPOLATION, deprecate
2121

2222

2323
def preprocess(image):
@@ -102,6 +102,9 @@ def __call__(
102102
`return_dict` is True, otherwise a `tuple. When returning a tuple, the first element is a list with the
103103
generated images.
104104
"""
105+
message = "Please use `image` instead of `init_image`."
106+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
107+
image = init_image or image
105108

106109
if isinstance(image, PIL.Image.Image):
107110
batch_size = 1

src/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ def __call__(
528528
return_dict: bool = True,
529529
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
530530
callback_steps: Optional[int] = 1,
531+
**kwargs,
531532
):
532533
r"""
533534
Function invoked when calling the pipeline for generation.
@@ -584,6 +585,10 @@ def __call__(
584585
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
585586
(nsfw) content, according to the `safety_checker`.
586587
"""
588+
message = "Please use `image` instead of `init_image`."
589+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
590+
image = init_image or image
591+
587592
# 1. Check inputs
588593
self.check_inputs(prompt, strength, callback_steps)
589594

src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def __call__(
241241
return_dict: bool = True,
242242
callback: Optional[Callable[[int, int, np.ndarray], None]] = None,
243243
callback_steps: Optional[int] = 1,
244+
**kwargs,
244245
):
245246
r"""
246247
Function invoked when calling the pipeline for generation.
@@ -296,6 +297,10 @@ def __call__(
296297
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
297298
(nsfw) content, according to the `safety_checker`.
298299
"""
300+
message = "Please use `image` instead of `init_image`."
301+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
302+
image = init_image or image
303+
299304
if isinstance(prompt, str):
300305
batch_size = 1
301306
elif isinstance(prompt, list):

src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint_legacy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def __call__(
241241
return_dict: bool = True,
242242
callback: Optional[Callable[[int, int, np.ndarray], None]] = None,
243243
callback_steps: Optional[int] = 1,
244+
**kwargs,
244245
):
245246
r"""
246247
Function invoked when calling the pipeline for generation.
@@ -301,6 +302,10 @@ def __call__(
301302
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
302303
(nsfw) content, according to the `safety_checker`.
303304
"""
305+
message = "Please use `image` instead of `init_image`."
306+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
307+
image = init_image or image
308+
304309
if isinstance(prompt, str):
305310
batch_size = 1
306311
elif isinstance(prompt, list):

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ def __call__(
493493
return_dict: bool = True,
494494
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
495495
callback_steps: Optional[int] = 1,
496+
**kwargs,
496497
):
497498
r"""
498499
Function invoked when calling the pipeline for generation.
@@ -549,6 +550,10 @@ def __call__(
549550
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
550551
(nsfw) content, according to the `safety_checker`.
551552
"""
553+
message = "Please use `image` instead of `init_image`."
554+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
555+
image = init_image or image
556+
552557
# 1. Check inputs
553558
self.check_inputs(prompt, strength, callback_steps)
554559

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ def __call__(
492492
return_dict: bool = True,
493493
callback: Optional[Callable[[int, int, torch.FloatTensor], None]] = None,
494494
callback_steps: Optional[int] = 1,
495+
**kwargs,
495496
):
496497
r"""
497498
Function invoked when calling the pipeline for generation.
@@ -552,6 +553,10 @@ def __call__(
552553
list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work"
553554
(nsfw) content, according to the `safety_checker`.
554555
"""
556+
message = "Please use `image` instead of `init_image`."
557+
init_image = deprecate("init_image", "0.12.0", message, take_from=kwargs)
558+
image = init_image or image
559+
555560
# 1. Check inputs
556561
self.check_inputs(prompt, strength, callback_steps)
557562

0 commit comments

Comments
 (0)