diffusers 0.23.1__py3-none-any.whl → 0.25.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 +26 -2
- diffusers/commands/fp16_safetensors.py +10 -11
- diffusers/configuration_utils.py +13 -8
- diffusers/dependency_versions_check.py +0 -1
- diffusers/dependency_versions_table.py +5 -5
- diffusers/experimental/rl/value_guided_sampling.py +1 -1
- diffusers/image_processor.py +463 -51
- diffusers/loaders/__init__.py +82 -0
- diffusers/loaders/ip_adapter.py +159 -0
- diffusers/loaders/lora.py +1553 -0
- diffusers/loaders/lora_conversion_utils.py +284 -0
- diffusers/loaders/single_file.py +637 -0
- diffusers/loaders/textual_inversion.py +455 -0
- diffusers/loaders/unet.py +828 -0
- diffusers/loaders/utils.py +59 -0
- diffusers/models/__init__.py +26 -9
- diffusers/models/activations.py +9 -6
- diffusers/models/attention.py +301 -29
- diffusers/models/attention_flax.py +9 -1
- diffusers/models/attention_processor.py +378 -6
- diffusers/models/autoencoders/__init__.py +5 -0
- diffusers/models/{autoencoder_asym_kl.py → autoencoders/autoencoder_asym_kl.py} +17 -12
- diffusers/models/{autoencoder_kl.py → autoencoders/autoencoder_kl.py} +47 -23
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +402 -0
- diffusers/models/{autoencoder_tiny.py → autoencoders/autoencoder_tiny.py} +24 -28
- diffusers/models/{consistency_decoder_vae.py → autoencoders/consistency_decoder_vae.py} +51 -44
- diffusers/models/{vae.py → autoencoders/vae.py} +71 -17
- diffusers/models/controlnet.py +59 -39
- diffusers/models/controlnet_flax.py +19 -18
- diffusers/models/downsampling.py +338 -0
- diffusers/models/embeddings.py +112 -29
- diffusers/models/embeddings_flax.py +2 -0
- diffusers/models/lora.py +131 -1
- diffusers/models/modeling_flax_utils.py +14 -8
- diffusers/models/modeling_outputs.py +17 -0
- diffusers/models/modeling_utils.py +37 -29
- diffusers/models/normalization.py +110 -4
- diffusers/models/resnet.py +299 -652
- diffusers/models/transformer_2d.py +22 -5
- diffusers/models/transformer_temporal.py +183 -1
- diffusers/models/unet_2d_blocks_flax.py +5 -0
- diffusers/models/unet_2d_condition.py +46 -0
- diffusers/models/unet_2d_condition_flax.py +13 -13
- diffusers/models/unet_3d_blocks.py +957 -173
- diffusers/models/unet_3d_condition.py +16 -8
- diffusers/models/unet_kandinsky3.py +535 -0
- diffusers/models/unet_motion_model.py +48 -33
- diffusers/models/unet_spatio_temporal_condition.py +489 -0
- diffusers/models/upsampling.py +454 -0
- diffusers/models/uvit_2d.py +471 -0
- diffusers/models/vae_flax.py +7 -0
- diffusers/models/vq_model.py +12 -3
- diffusers/optimization.py +16 -9
- diffusers/pipelines/__init__.py +137 -76
- diffusers/pipelines/amused/__init__.py +62 -0
- diffusers/pipelines/amused/pipeline_amused.py +328 -0
- diffusers/pipelines/amused/pipeline_amused_img2img.py +347 -0
- diffusers/pipelines/amused/pipeline_amused_inpaint.py +378 -0
- diffusers/pipelines/animatediff/pipeline_animatediff.py +66 -8
- diffusers/pipelines/audioldm/pipeline_audioldm.py +1 -0
- diffusers/pipelines/auto_pipeline.py +23 -13
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -0
- diffusers/pipelines/controlnet/pipeline_controlnet.py +238 -35
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +148 -37
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +155 -41
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +123 -43
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +216 -39
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +106 -34
- diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py +1 -0
- diffusers/pipelines/ddim/pipeline_ddim.py +1 -0
- diffusers/pipelines/ddpm/pipeline_ddpm.py +1 -0
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +13 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +13 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +13 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +13 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +13 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +13 -1
- diffusers/pipelines/deprecated/__init__.py +153 -0
- diffusers/pipelines/{alt_diffusion → deprecated/alt_diffusion}/__init__.py +3 -3
- diffusers/pipelines/{alt_diffusion → deprecated/alt_diffusion}/pipeline_alt_diffusion.py +177 -34
- diffusers/pipelines/{alt_diffusion → deprecated/alt_diffusion}/pipeline_alt_diffusion_img2img.py +182 -37
- diffusers/pipelines/{alt_diffusion → deprecated/alt_diffusion}/pipeline_output.py +1 -1
- diffusers/pipelines/{audio_diffusion → deprecated/audio_diffusion}/__init__.py +1 -1
- diffusers/pipelines/{audio_diffusion → deprecated/audio_diffusion}/mel.py +2 -2
- diffusers/pipelines/{audio_diffusion → deprecated/audio_diffusion}/pipeline_audio_diffusion.py +4 -4
- diffusers/pipelines/{latent_diffusion_uncond → deprecated/latent_diffusion_uncond}/__init__.py +1 -1
- diffusers/pipelines/{latent_diffusion_uncond → deprecated/latent_diffusion_uncond}/pipeline_latent_diffusion_uncond.py +4 -4
- diffusers/pipelines/{pndm → deprecated/pndm}/__init__.py +1 -1
- diffusers/pipelines/{pndm → deprecated/pndm}/pipeline_pndm.py +4 -4
- diffusers/pipelines/{repaint → deprecated/repaint}/__init__.py +1 -1
- diffusers/pipelines/{repaint → deprecated/repaint}/pipeline_repaint.py +5 -5
- diffusers/pipelines/{score_sde_ve → deprecated/score_sde_ve}/__init__.py +1 -1
- diffusers/pipelines/{score_sde_ve → deprecated/score_sde_ve}/pipeline_score_sde_ve.py +5 -4
- diffusers/pipelines/{spectrogram_diffusion → deprecated/spectrogram_diffusion}/__init__.py +6 -6
- diffusers/pipelines/{spectrogram_diffusion/continous_encoder.py → deprecated/spectrogram_diffusion/continuous_encoder.py} +2 -2
- diffusers/pipelines/{spectrogram_diffusion → deprecated/spectrogram_diffusion}/midi_utils.py +1 -1
- diffusers/pipelines/{spectrogram_diffusion → deprecated/spectrogram_diffusion}/notes_encoder.py +2 -2
- diffusers/pipelines/{spectrogram_diffusion → deprecated/spectrogram_diffusion}/pipeline_spectrogram_diffusion.py +8 -7
- diffusers/pipelines/deprecated/stable_diffusion_variants/__init__.py +55 -0
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_cycle_diffusion.py +34 -13
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_onnx_stable_diffusion_inpaint_legacy.py +7 -6
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_stable_diffusion_inpaint_legacy.py +12 -11
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_stable_diffusion_model_editing.py +17 -11
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_stable_diffusion_paradigms.py +11 -10
- diffusers/pipelines/{stable_diffusion → deprecated/stable_diffusion_variants}/pipeline_stable_diffusion_pix2pix_zero.py +14 -13
- diffusers/pipelines/{stochastic_karras_ve → deprecated/stochastic_karras_ve}/__init__.py +1 -1
- diffusers/pipelines/{stochastic_karras_ve → deprecated/stochastic_karras_ve}/pipeline_stochastic_karras_ve.py +4 -4
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/__init__.py +3 -3
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/modeling_text_unet.py +83 -51
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/pipeline_versatile_diffusion.py +4 -4
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/pipeline_versatile_diffusion_dual_guided.py +7 -6
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/pipeline_versatile_diffusion_image_variation.py +7 -6
- diffusers/pipelines/{versatile_diffusion → deprecated/versatile_diffusion}/pipeline_versatile_diffusion_text_to_image.py +7 -6
- diffusers/pipelines/{vq_diffusion → deprecated/vq_diffusion}/__init__.py +3 -3
- diffusers/pipelines/{vq_diffusion → deprecated/vq_diffusion}/pipeline_vq_diffusion.py +5 -5
- diffusers/pipelines/dit/pipeline_dit.py +1 -0
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +3 -3
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpainting.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior.py +1 -1
- diffusers/pipelines/kandinsky3/__init__.py +49 -0
- diffusers/pipelines/kandinsky3/convert_kandinsky3_unet.py +98 -0
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +589 -0
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +654 -0
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +111 -11
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +102 -9
- diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +1 -0
- diffusers/pipelines/musicldm/pipeline_musicldm.py +1 -1
- diffusers/pipelines/onnx_utils.py +8 -5
- diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py +7 -2
- diffusers/pipelines/pipeline_flax_utils.py +11 -8
- diffusers/pipelines/pipeline_utils.py +63 -42
- diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +247 -38
- diffusers/pipelines/shap_e/pipeline_shap_e_img2img.py +3 -3
- diffusers/pipelines/stable_diffusion/__init__.py +37 -65
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +75 -78
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +2 -2
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py +2 -4
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py +1 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +174 -11
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +8 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py +1 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +178 -11
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +224 -13
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +74 -20
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py +4 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +7 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +5 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +5 -0
- diffusers/pipelines/stable_diffusion_attend_and_excite/__init__.py +48 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_attend_and_excite}/pipeline_stable_diffusion_attend_and_excite.py +6 -2
- diffusers/pipelines/stable_diffusion_diffedit/__init__.py +48 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_diffedit}/pipeline_stable_diffusion_diffedit.py +3 -3
- diffusers/pipelines/stable_diffusion_gligen/__init__.py +50 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_gligen}/pipeline_stable_diffusion_gligen.py +3 -2
- diffusers/pipelines/{stable_diffusion → stable_diffusion_gligen}/pipeline_stable_diffusion_gligen_text_image.py +4 -3
- diffusers/pipelines/stable_diffusion_k_diffusion/__init__.py +60 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_k_diffusion}/pipeline_stable_diffusion_k_diffusion.py +7 -1
- diffusers/pipelines/stable_diffusion_ldm3d/__init__.py +48 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_ldm3d}/pipeline_stable_diffusion_ldm3d.py +51 -7
- diffusers/pipelines/stable_diffusion_panorama/__init__.py +48 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_panorama}/pipeline_stable_diffusion_panorama.py +57 -8
- diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py +58 -6
- diffusers/pipelines/stable_diffusion_sag/__init__.py +48 -0
- diffusers/pipelines/{stable_diffusion → stable_diffusion_sag}/pipeline_stable_diffusion_sag.py +68 -10
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +194 -17
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +205 -16
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +206 -17
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +23 -17
- diffusers/pipelines/stable_video_diffusion/__init__.py +58 -0
- diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +652 -0
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +108 -12
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +115 -14
- diffusers/pipelines/text_to_video_synthesis/__init__.py +2 -0
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +6 -0
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +23 -3
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +334 -10
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +1331 -0
- diffusers/pipelines/unclip/pipeline_unclip.py +2 -1
- diffusers/pipelines/unclip/pipeline_unclip_image_variation.py +1 -0
- diffusers/pipelines/wuerstchen/modeling_paella_vq_model.py +1 -1
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py +14 -4
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +9 -5
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen.py +1 -1
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_combined.py +2 -2
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +5 -1
- diffusers/schedulers/__init__.py +4 -4
- diffusers/schedulers/deprecated/__init__.py +50 -0
- diffusers/schedulers/{scheduling_karras_ve.py → deprecated/scheduling_karras_ve.py} +4 -4
- diffusers/schedulers/{scheduling_sde_vp.py → deprecated/scheduling_sde_vp.py} +4 -6
- diffusers/schedulers/scheduling_amused.py +162 -0
- diffusers/schedulers/scheduling_consistency_models.py +2 -0
- diffusers/schedulers/scheduling_ddim.py +1 -3
- diffusers/schedulers/scheduling_ddim_inverse.py +2 -7
- diffusers/schedulers/scheduling_ddim_parallel.py +1 -3
- diffusers/schedulers/scheduling_ddpm.py +47 -3
- diffusers/schedulers/scheduling_ddpm_parallel.py +47 -3
- diffusers/schedulers/scheduling_deis_multistep.py +28 -6
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +28 -6
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +28 -6
- diffusers/schedulers/scheduling_dpmsolver_sde.py +3 -3
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +28 -6
- diffusers/schedulers/scheduling_euler_ancestral_discrete.py +59 -3
- diffusers/schedulers/scheduling_euler_discrete.py +102 -16
- diffusers/schedulers/scheduling_heun_discrete.py +17 -5
- diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +17 -5
- diffusers/schedulers/scheduling_k_dpm_2_discrete.py +17 -5
- diffusers/schedulers/scheduling_lcm.py +123 -29
- diffusers/schedulers/scheduling_lms_discrete.py +3 -3
- diffusers/schedulers/scheduling_pndm.py +1 -3
- diffusers/schedulers/scheduling_repaint.py +1 -3
- diffusers/schedulers/scheduling_unipc_multistep.py +28 -6
- diffusers/schedulers/scheduling_utils.py +3 -1
- diffusers/schedulers/scheduling_utils_flax.py +3 -1
- diffusers/training_utils.py +1 -1
- diffusers/utils/__init__.py +1 -2
- diffusers/utils/constants.py +10 -12
- diffusers/utils/dummy_pt_objects.py +75 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +105 -0
- diffusers/utils/dynamic_modules_utils.py +18 -22
- diffusers/utils/export_utils.py +8 -3
- diffusers/utils/hub_utils.py +24 -36
- diffusers/utils/logging.py +11 -11
- diffusers/utils/outputs.py +5 -5
- diffusers/utils/peft_utils.py +88 -44
- diffusers/utils/state_dict_utils.py +8 -0
- diffusers/utils/testing_utils.py +199 -1
- diffusers/utils/torch_utils.py +4 -4
- {diffusers-0.23.1.dist-info → diffusers-0.25.0.dist-info}/METADATA +86 -69
- diffusers-0.25.0.dist-info/RECORD +360 -0
- {diffusers-0.23.1.dist-info → diffusers-0.25.0.dist-info}/WHEEL +1 -1
- {diffusers-0.23.1.dist-info → diffusers-0.25.0.dist-info}/entry_points.txt +0 -1
- diffusers/loaders.py +0 -3336
- diffusers-0.23.1.dist-info/RECORD +0 -323
- /diffusers/pipelines/{alt_diffusion → deprecated/alt_diffusion}/modeling_roberta_series.py +0 -0
- {diffusers-0.23.1.dist-info → diffusers-0.25.0.dist-info}/LICENSE +0 -0
- {diffusers-0.23.1.dist-info → diffusers-0.25.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
3
|
+
from ....utils import (
|
4
|
+
DIFFUSERS_SLOW_IMPORT,
|
5
|
+
OptionalDependencyNotAvailable,
|
6
|
+
_LazyModule,
|
7
|
+
get_objects_from_module,
|
8
|
+
is_torch_available,
|
9
|
+
is_transformers_available,
|
10
|
+
)
|
11
|
+
|
12
|
+
|
13
|
+
_dummy_objects = {}
|
14
|
+
_import_structure = {}
|
15
|
+
|
16
|
+
try:
|
17
|
+
if not (is_transformers_available() and is_torch_available()):
|
18
|
+
raise OptionalDependencyNotAvailable()
|
19
|
+
except OptionalDependencyNotAvailable:
|
20
|
+
from ....utils import dummy_torch_and_transformers_objects
|
21
|
+
|
22
|
+
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
|
23
|
+
else:
|
24
|
+
_import_structure["pipeline_cycle_diffusion"] = ["CycleDiffusionPipeline"]
|
25
|
+
_import_structure["pipeline_stable_diffusion_inpaint_legacy"] = ["StableDiffusionInpaintPipelineLegacy"]
|
26
|
+
_import_structure["pipeline_stable_diffusion_model_editing"] = ["StableDiffusionModelEditingPipeline"]
|
27
|
+
|
28
|
+
_import_structure["pipeline_stable_diffusion_paradigms"] = ["StableDiffusionParadigmsPipeline"]
|
29
|
+
_import_structure["pipeline_stable_diffusion_pix2pix_zero"] = ["StableDiffusionPix2PixZeroPipeline"]
|
30
|
+
|
31
|
+
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
|
32
|
+
try:
|
33
|
+
if not (is_transformers_available() and is_torch_available()):
|
34
|
+
raise OptionalDependencyNotAvailable()
|
35
|
+
except OptionalDependencyNotAvailable:
|
36
|
+
from ....utils.dummy_torch_and_transformers_objects import *
|
37
|
+
|
38
|
+
else:
|
39
|
+
from .pipeline_cycle_diffusion import CycleDiffusionPipeline
|
40
|
+
from .pipeline_stable_diffusion_inpaint_legacy import StableDiffusionInpaintPipelineLegacy
|
41
|
+
from .pipeline_stable_diffusion_model_editing import StableDiffusionModelEditingPipeline
|
42
|
+
from .pipeline_stable_diffusion_paradigms import StableDiffusionParadigmsPipeline
|
43
|
+
from .pipeline_stable_diffusion_pix2pix_zero import StableDiffusionPix2PixZeroPipeline
|
44
|
+
|
45
|
+
else:
|
46
|
+
import sys
|
47
|
+
|
48
|
+
sys.modules[__name__] = _LazyModule(
|
49
|
+
__name__,
|
50
|
+
globals()["__file__"],
|
51
|
+
_import_structure,
|
52
|
+
module_spec=__spec__,
|
53
|
+
)
|
54
|
+
for name, value in _dummy_objects.items():
|
55
|
+
setattr(sys.modules[__name__], name, value)
|
@@ -21,17 +21,17 @@ import torch
|
|
21
21
|
from packaging import version
|
22
22
|
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
|
23
23
|
|
24
|
-
from
|
25
|
-
from
|
26
|
-
from
|
27
|
-
from
|
28
|
-
from
|
29
|
-
from
|
30
|
-
from
|
31
|
-
from
|
32
|
-
from
|
33
|
-
from .pipeline_output import StableDiffusionPipelineOutput
|
34
|
-
from .safety_checker import StableDiffusionSafetyChecker
|
24
|
+
from ....configuration_utils import FrozenDict
|
25
|
+
from ....image_processor import PipelineImageInput, VaeImageProcessor
|
26
|
+
from ....loaders import LoraLoaderMixin, TextualInversionLoaderMixin
|
27
|
+
from ....models import AutoencoderKL, UNet2DConditionModel
|
28
|
+
from ....models.lora import adjust_lora_scale_text_encoder
|
29
|
+
from ....schedulers import DDIMScheduler
|
30
|
+
from ....utils import PIL_INTERPOLATION, USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
|
31
|
+
from ....utils.torch_utils import randn_tensor
|
32
|
+
from ...pipeline_utils import DiffusionPipeline
|
33
|
+
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
34
|
+
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
35
35
|
|
36
36
|
|
37
37
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
@@ -61,6 +61,20 @@ def preprocess(image):
|
|
61
61
|
return image
|
62
62
|
|
63
63
|
|
64
|
+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.retrieve_latents
|
65
|
+
def retrieve_latents(
|
66
|
+
encoder_output: torch.Tensor, generator: Optional[torch.Generator] = None, sample_mode: str = "sample"
|
67
|
+
):
|
68
|
+
if hasattr(encoder_output, "latent_dist") and sample_mode == "sample":
|
69
|
+
return encoder_output.latent_dist.sample(generator)
|
70
|
+
elif hasattr(encoder_output, "latent_dist") and sample_mode == "argmax":
|
71
|
+
return encoder_output.latent_dist.mode()
|
72
|
+
elif hasattr(encoder_output, "latents"):
|
73
|
+
return encoder_output.latents
|
74
|
+
else:
|
75
|
+
raise AttributeError("Could not access latents of provided encoder_output")
|
76
|
+
|
77
|
+
|
64
78
|
def posterior_sample(scheduler, latents, timestep, clean_latents, generator, eta):
|
65
79
|
# 1. get previous step value (=t-1)
|
66
80
|
prev_timestep = timestep - scheduler.config.num_train_timesteps // scheduler.num_inference_steps
|
@@ -129,6 +143,11 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
129
143
|
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
|
130
144
|
implemented for all pipelines (downloading, saving, running on a particular device, etc.).
|
131
145
|
|
146
|
+
The pipeline also inherits the following loading methods:
|
147
|
+
- [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
|
148
|
+
- [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
|
149
|
+
- [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
|
150
|
+
|
132
151
|
Args:
|
133
152
|
vae ([`AutoencoderKL`]):
|
134
153
|
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
|
@@ -148,6 +167,7 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
148
167
|
feature_extractor ([`~transformers.CLIPImageProcessor`]):
|
149
168
|
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
|
150
169
|
"""
|
170
|
+
|
151
171
|
model_cpu_offload_seq = "text_encoder->unet->vae"
|
152
172
|
_optional_components = ["safety_checker", "feature_extractor"]
|
153
173
|
|
@@ -566,11 +586,12 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
566
586
|
|
567
587
|
if isinstance(generator, list):
|
568
588
|
init_latents = [
|
569
|
-
self.vae.encode(image[i : i + 1])
|
589
|
+
retrieve_latents(self.vae.encode(image[i : i + 1]), generator=generator[i])
|
590
|
+
for i in range(image.shape[0])
|
570
591
|
]
|
571
592
|
init_latents = torch.cat(init_latents, dim=0)
|
572
593
|
else:
|
573
|
-
init_latents = self.vae.encode(image)
|
594
|
+
init_latents = retrieve_latents(self.vae.encode(image), generator=generator)
|
574
595
|
|
575
596
|
init_latents = self.vae.config.scaling_factor * init_latents
|
576
597
|
|
@@ -6,12 +6,12 @@ import PIL.Image
|
|
6
6
|
import torch
|
7
7
|
from transformers import CLIPImageProcessor, CLIPTokenizer
|
8
8
|
|
9
|
-
from
|
10
|
-
from
|
11
|
-
from
|
12
|
-
from
|
13
|
-
from
|
14
|
-
from . import StableDiffusionPipelineOutput
|
9
|
+
from ....configuration_utils import FrozenDict
|
10
|
+
from ....schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
|
11
|
+
from ....utils import deprecate, logging
|
12
|
+
from ...onnx_utils import ORT_TO_NP_TYPE, OnnxRuntimeModel
|
13
|
+
from ...pipeline_utils import DiffusionPipeline
|
14
|
+
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
15
15
|
|
16
16
|
|
17
17
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
@@ -66,6 +66,7 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
|
|
66
66
|
feature_extractor ([`CLIPImageProcessor`]):
|
67
67
|
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
|
68
68
|
"""
|
69
|
+
|
69
70
|
_optional_components = ["safety_checker", "feature_extractor"]
|
70
71
|
_is_onnx = True
|
71
72
|
|
@@ -21,17 +21,17 @@ import torch
|
|
21
21
|
from packaging import version
|
22
22
|
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
|
23
23
|
|
24
|
-
from
|
25
|
-
from
|
26
|
-
from
|
27
|
-
from
|
28
|
-
from
|
29
|
-
from
|
30
|
-
from
|
31
|
-
from
|
32
|
-
from
|
33
|
-
from
|
34
|
-
from .safety_checker import StableDiffusionSafetyChecker
|
24
|
+
from ....configuration_utils import FrozenDict
|
25
|
+
from ....image_processor import VaeImageProcessor
|
26
|
+
from ....loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
|
27
|
+
from ....models import AutoencoderKL, UNet2DConditionModel
|
28
|
+
from ....models.lora import adjust_lora_scale_text_encoder
|
29
|
+
from ....schedulers import KarrasDiffusionSchedulers
|
30
|
+
from ....utils import PIL_INTERPOLATION, USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
|
31
|
+
from ....utils.torch_utils import randn_tensor
|
32
|
+
from ...pipeline_utils import DiffusionPipeline
|
33
|
+
from ...stable_diffusion import StableDiffusionPipelineOutput
|
34
|
+
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
35
35
|
|
36
36
|
|
37
37
|
logger = logging.get_logger(__name__)
|
@@ -115,6 +115,7 @@ class StableDiffusionInpaintPipelineLegacy(
|
|
115
115
|
feature_extractor ([`CLIPImageProcessor`]):
|
116
116
|
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
|
117
117
|
"""
|
118
|
+
|
118
119
|
model_cpu_offload_seq = "text_encoder->unet->vae"
|
119
120
|
_optional_components = ["feature_extractor"]
|
120
121
|
_exclude_from_cpu_offload = ["safety_checker"]
|
@@ -18,17 +18,17 @@ from typing import Any, Callable, Dict, List, Optional, Union
|
|
18
18
|
import torch
|
19
19
|
from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
|
20
20
|
|
21
|
-
from
|
22
|
-
from
|
23
|
-
from
|
24
|
-
from
|
25
|
-
from
|
26
|
-
from
|
27
|
-
from
|
28
|
-
from
|
29
|
-
from
|
30
|
-
from . import StableDiffusionPipelineOutput
|
31
|
-
from .safety_checker import StableDiffusionSafetyChecker
|
21
|
+
from ....image_processor import VaeImageProcessor
|
22
|
+
from ....loaders import LoraLoaderMixin, TextualInversionLoaderMixin
|
23
|
+
from ....models import AutoencoderKL, UNet2DConditionModel
|
24
|
+
from ....models.lora import adjust_lora_scale_text_encoder
|
25
|
+
from ....schedulers import PNDMScheduler
|
26
|
+
from ....schedulers.scheduling_utils import SchedulerMixin
|
27
|
+
from ....utils import USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
|
28
|
+
from ....utils.torch_utils import randn_tensor
|
29
|
+
from ...pipeline_utils import DiffusionPipeline
|
30
|
+
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
31
|
+
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
32
32
|
|
33
33
|
|
34
34
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
@@ -43,6 +43,11 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
43
43
|
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
|
44
44
|
implemented for all pipelines (downloading, saving, running on a particular device, etc.).
|
45
45
|
|
46
|
+
The pipeline also inherits the following loading methods:
|
47
|
+
- [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
|
48
|
+
- [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
|
49
|
+
- [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
|
50
|
+
|
46
51
|
Args:
|
47
52
|
vae ([`AutoencoderKL`]):
|
48
53
|
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
|
@@ -66,6 +71,7 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
66
71
|
with_augs ([`list`]):
|
67
72
|
Textual augmentations to apply while editing the text-to-image model. Set to `[]` for no augmentations.
|
68
73
|
"""
|
74
|
+
|
69
75
|
model_cpu_offload_seq = "text_encoder->unet->vae"
|
70
76
|
_optional_components = ["safety_checker", "feature_extractor"]
|
71
77
|
_exclude_from_cpu_offload = ["safety_checker"]
|
@@ -18,12 +18,12 @@ from typing import Any, Callable, Dict, List, Optional, Union
|
|
18
18
|
import torch
|
19
19
|
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
|
20
20
|
|
21
|
-
from
|
22
|
-
from
|
23
|
-
from
|
24
|
-
from
|
25
|
-
from
|
26
|
-
from
|
21
|
+
from ....image_processor import VaeImageProcessor
|
22
|
+
from ....loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
|
23
|
+
from ....models import AutoencoderKL, UNet2DConditionModel
|
24
|
+
from ....models.lora import adjust_lora_scale_text_encoder
|
25
|
+
from ....schedulers import KarrasDiffusionSchedulers
|
26
|
+
from ....utils import (
|
27
27
|
USE_PEFT_BACKEND,
|
28
28
|
deprecate,
|
29
29
|
logging,
|
@@ -31,10 +31,10 @@ from ...utils import (
|
|
31
31
|
scale_lora_layers,
|
32
32
|
unscale_lora_layers,
|
33
33
|
)
|
34
|
-
from
|
35
|
-
from
|
36
|
-
from . import StableDiffusionPipelineOutput
|
37
|
-
from .safety_checker import StableDiffusionSafetyChecker
|
34
|
+
from ....utils.torch_utils import randn_tensor
|
35
|
+
from ...pipeline_utils import DiffusionPipeline
|
36
|
+
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
37
|
+
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
38
38
|
|
39
39
|
|
40
40
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
@@ -96,6 +96,7 @@ class StableDiffusionParadigmsPipeline(
|
|
96
96
|
feature_extractor ([`~transformers.CLIPImageProcessor`]):
|
97
97
|
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
|
98
98
|
"""
|
99
|
+
|
99
100
|
model_cpu_offload_seq = "text_encoder->unet->vae"
|
100
101
|
_optional_components = ["safety_checker", "feature_extractor"]
|
101
102
|
_exclude_from_cpu_offload = ["safety_checker"]
|
@@ -28,14 +28,14 @@ from transformers import (
|
|
28
28
|
CLIPTokenizer,
|
29
29
|
)
|
30
30
|
|
31
|
-
from
|
32
|
-
from
|
33
|
-
from
|
34
|
-
from
|
35
|
-
from
|
36
|
-
from
|
37
|
-
from
|
38
|
-
from
|
31
|
+
from ....image_processor import PipelineImageInput, VaeImageProcessor
|
32
|
+
from ....loaders import LoraLoaderMixin, TextualInversionLoaderMixin
|
33
|
+
from ....models import AutoencoderKL, UNet2DConditionModel
|
34
|
+
from ....models.attention_processor import Attention
|
35
|
+
from ....models.lora import adjust_lora_scale_text_encoder
|
36
|
+
from ....schedulers import DDIMScheduler, DDPMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler
|
37
|
+
from ....schedulers.scheduling_ddim_inverse import DDIMInverseScheduler
|
38
|
+
from ....utils import (
|
39
39
|
PIL_INTERPOLATION,
|
40
40
|
USE_PEFT_BACKEND,
|
41
41
|
BaseOutput,
|
@@ -45,10 +45,10 @@ from ...utils import (
|
|
45
45
|
scale_lora_layers,
|
46
46
|
unscale_lora_layers,
|
47
47
|
)
|
48
|
-
from
|
49
|
-
from
|
50
|
-
from . import StableDiffusionPipelineOutput
|
51
|
-
from .safety_checker import StableDiffusionSafetyChecker
|
48
|
+
from ....utils.torch_utils import randn_tensor
|
49
|
+
from ...pipeline_utils import DiffusionPipeline
|
50
|
+
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
51
|
+
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
52
52
|
|
53
53
|
|
54
54
|
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
@@ -282,7 +282,7 @@ class Pix2PixZeroAttnProcessor:
|
|
282
282
|
|
283
283
|
class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline):
|
284
284
|
r"""
|
285
|
-
Pipeline for pixel-
|
285
|
+
Pipeline for pixel-level image editing using Pix2Pix Zero. Based on Stable Diffusion.
|
286
286
|
|
287
287
|
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
288
288
|
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
@@ -310,6 +310,7 @@ class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline):
|
|
310
310
|
Whether the pipeline requires a safety checker. We recommend setting it to True if you're using the
|
311
311
|
pipeline publicly.
|
312
312
|
"""
|
313
|
+
|
313
314
|
model_cpu_offload_seq = "text_encoder->unet->vae"
|
314
315
|
_optional_components = [
|
315
316
|
"safety_checker",
|
@@ -16,10 +16,10 @@ from typing import List, Optional, Tuple, Union
|
|
16
16
|
|
17
17
|
import torch
|
18
18
|
|
19
|
-
from
|
20
|
-
from
|
21
|
-
from
|
22
|
-
from
|
19
|
+
from ....models import UNet2DModel
|
20
|
+
from ....schedulers import KarrasVeScheduler
|
21
|
+
from ....utils.torch_utils import randn_tensor
|
22
|
+
from ...pipeline_utils import DiffusionPipeline, ImagePipelineOutput
|
23
23
|
|
24
24
|
|
25
25
|
class KarrasVePipeline(DiffusionPipeline):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import TYPE_CHECKING
|
2
2
|
|
3
|
-
from
|
3
|
+
from ....utils import (
|
4
4
|
DIFFUSERS_SLOW_IMPORT,
|
5
5
|
OptionalDependencyNotAvailable,
|
6
6
|
_LazyModule,
|
@@ -17,7 +17,7 @@ try:
|
|
17
17
|
if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
|
18
18
|
raise OptionalDependencyNotAvailable()
|
19
19
|
except OptionalDependencyNotAvailable:
|
20
|
-
from
|
20
|
+
from ....utils.dummy_torch_and_transformers_objects import (
|
21
21
|
VersatileDiffusionDualGuidedPipeline,
|
22
22
|
VersatileDiffusionImageVariationPipeline,
|
23
23
|
VersatileDiffusionPipeline,
|
@@ -45,7 +45,7 @@ if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
|
|
45
45
|
if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
|
46
46
|
raise OptionalDependencyNotAvailable()
|
47
47
|
except OptionalDependencyNotAvailable:
|
48
|
-
from
|
48
|
+
from ....utils.dummy_torch_and_transformers_objects import (
|
49
49
|
VersatileDiffusionDualGuidedPipeline,
|
50
50
|
VersatileDiffusionImageVariationPipeline,
|
51
51
|
VersatileDiffusionPipeline,
|