Views
No views yet

pip install torch
pip install git+https://github.com/huggingface/diffusers1import torch
2import os
3from diffusers import DiffusionPipeline
4model_name = "OPPOer/Qwen-Image-Pruning"
5if torch.cuda.is_available():
6 torch_dtype = torch.bfloat16
7 device = "cuda"
8else:
9 torch_dtype = torch.bfloat16
10 device = "cpu"
11pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
12pipe = pipe.to(device)
13# Generate image
14positive_magic = {"en": ", Ultra HD, 4K, cinematic composition.", # for english prompt,
15"zh": ",超清,4K,电影级构图。" # for chinese prompt,
16}
17negative_prompt = " "
18prompts = [
19 '一个穿着"QWEN"标志的T恤的中国美女正拿着黑色的马克笔面相镜头微笑。她身后的玻璃板上手写体写着 "一、Qwen-Image的技术路线: 探索视觉生成基础模型的极限,开创理解与生成一体化的未来。二、Qwen-Image的模型特色:1、复杂文字渲染。支持中英渲染、自动布局; 2、精准图像编辑。支持文字编辑、物体增减、风格变换。三、Qwen-Image的未来愿景:赋能专业内容创作、助力生成式AI发展。"',
20 '海报,温馨家庭场景,柔和阳光洒在野餐布上,色彩温暖明亮,主色调为浅黄、米白与淡绿,点缀着鲜艳的水果和野花,营造轻松愉快的氛围,画面简洁而富有层次,充满生活气息,传达家庭团聚与自然和谐的主题。文字内容:“共享阳光,共享爱。全家一起野餐,享受美好时光。让每一刻都充满欢笑与温暖。”',
21 '一个穿着校服的年轻女孩站在教室里,在黑板上写字。黑板中央用整洁的白粉笔写着“Introducing Qwen-Image, a foundational image generation model that excels in complex text rendering and precise image editing”。柔和的自然光线透过窗户,投下温柔的阴影。场景以写实的摄影风格呈现,细节精细,景深浅,色调温暖。女孩专注的表情和空气中的粉笔灰增添了动感。背景元素包括课桌和教育海报,略微模糊以突出中心动作。超精细32K分辨率,单反质量,柔和的散景效果,纪录片式的构图。',
22 '一个台球桌上放着两排台球,每排5个,第一行的台球上面分别写着"Qwen""Image" "将 "于" "8" ,第二排台球上面分别写着"月" "正" "式" "发" "布" 。',
23]
24output_dir = 'examples_Pruning'
25os.makedirs(output_dir, exist_ok=True)
26for prompt in prompts:
27 output_img_path = f"{output_dir}/{prompt[:80]}.png"
28 image = pipe(
29 prompt=prompt + positive_magic['zh'],
30 negative_prompt=negative_prompt,
31 width=1328,
32 height=1328,
33 num_inference_steps=8,
34 true_cfg_scale=1,
35 generator=torch.Generator(device="cuda").manual_seed(42)
36 ).images[0]
37 image.save(output_img_path)1import torch
2import os
3from diffusers import DiffusionPipeline
4model_name = "OPPOer/Qwen-Image-Pruning"
5lora_name = 'flymy_realism.safetensors'
6if torch.cuda.is_available():
7 torch_dtype = torch.bfloat16
8 device = "cuda"
9else:
10 torch_dtype = torch.bfloat16
11 device = "cpu"
12pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
13pipe = pipe.to(device)
14pipe.load_lora_weights(lora_name, adapter_name="lora")
15# Generate image
16positive_magic = {"en": ", Ultra HD, 4K, cinematic composition.", # for english prompt,
17"zh": ",超清,4K,电影级构图。" # for chinese prompt,
18}
19negative_prompt = " "
20prompts = [
21 '一个穿着"QWEN"标志的T恤的中国美女正拿着黑色的马克笔面相镜头微笑。她身后的玻璃板上手写体写着 "一、Qwen-Image的技术路线: 探索视觉生成基础模型的极限,开创理解与生成一体化的未来。二、Qwen-Image的模型特色:1、复杂文字渲染。支持中英渲染、自动布局; 2、精准图像编辑。支持文字编辑、物体增减、风格变换。三、Qwen-Image的未来愿景:赋能专业内容创作、助力生成式AI发展。"',
22 '海报,温馨家庭场景,柔和阳光洒在野餐布上,色彩温暖明亮,主色调为浅黄、米白与淡绿,点缀着鲜艳的水果和野花,营造轻松愉快的氛围,画面简洁而富有层次,充满生活气息,传达家庭团聚与自然和谐的主题。文字内容:“共享阳光,共享爱。全家一起野餐,享受美好时光。让每一刻都充满欢笑与温暖。”',
23 '一个穿着校服的年轻女孩站在教室里,在黑板上写字。黑板中央用整洁的白粉笔写着“Introducing Qwen-Image, a foundational image generation model that excels in complex text rendering and precise image editing”。柔和的自然光线透过窗户,投下温柔的阴影。场景以写实的摄影风格呈现,细节精细,景深浅,色调温暖。女孩专注的表情和空气中的粉笔灰增添了动感。背景元素包括课桌和教育海报,略微模糊以突出中心动作。超精细32K分辨率,单反质量,柔和的散景效果,纪录片式的构图。',
24 '一个台球桌上放着两排台球,每排5个,第一行的台球上面分别写着"Qwen""Image" "将 "于" "8" ,第二排台球上面分别写着"月" "正" "式" "发" "布" 。',
25]
26output_dir = 'examples_Pruning+Realism_LoRA'
27os.makedirs(output_dir, exist_ok=True)
28for prompt in prompts:
29 output_img_path = f"{output_dir}/{prompt[:80]}.png"
30 image = pipe(
31 prompt=prompt + positive_magic['zh'],
32 negative_prompt=negative_prompt,
33 width=1328,
34 height=1328,
35 num_inference_steps=8,
36 true_cfg_scale=1,
37 generator=torch.Generator(device="cuda").manual_seed(42)
38 ).images[0]
39 image.save(output_img_path)1import os
2import glob
3import torch
4from diffusers import DiffusionPipeline
5from diffusers.utils import load_image
6from diffusers import QwenImageControlNetPipeline, QwenImageControlNetModel
7model_name = "OPPOer/Qwen-Image-Pruning"
8controlnet_name = "InstantX/Qwen-Image-ControlNet-Union"
9# Load the pipeline
10if torch.cuda.is_available():
11 torch_dtype = torch.bfloat16
12 device = "cuda"
13else:
14 torch_dtype = torch.bfloat16
15 device = "cpu"
16controlnet = QwenImageControlNetModel.from_pretrained(controlnet_name, torch_dtype=torch.bfloat16)
17pipe = QwenImageControlNetPipeline.from_pretrained(
18 model_name, controlnet=controlnet, torch_dtype=torch.bfloat16
19)
20pipe = pipe.to(device)
21# Generate image
22prompt_dict = {
23 "soft_edge.png": "Photograph of a young man with light brown hair jumping mid-air off a large, reddish-brown rock. He's wearing a navy blue sweater, light blue shirt, gray pants, and brown shoes. His arms are outstretched, and he has a slight smile on his face. The background features a cloudy sky and a distant, leafless tree line. The grass around the rock is patchy.",
24 "canny.png": "Aesthetics art, traditional asian pagoda, elaborate golden accents, sky blue and white color palette, swirling cloud pattern, digital illustration, east asian architecture, ornamental rooftop, intricate detailing on building, cultural representation.",
25 "depth.png": "A swanky, minimalist living room with a huge floor-to-ceiling window letting in loads of natural light. A beige couch with white cushions sits on a wooden floor, with a matching coffee table in front. The walls are a soft, warm beige, decorated with two framed botanical prints. A potted plant chills in the corner near the window. Sunlight pours through the leaves outside, casting cool shadows on the floor.",
26 "pose.png": "Photograph of a young man with light brown hair and a beard, wearing a beige flat cap, black leather jacket, gray shirt, brown pants, and white sneakers. He's sitting on a concrete ledge in front of a large circular window, with a cityscape reflected in the glass. The wall is cream-colored, and the sky is clear blue. His shadow is cast on the wall.",
27}
28controlnet_conditioning_scale = 1.0
29output_dir = f'examples_Pruning+ControlNet'
30os.makedirs(output_dir, exist_ok=True)
31for path in glob.glob('conds/*'):
32 control_image = load_image(path)
33 image_name = path.split('/')[-1]
34 if image_name in prompt_dict:
35 image = pipe(
36 prompt=prompt_dict[image_name],
37 negative_prompt=" ",
38 control_image=control_image,
39 controlnet_conditioning_scale=controlnet_conditioning_scale,
40 width=control_image.size[0],
41 height=control_image.size[1],
42 num_inference_steps=8,
43 true_cfg_scale=4.0,
44 generator=torch.Generator(device="cuda").manual_seed(42),
45 ).images[0]
46 image.save(os.path.join(output_dir, image_name))@misc{ma2025pluggablepruningcontiguouslayer,
title={Pluggable Pruning with Contiguous Layer Distillation for Diffusion Transformers},
author={Jian Ma and Qirong Peng and Xujie Zhu and Peixing Xie and Chen Chen and Haonan Lu},
year={2025},
eprint={2511.16156},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2511.16156},
}