diffusers 0.27.1__py3-none-any.whl → 0.32.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- diffusers/__init__.py +233 -6
- diffusers/callbacks.py +209 -0
- diffusers/commands/env.py +102 -6
- diffusers/configuration_utils.py +45 -16
- diffusers/dependency_versions_table.py +4 -3
- diffusers/image_processor.py +434 -110
- diffusers/loaders/__init__.py +42 -9
- diffusers/loaders/ip_adapter.py +626 -36
- diffusers/loaders/lora_base.py +900 -0
- diffusers/loaders/lora_conversion_utils.py +991 -125
- diffusers/loaders/lora_pipeline.py +3812 -0
- diffusers/loaders/peft.py +571 -7
- diffusers/loaders/single_file.py +405 -173
- diffusers/loaders/single_file_model.py +385 -0
- diffusers/loaders/single_file_utils.py +1783 -713
- diffusers/loaders/textual_inversion.py +41 -23
- diffusers/loaders/transformer_flux.py +181 -0
- diffusers/loaders/transformer_sd3.py +89 -0
- diffusers/loaders/unet.py +464 -540
- diffusers/loaders/unet_loader_utils.py +163 -0
- diffusers/models/__init__.py +76 -7
- diffusers/models/activations.py +65 -10
- diffusers/models/adapter.py +53 -53
- diffusers/models/attention.py +605 -18
- diffusers/models/attention_flax.py +1 -1
- diffusers/models/attention_processor.py +4304 -687
- diffusers/models/autoencoders/__init__.py +8 -0
- diffusers/models/autoencoders/autoencoder_asym_kl.py +15 -17
- diffusers/models/autoencoders/autoencoder_dc.py +620 -0
- diffusers/models/autoencoders/autoencoder_kl.py +110 -28
- diffusers/models/autoencoders/autoencoder_kl_allegro.py +1149 -0
- diffusers/models/autoencoders/autoencoder_kl_cogvideox.py +1482 -0
- diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.py +1176 -0
- diffusers/models/autoencoders/autoencoder_kl_ltx.py +1338 -0
- diffusers/models/autoencoders/autoencoder_kl_mochi.py +1166 -0
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +19 -24
- diffusers/models/autoencoders/autoencoder_oobleck.py +464 -0
- diffusers/models/autoencoders/autoencoder_tiny.py +21 -18
- diffusers/models/autoencoders/consistency_decoder_vae.py +45 -20
- diffusers/models/autoencoders/vae.py +41 -29
- diffusers/models/autoencoders/vq_model.py +182 -0
- diffusers/models/controlnet.py +47 -800
- diffusers/models/controlnet_flux.py +70 -0
- diffusers/models/controlnet_sd3.py +68 -0
- diffusers/models/controlnet_sparsectrl.py +116 -0
- diffusers/models/controlnets/__init__.py +23 -0
- diffusers/models/controlnets/controlnet.py +872 -0
- diffusers/models/{controlnet_flax.py → controlnets/controlnet_flax.py} +9 -9
- diffusers/models/controlnets/controlnet_flux.py +536 -0
- diffusers/models/controlnets/controlnet_hunyuan.py +401 -0
- diffusers/models/controlnets/controlnet_sd3.py +489 -0
- diffusers/models/controlnets/controlnet_sparsectrl.py +788 -0
- diffusers/models/controlnets/controlnet_union.py +832 -0
- diffusers/models/controlnets/controlnet_xs.py +1946 -0
- diffusers/models/controlnets/multicontrolnet.py +183 -0
- diffusers/models/downsampling.py +85 -18
- diffusers/models/embeddings.py +1856 -158
- diffusers/models/embeddings_flax.py +23 -9
- diffusers/models/model_loading_utils.py +480 -0
- diffusers/models/modeling_flax_pytorch_utils.py +2 -1
- diffusers/models/modeling_flax_utils.py +2 -7
- diffusers/models/modeling_outputs.py +14 -0
- diffusers/models/modeling_pytorch_flax_utils.py +1 -1
- diffusers/models/modeling_utils.py +611 -146
- diffusers/models/normalization.py +361 -20
- diffusers/models/resnet.py +18 -23
- diffusers/models/transformers/__init__.py +16 -0
- diffusers/models/transformers/auraflow_transformer_2d.py +544 -0
- diffusers/models/transformers/cogvideox_transformer_3d.py +542 -0
- diffusers/models/transformers/dit_transformer_2d.py +240 -0
- diffusers/models/transformers/dual_transformer_2d.py +9 -8
- diffusers/models/transformers/hunyuan_transformer_2d.py +578 -0
- diffusers/models/transformers/latte_transformer_3d.py +327 -0
- diffusers/models/transformers/lumina_nextdit2d.py +340 -0
- diffusers/models/transformers/pixart_transformer_2d.py +445 -0
- diffusers/models/transformers/prior_transformer.py +13 -13
- diffusers/models/transformers/sana_transformer.py +488 -0
- diffusers/models/transformers/stable_audio_transformer.py +458 -0
- diffusers/models/transformers/t5_film_transformer.py +17 -19
- diffusers/models/transformers/transformer_2d.py +297 -187
- diffusers/models/transformers/transformer_allegro.py +422 -0
- diffusers/models/transformers/transformer_cogview3plus.py +386 -0
- diffusers/models/transformers/transformer_flux.py +593 -0
- diffusers/models/transformers/transformer_hunyuan_video.py +791 -0
- diffusers/models/transformers/transformer_ltx.py +469 -0
- diffusers/models/transformers/transformer_mochi.py +499 -0
- diffusers/models/transformers/transformer_sd3.py +461 -0
- diffusers/models/transformers/transformer_temporal.py +21 -19
- diffusers/models/unets/unet_1d.py +8 -8
- diffusers/models/unets/unet_1d_blocks.py +31 -31
- diffusers/models/unets/unet_2d.py +17 -10
- diffusers/models/unets/unet_2d_blocks.py +225 -149
- diffusers/models/unets/unet_2d_condition.py +41 -40
- diffusers/models/unets/unet_2d_condition_flax.py +6 -5
- diffusers/models/unets/unet_3d_blocks.py +192 -1057
- diffusers/models/unets/unet_3d_condition.py +22 -27
- diffusers/models/unets/unet_i2vgen_xl.py +22 -18
- diffusers/models/unets/unet_kandinsky3.py +2 -2
- diffusers/models/unets/unet_motion_model.py +1413 -89
- diffusers/models/unets/unet_spatio_temporal_condition.py +40 -16
- diffusers/models/unets/unet_stable_cascade.py +19 -18
- diffusers/models/unets/uvit_2d.py +2 -2
- diffusers/models/upsampling.py +95 -26
- diffusers/models/vq_model.py +12 -164
- diffusers/optimization.py +1 -1
- diffusers/pipelines/__init__.py +202 -3
- diffusers/pipelines/allegro/__init__.py +48 -0
- diffusers/pipelines/allegro/pipeline_allegro.py +938 -0
- diffusers/pipelines/allegro/pipeline_output.py +23 -0
- diffusers/pipelines/amused/pipeline_amused.py +12 -12
- diffusers/pipelines/amused/pipeline_amused_img2img.py +14 -12
- diffusers/pipelines/amused/pipeline_amused_inpaint.py +13 -11
- diffusers/pipelines/animatediff/__init__.py +8 -0
- diffusers/pipelines/animatediff/pipeline_animatediff.py +122 -109
- diffusers/pipelines/animatediff/pipeline_animatediff_controlnet.py +1106 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_sdxl.py +1288 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_sparsectrl.py +1010 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +236 -180
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video_controlnet.py +1341 -0
- diffusers/pipelines/animatediff/pipeline_output.py +3 -2
- diffusers/pipelines/audioldm/pipeline_audioldm.py +14 -14
- diffusers/pipelines/audioldm2/modeling_audioldm2.py +58 -39
- diffusers/pipelines/audioldm2/pipeline_audioldm2.py +121 -36
- diffusers/pipelines/aura_flow/__init__.py +48 -0
- diffusers/pipelines/aura_flow/pipeline_aura_flow.py +584 -0
- diffusers/pipelines/auto_pipeline.py +196 -28
- diffusers/pipelines/blip_diffusion/blip_image_processing.py +1 -1
- diffusers/pipelines/blip_diffusion/modeling_blip2.py +6 -6
- diffusers/pipelines/blip_diffusion/modeling_ctx_clip.py +1 -1
- diffusers/pipelines/blip_diffusion/pipeline_blip_diffusion.py +2 -2
- diffusers/pipelines/cogvideo/__init__.py +54 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox.py +772 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox_fun_control.py +825 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox_image2video.py +885 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox_video2video.py +851 -0
- diffusers/pipelines/cogvideo/pipeline_output.py +20 -0
- diffusers/pipelines/cogview3/__init__.py +47 -0
- diffusers/pipelines/cogview3/pipeline_cogview3plus.py +674 -0
- diffusers/pipelines/cogview3/pipeline_output.py +21 -0
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +6 -6
- diffusers/pipelines/controlnet/__init__.py +86 -80
- diffusers/pipelines/controlnet/multicontrolnet.py +7 -182
- diffusers/pipelines/controlnet/pipeline_controlnet.py +134 -87
- diffusers/pipelines/controlnet/pipeline_controlnet_blip_diffusion.py +2 -2
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +93 -77
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +88 -197
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +136 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +176 -80
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +125 -89
- diffusers/pipelines/controlnet/pipeline_controlnet_union_inpaint_sd_xl.py +1790 -0
- diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl.py +1501 -0
- diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl_img2img.py +1627 -0
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
- diffusers/pipelines/controlnet_hunyuandit/__init__.py +48 -0
- diffusers/pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py +1060 -0
- diffusers/pipelines/controlnet_sd3/__init__.py +57 -0
- diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +1133 -0
- diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py +1153 -0
- diffusers/pipelines/controlnet_xs/__init__.py +68 -0
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +916 -0
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_sd_xl.py +1111 -0
- diffusers/pipelines/ddpm/pipeline_ddpm.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +16 -30
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +20 -35
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +23 -41
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +22 -38
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +25 -41
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +19 -34
- diffusers/pipelines/deepfloyd_if/pipeline_output.py +6 -5
- diffusers/pipelines/deepfloyd_if/watermark.py +1 -1
- diffusers/pipelines/deprecated/alt_diffusion/modeling_roberta_series.py +11 -11
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +70 -30
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +48 -25
- diffusers/pipelines/deprecated/repaint/pipeline_repaint.py +2 -2
- diffusers/pipelines/deprecated/spectrogram_diffusion/pipeline_spectrogram_diffusion.py +7 -7
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +21 -20
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +27 -29
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +33 -27
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +33 -23
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +36 -30
- diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +102 -69
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion.py +13 -13
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_dual_guided.py +10 -5
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_image_variation.py +11 -6
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_text_to_image.py +10 -5
- diffusers/pipelines/deprecated/vq_diffusion/pipeline_vq_diffusion.py +5 -5
- diffusers/pipelines/dit/pipeline_dit.py +7 -4
- diffusers/pipelines/flux/__init__.py +69 -0
- diffusers/pipelines/flux/modeling_flux.py +47 -0
- diffusers/pipelines/flux/pipeline_flux.py +957 -0
- diffusers/pipelines/flux/pipeline_flux_control.py +889 -0
- diffusers/pipelines/flux/pipeline_flux_control_img2img.py +945 -0
- diffusers/pipelines/flux/pipeline_flux_control_inpaint.py +1141 -0
- diffusers/pipelines/flux/pipeline_flux_controlnet.py +1006 -0
- diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py +998 -0
- diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py +1204 -0
- diffusers/pipelines/flux/pipeline_flux_fill.py +969 -0
- diffusers/pipelines/flux/pipeline_flux_img2img.py +856 -0
- diffusers/pipelines/flux/pipeline_flux_inpaint.py +1022 -0
- diffusers/pipelines/flux/pipeline_flux_prior_redux.py +492 -0
- diffusers/pipelines/flux/pipeline_output.py +37 -0
- diffusers/pipelines/free_init_utils.py +41 -38
- diffusers/pipelines/free_noise_utils.py +596 -0
- diffusers/pipelines/hunyuan_video/__init__.py +48 -0
- diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py +687 -0
- diffusers/pipelines/hunyuan_video/pipeline_output.py +20 -0
- diffusers/pipelines/hunyuandit/__init__.py +48 -0
- diffusers/pipelines/hunyuandit/pipeline_hunyuandit.py +916 -0
- diffusers/pipelines/i2vgen_xl/pipeline_i2vgen_xl.py +33 -48
- diffusers/pipelines/kandinsky/pipeline_kandinsky.py +8 -8
- diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +32 -29
- diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py +11 -11
- diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py +12 -12
- diffusers/pipelines/kandinsky/pipeline_kandinsky_prior.py +10 -10
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +6 -6
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +34 -31
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py +10 -10
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +10 -10
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +6 -6
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpainting.py +8 -8
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior.py +7 -7
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior_emb2emb.py +6 -6
- diffusers/pipelines/kandinsky3/convert_kandinsky3_unet.py +3 -3
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +22 -35
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +26 -37
- diffusers/pipelines/kolors/__init__.py +54 -0
- diffusers/pipelines/kolors/pipeline_kolors.py +1070 -0
- diffusers/pipelines/kolors/pipeline_kolors_img2img.py +1250 -0
- diffusers/pipelines/kolors/pipeline_output.py +21 -0
- diffusers/pipelines/kolors/text_encoder.py +889 -0
- diffusers/pipelines/kolors/tokenizer.py +338 -0
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +82 -62
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +77 -60
- diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +12 -12
- diffusers/pipelines/latte/__init__.py +48 -0
- diffusers/pipelines/latte/pipeline_latte.py +881 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +80 -74
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +85 -76
- diffusers/pipelines/ledits_pp/pipeline_output.py +2 -2
- diffusers/pipelines/ltx/__init__.py +50 -0
- diffusers/pipelines/ltx/pipeline_ltx.py +789 -0
- diffusers/pipelines/ltx/pipeline_ltx_image2video.py +885 -0
- diffusers/pipelines/ltx/pipeline_output.py +20 -0
- diffusers/pipelines/lumina/__init__.py +48 -0
- diffusers/pipelines/lumina/pipeline_lumina.py +890 -0
- diffusers/pipelines/marigold/__init__.py +50 -0
- diffusers/pipelines/marigold/marigold_image_processing.py +576 -0
- diffusers/pipelines/marigold/pipeline_marigold_depth.py +813 -0
- diffusers/pipelines/marigold/pipeline_marigold_normals.py +690 -0
- diffusers/pipelines/mochi/__init__.py +48 -0
- diffusers/pipelines/mochi/pipeline_mochi.py +748 -0
- diffusers/pipelines/mochi/pipeline_output.py +20 -0
- diffusers/pipelines/musicldm/pipeline_musicldm.py +14 -14
- diffusers/pipelines/pag/__init__.py +80 -0
- diffusers/pipelines/pag/pag_utils.py +243 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd.py +1328 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd_inpaint.py +1543 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl.py +1610 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl_img2img.py +1683 -0
- diffusers/pipelines/pag/pipeline_pag_hunyuandit.py +969 -0
- diffusers/pipelines/pag/pipeline_pag_kolors.py +1136 -0
- diffusers/pipelines/pag/pipeline_pag_pixart_sigma.py +865 -0
- diffusers/pipelines/pag/pipeline_pag_sana.py +886 -0
- diffusers/pipelines/pag/pipeline_pag_sd.py +1062 -0
- diffusers/pipelines/pag/pipeline_pag_sd_3.py +994 -0
- diffusers/pipelines/pag/pipeline_pag_sd_3_img2img.py +1058 -0
- diffusers/pipelines/pag/pipeline_pag_sd_animatediff.py +866 -0
- diffusers/pipelines/pag/pipeline_pag_sd_img2img.py +1094 -0
- diffusers/pipelines/pag/pipeline_pag_sd_inpaint.py +1356 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl.py +1345 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_img2img.py +1544 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_inpaint.py +1776 -0
- diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py +17 -12
- diffusers/pipelines/pia/pipeline_pia.py +74 -164
- diffusers/pipelines/pipeline_flax_utils.py +5 -10
- diffusers/pipelines/pipeline_loading_utils.py +515 -53
- diffusers/pipelines/pipeline_utils.py +411 -222
- diffusers/pipelines/pixart_alpha/__init__.py +8 -1
- diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +76 -93
- diffusers/pipelines/pixart_alpha/pipeline_pixart_sigma.py +873 -0
- diffusers/pipelines/sana/__init__.py +47 -0
- diffusers/pipelines/sana/pipeline_output.py +21 -0
- diffusers/pipelines/sana/pipeline_sana.py +884 -0
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +27 -23
- diffusers/pipelines/shap_e/pipeline_shap_e.py +3 -3
- diffusers/pipelines/shap_e/pipeline_shap_e_img2img.py +14 -14
- diffusers/pipelines/shap_e/renderer.py +1 -1
- diffusers/pipelines/stable_audio/__init__.py +50 -0
- diffusers/pipelines/stable_audio/modeling_stable_audio.py +158 -0
- diffusers/pipelines/stable_audio/pipeline_stable_audio.py +756 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade.py +71 -25
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_combined.py +23 -19
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_prior.py +35 -34
- diffusers/pipelines/stable_diffusion/__init__.py +0 -1
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +20 -11
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py +2 -2
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py +6 -6
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +145 -79
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +43 -28
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py +13 -8
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +100 -68
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +109 -201
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +131 -32
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py +247 -87
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +30 -29
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +35 -27
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +49 -42
- diffusers/pipelines/stable_diffusion/safety_checker.py +2 -1
- diffusers/pipelines/stable_diffusion_3/__init__.py +54 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_output.py +21 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +1140 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +1036 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1250 -0
- diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +29 -20
- diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +59 -58
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +31 -25
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +38 -22
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +30 -24
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +24 -23
- diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +107 -67
- diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +316 -69
- diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py +10 -5
- diffusers/pipelines/stable_diffusion_safe/safety_checker.py +1 -1
- diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +98 -30
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +121 -83
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +161 -105
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +142 -218
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +45 -29
- diffusers/pipelines/stable_diffusion_xl/watermark.py +9 -3
- diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +110 -57
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +69 -39
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +105 -74
- diffusers/pipelines/text_to_video_synthesis/pipeline_output.py +3 -2
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +29 -49
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +32 -93
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +37 -25
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +54 -40
- diffusers/pipelines/unclip/pipeline_unclip.py +6 -6
- diffusers/pipelines/unclip/pipeline_unclip_image_variation.py +6 -6
- diffusers/pipelines/unidiffuser/modeling_text_decoder.py +1 -1
- diffusers/pipelines/unidiffuser/modeling_uvit.py +12 -12
- diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +29 -28
- diffusers/pipelines/wuerstchen/modeling_paella_vq_model.py +5 -5
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py +5 -10
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +6 -8
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen.py +4 -4
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_combined.py +12 -12
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +15 -14
- diffusers/{models/dual_transformer_2d.py → quantizers/__init__.py} +2 -6
- diffusers/quantizers/auto.py +139 -0
- diffusers/quantizers/base.py +233 -0
- diffusers/quantizers/bitsandbytes/__init__.py +2 -0
- diffusers/quantizers/bitsandbytes/bnb_quantizer.py +561 -0
- diffusers/quantizers/bitsandbytes/utils.py +306 -0
- diffusers/quantizers/gguf/__init__.py +1 -0
- diffusers/quantizers/gguf/gguf_quantizer.py +159 -0
- diffusers/quantizers/gguf/utils.py +456 -0
- diffusers/quantizers/quantization_config.py +669 -0
- diffusers/quantizers/torchao/__init__.py +15 -0
- diffusers/quantizers/torchao/torchao_quantizer.py +292 -0
- diffusers/schedulers/__init__.py +12 -2
- diffusers/schedulers/deprecated/__init__.py +1 -1
- diffusers/schedulers/deprecated/scheduling_karras_ve.py +25 -25
- diffusers/schedulers/scheduling_amused.py +5 -5
- diffusers/schedulers/scheduling_consistency_decoder.py +11 -11
- diffusers/schedulers/scheduling_consistency_models.py +23 -25
- diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py +572 -0
- diffusers/schedulers/scheduling_ddim.py +27 -26
- diffusers/schedulers/scheduling_ddim_cogvideox.py +452 -0
- diffusers/schedulers/scheduling_ddim_flax.py +2 -1
- diffusers/schedulers/scheduling_ddim_inverse.py +16 -16
- diffusers/schedulers/scheduling_ddim_parallel.py +32 -31
- diffusers/schedulers/scheduling_ddpm.py +27 -30
- diffusers/schedulers/scheduling_ddpm_flax.py +7 -3
- diffusers/schedulers/scheduling_ddpm_parallel.py +33 -36
- diffusers/schedulers/scheduling_ddpm_wuerstchen.py +14 -14
- diffusers/schedulers/scheduling_deis_multistep.py +150 -50
- diffusers/schedulers/scheduling_dpm_cogvideox.py +489 -0
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +221 -84
- diffusers/schedulers/scheduling_dpmsolver_multistep_flax.py +2 -2
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +158 -52
- diffusers/schedulers/scheduling_dpmsolver_sde.py +153 -34
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +275 -86
- diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +81 -57
- diffusers/schedulers/scheduling_edm_euler.py +62 -39
- diffusers/schedulers/scheduling_euler_ancestral_discrete.py +30 -29
- diffusers/schedulers/scheduling_euler_discrete.py +255 -74
- diffusers/schedulers/scheduling_flow_match_euler_discrete.py +458 -0
- diffusers/schedulers/scheduling_flow_match_heun_discrete.py +320 -0
- diffusers/schedulers/scheduling_heun_discrete.py +174 -46
- diffusers/schedulers/scheduling_ipndm.py +9 -9
- diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +138 -29
- diffusers/schedulers/scheduling_k_dpm_2_discrete.py +132 -26
- diffusers/schedulers/scheduling_karras_ve_flax.py +6 -6
- diffusers/schedulers/scheduling_lcm.py +23 -29
- diffusers/schedulers/scheduling_lms_discrete.py +105 -28
- diffusers/schedulers/scheduling_pndm.py +20 -20
- diffusers/schedulers/scheduling_repaint.py +21 -21
- diffusers/schedulers/scheduling_sasolver.py +157 -60
- diffusers/schedulers/scheduling_sde_ve.py +19 -19
- diffusers/schedulers/scheduling_tcd.py +41 -36
- diffusers/schedulers/scheduling_unclip.py +19 -16
- diffusers/schedulers/scheduling_unipc_multistep.py +243 -47
- diffusers/schedulers/scheduling_utils.py +12 -5
- diffusers/schedulers/scheduling_utils_flax.py +1 -3
- diffusers/schedulers/scheduling_vq_diffusion.py +10 -10
- diffusers/training_utils.py +214 -30
- diffusers/utils/__init__.py +17 -1
- diffusers/utils/constants.py +3 -0
- diffusers/utils/doc_utils.py +1 -0
- diffusers/utils/dummy_pt_objects.py +592 -7
- diffusers/utils/dummy_torch_and_torchsde_objects.py +15 -0
- diffusers/utils/dummy_torch_and_transformers_and_sentencepiece_objects.py +47 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +1001 -71
- diffusers/utils/dynamic_modules_utils.py +34 -29
- diffusers/utils/export_utils.py +50 -6
- diffusers/utils/hub_utils.py +131 -17
- diffusers/utils/import_utils.py +210 -8
- diffusers/utils/loading_utils.py +118 -5
- diffusers/utils/logging.py +4 -2
- diffusers/utils/peft_utils.py +37 -7
- diffusers/utils/state_dict_utils.py +13 -2
- diffusers/utils/testing_utils.py +193 -11
- diffusers/utils/torch_utils.py +4 -0
- diffusers/video_processor.py +113 -0
- {diffusers-0.27.1.dist-info → diffusers-0.32.2.dist-info}/METADATA +82 -91
- diffusers-0.32.2.dist-info/RECORD +550 -0
- {diffusers-0.27.1.dist-info → diffusers-0.32.2.dist-info}/WHEEL +1 -1
- diffusers/loaders/autoencoder.py +0 -146
- diffusers/loaders/controlnet.py +0 -136
- diffusers/loaders/lora.py +0 -1349
- diffusers/models/prior_transformer.py +0 -12
- diffusers/models/t5_film_transformer.py +0 -70
- diffusers/models/transformer_2d.py +0 -25
- diffusers/models/transformer_temporal.py +0 -34
- diffusers/models/unet_1d.py +0 -26
- diffusers/models/unet_1d_blocks.py +0 -203
- diffusers/models/unet_2d.py +0 -27
- diffusers/models/unet_2d_blocks.py +0 -375
- diffusers/models/unet_2d_condition.py +0 -25
- diffusers-0.27.1.dist-info/RECORD +0 -399
- {diffusers-0.27.1.dist-info → diffusers-0.32.2.dist-info}/LICENSE +0 -0
- {diffusers-0.27.1.dist-info → diffusers-0.32.2.dist-info}/entry_points.txt +0 -0
- {diffusers-0.27.1.dist-info → diffusers-0.32.2.dist-info}/top_level.txt +0 -0
@@ -25,8 +25,6 @@ from ...models import AutoencoderKL, UNet2DConditionModel
|
|
25
25
|
from ...models.attention_processor import (
|
26
26
|
AttnProcessor2_0,
|
27
27
|
FusedAttnProcessor2_0,
|
28
|
-
LoRAAttnProcessor2_0,
|
29
|
-
LoRAXFormersAttnProcessor,
|
30
28
|
XFormersAttnProcessor,
|
31
29
|
)
|
32
30
|
from ...models.lora import adjust_lora_scale_text_encoder
|
@@ -169,6 +167,8 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
169
167
|
Whether to use the [invisible_watermark library](https://github.com/ShieldMnt/invisible-watermark/) to
|
170
168
|
watermark output images. If not defined, it will default to True if the package is installed, otherwise no
|
171
169
|
watermarker will be used.
|
170
|
+
is_cosxl_edit (`bool`, *optional*):
|
171
|
+
When set the image latents are scaled.
|
172
172
|
"""
|
173
173
|
|
174
174
|
model_cpu_offload_seq = "text_encoder->text_encoder_2->unet->vae"
|
@@ -185,6 +185,7 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
185
185
|
scheduler: KarrasDiffusionSchedulers,
|
186
186
|
force_zeros_for_empty_prompt: bool = True,
|
187
187
|
add_watermarker: Optional[bool] = None,
|
188
|
+
is_cosxl_edit: Optional[bool] = False,
|
188
189
|
):
|
189
190
|
super().__init__()
|
190
191
|
|
@@ -201,6 +202,7 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
201
202
|
self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
|
202
203
|
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
|
203
204
|
self.default_sample_size = self.unet.config.sample_size
|
205
|
+
self.is_cosxl_edit = is_cosxl_edit
|
204
206
|
|
205
207
|
add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available()
|
206
208
|
|
@@ -218,10 +220,10 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
218
220
|
do_classifier_free_guidance: bool = True,
|
219
221
|
negative_prompt: Optional[str] = None,
|
220
222
|
negative_prompt_2: Optional[str] = None,
|
221
|
-
prompt_embeds: Optional[torch.
|
222
|
-
negative_prompt_embeds: Optional[torch.
|
223
|
-
pooled_prompt_embeds: Optional[torch.
|
224
|
-
negative_pooled_prompt_embeds: Optional[torch.
|
223
|
+
prompt_embeds: Optional[torch.Tensor] = None,
|
224
|
+
negative_prompt_embeds: Optional[torch.Tensor] = None,
|
225
|
+
pooled_prompt_embeds: Optional[torch.Tensor] = None,
|
226
|
+
negative_pooled_prompt_embeds: Optional[torch.Tensor] = None,
|
225
227
|
lora_scale: Optional[float] = None,
|
226
228
|
):
|
227
229
|
r"""
|
@@ -246,17 +248,17 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
246
248
|
negative_prompt_2 (`str` or `List[str]`, *optional*):
|
247
249
|
The prompt or prompts not to guide the image generation to be sent to `tokenizer_2` and
|
248
250
|
`text_encoder_2`. If not defined, `negative_prompt` is used in both text-encoders
|
249
|
-
prompt_embeds (`torch.
|
251
|
+
prompt_embeds (`torch.Tensor`, *optional*):
|
250
252
|
Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
|
251
253
|
provided, text embeddings will be generated from `prompt` input argument.
|
252
|
-
negative_prompt_embeds (`torch.
|
254
|
+
negative_prompt_embeds (`torch.Tensor`, *optional*):
|
253
255
|
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
|
254
256
|
weighting. If not provided, negative_prompt_embeds will be generated from `negative_prompt` input
|
255
257
|
argument.
|
256
|
-
pooled_prompt_embeds (`torch.
|
258
|
+
pooled_prompt_embeds (`torch.Tensor`, *optional*):
|
257
259
|
Pre-generated pooled text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting.
|
258
260
|
If not provided, pooled text embeddings will be generated from `prompt` input argument.
|
259
|
-
negative_pooled_prompt_embeds (`torch.
|
261
|
+
negative_pooled_prompt_embeds (`torch.Tensor`, *optional*):
|
260
262
|
Pre-generated negative pooled text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
|
261
263
|
weighting. If not provided, pooled negative_prompt_embeds will be generated from `negative_prompt`
|
262
264
|
input argument.
|
@@ -432,7 +434,6 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
432
434
|
extra_step_kwargs["generator"] = generator
|
433
435
|
return extra_step_kwargs
|
434
436
|
|
435
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_instruct_pix2pix.StableDiffusionInstructPix2PixPipeline.check_inputs
|
436
437
|
def check_inputs(
|
437
438
|
self,
|
438
439
|
prompt,
|
@@ -483,7 +484,12 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
483
484
|
|
484
485
|
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.prepare_latents
|
485
486
|
def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype, device, generator, latents=None):
|
486
|
-
shape = (
|
487
|
+
shape = (
|
488
|
+
batch_size,
|
489
|
+
num_channels_latents,
|
490
|
+
int(height) // self.vae_scale_factor,
|
491
|
+
int(width) // self.vae_scale_factor,
|
492
|
+
)
|
487
493
|
if isinstance(generator, list) and len(generator) != batch_size:
|
488
494
|
raise ValueError(
|
489
495
|
f"You have passed a list of generators of length {len(generator)}, but requested an effective batch"
|
@@ -517,8 +523,8 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
517
523
|
# make sure the VAE is in float32 mode, as it overflows in float16
|
518
524
|
needs_upcasting = self.vae.dtype == torch.float16 and self.vae.config.force_upcast
|
519
525
|
if needs_upcasting:
|
526
|
+
image = image.float()
|
520
527
|
self.upcast_vae()
|
521
|
-
image = image.to(next(iter(self.vae.post_quant_conv.parameters())).dtype)
|
522
528
|
|
523
529
|
image_latents = retrieve_latents(self.vae.encode(image), sample_mode="argmax")
|
524
530
|
|
@@ -551,6 +557,9 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
551
557
|
if image_latents.dtype != self.vae.dtype:
|
552
558
|
image_latents = image_latents.to(dtype=self.vae.dtype)
|
553
559
|
|
560
|
+
if self.is_cosxl_edit:
|
561
|
+
image_latents = image_latents * self.vae.config.scaling_factor
|
562
|
+
|
554
563
|
return image_latents
|
555
564
|
|
556
565
|
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.StableDiffusionXLPipeline._get_add_time_ids
|
@@ -581,8 +590,6 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
581
590
|
(
|
582
591
|
AttnProcessor2_0,
|
583
592
|
XFormersAttnProcessor,
|
584
|
-
LoRAXFormersAttnProcessor,
|
585
|
-
LoRAAttnProcessor2_0,
|
586
593
|
FusedAttnProcessor2_0,
|
587
594
|
),
|
588
595
|
)
|
@@ -611,14 +618,14 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
611
618
|
num_images_per_prompt: Optional[int] = 1,
|
612
619
|
eta: float = 0.0,
|
613
620
|
generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
|
614
|
-
latents: Optional[torch.
|
615
|
-
prompt_embeds: Optional[torch.
|
616
|
-
negative_prompt_embeds: Optional[torch.
|
617
|
-
pooled_prompt_embeds: Optional[torch.
|
618
|
-
negative_pooled_prompt_embeds: Optional[torch.
|
621
|
+
latents: Optional[torch.Tensor] = None,
|
622
|
+
prompt_embeds: Optional[torch.Tensor] = None,
|
623
|
+
negative_prompt_embeds: Optional[torch.Tensor] = None,
|
624
|
+
pooled_prompt_embeds: Optional[torch.Tensor] = None,
|
625
|
+
negative_pooled_prompt_embeds: Optional[torch.Tensor] = None,
|
619
626
|
output_type: Optional[str] = "pil",
|
620
627
|
return_dict: bool = True,
|
621
|
-
callback: Optional[Callable[[int, int, torch.
|
628
|
+
callback: Optional[Callable[[int, int, torch.Tensor], None]] = None,
|
622
629
|
callback_steps: int = 1,
|
623
630
|
cross_attention_kwargs: Optional[Dict[str, Any]] = None,
|
624
631
|
guidance_rescale: float = 0.0,
|
@@ -636,7 +643,7 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
636
643
|
prompt_2 (`str` or `List[str]`, *optional*):
|
637
644
|
The prompt or prompts to be sent to the `tokenizer_2` and `text_encoder_2`. If not defined, `prompt` is
|
638
645
|
used in both text-encoders
|
639
|
-
image (`torch.
|
646
|
+
image (`torch.Tensor` or `PIL.Image.Image` or `np.ndarray` or `List[torch.Tensor]` or `List[PIL.Image.Image]` or `List[np.ndarray]`):
|
640
647
|
The image(s) to modify with the pipeline.
|
641
648
|
height (`int`, *optional*, defaults to self.unet.config.sample_size * self.vae_scale_factor):
|
642
649
|
The height in pixels of the generated image.
|
@@ -659,7 +666,7 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
659
666
|
1`. Higher guidance scale encourages to generate images that are closely linked to the text `prompt`,
|
660
667
|
usually at the expense of lower image quality.
|
661
668
|
image_guidance_scale (`float`, *optional*, defaults to 1.5):
|
662
|
-
Image guidance scale is to push the generated image towards the
|
669
|
+
Image guidance scale is to push the generated image towards the initial image `image`. Image guidance
|
663
670
|
scale is enabled by setting `image_guidance_scale > 1`. Higher image guidance scale encourages to
|
664
671
|
generate images that are closely linked to the source image `image`, usually at the expense of lower
|
665
672
|
image quality. This pipeline requires a value of at least `1`.
|
@@ -678,21 +685,21 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
678
685
|
generator (`torch.Generator` or `List[torch.Generator]`, *optional*):
|
679
686
|
One or a list of [torch generator(s)](https://pytorch.org/docs/stable/generated/torch.Generator.html)
|
680
687
|
to make generation deterministic.
|
681
|
-
latents (`torch.
|
688
|
+
latents (`torch.Tensor`, *optional*):
|
682
689
|
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
|
683
690
|
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
|
684
691
|
tensor will ge generated by sampling using the supplied random `generator`.
|
685
|
-
prompt_embeds (`torch.
|
692
|
+
prompt_embeds (`torch.Tensor`, *optional*):
|
686
693
|
Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
|
687
694
|
provided, text embeddings will be generated from `prompt` input argument.
|
688
|
-
negative_prompt_embeds (`torch.
|
695
|
+
negative_prompt_embeds (`torch.Tensor`, *optional*):
|
689
696
|
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
|
690
697
|
weighting. If not provided, negative_prompt_embeds will be generated from `negative_prompt` input
|
691
698
|
argument.
|
692
|
-
pooled_prompt_embeds (`torch.
|
699
|
+
pooled_prompt_embeds (`torch.Tensor`, *optional*):
|
693
700
|
Pre-generated pooled text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting.
|
694
701
|
If not provided, pooled text embeddings will be generated from `prompt` input argument.
|
695
|
-
negative_pooled_prompt_embeds (`torch.
|
702
|
+
negative_pooled_prompt_embeds (`torch.Tensor`, *optional*):
|
696
703
|
Pre-generated negative pooled text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
|
697
704
|
weighting. If not provided, pooled negative_prompt_embeds will be generated from `negative_prompt`
|
698
705
|
input argument.
|
@@ -704,7 +711,7 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
704
711
|
plain tuple.
|
705
712
|
callback (`Callable`, *optional*):
|
706
713
|
A function that will be called every `callback_steps` steps during inference. The function will be
|
707
|
-
called with the following arguments: `callback(step: int, timestep: int, latents: torch.
|
714
|
+
called with the following arguments: `callback(step: int, timestep: int, latents: torch.Tensor)`.
|
708
715
|
callback_steps (`int`, *optional*, defaults to 1):
|
709
716
|
The frequency at which the `callback` function will be called. If not specified, the callback will be
|
710
717
|
called at every step.
|
@@ -918,7 +925,12 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
918
925
|
noise_pred = rescale_noise_cfg(noise_pred, noise_pred_text, guidance_rescale=guidance_rescale)
|
919
926
|
|
920
927
|
# compute the previous noisy sample x_t -> x_t-1
|
928
|
+
latents_dtype = latents.dtype
|
921
929
|
latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs, return_dict=False)[0]
|
930
|
+
if latents.dtype != latents_dtype:
|
931
|
+
if torch.backends.mps.is_available():
|
932
|
+
# some platforms (eg. apple mps) misbehave due to a pytorch bug: https://github.com/pytorch/pytorch/pull/99272
|
933
|
+
latents = latents.to(latents_dtype)
|
922
934
|
|
923
935
|
# call the callback, if provided
|
924
936
|
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
|
@@ -937,6 +949,10 @@ class StableDiffusionXLInstructPix2PixPipeline(
|
|
937
949
|
if needs_upcasting:
|
938
950
|
self.upcast_vae()
|
939
951
|
latents = latents.to(next(iter(self.vae.post_quant_conv.parameters())).dtype)
|
952
|
+
elif latents.dtype != self.vae.dtype:
|
953
|
+
if torch.backends.mps.is_available():
|
954
|
+
# some platforms (eg. apple mps) misbehave due to a pytorch bug: https://github.com/pytorch/pytorch/pull/99272
|
955
|
+
self.vae = self.vae.to(latents.dtype)
|
940
956
|
|
941
957
|
# unscale/denormalize the latents
|
942
958
|
# denormalize with the mean and std if available and not None
|
@@ -21,16 +21,22 @@ class StableDiffusionXLWatermarker:
|
|
21
21
|
|
22
22
|
self.encoder.set_watermark("bits", self.watermark)
|
23
23
|
|
24
|
-
def apply_watermark(self, images: torch.
|
24
|
+
def apply_watermark(self, images: torch.Tensor):
|
25
25
|
# can't encode images that are smaller than 256
|
26
26
|
if images.shape[-1] < 256:
|
27
27
|
return images
|
28
28
|
|
29
29
|
images = (255 * (images / 2 + 0.5)).cpu().permute(0, 2, 3, 1).float().numpy()
|
30
30
|
|
31
|
-
|
31
|
+
# Convert RGB to BGR, which is the channel order expected by the watermark encoder.
|
32
|
+
images = images[:, :, :, ::-1]
|
32
33
|
|
33
|
-
|
34
|
+
# Add watermark and convert BGR back to RGB
|
35
|
+
images = [self.encoder.encode(image, "dwtDct")[:, :, ::-1] for image in images]
|
36
|
+
|
37
|
+
images = np.array(images)
|
38
|
+
|
39
|
+
images = torch.from_numpy(images).permute(0, 3, 1, 2)
|
34
40
|
|
35
41
|
images = torch.clamp(2 * (images / 255 - 0.5), min=-1.0, max=1.0)
|
36
42
|
return images
|
@@ -21,11 +21,12 @@ import PIL.Image
|
|
21
21
|
import torch
|
22
22
|
from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection
|
23
23
|
|
24
|
-
from ...image_processor import PipelineImageInput
|
24
|
+
from ...image_processor import PipelineImageInput
|
25
25
|
from ...models import AutoencoderKLTemporalDecoder, UNetSpatioTemporalConditionModel
|
26
26
|
from ...schedulers import EulerDiscreteScheduler
|
27
27
|
from ...utils import BaseOutput, logging, replace_example_docstring
|
28
28
|
from ...utils.torch_utils import is_compiled_module, randn_tensor
|
29
|
+
from ...video_processor import VideoProcessor
|
29
30
|
from ..pipeline_utils import DiffusionPipeline
|
30
31
|
|
31
32
|
|
@@ -37,10 +38,14 @@ EXAMPLE_DOC_STRING = """
|
|
37
38
|
>>> from diffusers import StableVideoDiffusionPipeline
|
38
39
|
>>> from diffusers.utils import load_image, export_to_video
|
39
40
|
|
40
|
-
>>> pipe = StableVideoDiffusionPipeline.from_pretrained(
|
41
|
+
>>> pipe = StableVideoDiffusionPipeline.from_pretrained(
|
42
|
+
... "stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
|
43
|
+
... )
|
41
44
|
>>> pipe.to("cuda")
|
42
45
|
|
43
|
-
>>> image = load_image(
|
46
|
+
>>> image = load_image(
|
47
|
+
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/svd-docstring-example.jpeg"
|
48
|
+
... )
|
44
49
|
>>> image = image.resize((1024, 576))
|
45
50
|
|
46
51
|
>>> frames = pipe(image, num_frames=25, decode_chunk_size=8).frames[0]
|
@@ -57,26 +62,64 @@ def _append_dims(x, target_dims):
|
|
57
62
|
return x[(...,) + (None,) * dims_to_append]
|
58
63
|
|
59
64
|
|
60
|
-
# Copied from diffusers.pipelines.
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
elif output_type == "pt":
|
74
|
-
outputs = torch.stack(outputs)
|
75
|
-
|
76
|
-
elif not output_type == "pil":
|
77
|
-
raise ValueError(f"{output_type} does not exist. Please choose one of ['np', 'pt', 'pil']")
|
65
|
+
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.retrieve_timesteps
|
66
|
+
def retrieve_timesteps(
|
67
|
+
scheduler,
|
68
|
+
num_inference_steps: Optional[int] = None,
|
69
|
+
device: Optional[Union[str, torch.device]] = None,
|
70
|
+
timesteps: Optional[List[int]] = None,
|
71
|
+
sigmas: Optional[List[float]] = None,
|
72
|
+
**kwargs,
|
73
|
+
):
|
74
|
+
r"""
|
75
|
+
Calls the scheduler's `set_timesteps` method and retrieves timesteps from the scheduler after the call. Handles
|
76
|
+
custom timesteps. Any kwargs will be supplied to `scheduler.set_timesteps`.
|
78
77
|
|
79
|
-
|
78
|
+
Args:
|
79
|
+
scheduler (`SchedulerMixin`):
|
80
|
+
The scheduler to get timesteps from.
|
81
|
+
num_inference_steps (`int`):
|
82
|
+
The number of diffusion steps used when generating samples with a pre-trained model. If used, `timesteps`
|
83
|
+
must be `None`.
|
84
|
+
device (`str` or `torch.device`, *optional*):
|
85
|
+
The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
|
86
|
+
timesteps (`List[int]`, *optional*):
|
87
|
+
Custom timesteps used to override the timestep spacing strategy of the scheduler. If `timesteps` is passed,
|
88
|
+
`num_inference_steps` and `sigmas` must be `None`.
|
89
|
+
sigmas (`List[float]`, *optional*):
|
90
|
+
Custom sigmas used to override the timestep spacing strategy of the scheduler. If `sigmas` is passed,
|
91
|
+
`num_inference_steps` and `timesteps` must be `None`.
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
`Tuple[torch.Tensor, int]`: A tuple where the first element is the timestep schedule from the scheduler and the
|
95
|
+
second element is the number of inference steps.
|
96
|
+
"""
|
97
|
+
if timesteps is not None and sigmas is not None:
|
98
|
+
raise ValueError("Only one of `timesteps` or `sigmas` can be passed. Please choose one to set custom values")
|
99
|
+
if timesteps is not None:
|
100
|
+
accepts_timesteps = "timesteps" in set(inspect.signature(scheduler.set_timesteps).parameters.keys())
|
101
|
+
if not accepts_timesteps:
|
102
|
+
raise ValueError(
|
103
|
+
f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom"
|
104
|
+
f" timestep schedules. Please check whether you are using the correct scheduler."
|
105
|
+
)
|
106
|
+
scheduler.set_timesteps(timesteps=timesteps, device=device, **kwargs)
|
107
|
+
timesteps = scheduler.timesteps
|
108
|
+
num_inference_steps = len(timesteps)
|
109
|
+
elif sigmas is not None:
|
110
|
+
accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys())
|
111
|
+
if not accept_sigmas:
|
112
|
+
raise ValueError(
|
113
|
+
f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom"
|
114
|
+
f" sigmas schedules. Please check whether you are using the correct scheduler."
|
115
|
+
)
|
116
|
+
scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs)
|
117
|
+
timesteps = scheduler.timesteps
|
118
|
+
num_inference_steps = len(timesteps)
|
119
|
+
else:
|
120
|
+
scheduler.set_timesteps(num_inference_steps, device=device, **kwargs)
|
121
|
+
timesteps = scheduler.timesteps
|
122
|
+
return timesteps, num_inference_steps
|
80
123
|
|
81
124
|
|
82
125
|
@dataclass
|
@@ -85,12 +128,12 @@ class StableVideoDiffusionPipelineOutput(BaseOutput):
|
|
85
128
|
Output class for Stable Video Diffusion pipeline.
|
86
129
|
|
87
130
|
Args:
|
88
|
-
frames (`[List[List[PIL.Image.Image]]`, `np.ndarray`, `torch.
|
89
|
-
List of denoised PIL images of length `batch_size` or numpy array or torch tensor
|
90
|
-
|
131
|
+
frames (`[List[List[PIL.Image.Image]]`, `np.ndarray`, `torch.Tensor`]):
|
132
|
+
List of denoised PIL images of length `batch_size` or numpy array or torch tensor of shape `(batch_size,
|
133
|
+
num_frames, height, width, num_channels)`.
|
91
134
|
"""
|
92
135
|
|
93
|
-
frames: Union[List[List[PIL.Image.Image]], np.ndarray, torch.
|
136
|
+
frames: Union[List[List[PIL.Image.Image]], np.ndarray, torch.Tensor]
|
94
137
|
|
95
138
|
|
96
139
|
class StableVideoDiffusionPipeline(DiffusionPipeline):
|
@@ -104,7 +147,8 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
104
147
|
vae ([`AutoencoderKLTemporalDecoder`]):
|
105
148
|
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
|
106
149
|
image_encoder ([`~transformers.CLIPVisionModelWithProjection`]):
|
107
|
-
Frozen CLIP image-encoder
|
150
|
+
Frozen CLIP image-encoder
|
151
|
+
([laion/CLIP-ViT-H-14-laion2B-s32B-b79K](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K)).
|
108
152
|
unet ([`UNetSpatioTemporalConditionModel`]):
|
109
153
|
A `UNetSpatioTemporalConditionModel` to denoise the encoded image latents.
|
110
154
|
scheduler ([`EulerDiscreteScheduler`]):
|
@@ -134,7 +178,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
134
178
|
feature_extractor=feature_extractor,
|
135
179
|
)
|
136
180
|
self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
|
137
|
-
self.
|
181
|
+
self.video_processor = VideoProcessor(do_resize=True, vae_scale_factor=self.vae_scale_factor)
|
138
182
|
|
139
183
|
def _encode_image(
|
140
184
|
self,
|
@@ -142,12 +186,12 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
142
186
|
device: Union[str, torch.device],
|
143
187
|
num_videos_per_prompt: int,
|
144
188
|
do_classifier_free_guidance: bool,
|
145
|
-
) -> torch.
|
189
|
+
) -> torch.Tensor:
|
146
190
|
dtype = next(self.image_encoder.parameters()).dtype
|
147
191
|
|
148
192
|
if not isinstance(image, torch.Tensor):
|
149
|
-
image = self.
|
150
|
-
image = self.
|
193
|
+
image = self.video_processor.pil_to_numpy(image)
|
194
|
+
image = self.video_processor.numpy_to_pt(image)
|
151
195
|
|
152
196
|
# We normalize the image before resizing to match with the original implementation.
|
153
197
|
# Then we unnormalize it after resizing.
|
@@ -194,6 +238,9 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
194
238
|
image = image.to(device=device)
|
195
239
|
image_latents = self.vae.encode(image).latent_dist.mode()
|
196
240
|
|
241
|
+
# duplicate image_latents for each generation per prompt, using mps friendly method
|
242
|
+
image_latents = image_latents.repeat(num_videos_per_prompt, 1, 1, 1)
|
243
|
+
|
197
244
|
if do_classifier_free_guidance:
|
198
245
|
negative_image_latents = torch.zeros_like(image_latents)
|
199
246
|
|
@@ -202,9 +249,6 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
202
249
|
# to avoid doing two forward passes
|
203
250
|
image_latents = torch.cat([negative_image_latents, image_latents])
|
204
251
|
|
205
|
-
# duplicate image_latents for each generation per prompt, using mps friendly method
|
206
|
-
image_latents = image_latents.repeat(num_videos_per_prompt, 1, 1, 1)
|
207
|
-
|
208
252
|
return image_latents
|
209
253
|
|
210
254
|
def _get_add_time_ids(
|
@@ -235,7 +279,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
235
279
|
|
236
280
|
return add_time_ids
|
237
281
|
|
238
|
-
def decode_latents(self, latents: torch.
|
282
|
+
def decode_latents(self, latents: torch.Tensor, num_frames: int, decode_chunk_size: int = 14):
|
239
283
|
# [batch, frames, channels, height, width] -> [batch*frames, channels, height, width]
|
240
284
|
latents = latents.flatten(0, 1)
|
241
285
|
|
@@ -271,7 +315,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
271
315
|
and not isinstance(image, list)
|
272
316
|
):
|
273
317
|
raise ValueError(
|
274
|
-
"`image` has to be of type `torch.
|
318
|
+
"`image` has to be of type `torch.Tensor` or `PIL.Image.Image` or `List[PIL.Image.Image]` but is"
|
275
319
|
f" {type(image)}"
|
276
320
|
)
|
277
321
|
|
@@ -288,7 +332,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
288
332
|
dtype: torch.dtype,
|
289
333
|
device: Union[str, torch.device],
|
290
334
|
generator: torch.Generator,
|
291
|
-
latents: Optional[torch.
|
335
|
+
latents: Optional[torch.Tensor] = None,
|
292
336
|
):
|
293
337
|
shape = (
|
294
338
|
batch_size,
|
@@ -333,11 +377,12 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
333
377
|
@replace_example_docstring(EXAMPLE_DOC_STRING)
|
334
378
|
def __call__(
|
335
379
|
self,
|
336
|
-
image: Union[PIL.Image.Image, List[PIL.Image.Image], torch.
|
380
|
+
image: Union[PIL.Image.Image, List[PIL.Image.Image], torch.Tensor],
|
337
381
|
height: int = 576,
|
338
382
|
width: int = 1024,
|
339
383
|
num_frames: Optional[int] = None,
|
340
384
|
num_inference_steps: int = 25,
|
385
|
+
sigmas: Optional[List[float]] = None,
|
341
386
|
min_guidance_scale: float = 1.0,
|
342
387
|
max_guidance_scale: float = 3.0,
|
343
388
|
fps: int = 7,
|
@@ -346,7 +391,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
346
391
|
decode_chunk_size: Optional[int] = None,
|
347
392
|
num_videos_per_prompt: Optional[int] = 1,
|
348
393
|
generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
|
349
|
-
latents: Optional[torch.
|
394
|
+
latents: Optional[torch.Tensor] = None,
|
350
395
|
output_type: Optional[str] = "pil",
|
351
396
|
callback_on_step_end: Optional[Callable[[int, int, Dict], None]] = None,
|
352
397
|
callback_on_step_end_tensor_inputs: List[str] = ["latents"],
|
@@ -356,39 +401,46 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
356
401
|
The call function to the pipeline for generation.
|
357
402
|
|
358
403
|
Args:
|
359
|
-
image (`PIL.Image.Image` or `List[PIL.Image.Image]` or `torch.
|
360
|
-
Image(s) to guide image generation. If you provide a tensor, the expected value range is between `[0,
|
404
|
+
image (`PIL.Image.Image` or `List[PIL.Image.Image]` or `torch.Tensor`):
|
405
|
+
Image(s) to guide image generation. If you provide a tensor, the expected value range is between `[0,
|
406
|
+
1]`.
|
361
407
|
height (`int`, *optional*, defaults to `self.unet.config.sample_size * self.vae_scale_factor`):
|
362
408
|
The height in pixels of the generated image.
|
363
409
|
width (`int`, *optional*, defaults to `self.unet.config.sample_size * self.vae_scale_factor`):
|
364
410
|
The width in pixels of the generated image.
|
365
411
|
num_frames (`int`, *optional*):
|
366
|
-
The number of video frames to generate. Defaults to `self.unet.config.num_frames`
|
367
|
-
|
412
|
+
The number of video frames to generate. Defaults to `self.unet.config.num_frames` (14 for
|
413
|
+
`stable-video-diffusion-img2vid` and to 25 for `stable-video-diffusion-img2vid-xt`).
|
368
414
|
num_inference_steps (`int`, *optional*, defaults to 25):
|
369
415
|
The number of denoising steps. More denoising steps usually lead to a higher quality video at the
|
370
416
|
expense of slower inference. This parameter is modulated by `strength`.
|
417
|
+
sigmas (`List[float]`, *optional*):
|
418
|
+
Custom sigmas to use for the denoising process with schedulers which support a `sigmas` argument in
|
419
|
+
their `set_timesteps` method. If not defined, the default behavior when `num_inference_steps` is passed
|
420
|
+
will be used.
|
371
421
|
min_guidance_scale (`float`, *optional*, defaults to 1.0):
|
372
422
|
The minimum guidance scale. Used for the classifier free guidance with first frame.
|
373
423
|
max_guidance_scale (`float`, *optional*, defaults to 3.0):
|
374
424
|
The maximum guidance scale. Used for the classifier free guidance with last frame.
|
375
425
|
fps (`int`, *optional*, defaults to 7):
|
376
|
-
Frames per second. The rate at which the generated images shall be exported to a video after
|
377
|
-
Note that Stable Diffusion Video's UNet was micro-conditioned on fps-1 during training.
|
426
|
+
Frames per second. The rate at which the generated images shall be exported to a video after
|
427
|
+
generation. Note that Stable Diffusion Video's UNet was micro-conditioned on fps-1 during training.
|
378
428
|
motion_bucket_id (`int`, *optional*, defaults to 127):
|
379
429
|
Used for conditioning the amount of motion for the generation. The higher the number the more motion
|
380
430
|
will be in the video.
|
381
431
|
noise_aug_strength (`float`, *optional*, defaults to 0.02):
|
382
|
-
The amount of noise added to the init image, the higher it is the less the video will look like the
|
432
|
+
The amount of noise added to the init image, the higher it is the less the video will look like the
|
433
|
+
init image. Increase it for more motion.
|
383
434
|
decode_chunk_size (`int`, *optional*):
|
384
|
-
The number of frames to decode at a time. Higher chunk size leads to better temporal consistency at the
|
385
|
-
|
435
|
+
The number of frames to decode at a time. Higher chunk size leads to better temporal consistency at the
|
436
|
+
expense of more memory usage. By default, the decoder decodes all frames at once for maximal quality.
|
437
|
+
For lower memory usage, reduce `decode_chunk_size`.
|
386
438
|
num_videos_per_prompt (`int`, *optional*, defaults to 1):
|
387
439
|
The number of videos to generate per prompt.
|
388
440
|
generator (`torch.Generator` or `List[torch.Generator]`, *optional*):
|
389
441
|
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make
|
390
442
|
generation deterministic.
|
391
|
-
latents (`torch.
|
443
|
+
latents (`torch.Tensor`, *optional*):
|
392
444
|
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for video
|
393
445
|
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
|
394
446
|
tensor is generated by sampling using the supplied random `generator`.
|
@@ -398,7 +450,8 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
398
450
|
A function that is called at the end of each denoising step during inference. The function is called
|
399
451
|
with the following arguments:
|
400
452
|
`callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`.
|
401
|
-
`callback_kwargs` will include a list of all tensors as specified by
|
453
|
+
`callback_kwargs` will include a list of all tensors as specified by
|
454
|
+
`callback_on_step_end_tensor_inputs`.
|
402
455
|
callback_on_step_end_tensor_inputs (`List`, *optional*):
|
403
456
|
The list of tensor inputs for the `callback_on_step_end` function. The tensors specified in the list
|
404
457
|
will be passed as `callback_kwargs` argument. You will only be able to include variables listed in the
|
@@ -411,8 +464,9 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
411
464
|
|
412
465
|
Returns:
|
413
466
|
[`~pipelines.stable_diffusion.StableVideoDiffusionPipelineOutput`] or `tuple`:
|
414
|
-
If `return_dict` is `True`, [`~pipelines.stable_diffusion.StableVideoDiffusionPipelineOutput`] is
|
415
|
-
otherwise a `tuple` of (`List[List[PIL.Image.Image]]` or `np.ndarray` or `torch.
|
467
|
+
If `return_dict` is `True`, [`~pipelines.stable_diffusion.StableVideoDiffusionPipelineOutput`] is
|
468
|
+
returned, otherwise a `tuple` of (`List[List[PIL.Image.Image]]` or `np.ndarray` or `torch.Tensor`) is
|
469
|
+
returned.
|
416
470
|
"""
|
417
471
|
# 0. Default height and width to unet
|
418
472
|
height = height or self.unet.config.sample_size * self.vae_scale_factor
|
@@ -445,7 +499,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
445
499
|
fps = fps - 1
|
446
500
|
|
447
501
|
# 4. Encode input image using VAE
|
448
|
-
image = self.
|
502
|
+
image = self.video_processor.preprocess(image, height=height, width=width).to(device)
|
449
503
|
noise = randn_tensor(image.shape, generator=generator, device=device, dtype=image.dtype)
|
450
504
|
image = image + noise_aug_strength * noise
|
451
505
|
|
@@ -482,8 +536,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
482
536
|
added_time_ids = added_time_ids.to(device)
|
483
537
|
|
484
538
|
# 6. Prepare timesteps
|
485
|
-
self.scheduler
|
486
|
-
timesteps = self.scheduler.timesteps
|
539
|
+
timesteps, num_inference_steps = retrieve_timesteps(self.scheduler, num_inference_steps, device, None, sigmas)
|
487
540
|
|
488
541
|
# 7. Prepare latent variables
|
489
542
|
num_channels_latents = self.unet.config.in_channels
|
@@ -552,7 +605,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
|
|
552
605
|
if needs_upcasting:
|
553
606
|
self.vae.to(dtype=torch.float16)
|
554
607
|
frames = self.decode_latents(latents, num_frames, decode_chunk_size)
|
555
|
-
frames =
|
608
|
+
frames = self.video_processor.postprocess_video(video=frames, output_type=output_type)
|
556
609
|
else:
|
557
610
|
frames = latents
|
558
611
|
|
@@ -627,7 +680,7 @@ def _filter2d(input, kernel):
|
|
627
680
|
|
628
681
|
height, width = tmp_kernel.shape[-2:]
|
629
682
|
|
630
|
-
padding_shape:
|
683
|
+
padding_shape: List[int] = _compute_padding([height, width])
|
631
684
|
input = torch.nn.functional.pad(input, padding_shape, mode="reflect")
|
632
685
|
|
633
686
|
# kernel and input tensor reshape to align element-wise or batch-wise params
|