{"record":{"id":"6389a573a3e5cc14","repo":"unslothai/unsloth","slug":"state-family-name-is-an-image-editing-model-and","errorCode":null,"errorMessage":"{state.family.name} is an image-editing model and does not support masks (mask_image).","messagePattern":"(.+?) is an image-editing model and does not support masks \\(mask_image\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion.py","lineNumber":5362,"sourceCode":"                        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\"\n                    pipe = self._workflow_pipe(state, state.family.img2img_pipeline_class, workflow)\n                    init_pil = decode_b64_image(init_image, mode = \"RGB\")\n                    iw, ih = init_pil.size\n                    # Cap the factor, then the absolute output (longest side 2048); round to a multiple of 16 (VAE downsample + patch).\n                    factor = max(1.0, min(float(upscale), 4.0))","sourceCodeStart":5344,"sourceCodeEnd":5380,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion.py#L5344-L5380","documentation":"Edit-capable families have no inpaint pipeline, so a mask_image would be silently dropped if accepted. This ValueError rejects a request that supplies mask_image to an editing family before any work starts, telling the caller to use the instruction prompt instead of a mask.","triggerScenarios":"A request with mask_image set while the loaded family has edit=True (the mask+init_image combination would normally select the inpaint workflow, which does not exist for edit families).","commonSituations":"Porting an inpainting workflow (mask + init image) to a newer instruction-editing model and assuming mask semantics carry over; UI state where an old painted mask is still attached after loading an edit model.","solutions":["Remove mask_image and express the edit through the prompt instruction (e.g. 'replace the masked region concept' via natural language).","Load an inpaint-capable family if mask-based editing is required."],"exampleFix":"# before\nengine.generate(prompt=\"repaint\", init_image=img, mask_image=mask)\n# after (edit family)\nengine.generate(prompt=\"change the hair color to red\", init_image=img)","handlingStrategy":"validation","validationCode":"if getattr(loaded_family, \"edit\", False) and mask_image is not None:\n    raise UserError(\"Edit models take instructions, not masks: remove mask_image.\")","typeGuard":"def family_accepts_mask(family) -> bool:\n    return not bool(getattr(family, \"edit\", False))","tryCatchPattern":"try:\n    out = engine.generate(prompt=p, init_image=img, mask_image=mask)\nexcept ValueError as e:\n    if \"does not support masks\" in str(e):\n        out = engine.generate(prompt=mask_intent_as_instruction, init_image=img)\n    else:\n        raise","preventionTips":["Hide the mask/inpaint canvas when an edit family is loaded.","Translate painted-mask intents into natural-language instructions for edit models."],"tags":["diffusion","validation","inpainting","mask","image-editing"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}