Views
No views yet



pip install git+https://github.com/huggingface/diffusers1from diffusers import DiffusionPipeline
2import torch
3
4model_name = "Qwen/Qwen-Image"
5
6# Load the pipeline
7if torch.cuda.is_available():
8 torch_dtype = torch.bfloat16
9 device = "cuda"
10else:
11 torch_dtype = torch.float32
12 device = "cpu"
13
14pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
15pipe = pipe.to(device)
16
17positive_magic = {
18 "en": ", Ultra HD, 4K, cinematic composition.", # for english prompt
19 "zh": ", 超清,4K,电影级构图." # for chinese prompt
20}
21
22# Generate image
23prompt = '''A coffee shop entrance features a chalkboard sign reading "Qwen Coffee 😊 $2 per cup," with a neon light beside it displaying "通义千问". Next to it hangs a poster showing a beautiful Chinese woman, and beneath the poster is written "π≈3.1415926-53589793-23846264-33832795-02384197". Ultra HD, 4K, cinematic composition'''
24
25negative_prompt = " " # using an empty string if you do not have specific concept to remove
26
27
28# Generate with different aspect ratios
29aspect_ratios = {
30 "1:1": (1328, 1328),
31 "16:9": (1664, 928),
32 "9:16": (928, 1664),
33 "4:3": (1472, 1140),
34 "3:4": (1140, 1472),
35 "3:2": (1584, 1056),
36 "2:3": (1056, 1584),
37}
38
39width, height = aspect_ratios["16:9"]
40
41image = pipe(
42 prompt=prompt + positive_magic["en"],
43 negative_prompt=negative_prompt,
44 width=width,
45 height=height,
46 num_inference_steps=50,
47 true_cfg_scale=4.0,
48 generator=torch.Generator(device="cuda").manual_seed(42)
49).images[0]
50
51image.save("example.png")



1@misc{wu2025qwenimagetechnicalreport,
2 title={Qwen-Image Technical Report},
3 author={Chenfei Wu and Jiahao Li and Jingren Zhou and Junyang Lin and Kaiyuan Gao and Kun Yan and Sheng-ming Yin and Shuai Bai and Xiao Xu and Yilei Chen and Yuxiang Chen and Zecheng Tang and Zekai Zhang and Zhengyi Wang and An Yang and Bowen Yu and Chen Cheng and Dayiheng Liu and Deqing Li and Hang Zhang and Hao Meng and Hu Wei and Jingyuan Ni and Kai Chen and Kuan Cao and Liang Peng and Lin Qu and Minggang Wu and Peng Wang and Shuting Yu and Tingkun Wen and Wensen Feng and Xiaoxiao Xu and Yi Wang and Yichang Zhang and Yongqiang Zhu and Yujia Wu and Yuxuan Cai and Zenan Liu},
4 year={2025},
5 eprint={2508.02324},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2508.02324},
9}