Skip to content

Add MiniMax image-to-image backend for garment and modeled stages - #11

Open
octo-patch wants to merge 2 commits into
tandpfun:mainfrom
octo-patch:octo/20260729-image-to-image-tool-recvqbuPXILdto
Open

Add MiniMax image-to-image backend for garment and modeled stages#11
octo-patch wants to merge 2 commits into
tandpfun:mainfrom
octo-patch:octo/20260729-image-to-image-tool-recvqbuPXILdto

Conversation

@octo-patch

Copy link
Copy Markdown

Reason: Add a MiniMax image-to-image backend so garment and modeled edits can run through the /v1/image_generation endpoint instead of only the OpenAI edits schema.

What changed

The import pipeline generated the garment and modeled stages exclusively through the
OpenAI multipart /images/edits schema and parsed data[0].b64_json. This adds an
alternative MiniMax image-to-image backend behind a provider switch, so the generated
bytes flow into the existing chroma-cleanup and review pipeline unchanged.

  • miniMaxEdit() posts JSON to <base>/image_generation with Authorization: Bearer,
    mapping the one or two reference images to subject_reference
    ({ type: "character", image_file: "data:image/png;base64,..." }).
  • Requests carry the supported fields: model (image-01 / image-01-live), prompt,
    response_format, width/height derived from the stage size (validated to the
    [512, 2048], multiple-of-8 range) with aspect_ratio taking priority when set, plus
    optional prompt_optimizer and seed. The prompt is clamped to the documented
    1500-character limit.
  • Both response shapes are handled: data.image_base64[0] is decoded directly, and
    data.image_urls[0] is downloaded, returning PNG bytes either way. Non-zero
    base_resp.status_code surfaces status_msg as an error.
  • A small editImage() dispatcher selects the backend from WARDROBE_IMAGE_PROVIDER
    (default openai), preserving the existing OpenAI behavior. Clothing detection still
    uses the OpenAI vision model.
  • Global endpoint defaults to https://api.minimax.io/v1; the China endpoint
    (https://api.minimaxi.com/v1) is configurable via MINIMAX_API_BASE_URL.
  • .env.example and the README configuration table document the new variables.

Checks

  • npm run check (Vite production build) passes.
  • Exercised miniMaxEdit() with a stubbed fetch: verified endpoint/auth/JSON headers,
    subject_reference mapping for one and two references, width/height vs
    aspect_ratio selection, prompt clamping, base64 and URL response decoding to PNG
    bytes, and error propagation on a non-zero status code.

@octo-patch

Copy link
Copy Markdown
Author

Updated the MiniMax image response handling to decode base64 from data.image_urls and download URL responses, added n: 1 and seed configuration, and added focused tests. I ran npm test and npm run check.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant