Views
No views yet
diffusers1pip install dfloat11[cuda12]
2# or if you have CUDA version 11:
3# pip install dfloat11[cuda11]1import torch
2from diffusers import FluxPipeline, FluxTransformer2DModel
3from dfloat11 import DFloat11Model
4with no_init_weights():
5 transformer = FluxTransformer2DModel.from_config(
6 FluxTransformer2DModel.load_config(
7 "black-forest-labs/FLUX.1-dev",
8 subfolder="transformer"
9 ),
10 torch_dtype=torch.bfloat16
11 ).to(torch.bfloat16)
12
13pipe = FluxPipeline.from_pretrained(
14 "black-forest-labs/FLUX.1-dev",
15 transformer=transformer,
16 torch_dtype=torch.bfloat16
17)
18DFloat11Model.from_pretrained('mingyi456/SRPO-DF11', device='cpu', bfloat16_model=pipe.transformer)
19pipe.enable_model_cpu_offload()
20prompt = "A futuristic cityscape at sunset, with flying cars, neon lights, and reflective water canals"
21image = pipe(
22 prompt,
23 guidance_scale=3.5,
24 num_inference_steps=30,
25 max_sequence_length=256,
26 generator=torch.Generator("cpu").manual_seed(0)
27).images[0]
28image.save("SPRO.png")