qi21 / README.md
multimodalart's picture
multimodalart HF Staff
README: AoTI kernels, tiling and the KV-cache budget
b4bafd0 verified
|
Raw History Blame Contribute Delete
3.02 kB

A newer version of the Gradio SDK is available: 6.32.0

Upgrade
metadata
title: Qwen-Image-2.1
emoji: 🖼️
colorFrom: indigo
colorTo: pink
sdk: gradio
sdk_version: 6.28.0
app_file: app.py
short_description: Generate and edit images with Qwen-Image-2.1
python_version: '3.12'
startup_duration_timeout: 1h
license: other
license_name: qwen-research
license_link: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE

Qwen-Image-2.1

Text-to-image generation and multi-image editing with Qwen/Qwen-Image-2.1, running on ZeroGPU through the QwenImage21Pipeline in diffusers.

  • Text to image — leave the input gallery empty and describe what you want.
  • Image editing — upload up to 10 images and refer to them as <image1> … <image10> in the prompt (upload order).
  • Transparency — the model natively decodes RGBA. Ask for it in the prompt, e.g. "This is an RGBA image with transparency. … The image has alpha channel and the background is transparent."

Prompt enhancement

The Enhance prompt checkbox calls a companion Space, hugging-apps/qwen-image-2-1-prompt-enhancer, which keeps both official rewriters (Qwen-Image-2.1-PE-T2I and Qwen-Image-2.1-PE-I2I) warm and resident on their own GPU worker. Splitting them out keeps this Space's GPU allocation dedicated to diffusion.

Speed

The transformer blocks and the VAE decoder run as ahead-of-time compiled kernels (PyTorch AOTInductor) published in hugging-apps/qwen-image-2-1-aoti and built by hugging-apps/qwen-image-2-1-aoti-compile. One dynamic-shape artifact per module covers every resolution, aspect ratio and number of condition images; the first denoising step (the block-causal prefill) and the text encoder stay eager. Set the QWEN21_AOTI=0 variable to run fully eager.

Everything stays resident on the GPU. Outputs above 1536 px decode in tiles, and the prefix KV cache is switched off for requests whose condition images would not fit next to the weights (it costs about 2 GB per 1K-pixel condition image), which keeps many-image edits running at the cost of speed.

Safety

Editing requests (any submission with input images) are screened with hfmlsoc/ncii-guard-v02 before anything is generated.

Example assets

The images under examples/ are the official demo assets from the Qwen/Qwen-Image-2.1 Space, redistributed here under the Qwen Research License for non-commercial demonstration.

License

Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.

Research / evaluation use only — see the license.