feat(api): Add OpenAI-compatible Image Generation API (Text-to-Image & Image-to-Image)#855
Open
iazrael wants to merge 4 commits intojundot:mainfrom
Open
feat(api): Add OpenAI-compatible Image Generation API (Text-to-Image & Image-to-Image)#855iazrael wants to merge 4 commits intojundot:mainfrom
iazrael wants to merge 4 commits intojundot:mainfrom
Conversation
…model detection Add comprehensive Text-to-Image (T2I) and Image-to-Image (I2I) support via mflux: - Add ImageEngine with support for FLUX.1/FLUX.2, Z-Image, FIBO, SeedVR2, Qwen Image - Implement OpenAI-compatible /v1/images/generations endpoint - Add ImageRequest/ImageResponse Pydantic models with validation - Integrate image models into EnginePool with LRU eviction support - Refactor model_discovery.py: extract _check_image_model_from_config() helper to reduce nesting and improve testability of image model detection - Add .worktrees/ and outputs/ to .gitignore Supported features: - Batch generation (n=1-4 images) - Configurable size, quality, guidance scale, inference steps - Negative prompts and seed control - Image-to-image transformation with strength parameter Dependencies: - Add mflux>=0.17.0 for image generation Tests: - test_image_engine.py: ImageEngine unit tests with mocks - test_image_models.py: Pydantic model validation tests - test_image_gen.py: Integration test script Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add denoising step progress display in Active Models card for image generation requests. Shows step/total with speed metrics and per-request progress bars when generating images via mflux. - Add ImageProgressTracker singleton for thread-safe progress state - Add ImageProgressCallback implementing mflux duck-typed protocols - Integrate callback registration/cleanup in ImageEngine.generate_image() - Update admin stats API to read image_progress for image engines - Update dashboard template to show step progress with green indicator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9cee9b1 to
5f4d60b
Compare
Remove strict Literal type constraint on image size parameter. Instead accept any valid WxH format string and validate dynamically. This gives API callers full control over resolution while providing suggested values in documentation. - Change size field from Literal to str with WxH format validation - Add field_validator to ensure positive integer dimensions - Document suggested sizes including new 720x1280 portrait option - Update ImageEngine and model discovery for flexible resolution handling Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Big up on this, great idea and was going to implement the same myself. |
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.
Summary
Implements comprehensive image generation support for oMLX via mflux, enabling Text-to-Image (T2I) and Image-to-Image (I2I) capabilities with OpenAI-compatible API endpoints.
Closes #477
Features
Core Implementation
omlx/engine/image.py): Manages diffusion model loading, inference, and MLX executor for Metal command buffer safetymodel_index.json(FLUX.1/FLUX.2, Z-Image, FIBO, SeedVR2, Qwen Image)/v1/images/generationsendpoint with Pydantic validationSupported Models
API Compatibility
OpenAI DALL-E compatible request/response format:
POST /v1/images/generations { "model": "FLUX.1-dev", "prompt": "a sunset over mountains", "size": "1024x1024", "n": 1 }Changes
omlx/api/image_models.py,omlx/api/image_routes.py,omlx/engine/image.pymodel_discovery.py(refactored nested image detection into helper)engine_pool.py(ImageEngine integration)pyproject.toml(optional[image]dependency with mflux>=0.17.0)Tests
test_image_engine.py: Unit tests for ImageEngine (lazy import, model resolution, generation)test_image_models.py: Pydantic validation teststest_image_gen.py: Integration test scriptInstallation
Architecture Notes
_check_image_model_from_config()from deeply nested logic indetect_model_type()Related Issue: #477