@@ -35,7 +35,7 @@ import torch
3535from diffusers import Krea2Pipeline
3636
3737# Load from a local directory produced by the Krea 2 conversion (no hub repo yet).
38- pipe = Krea2Pipeline.from_pretrained(" path/to/krea2-diffusers " , torch_dtype = torch.bfloat16)
38+ pipe = Krea2Pipeline.from_pretrained(" krea/Krea-2-Raw " , torch_dtype = torch.bfloat16)
3939pipe.to(" cuda" )
4040
4141prompt = " a fox in the snow"
@@ -50,6 +50,27 @@ image = pipe(
5050image.save(" krea2.png" )
5151```
5252
53+ We additionally provide an example for using Krea2 Turbo :
54+
55+ ``` python
56+ import torch
57+ from diffusers import Krea2Pipeline
58+
59+ pipe = Krea2Pipeline.from_pretrained(" krea/Krea-2-Turbo" , torch_dtype = torch.bfloat16)
60+ pipe.to(" cuda" )
61+
62+ image = pipe(
63+ " a fox in the snow" ,
64+ height = 1024 ,
65+ width = 1024 ,
66+ num_inference_steps = 8 ,
67+ guidance_scale = 0.0 ,
68+ generator = torch.Generator(" cuda" ).manual_seed(0 ),
69+ ).images[0 ]
70+ image.save(" krea2_turbo.png" )
71+ ```
72+
73+
5374## Krea2Pipeline
5475
5576[[ autodoc]] Krea2Pipeline
@@ -59,3 +80,67 @@ image.save("krea2.png")
5980## Krea2PipelineOutput
6081
6182[[ autodoc]] pipelines.krea2.pipeline_output.Krea2PipelineOutput
83+
84+ ## Modular
85+
86+ Krea 2 is also available as a [ modular pipeline] ( ../../modular_diffusers/overview ) . Classifier-free guidance is
87+ configured through the ` guider ` component rather than a ` guidance_scale ` call argument. Krea 2 uses cond-anchored CFG,
88+ which is [ ` ClassifierFreeGuidance ` ] with ` use_original_formulation=True ` .
89+
90+ ``` python
91+ import torch
92+ from diffusers import ClassifierFreeGuidance, ModularPipeline
93+
94+ pipe = ModularPipeline.from_pretrained(" krea/Krea-2-Raw" )
95+ pipe.load_components(torch_dtype = torch.bfloat16)
96+ pipe.to(" cuda" )
97+
98+
99+ image = pipe(
100+ prompt = " a fox in the snow" ,
101+ height = 1024 ,
102+ width = 1024 ,
103+ num_inference_steps = 28 ,
104+ generator = torch.Generator(" cuda" ).manual_seed(0 ),
105+ ).images[0 ]
106+ image.save(" krea2.png" )
107+ ```
108+
109+ We additionally provide an example for using Krea2 Turbo. The distilled checkpoint maps to its own set of blocks
110+ ([ ` Krea2TurboAutoBlocks ` ] ): it runs guidance-free (no ` guider ` ), takes no negative prompt, and samples in a few steps.
111+ ` ModularPipeline.from_pretrained ` picks the turbo blocks automatically from the checkpoint's ` is_distilled ` config, so
112+ no guidance configuration is needed:
113+
114+ ``` python
115+ import torch
116+ from diffusers import ModularPipeline
117+
118+ pipe = ModularPipeline.from_pretrained(" krea/Krea-2-Turbo" )
119+ pipe.load_components(torch_dtype = torch.bfloat16)
120+ pipe.to(" cuda" )
121+
122+ image = pipe(
123+ prompt = " a fox in the snow" ,
124+ height = 1024 ,
125+ width = 1024 ,
126+ num_inference_steps = 8 ,
127+ generator = torch.Generator(" cuda" ).manual_seed(0 ),
128+ ).images[0 ]
129+ image.save(" krea2_turbo.png" )
130+ ```
131+
132+ ## Krea2ModularPipeline
133+
134+ [[ autodoc]] Krea2ModularPipeline
135+
136+ ## Krea2AutoBlocks
137+
138+ [[ autodoc]] Krea2AutoBlocks
139+
140+ ## Krea2TurboModularPipeline
141+
142+ [[ autodoc]] Krea2TurboModularPipeline
143+
144+ ## Krea2TurboAutoBlocks
145+
146+ [[ autodoc]] Krea2TurboAutoBlocks
0 commit comments