naykun commited on
Commit
b3179ad
·
verified ·
1 Parent(s): 840b4ad

Update README with header, introduction, and usage

Browse files
Files changed (1) hide show
  1. README.md +156 -0
README.md ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: qwen-research
4
+ license_link: LICENSE
5
+ pipeline_tag: text-to-image
6
+ tags:
7
+ - diffusers
8
+ - qwen
9
+ - image-generation
10
+ - image-editing
11
+ - rgba
12
+ ---
13
+
14
+ <p align="center">
15
+ <img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Image/image2.1/logo.png" width="400"/>
16
+ </p>
17
+ <p align="center">
18
+ 🤖 <a href="https://modelscope.cn/models/Qwen/Qwen-Image-2.1">ModelScope</a>&nbsp;&nbsp;|
19
+ &nbsp;&nbsp;🤗 <a href="https://huggingface.co/Qwen/Qwen-Image-2.1">HuggingFace</a>&nbsp;&nbsp;|
20
+ &nbsp;&nbsp;📑 <a href="https://qwen.ai/blog?id=qwen-image-2.1">Blog</a>&nbsp;&nbsp;|
21
+ &nbsp;&nbsp;🖥️ <a href="https://huggingface.co/spaces/Qwen/Qwen-Image-2.1">Demo</a>&nbsp;&nbsp;|
22
+ &nbsp;&nbsp;🫨 <a href="https://discord.gg/CV4E9rpNSD">Discord</a>
23
+ </p>
24
+
25
+ ## Introduction
26
+
27
+ We are excited to open-source **Qwen-Image-2.1**, a unified text-to-image generation and image editing model in the Qwen family. With just **7B parameters in its visual generation component** (32 Single-Stream DiT layers), Qwen-Image-2.1 balances generation quality, inference efficiency, and versatility.
28
+
29
+ Four key improvements define this release:
30
+
31
+ - **Compact and Efficient** — A lightweight architecture with mixed-granularity attention and prefix KV cache reuse delivers strong image quality at low computational cost.
32
+ - **Native Transparency, Unified Creation and Editing** — Generate regular or transparent (RGBA) images from text, edit transparent layers, and extract subjects from photographs—all in one model.
33
+ - **Versatile Editing** — Support up to **10 reference images**, specify local edits via circles, painted annotations, or separate masks, and preserve identity for people and products.
34
+ - **Realistic Textures and Refined Aesthetics** — Improved typography, portrait lighting, and fine details for more visually compelling results.
35
+
36
+ <p align="center">
37
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-01.png" width="100%"/>
38
+ </p>
39
+
40
+ For more details, see the [GitHub repo](https://github.com/QwenLM/Qwen-Image-2.1) and [Blog](https://qwen.ai/blog?id=qwen-image-2.1).
41
+
42
+ ## Quick Start
43
+
44
+ ### Installation
45
+
46
+ ```bash
47
+ pip install torch>=2.4.0
48
+ pip install transformers>=5.17
49
+ pip install git+https://github.com/huggingface/diffusers
50
+ pip install accelerate pillow
51
+ ```
52
+
53
+ ### Text-to-Image
54
+
55
+ ```python
56
+ import torch
57
+ from diffusers import QwenImage21Pipeline
58
+
59
+ pipe = QwenImage21Pipeline.from_pretrained(
60
+ "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
61
+ ).to("cuda")
62
+
63
+ image = pipe(
64
+ prompt="A neon shop sign that reads \"QWEN IMAGE 2.1\", rainy night, reflections on wet pavement",
65
+ width=2048, height=2048,
66
+ num_inference_steps=40,
67
+ generator=torch.Generator("cuda").manual_seed(42),
68
+ ).images[0]
69
+
70
+ image.save("t2i_example.png")
71
+ ```
72
+
73
+ ### Image Editing
74
+
75
+ ```python
76
+ import torch
77
+ from PIL import Image
78
+ from diffusers import QwenImage21Pipeline
79
+
80
+ pipe = QwenImage21Pipeline.from_pretrained(
81
+ "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
82
+ ).to("cuda")
83
+
84
+ input_image = Image.open("input.png")
85
+
86
+ image = pipe(
87
+ prompt="Change the background to a sunset beach",
88
+ image=input_image,
89
+ num_inference_steps=40,
90
+ generator=torch.Generator("cuda").manual_seed(42),
91
+ ).images[0]
92
+
93
+ image.save("edit_example.png")
94
+ ```
95
+
96
+ ### Transparent Image Generation (RGBA)
97
+
98
+ Use the recommended prompt format for transparent images:
99
+
100
+ ```python
101
+ image = pipe(
102
+ prompt="This is an RGBA image with transparency. A cute cartoon dragon sticker. The image has alpha channel and the background is transparent.",
103
+ width=2048, height=2048,
104
+ num_inference_steps=40,
105
+ generator=torch.Generator("cuda").manual_seed(42),
106
+ ).images[0]
107
+
108
+ image.save("transparent_example.png")
109
+ ```
110
+
111
+ ### Supported Aspect Ratios
112
+
113
+ ```python
114
+ aspect_ratios = {
115
+ "1:1": (2048, 2048),
116
+ "4:3": (2400, 1792),
117
+ "3:4": (1792, 2400),
118
+ "3:2": (2528, 1696),
119
+ "2:3": (1696, 2528),
120
+ "16:9": (2752, 1536),
121
+ "9:16": (1536, 2752),
122
+ }
123
+ ```
124
+
125
+ ### Memory Optimization
126
+
127
+ ```python
128
+ pipe = QwenImage21Pipeline.from_pretrained(
129
+ "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
130
+ )
131
+ pipe.enable_model_cpu_offload()
132
+ ```
133
+
134
+ ## Showcase
135
+
136
+ <p align="center">
137
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-04.png" width="30%"/>
138
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-05.png" width="30%"/>
139
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-06.png" width="30%"/>
140
+ </p>
141
+ <p align="center"><em>Native transparent image generation</em></p>
142
+
143
+ <p align="center">
144
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-15.png" width="100%"/>
145
+ </p>
146
+ <p align="center"><em>Group photograph generated from six portrait references</em></p>
147
+
148
+ <p align="center">
149
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-43.png" width="48%"/>
150
+ <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen-Image/image2.1/images/example-44.png" width="48%"/>
151
+ </p>
152
+ <p align="center"><em>Text rendering</em></p>
153
+
154
+ ## License
155
+
156
+ This model is licensed under the [Qwen Research License Agreement](./LICENSE).