Skip to content

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.

License

Notifications You must be signed in to change notification settings

artryazanov/qwen-image-edit-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qwen Image Edit Docker

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.

License Docker Gradio

Features

  • 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 FlowMatchEulerDiscreteScheduler for 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.

Prerequisites

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

Installation

  1. Clone the repository:
    git clone https://github.com/artryazanov/qwen-image-edit-docker.git
    cd qwen-image-edit-docker

Usage

Option 1: Docker Compose (Recommended)

This is the simplest way to run the service.

  1. Start the container:

    docker-compose up --build

    Add -d to run in detached mode (background).

  2. Access the Web UI: Open your browser/client and go to: http://localhost:7860

  3. Stop the container:

    docker-compose down

Option 2: Docker CLI

If you prefer using the Docker CLI directly:

  1. Build the image:

    docker build -t my-qwen-edit .
  2. Run the container:

    docker run --gpus all -p 7860:7860 \
        --ipc=host \
        -v ~/.cache/huggingface:/root/.cache/huggingface \
        my-qwen-edit

API Documentation

This service exposes an API endpoint via Gradio that you can use to integrate with your PHP or other applications.

Endpoint: /run/predict

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
}

Configuration

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/huggingface to the container to persist model files. You can change the source path if your cache is located elsewhere.

Project Structure

  • 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.

License

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks