Views
No views yet
1import torch
2from diffusers import FluxPipeline
3
4# Load the base model
5pipe = FluxPipeline.from_pretrained(
6 "black-forest-labs/FLUX.1-dev",
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10
11# Load the LoRA weights
12pipe.load_lora_weights("ighoshsubho/lora-grpo-flux-dev")
13
14# Generate an image
15prompt = "A serene landscape with mountains and a lake at sunset"
16image = pipe(
17 prompt,
18 height=512,
19 width=512,
20 guidance_scale=3.5,
21 num_inference_steps=20,
22 max_sequence_length=256,
23).images[0]
24
25image.save("generated_image.png")1# You can adjust the LoRA influence
2pipe.set_adapters(["default"], adapter_weights=[0.8]) # 80% LoRA influence1@article{liu2025flow,
2 title={Flow-GRPO: Training Flow Matching Models via Online RL},
3 author={Liu, Jie and Liu, Gongye and Liang, Jiajun and Li, Yangguang and Liu, Jiaheng and Wang, Xintao and Wan, Pengfei and Zhang, Di and Ouyang, Wanli},
4 journal={arXiv preprint arXiv:2505.05470},
5 year={2025}
6}