A Dockerized environment for Qwen-Image-Edit, served via a Gradio interface and API. This project allows you to easily edit images using text prompts, leveraging the power of local NVIDIA GPUs with FlowMatchEulerDiscreteScheduler for high-quality results.
Warning
Experimental Status: Improved generation quality has not yet been achieved on consumer hardware (tested on RTX 4080 16GB). Results may be unsatisfactory. Proceed with deployment primarily for testing or development purposes.
- Easy Deployment: One-command startup using Docker Compose.
- GPU Acceleration: Optimized for NVIDIA GPUs with CUDA support, utilizing 4-bit quantization (NF4) and BFloat16 for efficiency.
- Advanced Scheduling: Uses
FlowMatchEulerDiscreteSchedulerfor superior generation quality. - Web Interface: User-friendly Gradio web UI with resolution controls.
- API Endpoint: REST-like API for integration with other applications.
- Persistent Cache: Hugging Face models are cached on the host.
Before running this project, ensure you have the following installed:
- Docker Engine: Install Docker
- NVIDIA GPU: A generic NVIDIA GPU (e.g., RTX 4080) with at least 16GB VRAM recommended.
- NVIDIA Container Toolkit: Required for Docker to access your GPU. Installation Guide
- Clone the repository:
git clone https://github.com/artryazanov/qwen-image-edit-docker.git cd qwen-image-edit-docker
This is the simplest way to run the service.
-
Start the container:
docker-compose up --build
Add
-dto run in detached mode (background). -
Access the Web UI: Open your browser/client and go to: http://localhost:7860
-
Stop the container:
docker-compose down
If you prefer using the Docker CLI directly:
-
Build the image:
docker build -t my-qwen-edit . -
Run the container:
docker run --gpus all -p 7860:7860 \ --ipc=host \ -v ~/.cache/huggingface:/root/.cache/huggingface \ my-qwen-edit
This service exposes an API endpoint via Gradio that you can use to integrate with your PHP or other applications.
Depending on the Gradio version, the endpoint might be available at /api/predict or /run/predict. Check the "Use via API" link in the footer of the web UI for the exact details for your version.
Method: POST
Content-Type: application/json
Payload Structure:
{
"data": [
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg==",
"make it look like a painting",
"Square (1024x1024)"
]
}- Argument 1: Input image (base64 string or URL).
- Argument 2: Text prompt.
- Argument 3: Resolution choice. Options are:
"Square (1024x1024)""HD (1280x720)""Full HD (1920x1080)"
Response Structure:
{
"data": [
"data:image/png;base64,..."
],
"is_generating": false,
"duration": 0.123,
"average_duration": 0.123
}You can configure the deployment by modifying docker-compose.yml:
- Ports: Change
"7860:7860"if you need to expose a different port on the host. - Volumes: The command maps
~/.cache/huggingfaceto the container to persist model files. You can change the source path if your cache is located elsewhere.
Dockerfile: Defines the environment and dependencies.app.py: Main entry point for the Gradio application.docker-compose.yml: Configuration for orchestration..dockerignore: Files to exclude from the build context.
This project's code (Dockerfile, Python scripts) is licensed under the MIT License.
The underlying model Qwen-Image-Edit is subject to its own license from Alibaba Cloud (typically Apache 2.0 or Qwen License). By using this container, you also agree to the terms of the model's license.