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 ChromaPipeline, ChromaTransformer2DModel
3from dfloat11 import DFloat11Model
4from transformers.modeling_utils import no_init_weights
5pattern_dict = {
6 r"distilled_guidance_layer\.layers\.\d+": (
7 "linear_1",
8 "linear_2"
9 ),
10 r"transformer_blocks\.\d+": (
11 "attn.to_q",
12 "attn.to_k",
13 "attn.to_v",
14 "attn.add_k_proj",
15 "attn.add_v_proj",
16 "attn.add_q_proj",
17 "attn.to_out.0",
18 "attn.to_add_out",
19 "ff.net.0.proj",
20 "ff.net.2",
21 "ff_context.net.0.proj",
22 "ff_context.net.2",
23 ),
24 r"single_transformer_blocks\.\d+": (
25 "proj_mlp",
26 "proj_out",
27 "attn.to_q",
28 "attn.to_k",
29 "attn.to_v",
30 ),
31}
32with no_init_weights():
33 transformer = ChromaTransformer2DModel.from_config(
34 ChromaTransformer2DModel.load_config(
35 "lodestones/Chroma1-HD",
36 subfolder="transformer"
37 ),
38 torch_dtype=torch.bfloat16
39 ).to(torch.bfloat16)
40
41pipe = ChromaPipeline.from_pretrained(
42 "lodestones/Chroma1-HD",
43 transformer=transformer,
44 torch_dtype=torch.bfloat16
45)
46DFloat11Model.from_single_file('uncannyPhotorealism_v12-DF11.safetensors', device='cpu', bfloat16_model=pipe.transformer, pattern_dict=pattern_dict) # Make sure to download the file first, and edit the filepath accordingly
47pipe.enable_model_cpu_offload()
48prompt = """professional cinematic film still. a beautiful punk woman in her early twenties. shaking her head and hair in the middle the crowd at a punk rock concert. her hair is all over the place with her movement. she is sweating. the woman has a narrow waist and small perky breasts. She has full lips, long curly blond hair, her hair is shaved on one side, freckles dust her nose.
49Wearing denim shorts and a crop top.
50A tattoo is visible on her chest above her top, it reads:
51"UnCanny"
52The photo is sharp and crisp, 8k - with a stylized cinematic atmosphere.
53"""
54negative_prompt = "heavy bokeh, heavy film grain, jpeg artifacts, blurry, plasticy skin, undetailed skin, unsaturated tones, 3D image, CGI rendering, AI generated image, watermark, signature. undetailed bodies, undetailed faces, undetailed background. Anime, cartoon, manga, cel-shaded, stylized illustration, unrealistic proportions, painterly, sketch, illustration styles, CGI style, monochrome"
55image = pipe(
56 prompt,
57 guidance_scale=3.5,
58 num_inference_steps=35,
59 max_sequence_length=256,
60 generator=torch.Generator("cpu").manual_seed(0)
61).images[0]
62image.save("uncannyPhotorealism_v12-DF11.png")