From d9aab8365cd035ce187361ad5f4043d45a5544a1 Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Tue, 19 May 2026 12:11:51 +0200 Subject: [PATCH] properly check for ftfy and warn if unavailable in all pipelines --- src/diffusers/pipelines/chronoedit/pipeline_chronoedit.py | 7 +++++-- src/diffusers/pipelines/kandinsky5/pipeline_kandinsky.py | 3 +++ .../pipelines/kandinsky5/pipeline_kandinsky_i2i.py | 3 +++ .../pipelines/kandinsky5/pipeline_kandinsky_i2v.py | 3 +++ .../pipelines/kandinsky5/pipeline_kandinsky_t2i.py | 3 +++ src/diffusers/pipelines/lucy/pipeline_lucy_edit.py | 7 +++++-- src/diffusers/pipelines/prx/pipeline_prx.py | 7 +++++-- .../pipelines/skyreels_v2/pipeline_skyreels_v2.py | 7 +++++-- .../skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py | 7 +++++-- .../pipeline_skyreels_v2_diffusion_forcing_i2v.py | 7 +++++-- .../pipeline_skyreels_v2_diffusion_forcing_v2v.py | 7 +++++-- .../pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py | 7 +++++-- src/diffusers/pipelines/wan/pipeline_wan.py | 4 +++- src/diffusers/pipelines/wan/pipeline_wan_animate.py | 7 +++++-- src/diffusers/pipelines/wan/pipeline_wan_i2v.py | 7 +++++-- src/diffusers/pipelines/wan/pipeline_wan_vace.py | 7 +++++-- 16 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/diffusers/pipelines/chronoedit/pipeline_chronoedit.py b/src/diffusers/pipelines/chronoedit/pipeline_chronoedit.py index 1e0cc0ea5c2a..2c21c9b2a403 100644 --- a/src/diffusers/pipelines/chronoedit/pipeline_chronoedit.py +++ b/src/diffusers/pipelines/chronoedit/pipeline_chronoedit.py @@ -25,7 +25,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, ChronoEditTransformer3DModel from ...schedulers import FlowMatchEulerDiscreteScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -95,7 +95,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky.py b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky.py index 1c94a8219e2a..d8f796335270 100644 --- a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky.py +++ b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky.py @@ -28,6 +28,7 @@ # Add imports for offloading and tiling from ...utils import ( + BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, @@ -103,6 +104,8 @@ def basic_clean(text): """ if is_ftfy_available(): text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py index 244db7300767..af2188d0a52d 100644 --- a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py +++ b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py @@ -30,6 +30,7 @@ # Add imports for offloading and tiling from ...utils import ( + BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, @@ -92,6 +93,8 @@ def basic_clean(text): """ if is_ftfy_available(): text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2v.py b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2v.py index ad4bb182d248..01aa6bfca44d 100644 --- a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2v.py +++ b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2v.py @@ -29,6 +29,7 @@ # Add imports for offloading and tiling from ...utils import ( + BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, @@ -100,6 +101,8 @@ def basic_clean(text): """ if is_ftfy_available(): text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py index 2a58d4bed33a..f4bebab40a15 100644 --- a/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py +++ b/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py @@ -30,6 +30,7 @@ # Add imports for offloading and tiling from ...utils import ( + BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, @@ -92,6 +93,8 @@ def basic_clean(text): """ if is_ftfy_available(): text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/lucy/pipeline_lucy_edit.py b/src/diffusers/pipelines/lucy/pipeline_lucy_edit.py index 392af492b702..c6797b89ab2f 100644 --- a/src/diffusers/pipelines/lucy/pipeline_lucy_edit.py +++ b/src/diffusers/pipelines/lucy/pipeline_lucy_edit.py @@ -28,7 +28,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, WanTransformer3DModel from ...schedulers import FlowMatchEulerDiscreteScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -101,7 +101,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/prx/pipeline_prx.py b/src/diffusers/pipelines/prx/pipeline_prx.py index e14815b91c41..8d6fc30a5f52 100644 --- a/src/diffusers/pipelines/prx/pipeline_prx.py +++ b/src/diffusers/pipelines/prx/pipeline_prx.py @@ -33,7 +33,7 @@ from diffusers.pipelines.pipeline_utils import DiffusionPipeline from diffusers.pipelines.prx.pipeline_output import PRXPipelineOutput from diffusers.schedulers import FlowMatchEulerDiscreteScheduler -from diffusers.utils import is_ftfy_available, logging, replace_example_docstring +from diffusers.utils import BACKENDS_MAPPING, is_ftfy_available, logging, replace_example_docstring from diffusers.utils.torch_utils import randn_tensor @@ -197,7 +197,10 @@ def clean_text(self, text: str) -> str: text = re.sub(regex2, " ", text) # Basic cleaning - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) text = text.strip() diff --git a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2.py b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2.py index c92608fad3b6..d2ae884e1691 100644 --- a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2.py +++ b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2.py @@ -23,7 +23,7 @@ from ...loaders import SkyReelsV2LoraLoaderMixin from ...models import AutoencoderKLWan, SkyReelsV2Transformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -88,7 +88,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py index 8751240a1af9..f57d2556bcf2 100644 --- a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py +++ b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py @@ -25,7 +25,7 @@ from ...loaders import SkyReelsV2LoraLoaderMixin from ...models import AutoencoderKLWan, SkyReelsV2Transformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -95,7 +95,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_i2v.py b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_i2v.py index a8f1b3a84a4a..3da5919f2865 100644 --- a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_i2v.py +++ b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_i2v.py @@ -30,7 +30,7 @@ from ...loaders import SkyReelsV2LoraLoaderMixin from ...models import AutoencoderKLWan, SkyReelsV2Transformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ..pipeline_utils import DiffusionPipeline from .pipeline_output import SkyReelsV2PipelineOutput @@ -100,7 +100,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_v2v.py b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_v2v.py index 924acb850d09..caa5863b54a6 100644 --- a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_v2v.py +++ b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_v2v.py @@ -27,7 +27,7 @@ from ...loaders import SkyReelsV2LoraLoaderMixin from ...models import AutoencoderKLWan, SkyReelsV2Transformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -96,7 +96,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py index 7c24b898e0bb..eda6e6c8c0f5 100644 --- a/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py +++ b/src/diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py @@ -25,7 +25,7 @@ from ...loaders import SkyReelsV2LoraLoaderMixin from ...models import AutoencoderKLWan, SkyReelsV2Transformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -94,7 +94,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/wan/pipeline_wan.py b/src/diffusers/pipelines/wan/pipeline_wan.py index 6cbe6d85de78..c45463493afc 100644 --- a/src/diffusers/pipelines/wan/pipeline_wan.py +++ b/src/diffusers/pipelines/wan/pipeline_wan.py @@ -23,7 +23,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, WanTransformer3DModel from ...schedulers import FlowMatchEulerDiscreteScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -78,6 +78,8 @@ def basic_clean(text): if is_ftfy_available(): text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/wan/pipeline_wan_animate.py b/src/diffusers/pipelines/wan/pipeline_wan_animate.py index 5806032c0142..a92bed0aa7a3 100644 --- a/src/diffusers/pipelines/wan/pipeline_wan_animate.py +++ b/src/diffusers/pipelines/wan/pipeline_wan_animate.py @@ -27,7 +27,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, WanAnimateTransformer3DModel from ...schedulers import UniPCMultistepScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -117,7 +117,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/wan/pipeline_wan_i2v.py b/src/diffusers/pipelines/wan/pipeline_wan_i2v.py index f669e9b1d0ec..2c3886dafaf6 100644 --- a/src/diffusers/pipelines/wan/pipeline_wan_i2v.py +++ b/src/diffusers/pipelines/wan/pipeline_wan_i2v.py @@ -25,7 +25,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, WanTransformer3DModel from ...schedulers import FlowMatchEulerDiscreteScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -94,7 +94,10 @@ def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip() diff --git a/src/diffusers/pipelines/wan/pipeline_wan_vace.py b/src/diffusers/pipelines/wan/pipeline_wan_vace.py index c016eec1b535..514bc20a27ab 100644 --- a/src/diffusers/pipelines/wan/pipeline_wan_vace.py +++ b/src/diffusers/pipelines/wan/pipeline_wan_vace.py @@ -25,7 +25,7 @@ from ...loaders import WanLoraLoaderMixin from ...models import AutoencoderKLWan, WanVACETransformer3DModel from ...schedulers import FlowMatchEulerDiscreteScheduler -from ...utils import is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring +from ...utils import BACKENDS_MAPPING, is_ftfy_available, is_torch_xla_available, logging, replace_example_docstring from ...utils.torch_utils import randn_tensor from ...video_processor import VideoProcessor from ..pipeline_utils import DiffusionPipeline @@ -108,7 +108,10 @@ def prepare_video_and_mask(first_img: PIL.Image.Image, last_img: PIL.Image.Image def basic_clean(text): - text = ftfy.fix_text(text) + if is_ftfy_available(): + text = ftfy.fix_text(text) + else: + logger.warning(BACKENDS_MAPPING["ftfy"][-1].format("Cleaning prompts")) text = html.unescape(html.unescape(text)) return text.strip()