Skip to content

53 messages in src/diffusers are missing the f-string prefix (safety-checker ValueError in 46 pipelines) #14803

Description

@David-Wu1119

Following the AI-assisted contribution guide, I'm opening one issue for a recurring pattern rather than per-file PRs, and I'll wait for a maintainer's go-ahead before opening a PR.

The pattern

53 messages under src/diffusers contain {...} placeholders but are plain strings, not f-strings, so users see the placeholder text instead of the value. Every referenced name is in scope at its call site, so the fix is only the f prefix. Found with an AST scan for string literals passed to raise, logger.* or print whose placeholders name variables in the enclosing function; each hit was then read by hand.

1. Safety-checker ValueError in 46 pipelines (the most user-visible one)

raise ValueError(
    "Make sure to define a feature extractor when loading {self.__class__} if you want to use the safety"
    " checker. If you do not want to use the safety checker, you can pass `'safety_checker=None'` instead."
)

When safety_checker is passed without feature_extractor, the error reads ...when loading {self.__class__} if... instead of naming the pipeline class. None of these __init__s are # Copied from, so each copy needs the same one-character edit:

46 locations
  • pipelines/controlnet/pipeline_controlnet.py:239
  • pipelines/controlnet/pipeline_controlnet_img2img.py:217
  • pipelines/controlnet/pipeline_controlnet_inpaint.py:220
  • pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py:262
  • pipelines/deepfloyd_if/pipeline_if.py:153
  • pipelines/deepfloyd_if/pipeline_if_img2img.py:177
  • pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py:183
  • pipelines/deepfloyd_if/pipeline_if_inpainting.py:180
  • pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py:185
  • pipelines/deepfloyd_if/pipeline_if_superresolution.py:141
  • pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py:252
  • pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py:280
  • pipelines/deprecated/controlnet_xs/pipeline_controlnet_xs.py:177
  • pipelines/deprecated/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py:85
  • pipelines/deprecated/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py:245
  • pipelines/deprecated/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py:345
  • pipelines/deprecated/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py:169
  • pipelines/deprecated/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py:230
  • pipelines/deprecated/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py:260
  • pipelines/deprecated/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py:231
  • pipelines/deprecated/stable_diffusion_safe/pipeline_stable_diffusion_safe.py:125
  • pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py:213
  • pipelines/deprecated/stable_diffusion_variants/pipeline_onnx_stable_diffusion_inpaint_legacy.py:138
  • pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py:183
  • pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py:111
  • pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py:135
  • pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py:353
  • pipelines/hunyuandit/pipeline_hunyuandit.py:235
  • pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py:207
  • pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py:367
  • pipelines/pag/pipeline_pag_controlnet_sd.py:247
  • pipelines/pag/pipeline_pag_controlnet_sd_inpaint.py:221
  • pipelines/pag/pipeline_pag_hunyuandit.py:240
  • pipelines/pag/pipeline_pag_sd.py:258
  • pipelines/pag/pipeline_pag_sd_img2img.py:253
  • pipelines/pag/pipeline_pag_sd_inpaint.py:285
  • pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py:101
  • pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py:154
  • pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py:153
  • pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py:127
  • pipelines/stable_diffusion/pipeline_stable_diffusion.py:253
  • pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py:103
  • pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py:281
  • pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py:228
  • pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py:154
  • pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py:256

2. DeepFloyd IF super-resolution warnings (3): "It seems like you have loaded a checkpoint that shall not be used for super resolution from {unet.config._name_or_path} as it accepts {unet.config.in_channels} input channels..." in pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py:189, pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py:191, pipelines/deepfloyd_if/pipeline_if_superresolution.py:147.

3. bitsandbytes quantizer (2): logger.info("target_dtype {target_dtype} is replaced by ...") in quantizers/bitsandbytes/bnb_quantizer.py:452, quantizers/bitsandbytes/bnb_quantizer.py:98.

4. DPMSolverSinglestepScheduler.set_timesteps warnings (2): "Changing scheduler {self.config} to have lower_order_final set to True..." in schedulers/scheduling_dpmsolver_singlestep.py:424, schedulers/scheduling_dpmsolver_singlestep.py:430.

Proposed fix

A single PR adding the f prefix at these 53 sites, with no other changes. It would pass make quality, make fix-copies (to confirm no copy checks drift), and the self-review skill, with the notes shared on the PR. There are also about 24 more copies of the safety-checker message under examples/community. I'd leave those out unless you'd like them in the same PR.

Would a PR along these lines be welcome?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions