[bugfix] Return individual images for batched image API requests (#1917)

For n > 1, the image endpoints returned one preview grid instead of n images.
The endpoints now run one model batch, save each decoded sample as its own file,
and return one URL or base64 item for each image. This applies to generations
and edits.

A keyword-only return_samples field (default False) is added to OutputConfig,
SamplingParam and ForwardBatch. Batched image requests set it and do not build
preview frames. The worker keeps the sample tensor for these requests, and
non-output ranks clear the field. Defaults and positional arguments do not
change.
This commit is contained in:
Boyang ZHONG
2026-10-07 15:06:02 -07:00
committed by GitHub
parent 7d61590213
commit dc72a35f4e
12 changed files with 213 additions and 80 deletions
+8
View File
@@ -40,3 +40,11 @@ The following two classes `PipelineConfig` and `SamplingParam` are used to confi
members:
- from_pretrained
heading_level: 4
### Returning samples without previews
Set `OutputConfig(return_samples=True, return_frames=False, save_video=False)`
to receive the decoded CPU tensor in `GenerationResult.samples` without building
preview grids or writing media. Pixel samples retain the existing float `[0, 1]`
contract. `return_frames=True` continues to return both samples and preview frames.
The legacy sampling/keyword interface accepts the same `return_samples` option.