Repository navigation
feat(image): honor JPEG/WebP quality in H3-Image and synchronous responses - #1704
Open
NorthCedar wants to merge 3 commits into
Open
NorthCedar wants to merge 3 commits into
NorthCedar wants to merge 3 commits into
Conversation
Additional validationThe output-encoding changes were backported onto an existing MUSA deployment while retaining its model implementation and runtime dependencies.
These checks cover the LightX2V APIs and the adapted runner. Other models, external presigned uploads, and performance benchmarks were not tested in this deployment run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1702.
Problem
MiniMax-H3-Image has no request-level output quality setting. Its PIL and OpenCV file writers use their encoder defaults, while synchronous image APIs always encode PNG and report PNG in response metadata, download filenames and presigned-upload Content-Type. Selecting a JPEG/WebP output filename therefore does not select that format for synchronous responses.
This prevents callers from trading file size against image quality.
Change
output_compressionto H3-Image CLI, Python generation, startup defaults and image requests: integer 0–100, default 95. Explicit zero is retained; invalid values are rejected before inference.pilandopencv). PNG ignores the setting. Shared file-writer callers that omit quality retain their previous encoder defaults.save_result_path; synchronous requests without a filename suffix default to PNG. Nooutput_formatrequest field is added.The synchronous encoding change is shared by image-serving runners; per-request field admission remains model-specific. This does not change model inference or sampling.
Testing
92 CPU tests passed, covering both actual H3-Image runner save paths, JPEG/WebP quality-dependent files, PNG invariance, synchronous responses, download/upload types, pixel conversion and validation. Additional checks covered startup defaults, request overrides/reset, explicit zero, Python/CLI forwarding and cache eviction.
Additional deployment validation passed 79 CPU encoding/API tests using the existing runtime dependencies. Checks against the adapted runner covered request-field admission, startup defaults, request overrides and reset, explicit zero, invalid values, JPEG/WebP file encoding and PNG invariance.
Eleven text-to-image requests completed successfully on four MUSA GPUs with a fixed prompt, seed 42 and 2048 × 2048 output, exercising native synchronous and OpenAI-compatible generation APIs. JPEG/WebP file sizes changed with the requested quality, explicit zero was honored, and omitted quality matched explicit 95 in same-interface comparisons. PNG outputs at quality 10 and 95 were byte-identical. Invalid quality values returned HTTP 422. Response formats, filenames and actual download Content-Type values matched the encoded images; downloaded content was byte-identical to the generated files. The service remained healthy with no task failures or container restarts.
Fixed-image encoding measurements are recorded in #1702 (832 × 1104 RGB, Pillow 12.2.0):
The reference PNG was 1405.3 KiB; PNG output was unchanged across quality values, and omitted quality matched 95. These are encoding measurements on fixed pixels, not model inference benchmarks.
Full-repository pre-commit checks passed with the repository-pinned Ruff 0.11.0. Together with #1705, 118 image tests passed; the wider CPU suite reported 430 passed and the same six failures reproduced on the unmodified upstream base. Diffusers numerical-parity checks were not run. Deployment validation covered the adapted runner and LightX2V APIs; other models, external presigned uploads and performance benchmarks were not tested in that run.