{"record":{"id":"e113b8a0ead08d37","repo":"unslothai/unsloth","slug":"state-family-name-is-an-image-editing-model-pro","errorCode":null,"errorMessage":"{state.family.name} is an image-editing model: provide an input image.","messagePattern":"(.+?) is an image-editing model: provide an input image\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion.py","lineNumber":5357,"sourceCode":"                cn_scale = cn_gstart = cn_gend = cn_mode = None\n                ref_extra: list = []\n                # Validate dependencies up front: mask/upscale/reference need an input image, and reference needs a supporting family.\n                if init_image is None:\n                    if mask_image is not None:\n                        raise ValueError(\"mask_image requires an input image (init_image).\")\n                    if upscale is not None and upscale > 1.0:\n                        raise ValueError(\"upscale requires an input image (init_image).\")\n                    if reference_images:\n                        raise ValueError(\"reference_images require an input image (init_image).\")\n                if reference_images and not getattr(state.family, \"reference\", False):\n                    raise ValueError(\n                        f\"Reference images are not supported for the '{state.family.name}' \"\n                        \"model family.\"\n                    )\n                if getattr(state.family, \"edit\", False):\n                    # Instruction editing: the loaded pipe IS the edit pipeline and always needs an input image; the prompt is the instruction.\n                    if init_image is None:\n                        raise ValueError(\n                            f\"{state.family.name} is an image-editing model: provide an input image.\"\n                        )\n                    if mask_image is not None:\n                        # The edit family has no inpaint pipeline; a mask would be silently dropped.\n                        raise ValueError(\n                            f\"{state.family.name} is an image-editing model and does not \"\n                            \"support masks (mask_image).\"\n                        )\n                    workflow = \"edit\"\n                    init_pil = decode_b64_image(init_image, mode = \"RGB\")\n                elif mask_image is not None and init_image is not None:\n                    workflow = \"inpaint\"\n                    pipe = self._workflow_pipe(state, state.family.inpaint_pipeline_class, workflow)\n                    init_pil = decode_b64_image(init_image, mode = \"RGB\")\n                    mask_pil = decode_b64_image(mask_image, mode = \"L\")\n                elif init_image is not None and upscale is not None and upscale > 1.0:\n                    # Upscale (hires fix): enlarge with Lanczos, then re-run img2img at low strength to add detail.\n                    workflow = \"upscale\"","sourceCodeStart":5339,"sourceCodeEnd":5375,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion.py#L5339-L5375","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Include init_image (base64 input image) in the request; for edit families the prompt becomes the edit instruction.","Or load a non-edit model family if you wanted plain text-to-image generation."],"exampleFix":"# before\nresult = engine.generate(prompt=\"a cat\", init_image=None)\n# after\nresult = engine.generate(\n    prompt=\"make the cat wear a hat\",\n    init_image=\"data:image/png;base64,...\",\n)","handlingStrategy":"validation","validationCode":"if getattr(loaded_family, \"edit\", False) and init_image is None:\n    raise UserError(\"This model edits images: attach an input image; the prompt is the instruction.\")","typeGuard":"def is_edit_family(family) -> bool:\n    return bool(getattr(family, \"edit\", False))","tryCatchPattern":"try:\n    out = engine.generate(prompt=instruction, init_image=init_image)\nexcept ValueError as e:\n    if \"image-editing model\" in str(e):\n        prompt_for_image_upload(str(e))\n    else:\n        raise","preventionTips":["Drive the UI tab from family capabilities: edit families always require an image input.","In scripts, branch on family.edit and refuse to send image-less requests."],"tags":["diffusion","validation","image-editing","init-image"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}