diffusers 0.26.3__py3-none-any.whl → 0.27.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- diffusers/__init__.py +20 -1
- diffusers/commands/__init__.py +1 -1
- diffusers/commands/diffusers_cli.py +1 -1
- diffusers/commands/env.py +1 -1
- diffusers/commands/fp16_safetensors.py +1 -1
- diffusers/configuration_utils.py +7 -3
- diffusers/dependency_versions_check.py +1 -1
- diffusers/dependency_versions_table.py +2 -2
- diffusers/experimental/rl/value_guided_sampling.py +1 -1
- diffusers/image_processor.py +110 -4
- diffusers/loaders/autoencoder.py +7 -8
- diffusers/loaders/controlnet.py +17 -8
- diffusers/loaders/ip_adapter.py +86 -23
- diffusers/loaders/lora.py +105 -310
- diffusers/loaders/lora_conversion_utils.py +1 -1
- diffusers/loaders/peft.py +1 -1
- diffusers/loaders/single_file.py +51 -12
- diffusers/loaders/single_file_utils.py +274 -49
- diffusers/loaders/textual_inversion.py +23 -4
- diffusers/loaders/unet.py +195 -41
- diffusers/loaders/utils.py +1 -1
- diffusers/models/__init__.py +3 -1
- diffusers/models/activations.py +9 -9
- diffusers/models/attention.py +26 -36
- diffusers/models/attention_flax.py +1 -1
- diffusers/models/attention_processor.py +171 -114
- diffusers/models/autoencoders/autoencoder_asym_kl.py +1 -1
- diffusers/models/autoencoders/autoencoder_kl.py +3 -1
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +1 -1
- diffusers/models/autoencoders/autoencoder_tiny.py +4 -2
- diffusers/models/autoencoders/consistency_decoder_vae.py +1 -1
- diffusers/models/autoencoders/vae.py +1 -1
- diffusers/models/controlnet.py +1 -1
- diffusers/models/controlnet_flax.py +1 -1
- diffusers/models/downsampling.py +8 -12
- diffusers/models/dual_transformer_2d.py +1 -1
- diffusers/models/embeddings.py +3 -4
- diffusers/models/embeddings_flax.py +1 -1
- diffusers/models/lora.py +33 -10
- diffusers/models/modeling_flax_pytorch_utils.py +1 -1
- diffusers/models/modeling_flax_utils.py +1 -1
- diffusers/models/modeling_pytorch_flax_utils.py +1 -1
- diffusers/models/modeling_utils.py +4 -6
- diffusers/models/normalization.py +1 -1
- diffusers/models/resnet.py +31 -58
- diffusers/models/resnet_flax.py +1 -1
- diffusers/models/t5_film_transformer.py +1 -1
- diffusers/models/transformer_2d.py +1 -1
- diffusers/models/transformer_temporal.py +1 -1
- diffusers/models/transformers/dual_transformer_2d.py +1 -1
- diffusers/models/transformers/t5_film_transformer.py +1 -1
- diffusers/models/transformers/transformer_2d.py +29 -31
- diffusers/models/transformers/transformer_temporal.py +1 -1
- diffusers/models/unet_1d.py +1 -1
- diffusers/models/unet_1d_blocks.py +1 -1
- diffusers/models/unet_2d.py +1 -1
- diffusers/models/unet_2d_blocks.py +1 -1
- diffusers/models/unet_2d_condition.py +1 -1
- diffusers/models/unets/__init__.py +1 -0
- diffusers/models/unets/unet_1d.py +1 -1
- diffusers/models/unets/unet_1d_blocks.py +1 -1
- diffusers/models/unets/unet_2d.py +4 -4
- diffusers/models/unets/unet_2d_blocks.py +238 -98
- diffusers/models/unets/unet_2d_blocks_flax.py +1 -1
- diffusers/models/unets/unet_2d_condition.py +420 -323
- diffusers/models/unets/unet_2d_condition_flax.py +21 -12
- diffusers/models/unets/unet_3d_blocks.py +50 -40
- diffusers/models/unets/unet_3d_condition.py +47 -8
- diffusers/models/unets/unet_i2vgen_xl.py +75 -30
- diffusers/models/unets/unet_kandinsky3.py +1 -1
- diffusers/models/unets/unet_motion_model.py +48 -8
- diffusers/models/unets/unet_spatio_temporal_condition.py +1 -1
- diffusers/models/unets/unet_stable_cascade.py +610 -0
- diffusers/models/unets/uvit_2d.py +1 -1
- diffusers/models/upsampling.py +10 -16
- diffusers/models/vae_flax.py +1 -1
- diffusers/models/vq_model.py +1 -1
- diffusers/optimization.py +1 -1
- diffusers/pipelines/__init__.py +26 -0
- diffusers/pipelines/amused/pipeline_amused.py +1 -1
- diffusers/pipelines/amused/pipeline_amused_img2img.py +1 -1
- diffusers/pipelines/amused/pipeline_amused_inpaint.py +1 -1
- diffusers/pipelines/animatediff/pipeline_animatediff.py +162 -417
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +165 -137
- diffusers/pipelines/animatediff/pipeline_output.py +7 -6
- diffusers/pipelines/audioldm/pipeline_audioldm.py +3 -19
- diffusers/pipelines/audioldm2/modeling_audioldm2.py +1 -1
- diffusers/pipelines/audioldm2/pipeline_audioldm2.py +3 -3
- diffusers/pipelines/auto_pipeline.py +7 -16
- diffusers/pipelines/blip_diffusion/blip_image_processing.py +1 -1
- diffusers/pipelines/blip_diffusion/modeling_blip2.py +1 -1
- diffusers/pipelines/blip_diffusion/modeling_ctx_clip.py +2 -2
- diffusers/pipelines/blip_diffusion/pipeline_blip_diffusion.py +2 -2
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -1
- diffusers/pipelines/controlnet/pipeline_controlnet.py +90 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_blip_diffusion.py +2 -2
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +98 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +92 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +145 -70
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +126 -89
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +108 -96
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
- diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py +1 -1
- diffusers/pipelines/ddim/pipeline_ddim.py +1 -1
- diffusers/pipelines/ddpm/pipeline_ddpm.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +5 -5
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +5 -5
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +5 -5
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +10 -120
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +10 -91
- diffusers/pipelines/deprecated/audio_diffusion/mel.py +1 -1
- diffusers/pipelines/deprecated/audio_diffusion/pipeline_audio_diffusion.py +1 -1
- diffusers/pipelines/deprecated/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py +1 -1
- diffusers/pipelines/deprecated/pndm/pipeline_pndm.py +1 -1
- diffusers/pipelines/deprecated/repaint/pipeline_repaint.py +1 -1
- diffusers/pipelines/deprecated/score_sde_ve/pipeline_score_sde_ve.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/continuous_encoder.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/midi_utils.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/notes_encoder.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/pipeline_spectrogram_diffusion.py +1 -1
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +5 -4
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +5 -4
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +7 -22
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +5 -39
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +5 -5
- diffusers/pipelines/deprecated/stochastic_karras_ve/pipeline_stochastic_karras_ve.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +31 -22
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_dual_guided.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_image_variation.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_text_to_image.py +1 -2
- diffusers/pipelines/deprecated/vq_diffusion/pipeline_vq_diffusion.py +1 -1
- diffusers/pipelines/dit/pipeline_dit.py +1 -1
- diffusers/pipelines/free_init_utils.py +184 -0
- diffusers/pipelines/i2vgen_xl/pipeline_i2vgen_xl.py +22 -104
- diffusers/pipelines/kandinsky/pipeline_kandinsky.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py +2 -2
- diffusers/pipelines/kandinsky/pipeline_kandinsky_prior.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpainting.py +2 -2
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +104 -93
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +112 -74
- diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +1 -1
- diffusers/pipelines/ledits_pp/__init__.py +55 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +1505 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +1797 -0
- diffusers/pipelines/ledits_pp/pipeline_output.py +43 -0
- diffusers/pipelines/musicldm/pipeline_musicldm.py +3 -19
- diffusers/pipelines/onnx_utils.py +1 -1
- diffusers/pipelines/paint_by_example/image_encoder.py +1 -1
- diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py +3 -3
- diffusers/pipelines/pia/pipeline_pia.py +168 -327
- diffusers/pipelines/pipeline_flax_utils.py +1 -1
- diffusers/pipelines/pipeline_loading_utils.py +508 -0
- diffusers/pipelines/pipeline_utils.py +188 -534
- diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +56 -10
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +3 -3
- diffusers/pipelines/shap_e/camera.py +1 -1
- diffusers/pipelines/shap_e/pipeline_shap_e.py +1 -1
- diffusers/pipelines/shap_e/pipeline_shap_e_img2img.py +1 -1
- diffusers/pipelines/shap_e/renderer.py +1 -1
- diffusers/pipelines/stable_cascade/__init__.py +50 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade.py +482 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_combined.py +311 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_prior.py +638 -0
- diffusers/pipelines/stable_diffusion/clip_image_project_model.py +1 -1
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +4 -1
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_img2img.py +2 -2
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_inpaint.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +90 -146
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +5 -4
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py +4 -32
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +92 -119
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +92 -119
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +13 -59
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py +3 -31
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +5 -33
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +5 -21
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +7 -21
- diffusers/pipelines/stable_diffusion/safety_checker.py +1 -1
- diffusers/pipelines/stable_diffusion/safety_checker_flax.py +1 -1
- diffusers/pipelines/stable_diffusion/stable_unclip_image_normalizer.py +1 -1
- diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +5 -21
- diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +9 -38
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +5 -34
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +6 -35
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +7 -6
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +4 -124
- diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +282 -80
- diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +94 -46
- diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py +3 -3
- diffusers/pipelines/stable_diffusion_safe/safety_checker.py +1 -1
- diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +6 -22
- diffusers/pipelines/stable_diffusion_xl/pipeline_flax_stable_diffusion_xl.py +1 -1
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +96 -148
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +98 -154
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +98 -153
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +25 -87
- diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +89 -80
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +5 -49
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +80 -88
- diffusers/pipelines/text_to_video_synthesis/pipeline_output.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +15 -86
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +20 -93
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +5 -5
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +3 -19
- diffusers/pipelines/unclip/pipeline_unclip.py +1 -1
- diffusers/pipelines/unclip/pipeline_unclip_image_variation.py +1 -1
- diffusers/pipelines/unclip/text_proj.py +1 -1
- diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +35 -35
- diffusers/pipelines/wuerstchen/modeling_paella_vq_model.py +1 -1
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py +4 -21
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_diffnext.py +2 -2
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +4 -5
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen.py +8 -8
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_combined.py +1 -1
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +2 -2
- diffusers/schedulers/__init__.py +7 -1
- diffusers/schedulers/deprecated/scheduling_karras_ve.py +1 -1
- diffusers/schedulers/deprecated/scheduling_sde_vp.py +1 -1
- diffusers/schedulers/scheduling_consistency_models.py +42 -19
- diffusers/schedulers/scheduling_ddim.py +2 -4
- diffusers/schedulers/scheduling_ddim_flax.py +13 -5
- diffusers/schedulers/scheduling_ddim_inverse.py +2 -4
- diffusers/schedulers/scheduling_ddim_parallel.py +2 -4
- diffusers/schedulers/scheduling_ddpm.py +2 -4
- diffusers/schedulers/scheduling_ddpm_flax.py +1 -1
- diffusers/schedulers/scheduling_ddpm_parallel.py +2 -4
- diffusers/schedulers/scheduling_ddpm_wuerstchen.py +1 -1
- diffusers/schedulers/scheduling_deis_multistep.py +46 -19
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +107 -21
- diffusers/schedulers/scheduling_dpmsolver_multistep_flax.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +9 -7
- diffusers/schedulers/scheduling_dpmsolver_sde.py +35 -35
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +49 -18
- diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +683 -0
- diffusers/schedulers/scheduling_edm_euler.py +381 -0
- diffusers/schedulers/scheduling_euler_ancestral_discrete.py +43 -15
- diffusers/schedulers/scheduling_euler_discrete.py +42 -17
- diffusers/schedulers/scheduling_euler_discrete_flax.py +1 -1
- diffusers/schedulers/scheduling_heun_discrete.py +35 -35
- diffusers/schedulers/scheduling_ipndm.py +37 -11
- diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +44 -44
- diffusers/schedulers/scheduling_k_dpm_2_discrete.py +44 -44
- diffusers/schedulers/scheduling_karras_ve_flax.py +1 -1
- diffusers/schedulers/scheduling_lcm.py +38 -14
- diffusers/schedulers/scheduling_lms_discrete.py +43 -15
- diffusers/schedulers/scheduling_lms_discrete_flax.py +1 -1
- diffusers/schedulers/scheduling_pndm.py +2 -4
- diffusers/schedulers/scheduling_pndm_flax.py +2 -4
- diffusers/schedulers/scheduling_repaint.py +1 -1
- diffusers/schedulers/scheduling_sasolver.py +41 -9
- diffusers/schedulers/scheduling_sde_ve.py +1 -1
- diffusers/schedulers/scheduling_sde_ve_flax.py +1 -1
- diffusers/schedulers/scheduling_tcd.py +686 -0
- diffusers/schedulers/scheduling_unclip.py +1 -1
- diffusers/schedulers/scheduling_unipc_multistep.py +46 -19
- diffusers/schedulers/scheduling_utils.py +2 -1
- diffusers/schedulers/scheduling_utils_flax.py +1 -1
- diffusers/schedulers/scheduling_vq_diffusion.py +1 -1
- diffusers/training_utils.py +9 -2
- diffusers/utils/__init__.py +2 -1
- diffusers/utils/accelerate_utils.py +1 -1
- diffusers/utils/constants.py +1 -1
- diffusers/utils/doc_utils.py +1 -1
- diffusers/utils/dummy_pt_objects.py +60 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +75 -0
- diffusers/utils/dynamic_modules_utils.py +1 -1
- diffusers/utils/export_utils.py +3 -3
- diffusers/utils/hub_utils.py +60 -16
- diffusers/utils/import_utils.py +15 -1
- diffusers/utils/loading_utils.py +2 -0
- diffusers/utils/logging.py +1 -1
- diffusers/utils/model_card_template.md +24 -0
- diffusers/utils/outputs.py +14 -7
- diffusers/utils/peft_utils.py +1 -1
- diffusers/utils/state_dict_utils.py +1 -1
- diffusers/utils/testing_utils.py +2 -0
- diffusers/utils/torch_utils.py +1 -1
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/METADATA +46 -46
- diffusers-0.27.0.dist-info/RECORD +399 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/WHEEL +1 -1
- diffusers-0.26.3.dist-info/RECORD +0 -384
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/LICENSE +0 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/entry_points.txt +0 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -147,7 +147,7 @@ class FlaxStableDiffusionImg2ImgPipeline(FlaxDiffusionPipeline):
|
|
147
147
|
self.dtype = dtype
|
148
148
|
|
149
149
|
if safety_checker is None:
|
150
|
-
logger.
|
150
|
+
logger.warning(
|
151
151
|
f"You have disabled the safety checker for {self.__class__} by passing `safety_checker=None`. Ensure"
|
152
152
|
" that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered"
|
153
153
|
" results in services or applications open to the public. Both the diffusers team and Hugging Face"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -23,7 +23,6 @@ from ...configuration_utils import FrozenDict
|
|
23
23
|
from ...image_processor import PipelineImageInput, VaeImageProcessor
|
24
24
|
from ...loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
|
25
25
|
from ...models import AutoencoderKL, ImageProjection, UNet2DConditionModel
|
26
|
-
from ...models.attention_processor import FusedAttnProcessor2_0
|
27
26
|
from ...models.lora import adjust_lora_scale_text_encoder
|
28
27
|
from ...schedulers import KarrasDiffusionSchedulers
|
29
28
|
from ...utils import (
|
@@ -35,7 +34,7 @@ from ...utils import (
|
|
35
34
|
unscale_lora_layers,
|
36
35
|
)
|
37
36
|
from ...utils.torch_utils import randn_tensor
|
38
|
-
from ..pipeline_utils import DiffusionPipeline
|
37
|
+
from ..pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
39
38
|
from .pipeline_output import StableDiffusionPipelineOutput
|
40
39
|
from .safety_checker import StableDiffusionSafetyChecker
|
41
40
|
|
@@ -116,7 +115,12 @@ def retrieve_timesteps(
|
|
116
115
|
|
117
116
|
|
118
117
|
class StableDiffusionPipeline(
|
119
|
-
DiffusionPipeline,
|
118
|
+
DiffusionPipeline,
|
119
|
+
StableDiffusionMixin,
|
120
|
+
TextualInversionLoaderMixin,
|
121
|
+
LoraLoaderMixin,
|
122
|
+
IPAdapterMixin,
|
123
|
+
FromSingleFileMixin,
|
120
124
|
):
|
121
125
|
r"""
|
122
126
|
Pipeline for text-to-image generation using Stable Diffusion.
|
@@ -248,35 +252,6 @@ class StableDiffusionPipeline(
|
|
248
252
|
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
|
249
253
|
self.register_to_config(requires_safety_checker=requires_safety_checker)
|
250
254
|
|
251
|
-
def enable_vae_slicing(self):
|
252
|
-
r"""
|
253
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
254
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
255
|
-
"""
|
256
|
-
self.vae.enable_slicing()
|
257
|
-
|
258
|
-
def disable_vae_slicing(self):
|
259
|
-
r"""
|
260
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
261
|
-
computing decoding in one step.
|
262
|
-
"""
|
263
|
-
self.vae.disable_slicing()
|
264
|
-
|
265
|
-
def enable_vae_tiling(self):
|
266
|
-
r"""
|
267
|
-
Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
|
268
|
-
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
|
269
|
-
processing larger images.
|
270
|
-
"""
|
271
|
-
self.vae.enable_tiling()
|
272
|
-
|
273
|
-
def disable_vae_tiling(self):
|
274
|
-
r"""
|
275
|
-
Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to
|
276
|
-
computing decoding in one step.
|
277
|
-
"""
|
278
|
-
self.vae.disable_tiling()
|
279
|
-
|
280
255
|
def _encode_prompt(
|
281
256
|
self,
|
282
257
|
prompt,
|
@@ -369,7 +344,7 @@ class StableDiffusionPipeline(
|
|
369
344
|
batch_size = prompt_embeds.shape[0]
|
370
345
|
|
371
346
|
if prompt_embeds is None:
|
372
|
-
# textual inversion:
|
347
|
+
# textual inversion: process multi-vector tokens if necessary
|
373
348
|
if isinstance(self, TextualInversionLoaderMixin):
|
374
349
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
375
350
|
|
@@ -451,7 +426,7 @@ class StableDiffusionPipeline(
|
|
451
426
|
else:
|
452
427
|
uncond_tokens = negative_prompt
|
453
428
|
|
454
|
-
# textual inversion:
|
429
|
+
# textual inversion: process multi-vector tokens if necessary
|
455
430
|
if isinstance(self, TextualInversionLoaderMixin):
|
456
431
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
457
432
|
|
@@ -514,31 +489,54 @@ class StableDiffusionPipeline(
|
|
514
489
|
|
515
490
|
return image_embeds, uncond_image_embeds
|
516
491
|
|
517
|
-
def prepare_ip_adapter_image_embeds(
|
518
|
-
|
519
|
-
|
492
|
+
def prepare_ip_adapter_image_embeds(
|
493
|
+
self, ip_adapter_image, ip_adapter_image_embeds, device, num_images_per_prompt, do_classifier_free_guidance
|
494
|
+
):
|
495
|
+
if ip_adapter_image_embeds is None:
|
496
|
+
if not isinstance(ip_adapter_image, list):
|
497
|
+
ip_adapter_image = [ip_adapter_image]
|
520
498
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
499
|
+
if len(ip_adapter_image) != len(self.unet.encoder_hid_proj.image_projection_layers):
|
500
|
+
raise ValueError(
|
501
|
+
f"`ip_adapter_image` must have same length as the number of IP Adapters. Got {len(ip_adapter_image)} images and {len(self.unet.encoder_hid_proj.image_projection_layers)} IP Adapters."
|
502
|
+
)
|
525
503
|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
504
|
+
image_embeds = []
|
505
|
+
for single_ip_adapter_image, image_proj_layer in zip(
|
506
|
+
ip_adapter_image, self.unet.encoder_hid_proj.image_projection_layers
|
507
|
+
):
|
508
|
+
output_hidden_state = not isinstance(image_proj_layer, ImageProjection)
|
509
|
+
single_image_embeds, single_negative_image_embeds = self.encode_image(
|
510
|
+
single_ip_adapter_image, device, 1, output_hidden_state
|
511
|
+
)
|
512
|
+
single_image_embeds = torch.stack([single_image_embeds] * num_images_per_prompt, dim=0)
|
513
|
+
single_negative_image_embeds = torch.stack(
|
514
|
+
[single_negative_image_embeds] * num_images_per_prompt, dim=0
|
515
|
+
)
|
536
516
|
|
537
|
-
|
538
|
-
|
539
|
-
|
517
|
+
if do_classifier_free_guidance:
|
518
|
+
single_image_embeds = torch.cat([single_negative_image_embeds, single_image_embeds])
|
519
|
+
single_image_embeds = single_image_embeds.to(device)
|
540
520
|
|
541
|
-
|
521
|
+
image_embeds.append(single_image_embeds)
|
522
|
+
else:
|
523
|
+
repeat_dims = [1]
|
524
|
+
image_embeds = []
|
525
|
+
for single_image_embeds in ip_adapter_image_embeds:
|
526
|
+
if do_classifier_free_guidance:
|
527
|
+
single_negative_image_embeds, single_image_embeds = single_image_embeds.chunk(2)
|
528
|
+
single_image_embeds = single_image_embeds.repeat(
|
529
|
+
num_images_per_prompt, *(repeat_dims * len(single_image_embeds.shape[1:]))
|
530
|
+
)
|
531
|
+
single_negative_image_embeds = single_negative_image_embeds.repeat(
|
532
|
+
num_images_per_prompt, *(repeat_dims * len(single_negative_image_embeds.shape[1:]))
|
533
|
+
)
|
534
|
+
single_image_embeds = torch.cat([single_negative_image_embeds, single_image_embeds])
|
535
|
+
else:
|
536
|
+
single_image_embeds = single_image_embeds.repeat(
|
537
|
+
num_images_per_prompt, *(repeat_dims * len(single_image_embeds.shape[1:]))
|
538
|
+
)
|
539
|
+
image_embeds.append(single_image_embeds)
|
542
540
|
|
543
541
|
return image_embeds
|
544
542
|
|
@@ -593,6 +591,8 @@ class StableDiffusionPipeline(
|
|
593
591
|
negative_prompt=None,
|
594
592
|
prompt_embeds=None,
|
595
593
|
negative_prompt_embeds=None,
|
594
|
+
ip_adapter_image=None,
|
595
|
+
ip_adapter_image_embeds=None,
|
596
596
|
callback_on_step_end_tensor_inputs=None,
|
597
597
|
):
|
598
598
|
if height % 8 != 0 or width % 8 != 0:
|
@@ -636,6 +636,21 @@ class StableDiffusionPipeline(
|
|
636
636
|
f" {negative_prompt_embeds.shape}."
|
637
637
|
)
|
638
638
|
|
639
|
+
if ip_adapter_image is not None and ip_adapter_image_embeds is not None:
|
640
|
+
raise ValueError(
|
641
|
+
"Provide either `ip_adapter_image` or `ip_adapter_image_embeds`. Cannot leave both `ip_adapter_image` and `ip_adapter_image_embeds` defined."
|
642
|
+
)
|
643
|
+
|
644
|
+
if ip_adapter_image_embeds is not None:
|
645
|
+
if not isinstance(ip_adapter_image_embeds, list):
|
646
|
+
raise ValueError(
|
647
|
+
f"`ip_adapter_image_embeds` has to be of type `list` but is {type(ip_adapter_image_embeds)}"
|
648
|
+
)
|
649
|
+
elif ip_adapter_image_embeds[0].ndim not in [3, 4]:
|
650
|
+
raise ValueError(
|
651
|
+
f"`ip_adapter_image_embeds` has to be a list of 3D or 4D tensors but is {ip_adapter_image_embeds[0].ndim}D"
|
652
|
+
)
|
653
|
+
|
639
654
|
def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype, device, generator, latents=None):
|
640
655
|
shape = (batch_size, num_channels_latents, height // self.vae_scale_factor, width // self.vae_scale_factor)
|
641
656
|
if isinstance(generator, list) and len(generator) != batch_size:
|
@@ -653,93 +668,6 @@ class StableDiffusionPipeline(
|
|
653
668
|
latents = latents * self.scheduler.init_noise_sigma
|
654
669
|
return latents
|
655
670
|
|
656
|
-
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
|
657
|
-
r"""Enables the FreeU mechanism as in https://arxiv.org/abs/2309.11497.
|
658
|
-
|
659
|
-
The suffixes after the scaling factors represent the stages where they are being applied.
|
660
|
-
|
661
|
-
Please refer to the [official repository](https://github.com/ChenyangSi/FreeU) for combinations of the values
|
662
|
-
that are known to work well for different pipelines such as Stable Diffusion v1, v2, and Stable Diffusion XL.
|
663
|
-
|
664
|
-
Args:
|
665
|
-
s1 (`float`):
|
666
|
-
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
|
667
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
668
|
-
s2 (`float`):
|
669
|
-
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
|
670
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
671
|
-
b1 (`float`): Scaling factor for stage 1 to amplify the contributions of backbone features.
|
672
|
-
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
|
673
|
-
"""
|
674
|
-
if not hasattr(self, "unet"):
|
675
|
-
raise ValueError("The pipeline must have `unet` for using FreeU.")
|
676
|
-
self.unet.enable_freeu(s1=s1, s2=s2, b1=b1, b2=b2)
|
677
|
-
|
678
|
-
def disable_freeu(self):
|
679
|
-
"""Disables the FreeU mechanism if enabled."""
|
680
|
-
self.unet.disable_freeu()
|
681
|
-
|
682
|
-
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.StableDiffusionXLPipeline.fuse_qkv_projections
|
683
|
-
def fuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
684
|
-
"""
|
685
|
-
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query,
|
686
|
-
key, value) are fused. For cross-attention modules, key and value projection matrices are fused.
|
687
|
-
|
688
|
-
<Tip warning={true}>
|
689
|
-
|
690
|
-
This API is 🧪 experimental.
|
691
|
-
|
692
|
-
</Tip>
|
693
|
-
|
694
|
-
Args:
|
695
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
696
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
697
|
-
"""
|
698
|
-
self.fusing_unet = False
|
699
|
-
self.fusing_vae = False
|
700
|
-
|
701
|
-
if unet:
|
702
|
-
self.fusing_unet = True
|
703
|
-
self.unet.fuse_qkv_projections()
|
704
|
-
self.unet.set_attn_processor(FusedAttnProcessor2_0())
|
705
|
-
|
706
|
-
if vae:
|
707
|
-
if not isinstance(self.vae, AutoencoderKL):
|
708
|
-
raise ValueError("`fuse_qkv_projections()` is only supported for the VAE of type `AutoencoderKL`.")
|
709
|
-
|
710
|
-
self.fusing_vae = True
|
711
|
-
self.vae.fuse_qkv_projections()
|
712
|
-
self.vae.set_attn_processor(FusedAttnProcessor2_0())
|
713
|
-
|
714
|
-
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.StableDiffusionXLPipeline.unfuse_qkv_projections
|
715
|
-
def unfuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
716
|
-
"""Disable QKV projection fusion if enabled.
|
717
|
-
|
718
|
-
<Tip warning={true}>
|
719
|
-
|
720
|
-
This API is 🧪 experimental.
|
721
|
-
|
722
|
-
</Tip>
|
723
|
-
|
724
|
-
Args:
|
725
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
726
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
727
|
-
|
728
|
-
"""
|
729
|
-
if unet:
|
730
|
-
if not self.fusing_unet:
|
731
|
-
logger.warning("The UNet was not initially fused for QKV projections. Doing nothing.")
|
732
|
-
else:
|
733
|
-
self.unet.unfuse_qkv_projections()
|
734
|
-
self.fusing_unet = False
|
735
|
-
|
736
|
-
if vae:
|
737
|
-
if not self.fusing_vae:
|
738
|
-
logger.warning("The VAE was not initially fused for QKV projections. Doing nothing.")
|
739
|
-
else:
|
740
|
-
self.vae.unfuse_qkv_projections()
|
741
|
-
self.fusing_vae = False
|
742
|
-
|
743
671
|
# Copied from diffusers.pipelines.latent_consistency_models.pipeline_latent_consistency_text2img.LatentConsistencyModelPipeline.get_guidance_scale_embedding
|
744
672
|
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
745
673
|
"""
|
@@ -818,6 +746,7 @@ class StableDiffusionPipeline(
|
|
818
746
|
prompt_embeds: Optional[torch.FloatTensor] = None,
|
819
747
|
negative_prompt_embeds: Optional[torch.FloatTensor] = None,
|
820
748
|
ip_adapter_image: Optional[PipelineImageInput] = None,
|
749
|
+
ip_adapter_image_embeds: Optional[List[torch.FloatTensor]] = None,
|
821
750
|
output_type: Optional[str] = "pil",
|
822
751
|
return_dict: bool = True,
|
823
752
|
cross_attention_kwargs: Optional[Dict[str, Any]] = None,
|
@@ -869,6 +798,11 @@ class StableDiffusionPipeline(
|
|
869
798
|
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
|
870
799
|
not provided, `negative_prompt_embeds` are generated from the `negative_prompt` input argument.
|
871
800
|
ip_adapter_image: (`PipelineImageInput`, *optional*): Optional image input to work with IP Adapters.
|
801
|
+
ip_adapter_image_embeds (`List[torch.FloatTensor]`, *optional*):
|
802
|
+
Pre-generated image embeddings for IP-Adapter. It should be a list of length same as number of IP-adapters.
|
803
|
+
Each element should be a tensor of shape `(batch_size, num_images, emb_dim)`. It should contain the negative image embedding
|
804
|
+
if `do_classifier_free_guidance` is set to `True`.
|
805
|
+
If not provided, embeddings are computed from the `ip_adapter_image` input argument.
|
872
806
|
output_type (`str`, *optional*, defaults to `"pil"`):
|
873
807
|
The output format of the generated image. Choose between `PIL.Image` or `np.array`.
|
874
808
|
return_dict (`bool`, *optional*, defaults to `True`):
|
@@ -934,6 +868,8 @@ class StableDiffusionPipeline(
|
|
934
868
|
negative_prompt,
|
935
869
|
prompt_embeds,
|
936
870
|
negative_prompt_embeds,
|
871
|
+
ip_adapter_image,
|
872
|
+
ip_adapter_image_embeds,
|
937
873
|
callback_on_step_end_tensor_inputs,
|
938
874
|
)
|
939
875
|
|
@@ -976,9 +912,13 @@ class StableDiffusionPipeline(
|
|
976
912
|
if self.do_classifier_free_guidance:
|
977
913
|
prompt_embeds = torch.cat([negative_prompt_embeds, prompt_embeds])
|
978
914
|
|
979
|
-
if ip_adapter_image is not None:
|
915
|
+
if ip_adapter_image is not None or ip_adapter_image_embeds is not None:
|
980
916
|
image_embeds = self.prepare_ip_adapter_image_embeds(
|
981
|
-
ip_adapter_image,
|
917
|
+
ip_adapter_image,
|
918
|
+
ip_adapter_image_embeds,
|
919
|
+
device,
|
920
|
+
batch_size * num_images_per_prompt,
|
921
|
+
self.do_classifier_free_guidance,
|
982
922
|
)
|
983
923
|
|
984
924
|
# 4. Prepare timesteps
|
@@ -1001,7 +941,11 @@ class StableDiffusionPipeline(
|
|
1001
941
|
extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta)
|
1002
942
|
|
1003
943
|
# 6.1 Add image embeds for IP-Adapter
|
1004
|
-
added_cond_kwargs =
|
944
|
+
added_cond_kwargs = (
|
945
|
+
{"image_embeds": image_embeds}
|
946
|
+
if (ip_adapter_image is not None or ip_adapter_image_embeds is not None)
|
947
|
+
else None
|
948
|
+
)
|
1005
949
|
|
1006
950
|
# 6.2 Optionally get Guidance Scale Embedding
|
1007
951
|
timestep_cond = None
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -242,7 +242,7 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader
|
|
242
242
|
batch_size = prompt_embeds.shape[0]
|
243
243
|
|
244
244
|
if prompt_embeds is None:
|
245
|
-
# textual inversion:
|
245
|
+
# textual inversion: process multi-vector tokens if necessary
|
246
246
|
if isinstance(self, TextualInversionLoaderMixin):
|
247
247
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
248
248
|
|
@@ -324,7 +324,7 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader
|
|
324
324
|
else:
|
325
325
|
uncond_tokens = negative_prompt
|
326
326
|
|
327
|
-
# textual inversion:
|
327
|
+
# textual inversion: process multi-vector tokens if necessary
|
328
328
|
if isinstance(self, TextualInversionLoaderMixin):
|
329
329
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
330
330
|
|
@@ -408,7 +408,6 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader
|
|
408
408
|
extra_step_kwargs["generator"] = generator
|
409
409
|
return extra_step_kwargs
|
410
410
|
|
411
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusionImg2ImgPipeline.check_inputs
|
412
411
|
def check_inputs(
|
413
412
|
self,
|
414
413
|
prompt,
|
@@ -467,6 +466,8 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader
|
|
467
466
|
|
468
467
|
t_start = max(num_inference_steps - init_timestep, 0)
|
469
468
|
timesteps = self.scheduler.timesteps[t_start * self.scheduler.order :]
|
469
|
+
if hasattr(self.scheduler, "set_begin_index"):
|
470
|
+
self.scheduler.set_begin_index(t_start * self.scheduler.order)
|
470
471
|
|
471
472
|
return timesteps, num_inference_steps - t_start
|
472
473
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -26,7 +26,7 @@ from ...models import AutoencoderKL, UNet2DConditionModel
|
|
26
26
|
from ...schedulers import KarrasDiffusionSchedulers
|
27
27
|
from ...utils import deprecate, logging
|
28
28
|
from ...utils.torch_utils import randn_tensor
|
29
|
-
from ..pipeline_utils import DiffusionPipeline
|
29
|
+
from ..pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
30
30
|
from . import StableDiffusionPipelineOutput
|
31
31
|
from .safety_checker import StableDiffusionSafetyChecker
|
32
32
|
|
@@ -34,7 +34,7 @@ from .safety_checker import StableDiffusionSafetyChecker
|
|
34
34
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
35
35
|
|
36
36
|
|
37
|
-
class StableDiffusionImageVariationPipeline(DiffusionPipeline):
|
37
|
+
class StableDiffusionImageVariationPipeline(DiffusionPipeline, StableDiffusionMixin):
|
38
38
|
r"""
|
39
39
|
Pipeline to generate image variations from an input image using Stable Diffusion.
|
40
40
|
|
@@ -82,7 +82,7 @@ class StableDiffusionImageVariationPipeline(DiffusionPipeline):
|
|
82
82
|
super().__init__()
|
83
83
|
|
84
84
|
if safety_checker is None and requires_safety_checker:
|
85
|
-
logger.
|
85
|
+
logger.warning(
|
86
86
|
f"You have disabled the safety checker for {self.__class__} by passing `safety_checker=None`. Ensure"
|
87
87
|
" that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered"
|
88
88
|
" results in services or applications open to the public. Both the diffusers team and Hugging Face"
|
@@ -240,34 +240,6 @@ class StableDiffusionImageVariationPipeline(DiffusionPipeline):
|
|
240
240
|
latents = latents * self.scheduler.init_noise_sigma
|
241
241
|
return latents
|
242
242
|
|
243
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_freeu
|
244
|
-
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
|
245
|
-
r"""Enables the FreeU mechanism as in https://arxiv.org/abs/2309.11497.
|
246
|
-
|
247
|
-
The suffixes after the scaling factors represent the stages where they are being applied.
|
248
|
-
|
249
|
-
Please refer to the [official repository](https://github.com/ChenyangSi/FreeU) for combinations of the values
|
250
|
-
that are known to work well for different pipelines such as Stable Diffusion v1, v2, and Stable Diffusion XL.
|
251
|
-
|
252
|
-
Args:
|
253
|
-
s1 (`float`):
|
254
|
-
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
|
255
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
256
|
-
s2 (`float`):
|
257
|
-
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
|
258
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
259
|
-
b1 (`float`): Scaling factor for stage 1 to amplify the contributions of backbone features.
|
260
|
-
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
|
261
|
-
"""
|
262
|
-
if not hasattr(self, "unet"):
|
263
|
-
raise ValueError("The pipeline must have `unet` for using FreeU.")
|
264
|
-
self.unet.enable_freeu(s1=s1, s2=s2, b1=b1, b2=b2)
|
265
|
-
|
266
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_freeu
|
267
|
-
def disable_freeu(self):
|
268
|
-
"""Disables the FreeU mechanism if enabled."""
|
269
|
-
self.unet.disable_freeu()
|
270
|
-
|
271
243
|
@torch.no_grad()
|
272
244
|
def __call__(
|
273
245
|
self,
|