Skip to content

fix(diffusers,vllm-omni,tinygrad): save generated images as PNG explicitly#10729

Merged
mudler merged 1 commit into
masterfrom
fix/diffusers-image-save-format
Jul 7, 2026
Merged

fix(diffusers,vllm-omni,tinygrad): save generated images as PNG explicitly#10729
mudler merged 1 commit into
masterfrom
fix/diffusers-image-save-format

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Problem

Image generation completes GPU inference but crashes at the file-save step. The Python image backends call PIL Image.save(request.dst) without a format, so Pillow infers the encoder from the file extension. The core passes an absolute staging path ending in .tmp (e.g. /staging/localai-output-*.tmp, from core/services/nodes/file_transfer_server.go), which Pillow can't map to a format:

rpc error: code = Unknown desc = Exception calling application: unknown file extension: .tmp

The worker dies right after a successful inference, so the image never reaches the UI.

Fix

Pass format="PNG" explicitly. LocalAI serves generated images as PNG regardless of the temp path (core/http/endpoints/openai/image.go appends .png), so this is always correct and no longer depends on the destination extension the core happens to allocate.

Fixed in all three image backends that had the identical pattern:

(mlx-vlm already passes format='JPEG'; chatterbox uses torchaudio — both fine.)

Testing

All three files pass python -m py_compile. Full runtime verification requires the backend images + GPU + models (CI/backend-image territory); the change is a one-argument PIL usage fix.

Closes #10727

🤖 Generated with Claude Code

…citly

The image backends call PIL Image.save(request.dst) without a format, so
Pillow infers the encoder from the file extension. The core passes an
absolute staging path ending in .tmp (e.g. /staging/localai-output-*.tmp),
which Pillow can't map to a format, raising "unknown file extension: .tmp"
and crashing the worker right after a successful GPU inference.

Pass format="PNG" explicitly. LocalAI serves generated images as PNG
regardless of the temporary path, so this is always correct and no longer
depends on the extension of the destination the core happens to allocate.

diffusers is the reported backend (#10727); vllm-omni and tinygrad carry
the identical latent crash for any .tmp staging destination.

Closes #10727

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
@mudler mudler enabled auto-merge (squash) July 7, 2026 20:37
@mudler mudler merged commit 7dde5a4 into master Jul 7, 2026
72 of 74 checks passed
@mudler mudler deleted the fix/diffusers-image-save-format branch July 7, 2026 21:24
@localai-bot localai-bot added the bug Something isn't working label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(diffusers): Python backend crashes saving image to .tmp path without explicit format

2 participants