Qwen-Image-Edit-2509-LoRAs-Fast-Fusion is a fast, interactive web application built with Gradio that enables advanced image editing using the Qwen/Qwen-Image-Edit-2509 model from Alibaba's Qwen team. It leverages specialized LoRA adapters for efficient, low-step inference (as few as 4 steps) on tasks like texture application, object fusion, and cloth design transfer. Upload a base image and a reference image, provide a prompt, and select an editing style to generate edited results with Lightning-fast acceleration. This app showcases Qwen-Image-Edit's capabilities in inpainting, outpainting, and style transfer, optimized with Flash Attention 3 (if supported) and a custom orange-red themed interface for a vibrant user experience.
- Specialized LoRA Adapters: Choose from "Texture Edit" (apply textures), "Fuse-Objects" (blend elements), or "Cloth-Design-Fuse" (transfer designs to clothing).
- Lightning Inference: Uses Qwen-Image-Lightning LoRA for ultra-fast generation (4 steps default).
- Prompt-Guided Edits: Natural language prompts guide the fusion (e.g., "Apply wood texture to the mug").
- Advanced Controls: Adjustable guidance scale, steps, seed randomization, and auto-resizing for optimal resolution (multiples of 16).
- GPU Optimization: Auto-detects CUDA; supports bfloat16 for efficiency.
- Gradio Interface: Dual-image upload with annotated outputs, examples, and progress tracking.
- Custom Theme: Orange-red gradients and shadows for a dynamic, fiery aesthetic.
To run this app locally, install the dependencies. Note that it requires recent versions of Hugging Face libraries from Git for compatibility with Qwen-Image-Edit.
pip install torch torchvision numpy gradio spaces sentencepiece huggingface_hub supervision kernels
pip install git+https://github.com/huggingface/accelerate.git
pip install git+https://github.com/huggingface/diffusers.git
pip install git+https://github.com/huggingface/peft.git
pip install git+https://github.com/QwenLM/QwenImage.git # For qwenimage custom components- GPU: NVIDIA GPU with CUDA 11.8+ and at least 8GB VRAM (e.g., RTX 30-series or A100) for fast inference. Falls back to CPU (slower).
- RAM: 16GB+ recommended.
- Storage: ~10GB for model weights and LoRAs (downloaded on first run).
-
Clone the Repository:
git clone https://github.com/PRITHIVSAKTHIUR/Qwen-Image-Edit-2509-LoRAs-Fast-Fusion.git cd Qwen-Image-Edit-2509-LoRAs-Fast-Fusion -
Install Dependencies: Run the pip commands from the Requirements section above.
-
Prepare Examples (Optional): Ensure the
examples/folder contains sample images likeCloth1.jpg,Design1.png,Cup1.png,Wood1.png, etc. Download them if needed or replace with your own. -
Run Locally:
python app.py
- The app launches a local web server (typically at
http://127.0.0.1:7860). - Open the URL in your browser to start editing.
- The app launches a local web server (typically at
- Optimized for HF Spaces with
@spaces.GPU(30-second duration limit per inference). - Fork the repo, create a new Space on Hugging Face, and link it. Enable GPU in Space settings.
- Models and LoRAs auto-download on startup.
| Component | Requirement | Details from Log |
|---|---|---|
| GPU Model | NVIDIA Enterprise (H200 / H100 / A100) | High VRAM requirement (MIG or full card) |
| VRAM | 80 GB Recommended (Min 70 GB) | Peak tensor packing reached 60.8 GB |
| System RAM | 128 GB+ | Required for safe model offloading/loading |
| Disk Space | ~60 GB+ | Transformer (~21GB) + Text Encoders (~17GB) + LoRAs |
| Python | v3.13 | Detected cpython-313 |
| PyTorch | v2.9.1 | 2.9.1+cu128 |
| CUDA | v12.8 | torch29-cxx11-cu128 |
- Upload Images: Select a "Base Image" (e.g., a mug) and a "Reference Image" (e.g., wood texture).
- Enter Prompt: Describe the edit (e.g., "Apply wood texture to the mug"). Defaults provided for each style.
- Choose Editing Style: Dropdown for "Texture Edit", "Fuse-Objects", or "Cloth-Design-Fuse".
- Tune Settings (Optional): Adjust seed, guidance scale (default: 1.0), and steps (default: 4) in the Advanced accordion.
- Click Edit Image: Generates the output with progress bar. Randomize seed for variations.
- Test Examples: Use built-in examples for quick demos like shirt design transfer.
- Inputs: Two PIL Images (base + reference), Text Prompt, LoRA Style, Seed/Params.
- Output: Edited PIL Image (PNG format) + Updated Seed.
- Texture Edit: Base: Mug photo; Reference: Wood pattern; Prompt: "Apply wood texture to mug."
- Cloth-Design-Fuse: Base: Person in shirt; Reference: Graphic design; Prompt: "Put this design on their shirt."
- Fuse-Objects: Base: Cat photo; Reference: Glasses; Prompt: "A cat wearing glasses."
app.py: Main Gradio app with pipeline loading, inference function, and UI setup.examples/: Sample image pairs for testing various edits.- Custom Theme:
OrangeRedThemeclass for bold, gradient-based styling. - Key Components:
QwenImageEditPlusPipeline: Core editing pipeline with LoRA fusion.infer(...): Handles image preprocessing, adapter selection, and generation.- LoRAs: Lightning (speed), Texture, Fusion, Shirt Design—loaded and fused dynamically.
- Base: Qwen/Qwen-Image-Edit-2509
- Transformer: linoyts/Qwen-Image-Edit-Rapid-AIO (subfolder: transformer)
- LoRAs: From lightx2v, tarn59, ostris
- Model/LoRA Loading Error: Verify internet access and Git installs. Clear cache with
huggingface-cli delete-cache. - CUDA/FA3 Issues: If Flash Attention 3 fails, it uses default attention. Ensure CUDA toolkit matches PyTorch version.
- Out of Memory: Reduce steps or image size; use
torch_dtype=torch.float16for lower VRAM. - No Output/Blurry Results: Increase guidance scale (try 2.0+) or steps (8+). Ensure prompts are descriptive.
- Gradio Errors: Update Gradio (
pip install --upgrade gradio) or check for port conflicts (e.g.,--port 7861).
Contributions welcome! Fork, branch, PR.
- Qwen Team: For the Qwen-Image-Edit model.
- Gradio: Intuitive UI framework.
- Hugging Face Diffusers/PEFT: For pipeline and adapter handling.
- LoRA Creators: lightx2v, tarn59, ostris.
For bugs or ideas, open a GitHub issue. Edit away!