unslothai/unsloth · error · ValueError

{state.family.name} is an image-editing model: provide an in

Error message

{state.family.name} is an image-editing model: provide an input image.

What it means

Thrown when the loaded model family has the 'edit' capability (instruction-based image editing, e.g. an edit-tuned pipeline) but the request has no init_image. The edit pipeline is the loaded pipe itself and always needs an input image; the prompt is treated as the editing instruction. Failing fast avoids a pipeline call that would otherwise crash or produce garbage.

Source

Thrown at studio/backend/core/inference/diffusion.py:5357

                cn_scale = cn_gstart = cn_gend = cn_mode = None
                ref_extra: list = []
                # Validate dependencies up front: mask/upscale/reference need an input image, and reference needs a supporting family.
                if init_image is None:
                    if mask_image is not None:
                        raise ValueError("mask_image requires an input image (init_image).")
                    if upscale is not None and upscale > 1.0:
                        raise ValueError("upscale requires an input image (init_image).")
                    if reference_images:
                        raise ValueError("reference_images require an input image (init_image).")
                if reference_images and not getattr(state.family, "reference", False):
                    raise ValueError(
                        f"Reference images are not supported for the '{state.family.name}' "
                        "model family."
                    )
                if getattr(state.family, "edit", False):
                    # Instruction editing: the loaded pipe IS the edit pipeline and always needs an input image; the prompt is the instruction.
                    if init_image is None:
                        raise ValueError(
                            f"{state.family.name} is an image-editing model: provide an input image."
                        )
                    if mask_image is not None:
                        # The edit family has no inpaint pipeline; a mask would be silently dropped.
                        raise ValueError(
                            f"{state.family.name} is an image-editing model and does not "
                            "support masks (mask_image)."
                        )
                    workflow = "edit"
                    init_pil = decode_b64_image(init_image, mode = "RGB")
                elif mask_image is not None and init_image is not None:
                    workflow = "inpaint"
                    pipe = self._workflow_pipe(state, state.family.inpaint_pipeline_class, workflow)
                    init_pil = decode_b64_image(init_image, mode = "RGB")
                    mask_pil = decode_b64_image(mask_image, mode = "L")
                elif init_image is not None and upscale is not None and upscale > 1.0:
                    # Upscale (hires fix): enlarge with Lanczos, then re-run img2img at low strength to add detail.
                    workflow = "upscale"

View on GitHub (pinned to 203007d190)

Solutions

  1. Include init_image (base64 input image) in the request; for edit families the prompt becomes the edit instruction.
  2. Or load a non-edit model family if you wanted plain text-to-image generation.

Example fix

# before
result = engine.generate(prompt="a cat", init_image=None)
# after
result = engine.generate(
    prompt="make the cat wear a hat",
    init_image="data:image/png;base64,...",
)
Defensive patterns

Strategy: validation

Validate before calling

if getattr(loaded_family, "edit", False) and init_image is None:
    raise UserError("This model edits images: attach an input image; the prompt is the instruction.")

Type guard

def is_edit_family(family) -> bool:
    return bool(getattr(family, "edit", False))

Try / catch

try:
    out = engine.generate(prompt=instruction, init_image=init_image)
except ValueError as e:
    if "image-editing model" in str(e):
        prompt_for_image_upload(str(e))
    else:
        raise

Prevention

When it happens

Trigger: Calling generate with a family where getattr(state.family, 'edit', False) is true and init_image is None — i.e. a plain txt2img-style request body against an editing model.

Common situations: Loading an instruction-edit model (e.g. a Qwen-Image-Edit / FLUX Edit style checkpoint) and then using the normal text-to-image tab without attaching an image; automated scripts reusing a txt2img payload after switching the loaded model.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/e113b8a0ead08d37. Report an issue: GitHub.