• Stefy Lanza (nextime / spora )'s avatar
    edit the image the caller sent, not a new one (v0.4.93) · 9fc41a89
    Stefy Lanza (nextime / spora ) authored
    Reported from a client against nesaorg/PonyRealism-Uncensored as three
    symptoms -- "the edit result is garbage", "size is ignored", and a 500. Two
    defects, neither of which announced itself.
    
    The edit was never an edit. _load_img2img_pipeline picked its class by looking
    for 'xl', 'sdxl', 'stable-diffusion' or 'sd' in the MODEL NAME, and
    "nesaorg/ponyrealism-uncensored" contains none of them, so it fell through to
    the generic DiffusionPipeline -- which faithfully honours the checkpoint's
    model_index.json, and that one declares StableDiffusionXLPipeline: the
    text-to-image class. Every diffusers __call__ ends in **kwargs (it carries the
    deprecated callback pair), so `image` and `strength` were accepted, dropped,
    and the pipeline rendered a fresh picture from the prompt alone at its default
    1024x1024. One defect, all three symptoms: garbage (a prompt saying "add X,
    keep everything else" rendered from scratch), size ignored (1024x1024 is the
    text-to-image default, not the source's shape), and 200 OK throughout.
    stable-diffusion-xl-base-1.0 worked only because its NAME contains "xl".
    
    Both loaders now ask AutoPipelineForImage2Image / AutoPipelineForInpainting,
    which read the declared class and substitute the one for this task. A guard
    backs it up, on cached pipelines as well as freshly loaded ones -- an install
    already holding a text-to-image pipeline would otherwise keep using it until it
    restarted. A pipeline with no `image` input is converted with from_pipe (the
    same components, no second copy in VRAM) or refused with 501. A 200 carrying a
    picture of something else is the one outcome worth ruling out.
    
    The 500 was a cache key used as a repo id. These endpoints keep task-specific
    pipelines in MultiModelManager.models under "img2img:<repo>", and the manager's
    fuzzy already-loaded pass matched one by its last path segment, then assigned
    the whole key to resolved_name -- so from_pretrained was asked for a repo
    called "img2img:nesaorg/PonyRealism-Uncensored" and answered "Repo id must use
    alphanumeric chars" about a model that loads perfectly well. That pass now
    skips task namespaces, which the endpoints look up by exact key anyway.
    
    Writing the test for that found two more namespaces with the identical latent
    bug -- depth: and segment: -- so _TASK_NAMESPACES covers four, and an invariant
    test asserts every task prefix the endpoints invent is declared. A future
    endpoint cannot reintroduce this quietly.
    
    Not fixed, because it is not a bug: /v1/images/edits is plain img2img, so "add
    X and keep everything else exactly the same" cannot work however correct the
    pipeline is. That needs a mask through /v1/images/inpaint, or an
    instruction-edit model exposed with a capability clients can prefer.
    
    16 tests; full suite 4537 passed with the same 15 pre-existing failures as
    0.4.91 (diff empty).
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01S8LAP3ueNzQJtwzhgVbq66
    9fc41a89
test_image_edit_uses_an_image_pipeline.py 9.26 KB