Views
No views yet
CUDA_VISIBLE_DEVICES=0,1,2,3 python infer_Glance_qwen.py1import torch
2from pipeline.qwen import GlanceQwenSlowPipeline, GlanceQwenFastPipeline
3from utils.distribute_free import distribute, free_pipe
4
5repo = "CSU-JPG/Glance"
6slow_pipe = GlanceQwenSlowPipeline.from_pretrained("Qwen/Qwen-Image", torch_dtype=torch.float32)
7slow_pipe.load_lora_weights(repo, weight_name="glance_qwen_slow.safetensors")
8distribute(slow_pipe)
9
10prompt = "Please create a photograph capturing a young woman showcasing a dynamic presence as she bicycles alongside a river during a hot summer day. Her long hair streams behind her as she pedals, dressed in snug tights and a vibrant yellow tank top, complemented by New Balance running shoes that highlight her lean, athletic build. She sports a small backpack and sunglasses resting confidently atop her head."
11latents = slow_pipe(
12 prompt=prompt,
13 negative_prompt=" ",
14 width=1024,
15 height=1024,
16 num_inference_steps=5,
17 true_cfg_scale=5,
18 generator=torch.Generator(device="cuda").manual_seed(0),
19 output_type="latent"
20).images[0].unsqueeze(0).detach().cpu()
21free_pipe(slow_pipe)
22
23fast_pipe = GlanceQwenFastPipeline.from_pretrained("Qwen/Qwen-Image", torch_dtype=torch.float32)
24fast_pipe.load_lora_weights(repo, weight_name="glance_qwen_fast.safetensors")
25distribute(fast_pipe)
26
27image = fast_pipe(
28 prompt=prompt,
29 negative_prompt=" ",
30 width=1024,
31 height=1024,
32 num_inference_steps=5,
33 true_cfg_scale=5,
34 generator=torch.Generator(device="cuda").manual_seed(0),
35 latents=latents.to("cuda", dtype=torch.float32)
36).images[0]
37image.save("output.png")
accelerate launch train_Glance_qwen.py --config ./train_configs/Glance_qwen.yamlNote: All the training code is primarily based on flymyai-lora-trainer.
Glance_qwen.yaml is properly configured with your dataset paths, model settings, output directory, and other hyperparameters. You can also explicitly specify whether to train the Slow-LoRA or Fast-LoRA variant directly within the configuration file.python train_Glance_qwen.py --config ./train_configs/Glance_qwen.yamlaccelerate launch train_Glance_flux.py --config ./train_configs/Glance_flux.yaml@misc{dong2025glanceacceleratingdiffusionmodels,
title={Glance: Accelerating Diffusion Models with 1 Sample},
author={Zhuobai Dong and Rui Zhao and Songjie Wu and Junchao Yi and Linjie Li and Zhengyuan Yang and Lijuan Wang and Alex Jinpeng Wang},
year={2025},
eprint={2512.02899},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2512.02899},
}