Views
No views yet
pip install -U diffusers transformers torchao accelerate1import torch
2
3from diffusers import AutoModel, DiffusionPipeline
4
5torch_dtype = torch.bfloat16
6device = "cuda"
7
8transformer = AutoModel.from_pretrained(
9 "dimitribarbot/Qwen-Image-int8wo",
10 torch_dtype=torch_dtype,
11 use_safetensors=False
12)
13pipe = DiffusionPipeline.from_pretrained(
14 "Qwen/Qwen-Image",
15 transformer=transformer,
16 torch_dtype=torch_dtype
17)
18pipe.enable_model_cpu_offload()
19pipe.enable_vae_tiling()
20
21prompt = "a woman and a man sitting at a cafe, the woman has red hair and she's wearing purple sweater with a black scarf and a white hat, the man is sitting on the other side of the table and he's wearing a white shirt with a purple scarf and red hat, both of them are sipping their coffee while in the table there's some cake slices on their respective plates, each with forks and knives at each side."
22negative_prompt = ""
23
24generator = torch.Generator(device=device).manual_seed(42)
25
26image = pipe(
27 prompt=prompt,
28 negative_prompt=negative_prompt,
29 width=1664,
30 height=928,
31 num_inference_steps=25,
32 true_cfg_scale=4.0,
33 generator=generator,
34).images[0]
35
36image.save("qwen_image_torchao.png")