Image Generation Service
Relevant source files
The following files were used as context for generating this wiki page:
The Image Generation Service is a core microservice within the Aether-X Ultimate platform responsible for creating visual content from natural language descriptions. It leverages diffusion-based AI models to transform text prompts into high-quality images, which are then delivered to users as Base64-encoded strings.
This service operates on port 8001 and is designed to handle both individual and batch generation requests. It is integrated into the broader platform ecosystem through the API Gateway, which provides load balancing and rate limiting for all image-related operations.
Sources: IMPLEMENTATION_COMPLETE.md:12, services/image-generation/app.py:88
Service Architecture
The service is built using the Flask web framework and utilizes the Hugging Face diffusers library for model inference. It is architected to run as a containerized microservice, often utilizing GPU acceleration (CUDA) when available to optimize generation speed.
Core Components
- Stable Diffusion Engine: Uses the
StableDiffusionPipeline(specifically versionv1-4) to perform text-to-image inference. - Base64 Encoder: A utility function that converts PIL image objects into Base64-encoded PNG strings for JSON-compatible transmission.
- Flask API: Provides RESTful endpoints for health monitoring and generation triggers.
Sources: services/image-generation/app.py:11-25
Data Flow
The following diagram illustrates the request flow from the external user through the gateway to the Image Generation Service.
This diagram shows the end-to-end flow for a text-to-image request within the Aether-X architecture.
Sources: services/api-gateway/app.py:116-125, services/image-generation/app.py:33-54
API Reference
The service exposes endpoints for single and multiple image generations. All successful generation responses include the original prompt and the resulting image data.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Returns the service health status. |
/generate | POST | Generates a single image from a provided prompt. |
/batch-generate | POST | Generates multiple images from an array of prompts. |
Sources: services/image-generation/app.py:27-86
Request/Response Schema
Single Generation Request:
{
"prompt": "a futuristic city at sunset"
}
Sources: services/image-generation/app.py:38-39
Successful Response:
{
"prompt": "a futuristic city at sunset",
"image_base64": "iVBORw0KGgoAAA...",
"status": "success"
}
Sources: services/image-generation/app.py:51-54
Infrastructure & Deployment
The Image Generation Service is designed for high availability and scalable deployment using Docker and Kubernetes.
Container Configuration
The service depends on Redis for caching and MongoDB for potential metadata storage as defined in the global orchestration layer.
image-generation:
build: ./services/image-generation
container_name: aether-x-image-generation
ports:
- "8001:8001"
depends_on:
- redis
- mongodb
Sources: docker-compose.yml:25-39
Kubernetes Deployment
In production environments, the service is deployed with the following resource constraints and health probes:
| Parameter | Value |
|---|---|
| Replicas | 3 |
| Memory Request | 1Gi |
| Memory Limit | 2Gi |
| CPU Request | 500m |
| CPU Limit | 1000m |
| Port | 8001 |
Sources: k8s/deployment.yaml:49-80
Database Integration
While the service primarily performs in-memory inference, the platform's initialization scripts prepare storage for generated content. Generated image metadata and pathing (or Base64 data) can be stored in the content_generated table across various database backends.
- MySQL/PostgreSQL: Stores generated content in the
content_generatedtable with acontent_typeof 'image'. - MongoDB: Stores content in the
content_generatedcollection with JSON schema validation.
Sources: infrastructure/databases/init-databases.sh:42-50, infrastructure/databases/init-databases.sh:139-156
Summary
The Image Generation Service provides a critical creative capability to the Aether-X Ultimate platform. By encapsulating Stable Diffusion within a scalable Flask microservice and utilizing Base64 encoding for data transfer, it enables seamless integration with the No-Code Development and Video Generation services to produce complex, multi-modal AI applications.