Views
No views yet
diffusers library, ComfyUI, or any other model), although models that use architectures which are unfamiliar to me might be more difficult.diffusers1import torch
2from diffusers import FluxPipeline, FluxTransformer2DModel
3from dfloat11 import DFloat11Model
4# from transformers.modeling_utils import no_init_weights # for transformers<5.0.0
5from transformers.initialization import no_init_weights # for transformers>=5.0.0
6with no_init_weights():
7 transformer = FluxTransformer2DModel.from_config(
8 FluxTransformer2DModel.load_config(
9 "Shakker-Labs/AWPortrait-FL", subfolder="transformer"
10 ),
11 torch_dtype=torch.bfloat16
12 ).to(torch.bfloat16)
13DFloat11Model.from_pretrained(
14 "mingyi456/AWPortrait-FL-DF11",
15 device="cpu",
16 bfloat16_model=transformer,
17)
18pipe = FluxPipeline.from_pretrained(
19 "Shakker-Labs/AWPortrait-FL",
20 transformer=transformer,
21 torch_dtype=torch.bfloat16
22)
23pipe.enable_model_cpu_offload()
24prompt = "close up portrait, Amidst the interplay of light and shadows in a photography studio,a soft spotlight traces the contours of a face,highlighting a figure clad in a sleek black turtleneck. The garment,hugging the skin with subtle luxury,complements the Caucasian model's understated makeup,embodying minimalist elegance. Behind,a pale gray backdrop extends,its fine texture shimmering subtly in the dim light,artfully balancing the composition and focusing attention on the subject. In a palette of black,gray,and skin tones,simplicity intertwines with profundity,as every detail whispers untold stories."
25image = pipe(
26 prompt,
27 num_inference_steps=24,
28 guidance_scale=3.5,
29 width=768, height=1024,
30).images[0]
31image.save('image awportrait-fl.png')pattern_dict for compression:1pattern_dict = {
2 "transformer_blocks\.\d+" : (
3 "norm1.linear",
4 "norm1_context.linear",
5 "attn.to_q",
6 "attn.to_k",
7 "attn.to_v",
8 "attn.add_k_proj",
9 "attn.add_v_proj",
10 "attn.add_q_proj",
11 "attn.to_out.0",
12 "attn.to_add_out",
13 "ff.net.0.proj",
14 "ff.net.2",
15 "ff_context.net.0.proj",
16 "ff_context.net.2",
17 ),
18 "single_transformer_blocks\.\d+" : (
19 "norm.linear",
20 "proj_mlp",
21 "proj_out",
22 "attn.to_q",
23 "attn.to_k",
24 "attn.to_v",
25 )
26}