diffusers 0.27.0__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.
Files changed (445) hide show
  1. diffusers/__init__.py +233 -6
  2. diffusers/callbacks.py +209 -0
  3. diffusers/commands/env.py +102 -6
  4. diffusers/configuration_utils.py +45 -16
  5. diffusers/dependency_versions_table.py +4 -3
  6. diffusers/image_processor.py +434 -110
  7. diffusers/loaders/__init__.py +42 -9
  8. diffusers/loaders/ip_adapter.py +626 -36
  9. diffusers/loaders/lora_base.py +900 -0
  10. diffusers/loaders/lora_conversion_utils.py +991 -125
  11. diffusers/loaders/lora_pipeline.py +3812 -0
  12. diffusers/loaders/peft.py +571 -7
  13. diffusers/loaders/single_file.py +405 -173
  14. diffusers/loaders/single_file_model.py +385 -0
  15. diffusers/loaders/single_file_utils.py +1783 -713
  16. diffusers/loaders/textual_inversion.py +41 -23
  17. diffusers/loaders/transformer_flux.py +181 -0
  18. diffusers/loaders/transformer_sd3.py +89 -0
  19. diffusers/loaders/unet.py +464 -540
  20. diffusers/loaders/unet_loader_utils.py +163 -0
  21. diffusers/models/__init__.py +76 -7
  22. diffusers/models/activations.py +65 -10
  23. diffusers/models/adapter.py +53 -53
  24. diffusers/models/attention.py +605 -18
  25. diffusers/models/attention_flax.py +1 -1
  26. diffusers/models/attention_processor.py +4304 -687
  27. diffusers/models/autoencoders/__init__.py +8 -0
  28. diffusers/models/autoencoders/autoencoder_asym_kl.py +15 -17
  29. diffusers/models/autoencoders/autoencoder_dc.py +620 -0
  30. diffusers/models/autoencoders/autoencoder_kl.py +110 -28
  31. diffusers/models/autoencoders/autoencoder_kl_allegro.py +1149 -0
  32. diffusers/models/autoencoders/autoencoder_kl_cogvideox.py +1482 -0
  33. diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.py +1176 -0
  34. diffusers/models/autoencoders/autoencoder_kl_ltx.py +1338 -0
  35. diffusers/models/autoencoders/autoencoder_kl_mochi.py +1166 -0
  36. diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +19 -24
  37. diffusers/models/autoencoders/autoencoder_oobleck.py +464 -0
  38. diffusers/models/autoencoders/autoencoder_tiny.py +21 -18
  39. diffusers/models/autoencoders/consistency_decoder_vae.py +45 -20
  40. diffusers/models/autoencoders/vae.py +41 -29
  41. diffusers/models/autoencoders/vq_model.py +182 -0
  42. diffusers/models/controlnet.py +47 -800
  43. diffusers/models/controlnet_flux.py +70 -0
  44. diffusers/models/controlnet_sd3.py +68 -0
  45. diffusers/models/controlnet_sparsectrl.py +116 -0
  46. diffusers/models/controlnets/__init__.py +23 -0
  47. diffusers/models/controlnets/controlnet.py +872 -0
  48. diffusers/models/{controlnet_flax.py → controlnets/controlnet_flax.py} +9 -9
  49. diffusers/models/controlnets/controlnet_flux.py +536 -0
  50. diffusers/models/controlnets/controlnet_hunyuan.py +401 -0
  51. diffusers/models/controlnets/controlnet_sd3.py +489 -0
  52. diffusers/models/controlnets/controlnet_sparsectrl.py +788 -0
  53. diffusers/models/controlnets/controlnet_union.py +832 -0
  54. diffusers/models/controlnets/controlnet_xs.py +1946 -0
  55. diffusers/models/controlnets/multicontrolnet.py +183 -0
  56. diffusers/models/downsampling.py +85 -18
  57. diffusers/models/embeddings.py +1856 -158
  58. diffusers/models/embeddings_flax.py +23 -9
  59. diffusers/models/model_loading_utils.py +480 -0
  60. diffusers/models/modeling_flax_pytorch_utils.py +2 -1
  61. diffusers/models/modeling_flax_utils.py +2 -7
  62. diffusers/models/modeling_outputs.py +14 -0
  63. diffusers/models/modeling_pytorch_flax_utils.py +1 -1
  64. diffusers/models/modeling_utils.py +611 -146
  65. diffusers/models/normalization.py +361 -20
  66. diffusers/models/resnet.py +18 -23
  67. diffusers/models/transformers/__init__.py +16 -0
  68. diffusers/models/transformers/auraflow_transformer_2d.py +544 -0
  69. diffusers/models/transformers/cogvideox_transformer_3d.py +542 -0
  70. diffusers/models/transformers/dit_transformer_2d.py +240 -0
  71. diffusers/models/transformers/dual_transformer_2d.py +9 -8
  72. diffusers/models/transformers/hunyuan_transformer_2d.py +578 -0
  73. diffusers/models/transformers/latte_transformer_3d.py +327 -0
  74. diffusers/models/transformers/lumina_nextdit2d.py +340 -0
  75. diffusers/models/transformers/pixart_transformer_2d.py +445 -0
  76. diffusers/models/transformers/prior_transformer.py +13 -13
  77. diffusers/models/transformers/sana_transformer.py +488 -0
  78. diffusers/models/transformers/stable_audio_transformer.py +458 -0
  79. diffusers/models/transformers/t5_film_transformer.py +17 -19
  80. diffusers/models/transformers/transformer_2d.py +297 -187
  81. diffusers/models/transformers/transformer_allegro.py +422 -0
  82. diffusers/models/transformers/transformer_cogview3plus.py +386 -0
  83. diffusers/models/transformers/transformer_flux.py +593 -0
  84. diffusers/models/transformers/transformer_hunyuan_video.py +791 -0
  85. diffusers/models/transformers/transformer_ltx.py +469 -0
  86. diffusers/models/transformers/transformer_mochi.py +499 -0
  87. diffusers/models/transformers/transformer_sd3.py +461 -0
  88. diffusers/models/transformers/transformer_temporal.py +21 -19
  89. diffusers/models/unets/unet_1d.py +8 -8
  90. diffusers/models/unets/unet_1d_blocks.py +31 -31
  91. diffusers/models/unets/unet_2d.py +17 -10
  92. diffusers/models/unets/unet_2d_blocks.py +225 -149
  93. diffusers/models/unets/unet_2d_condition.py +50 -53
  94. diffusers/models/unets/unet_2d_condition_flax.py +6 -5
  95. diffusers/models/unets/unet_3d_blocks.py +192 -1057
  96. diffusers/models/unets/unet_3d_condition.py +22 -27
  97. diffusers/models/unets/unet_i2vgen_xl.py +22 -18
  98. diffusers/models/unets/unet_kandinsky3.py +2 -2
  99. diffusers/models/unets/unet_motion_model.py +1413 -89
  100. diffusers/models/unets/unet_spatio_temporal_condition.py +40 -16
  101. diffusers/models/unets/unet_stable_cascade.py +19 -18
  102. diffusers/models/unets/uvit_2d.py +2 -2
  103. diffusers/models/upsampling.py +95 -26
  104. diffusers/models/vq_model.py +12 -164
  105. diffusers/optimization.py +1 -1
  106. diffusers/pipelines/__init__.py +202 -3
  107. diffusers/pipelines/allegro/__init__.py +48 -0
  108. diffusers/pipelines/allegro/pipeline_allegro.py +938 -0
  109. diffusers/pipelines/allegro/pipeline_output.py +23 -0
  110. diffusers/pipelines/amused/pipeline_amused.py +12 -12
  111. diffusers/pipelines/amused/pipeline_amused_img2img.py +14 -12
  112. diffusers/pipelines/amused/pipeline_amused_inpaint.py +13 -11
  113. diffusers/pipelines/animatediff/__init__.py +8 -0
  114. diffusers/pipelines/animatediff/pipeline_animatediff.py +122 -109
  115. diffusers/pipelines/animatediff/pipeline_animatediff_controlnet.py +1106 -0
  116. diffusers/pipelines/animatediff/pipeline_animatediff_sdxl.py +1288 -0
  117. diffusers/pipelines/animatediff/pipeline_animatediff_sparsectrl.py +1010 -0
  118. diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +236 -180
  119. diffusers/pipelines/animatediff/pipeline_animatediff_video2video_controlnet.py +1341 -0
  120. diffusers/pipelines/animatediff/pipeline_output.py +3 -2
  121. diffusers/pipelines/audioldm/pipeline_audioldm.py +14 -14
  122. diffusers/pipelines/audioldm2/modeling_audioldm2.py +58 -39
  123. diffusers/pipelines/audioldm2/pipeline_audioldm2.py +121 -36
  124. diffusers/pipelines/aura_flow/__init__.py +48 -0
  125. diffusers/pipelines/aura_flow/pipeline_aura_flow.py +584 -0
  126. diffusers/pipelines/auto_pipeline.py +196 -28
  127. diffusers/pipelines/blip_diffusion/blip_image_processing.py +1 -1
  128. diffusers/pipelines/blip_diffusion/modeling_blip2.py +6 -6
  129. diffusers/pipelines/blip_diffusion/modeling_ctx_clip.py +1 -1
  130. diffusers/pipelines/blip_diffusion/pipeline_blip_diffusion.py +2 -2
  131. diffusers/pipelines/cogvideo/__init__.py +54 -0
  132. diffusers/pipelines/cogvideo/pipeline_cogvideox.py +772 -0
  133. diffusers/pipelines/cogvideo/pipeline_cogvideox_fun_control.py +825 -0
  134. diffusers/pipelines/cogvideo/pipeline_cogvideox_image2video.py +885 -0
  135. diffusers/pipelines/cogvideo/pipeline_cogvideox_video2video.py +851 -0
  136. diffusers/pipelines/cogvideo/pipeline_output.py +20 -0
  137. diffusers/pipelines/cogview3/__init__.py +47 -0
  138. diffusers/pipelines/cogview3/pipeline_cogview3plus.py +674 -0
  139. diffusers/pipelines/cogview3/pipeline_output.py +21 -0
  140. diffusers/pipelines/consistency_models/pipeline_consistency_models.py +6 -6
  141. diffusers/pipelines/controlnet/__init__.py +86 -80
  142. diffusers/pipelines/controlnet/multicontrolnet.py +7 -182
  143. diffusers/pipelines/controlnet/pipeline_controlnet.py +134 -87
  144. diffusers/pipelines/controlnet/pipeline_controlnet_blip_diffusion.py +2 -2
  145. diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +93 -77
  146. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +88 -197
  147. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +136 -90
  148. diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +176 -80
  149. diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +125 -89
  150. diffusers/pipelines/controlnet/pipeline_controlnet_union_inpaint_sd_xl.py +1790 -0
  151. diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl.py +1501 -0
  152. diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl_img2img.py +1627 -0
  153. diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
  154. diffusers/pipelines/controlnet_hunyuandit/__init__.py +48 -0
  155. diffusers/pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py +1060 -0
  156. diffusers/pipelines/controlnet_sd3/__init__.py +57 -0
  157. diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +1133 -0
  158. diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py +1153 -0
  159. diffusers/pipelines/controlnet_xs/__init__.py +68 -0
  160. diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +916 -0
  161. diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_sd_xl.py +1111 -0
  162. diffusers/pipelines/ddpm/pipeline_ddpm.py +2 -2
  163. diffusers/pipelines/deepfloyd_if/pipeline_if.py +16 -30
  164. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +20 -35
  165. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +23 -41
  166. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +22 -38
  167. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +25 -41
  168. diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +19 -34
  169. diffusers/pipelines/deepfloyd_if/pipeline_output.py +6 -5
  170. diffusers/pipelines/deepfloyd_if/watermark.py +1 -1
  171. diffusers/pipelines/deprecated/alt_diffusion/modeling_roberta_series.py +11 -11
  172. diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +70 -30
  173. diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +48 -25
  174. diffusers/pipelines/deprecated/repaint/pipeline_repaint.py +2 -2
  175. diffusers/pipelines/deprecated/spectrogram_diffusion/pipeline_spectrogram_diffusion.py +7 -7
  176. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +21 -20
  177. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +27 -29
  178. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +33 -27
  179. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +33 -23
  180. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +36 -30
  181. diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +102 -69
  182. diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion.py +13 -13
  183. diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_dual_guided.py +10 -5
  184. diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_image_variation.py +11 -6
  185. diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_text_to_image.py +10 -5
  186. diffusers/pipelines/deprecated/vq_diffusion/pipeline_vq_diffusion.py +5 -5
  187. diffusers/pipelines/dit/pipeline_dit.py +7 -4
  188. diffusers/pipelines/flux/__init__.py +69 -0
  189. diffusers/pipelines/flux/modeling_flux.py +47 -0
  190. diffusers/pipelines/flux/pipeline_flux.py +957 -0
  191. diffusers/pipelines/flux/pipeline_flux_control.py +889 -0
  192. diffusers/pipelines/flux/pipeline_flux_control_img2img.py +945 -0
  193. diffusers/pipelines/flux/pipeline_flux_control_inpaint.py +1141 -0
  194. diffusers/pipelines/flux/pipeline_flux_controlnet.py +1006 -0
  195. diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py +998 -0
  196. diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py +1204 -0
  197. diffusers/pipelines/flux/pipeline_flux_fill.py +969 -0
  198. diffusers/pipelines/flux/pipeline_flux_img2img.py +856 -0
  199. diffusers/pipelines/flux/pipeline_flux_inpaint.py +1022 -0
  200. diffusers/pipelines/flux/pipeline_flux_prior_redux.py +492 -0
  201. diffusers/pipelines/flux/pipeline_output.py +37 -0
  202. diffusers/pipelines/free_init_utils.py +41 -38
  203. diffusers/pipelines/free_noise_utils.py +596 -0
  204. diffusers/pipelines/hunyuan_video/__init__.py +48 -0
  205. diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py +687 -0
  206. diffusers/pipelines/hunyuan_video/pipeline_output.py +20 -0
  207. diffusers/pipelines/hunyuandit/__init__.py +48 -0
  208. diffusers/pipelines/hunyuandit/pipeline_hunyuandit.py +916 -0
  209. diffusers/pipelines/i2vgen_xl/pipeline_i2vgen_xl.py +33 -48
  210. diffusers/pipelines/kandinsky/pipeline_kandinsky.py +8 -8
  211. diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +32 -29
  212. diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py +11 -11
  213. diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py +12 -12
  214. diffusers/pipelines/kandinsky/pipeline_kandinsky_prior.py +10 -10
  215. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +6 -6
  216. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +34 -31
  217. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py +10 -10
  218. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +10 -10
  219. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +6 -6
  220. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpainting.py +8 -8
  221. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior.py +7 -7
  222. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior_emb2emb.py +6 -6
  223. diffusers/pipelines/kandinsky3/convert_kandinsky3_unet.py +3 -3
  224. diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +22 -35
  225. diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +26 -37
  226. diffusers/pipelines/kolors/__init__.py +54 -0
  227. diffusers/pipelines/kolors/pipeline_kolors.py +1070 -0
  228. diffusers/pipelines/kolors/pipeline_kolors_img2img.py +1250 -0
  229. diffusers/pipelines/kolors/pipeline_output.py +21 -0
  230. diffusers/pipelines/kolors/text_encoder.py +889 -0
  231. diffusers/pipelines/kolors/tokenizer.py +338 -0
  232. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +82 -62
  233. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +77 -60
  234. diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +12 -12
  235. diffusers/pipelines/latte/__init__.py +48 -0
  236. diffusers/pipelines/latte/pipeline_latte.py +881 -0
  237. diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +80 -74
  238. diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +85 -76
  239. diffusers/pipelines/ledits_pp/pipeline_output.py +2 -2
  240. diffusers/pipelines/ltx/__init__.py +50 -0
  241. diffusers/pipelines/ltx/pipeline_ltx.py +789 -0
  242. diffusers/pipelines/ltx/pipeline_ltx_image2video.py +885 -0
  243. diffusers/pipelines/ltx/pipeline_output.py +20 -0
  244. diffusers/pipelines/lumina/__init__.py +48 -0
  245. diffusers/pipelines/lumina/pipeline_lumina.py +890 -0
  246. diffusers/pipelines/marigold/__init__.py +50 -0
  247. diffusers/pipelines/marigold/marigold_image_processing.py +576 -0
  248. diffusers/pipelines/marigold/pipeline_marigold_depth.py +813 -0
  249. diffusers/pipelines/marigold/pipeline_marigold_normals.py +690 -0
  250. diffusers/pipelines/mochi/__init__.py +48 -0
  251. diffusers/pipelines/mochi/pipeline_mochi.py +748 -0
  252. diffusers/pipelines/mochi/pipeline_output.py +20 -0
  253. diffusers/pipelines/musicldm/pipeline_musicldm.py +14 -14
  254. diffusers/pipelines/pag/__init__.py +80 -0
  255. diffusers/pipelines/pag/pag_utils.py +243 -0
  256. diffusers/pipelines/pag/pipeline_pag_controlnet_sd.py +1328 -0
  257. diffusers/pipelines/pag/pipeline_pag_controlnet_sd_inpaint.py +1543 -0
  258. diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl.py +1610 -0
  259. diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl_img2img.py +1683 -0
  260. diffusers/pipelines/pag/pipeline_pag_hunyuandit.py +969 -0
  261. diffusers/pipelines/pag/pipeline_pag_kolors.py +1136 -0
  262. diffusers/pipelines/pag/pipeline_pag_pixart_sigma.py +865 -0
  263. diffusers/pipelines/pag/pipeline_pag_sana.py +886 -0
  264. diffusers/pipelines/pag/pipeline_pag_sd.py +1062 -0
  265. diffusers/pipelines/pag/pipeline_pag_sd_3.py +994 -0
  266. diffusers/pipelines/pag/pipeline_pag_sd_3_img2img.py +1058 -0
  267. diffusers/pipelines/pag/pipeline_pag_sd_animatediff.py +866 -0
  268. diffusers/pipelines/pag/pipeline_pag_sd_img2img.py +1094 -0
  269. diffusers/pipelines/pag/pipeline_pag_sd_inpaint.py +1356 -0
  270. diffusers/pipelines/pag/pipeline_pag_sd_xl.py +1345 -0
  271. diffusers/pipelines/pag/pipeline_pag_sd_xl_img2img.py +1544 -0
  272. diffusers/pipelines/pag/pipeline_pag_sd_xl_inpaint.py +1776 -0
  273. diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py +17 -12
  274. diffusers/pipelines/pia/pipeline_pia.py +74 -164
  275. diffusers/pipelines/pipeline_flax_utils.py +5 -10
  276. diffusers/pipelines/pipeline_loading_utils.py +515 -53
  277. diffusers/pipelines/pipeline_utils.py +411 -222
  278. diffusers/pipelines/pixart_alpha/__init__.py +8 -1
  279. diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +76 -93
  280. diffusers/pipelines/pixart_alpha/pipeline_pixart_sigma.py +873 -0
  281. diffusers/pipelines/sana/__init__.py +47 -0
  282. diffusers/pipelines/sana/pipeline_output.py +21 -0
  283. diffusers/pipelines/sana/pipeline_sana.py +884 -0
  284. diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +27 -23
  285. diffusers/pipelines/shap_e/pipeline_shap_e.py +3 -3
  286. diffusers/pipelines/shap_e/pipeline_shap_e_img2img.py +14 -14
  287. diffusers/pipelines/shap_e/renderer.py +1 -1
  288. diffusers/pipelines/stable_audio/__init__.py +50 -0
  289. diffusers/pipelines/stable_audio/modeling_stable_audio.py +158 -0
  290. diffusers/pipelines/stable_audio/pipeline_stable_audio.py +756 -0
  291. diffusers/pipelines/stable_cascade/pipeline_stable_cascade.py +71 -25
  292. diffusers/pipelines/stable_cascade/pipeline_stable_cascade_combined.py +23 -19
  293. diffusers/pipelines/stable_cascade/pipeline_stable_cascade_prior.py +35 -34
  294. diffusers/pipelines/stable_diffusion/__init__.py +0 -1
  295. diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +20 -11
  296. diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
  297. diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py +2 -2
  298. diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py +6 -6
  299. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +145 -79
  300. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +43 -28
  301. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py +13 -8
  302. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +100 -68
  303. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +109 -201
  304. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +131 -32
  305. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py +247 -87
  306. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +30 -29
  307. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +35 -27
  308. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +49 -42
  309. diffusers/pipelines/stable_diffusion/safety_checker.py +2 -1
  310. diffusers/pipelines/stable_diffusion_3/__init__.py +54 -0
  311. diffusers/pipelines/stable_diffusion_3/pipeline_output.py +21 -0
  312. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +1140 -0
  313. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +1036 -0
  314. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1250 -0
  315. diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +29 -20
  316. diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +59 -58
  317. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +31 -25
  318. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +38 -22
  319. diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +30 -24
  320. diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +24 -23
  321. diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +107 -67
  322. diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +316 -69
  323. diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py +10 -5
  324. diffusers/pipelines/stable_diffusion_safe/safety_checker.py +1 -1
  325. diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +98 -30
  326. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +121 -83
  327. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +161 -105
  328. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +142 -218
  329. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +45 -29
  330. diffusers/pipelines/stable_diffusion_xl/watermark.py +9 -3
  331. diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +110 -57
  332. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +69 -39
  333. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +105 -74
  334. diffusers/pipelines/text_to_video_synthesis/pipeline_output.py +3 -2
  335. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +29 -49
  336. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +32 -93
  337. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +37 -25
  338. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +54 -40
  339. diffusers/pipelines/unclip/pipeline_unclip.py +6 -6
  340. diffusers/pipelines/unclip/pipeline_unclip_image_variation.py +6 -6
  341. diffusers/pipelines/unidiffuser/modeling_text_decoder.py +1 -1
  342. diffusers/pipelines/unidiffuser/modeling_uvit.py +12 -12
  343. diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +29 -28
  344. diffusers/pipelines/wuerstchen/modeling_paella_vq_model.py +5 -5
  345. diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py +5 -10
  346. diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +6 -8
  347. diffusers/pipelines/wuerstchen/pipeline_wuerstchen.py +4 -4
  348. diffusers/pipelines/wuerstchen/pipeline_wuerstchen_combined.py +12 -12
  349. diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +15 -14
  350. diffusers/{models/dual_transformer_2d.py → quantizers/__init__.py} +2 -6
  351. diffusers/quantizers/auto.py +139 -0
  352. diffusers/quantizers/base.py +233 -0
  353. diffusers/quantizers/bitsandbytes/__init__.py +2 -0
  354. diffusers/quantizers/bitsandbytes/bnb_quantizer.py +561 -0
  355. diffusers/quantizers/bitsandbytes/utils.py +306 -0
  356. diffusers/quantizers/gguf/__init__.py +1 -0
  357. diffusers/quantizers/gguf/gguf_quantizer.py +159 -0
  358. diffusers/quantizers/gguf/utils.py +456 -0
  359. diffusers/quantizers/quantization_config.py +669 -0
  360. diffusers/quantizers/torchao/__init__.py +15 -0
  361. diffusers/quantizers/torchao/torchao_quantizer.py +292 -0
  362. diffusers/schedulers/__init__.py +12 -2
  363. diffusers/schedulers/deprecated/__init__.py +1 -1
  364. diffusers/schedulers/deprecated/scheduling_karras_ve.py +25 -25
  365. diffusers/schedulers/scheduling_amused.py +5 -5
  366. diffusers/schedulers/scheduling_consistency_decoder.py +11 -11
  367. diffusers/schedulers/scheduling_consistency_models.py +23 -25
  368. diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py +572 -0
  369. diffusers/schedulers/scheduling_ddim.py +27 -26
  370. diffusers/schedulers/scheduling_ddim_cogvideox.py +452 -0
  371. diffusers/schedulers/scheduling_ddim_flax.py +2 -1
  372. diffusers/schedulers/scheduling_ddim_inverse.py +16 -16
  373. diffusers/schedulers/scheduling_ddim_parallel.py +32 -31
  374. diffusers/schedulers/scheduling_ddpm.py +27 -30
  375. diffusers/schedulers/scheduling_ddpm_flax.py +7 -3
  376. diffusers/schedulers/scheduling_ddpm_parallel.py +33 -36
  377. diffusers/schedulers/scheduling_ddpm_wuerstchen.py +14 -14
  378. diffusers/schedulers/scheduling_deis_multistep.py +150 -50
  379. diffusers/schedulers/scheduling_dpm_cogvideox.py +489 -0
  380. diffusers/schedulers/scheduling_dpmsolver_multistep.py +221 -84
  381. diffusers/schedulers/scheduling_dpmsolver_multistep_flax.py +2 -2
  382. diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +158 -52
  383. diffusers/schedulers/scheduling_dpmsolver_sde.py +153 -34
  384. diffusers/schedulers/scheduling_dpmsolver_singlestep.py +275 -86
  385. diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +81 -57
  386. diffusers/schedulers/scheduling_edm_euler.py +62 -39
  387. diffusers/schedulers/scheduling_euler_ancestral_discrete.py +30 -29
  388. diffusers/schedulers/scheduling_euler_discrete.py +255 -74
  389. diffusers/schedulers/scheduling_flow_match_euler_discrete.py +458 -0
  390. diffusers/schedulers/scheduling_flow_match_heun_discrete.py +320 -0
  391. diffusers/schedulers/scheduling_heun_discrete.py +174 -46
  392. diffusers/schedulers/scheduling_ipndm.py +9 -9
  393. diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +138 -29
  394. diffusers/schedulers/scheduling_k_dpm_2_discrete.py +132 -26
  395. diffusers/schedulers/scheduling_karras_ve_flax.py +6 -6
  396. diffusers/schedulers/scheduling_lcm.py +23 -29
  397. diffusers/schedulers/scheduling_lms_discrete.py +105 -28
  398. diffusers/schedulers/scheduling_pndm.py +20 -20
  399. diffusers/schedulers/scheduling_repaint.py +21 -21
  400. diffusers/schedulers/scheduling_sasolver.py +157 -60
  401. diffusers/schedulers/scheduling_sde_ve.py +19 -19
  402. diffusers/schedulers/scheduling_tcd.py +41 -36
  403. diffusers/schedulers/scheduling_unclip.py +19 -16
  404. diffusers/schedulers/scheduling_unipc_multistep.py +243 -47
  405. diffusers/schedulers/scheduling_utils.py +12 -5
  406. diffusers/schedulers/scheduling_utils_flax.py +1 -3
  407. diffusers/schedulers/scheduling_vq_diffusion.py +10 -10
  408. diffusers/training_utils.py +214 -30
  409. diffusers/utils/__init__.py +17 -1
  410. diffusers/utils/constants.py +3 -0
  411. diffusers/utils/doc_utils.py +1 -0
  412. diffusers/utils/dummy_pt_objects.py +592 -7
  413. diffusers/utils/dummy_torch_and_torchsde_objects.py +15 -0
  414. diffusers/utils/dummy_torch_and_transformers_and_sentencepiece_objects.py +47 -0
  415. diffusers/utils/dummy_torch_and_transformers_objects.py +1001 -71
  416. diffusers/utils/dynamic_modules_utils.py +34 -29
  417. diffusers/utils/export_utils.py +50 -6
  418. diffusers/utils/hub_utils.py +131 -17
  419. diffusers/utils/import_utils.py +210 -8
  420. diffusers/utils/loading_utils.py +118 -5
  421. diffusers/utils/logging.py +4 -2
  422. diffusers/utils/peft_utils.py +37 -7
  423. diffusers/utils/state_dict_utils.py +13 -2
  424. diffusers/utils/testing_utils.py +193 -11
  425. diffusers/utils/torch_utils.py +4 -0
  426. diffusers/video_processor.py +113 -0
  427. {diffusers-0.27.0.dist-info → diffusers-0.32.2.dist-info}/METADATA +82 -91
  428. diffusers-0.32.2.dist-info/RECORD +550 -0
  429. {diffusers-0.27.0.dist-info → diffusers-0.32.2.dist-info}/WHEEL +1 -1
  430. diffusers/loaders/autoencoder.py +0 -146
  431. diffusers/loaders/controlnet.py +0 -136
  432. diffusers/loaders/lora.py +0 -1349
  433. diffusers/models/prior_transformer.py +0 -12
  434. diffusers/models/t5_film_transformer.py +0 -70
  435. diffusers/models/transformer_2d.py +0 -25
  436. diffusers/models/transformer_temporal.py +0 -34
  437. diffusers/models/unet_1d.py +0 -26
  438. diffusers/models/unet_1d_blocks.py +0 -203
  439. diffusers/models/unet_2d.py +0 -27
  440. diffusers/models/unet_2d_blocks.py +0 -375
  441. diffusers/models/unet_2d_condition.py +0 -25
  442. diffusers-0.27.0.dist-info/RECORD +0 -399
  443. {diffusers-0.27.0.dist-info → diffusers-0.32.2.dist-info}/LICENSE +0 -0
  444. {diffusers-0.27.0.dist-info → diffusers-0.32.2.dist-info}/entry_points.txt +0 -0
  445. {diffusers-0.27.0.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.FloatTensor] = None,
222
- negative_prompt_embeds: Optional[torch.FloatTensor] = None,
223
- pooled_prompt_embeds: Optional[torch.FloatTensor] = None,
224
- negative_pooled_prompt_embeds: Optional[torch.FloatTensor] = None,
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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 = (batch_size, num_channels_latents, height // self.vae_scale_factor, width // self.vae_scale_factor)
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.FloatTensor] = None,
615
- prompt_embeds: Optional[torch.FloatTensor] = None,
616
- negative_prompt_embeds: Optional[torch.FloatTensor] = None,
617
- pooled_prompt_embeds: Optional[torch.FloatTensor] = None,
618
- negative_pooled_prompt_embeds: Optional[torch.FloatTensor] = None,
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.FloatTensor], None]] = None,
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.FloatTensor` or `PIL.Image.Image` or `np.ndarray` or `List[torch.FloatTensor]` or `List[PIL.Image.Image]` or `List[np.ndarray]`):
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 inital image `image`. Image guidance
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor`, *optional*):
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.FloatTensor)`.
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.FloatTensor):
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
- images = [self.encoder.encode(image, "dwtDct") for image in images]
31
+ # Convert RGB to BGR, which is the channel order expected by the watermark encoder.
32
+ images = images[:, :, :, ::-1]
32
33
 
33
- images = torch.from_numpy(np.array(images)).permute(0, 3, 1, 2)
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, VaeImageProcessor
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("stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16")
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("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/svd-docstring-example.jpeg")
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.animatediff.pipeline_animatediff.tensor2vid
61
- def tensor2vid(video: torch.Tensor, processor: VaeImageProcessor, output_type: str = "np"):
62
- batch_size, channels, num_frames, height, width = video.shape
63
- outputs = []
64
- for batch_idx in range(batch_size):
65
- batch_vid = video[batch_idx].permute(1, 0, 2, 3)
66
- batch_output = processor.postprocess(batch_vid, output_type)
67
-
68
- outputs.append(batch_output)
69
-
70
- if output_type == "np":
71
- outputs = np.stack(outputs)
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
- return outputs
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.FloatTensor`]):
89
- List of denoised PIL images of length `batch_size` or numpy array or torch tensor
90
- of shape `(batch_size, num_frames, height, width, num_channels)`.
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.FloatTensor]
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 ([laion/CLIP-ViT-H-14-laion2B-s32B-b79K](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K)).
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.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
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.FloatTensor:
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.image_processor.pil_to_numpy(image)
150
- image = self.image_processor.numpy_to_pt(image)
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.FloatTensor, num_frames: int, decode_chunk_size: int = 14):
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.FloatTensor` or `PIL.Image.Image` or `List[PIL.Image.Image]` but is"
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.FloatTensor] = None,
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.FloatTensor],
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.FloatTensor] = None,
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.FloatTensor`):
360
- Image(s) to guide image generation. If you provide a tensor, the expected value range is between `[0, 1]`.
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
- (14 for `stable-video-diffusion-img2vid` and to 25 for `stable-video-diffusion-img2vid-xt`).
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 generation.
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 init image. Increase it for more motion.
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 expense of more memory usage. By default, the decoder decodes all frames at once for maximal
385
- quality. For lower memory usage, reduce `decode_chunk_size`.
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.FloatTensor`, *optional*):
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 `callback_on_step_end_tensor_inputs`.
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 returned,
415
- otherwise a `tuple` of (`List[List[PIL.Image.Image]]` or `np.ndarray` or `torch.FloatTensor`) is returned.
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.image_processor.preprocess(image, height=height, width=width).to(device)
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.set_timesteps(num_inference_steps, device=device)
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 = tensor2vid(frames, self.image_processor, output_type=output_type)
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: list[int] = _compute_padding([height, width])
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