Buckets:
| import"../chunks/DsnmJJEf.js";import{i as B,h as N,C as z,H as a,a as j,D as t,E,s as C}from"../chunks/BtE7mKSK.js";import{p as S,o as V,s as e,f as K,a as _,b as L,c as n,d as u,r as s,n as r}from"../chunks/jDjavuwI.js";import{E as A}from"../chunks/SrSJA0zO.js";const Y='{"title":"Krea 2","local":"krea-2","sections":[{"title":"Text-to-image","local":"text-to-image","sections":[],"depth":2},{"title":"Krea2Pipeline","local":"diffusers.Krea2Pipeline","sections":[],"depth":2},{"title":"Krea2PipelineOutput","local":"diffusers.pipelines.krea2.Krea2PipelineOutput","sections":[],"depth":2}],"depth":1}';var X=u('<meta name="hf:doc:metadata"/>'),R=u("<p>Examples:</p> <!>",1),D=u(`<p></p> <!> <!> <p>Krea 2 (K2) is a flow-matching text-to-image model built around a single-stream MMDiT with grouped-query attention. A | |
| Qwen3-VL text encoder provides the conditioning: instead of the last hidden state, hidden states from twelve decoder | |
| layers are tapped per token and fused inside the transformer by a small text-fusion stage. Images are decoded with the | |
| Qwen-Image VAE.</p> <p>Two checkpoints are released, sharing the same architecture but with different recommended sampler settings:</p> <ul><li><strong>Base (midtrain)</strong> — use the full sampler with classifier-free guidance: <code>num_inference_steps=28</code>, <code>guidance_scale=4.5</code>.</li> <li><strong>TDM (distilled)</strong> — distilled for few-step sampling, run with <code>num_inference_steps=8</code> and guidance disabled | |
| (<code>guidance_scale=0.0</code>).</li></ul> <p><code>guidance_scale</code> follows the Krea 2 convention: the velocity is computed as <code>cond + guidance_scale * (cond - uncond)</code> and guidance is enabled whenever <code>guidance_scale > 0</code> (this equals the usual CFG formulation with scale <code>1 + guidance_scale</code>).</p> <!> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The Krea 2 pipeline for text-to-image generation.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Tokenize <code>prompt</code> into the fixed-length Krea 2 layout and tap the selected encoder hidden states.</p> <p>Returns a <code>(hidden_states, attention_mask)</code> tuple of shapes <code>(batch_size, text_seq_len, num_text_layers, text_hidden_dim)</code> and <code>(batch_size, text_seq_len)</code> (bool).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Build the <code>(text_seq_len + grid_height * grid_width, 3)</code> rotary coordinates for the combined sequence: | |
| text tokens sit at the origin, image tokens carry their <code>(0, h, w)</code> latent-grid coordinates.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for the Krea 2 pipeline.</p></div> <!> <p></p>`,1);function ee(J,U){S(U,!1),V(()=>{new URLSearchParams(window.location.search).get("fw")}),B();var h=D();N("1j2cvz3",o=>{var m=X();C(m,"content",Y),_(o,m)});var g=e(K(h),2);z(g,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var f=e(g,2);a(f,{title:"Krea 2",local:"krea-2",headingTag:"h1"});var b=e(f,10);a(b,{title:"Text-to-image",local:"text-to-image",headingTag:"h2"});var y=e(b,2);j(y,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS3JlYTJQaXBlbGluZSUwQSUwQSUyMyUyMExvYWQlMjBmcm9tJTIwYSUyMGxvY2FsJTIwZGlyZWN0b3J5JTIwcHJvZHVjZWQlMjBieSUyMHRoZSUyMEtyZWElMjAyJTIwY29udmVyc2lvbiUyMChubyUyMGh1YiUyMHJlcG8lMjB5ZXQpLiUwQXBpcGUlMjAlM0QlMjBLcmVhMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZrcmVhMi1kaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJhJTIwZm94JTIwaW4lMjB0aGUlMjBzbm93JTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMGhlaWdodCUzRDEwMjQlMkMlMEElMjAlMjAlMjAlMjB3aWR0aCUzRDEwMjQlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjglMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDQuNSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIya3JlYTIucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Krea2Pipeline | |
| <span class="hljs-comment"># Load from a local directory produced by the Krea 2 conversion (no hub repo yet).</span> | |
| pipe = Krea2Pipeline.from_pretrained(<span class="hljs-string">"path/to/krea2-diffusers"</span>, torch_dtype=torch.bfloat16) | |
| pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"a fox in the snow"</span> | |
| image = pipe( | |
| prompt, | |
| height=<span class="hljs-number">1024</span>, | |
| width=<span class="hljs-number">1024</span>, | |
| num_inference_steps=<span class="hljs-number">28</span>, | |
| guidance_scale=<span class="hljs-number">4.5</span>, | |
| generator=torch.Generator(<span class="hljs-string">"cuda"</span>).manual_seed(<span class="hljs-number">0</span>), | |
| ).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"krea2.png"</span>)`,lang:"python",wrap:!1});var v=e(y,2);a(v,{title:"Krea2Pipeline",local:"diffusers.Krea2Pipeline",headingTag:"h2"});var i=e(v,2),M=n(i);t(M,{name:"class diffusers.Krea2Pipeline",anchor:"diffusers.Krea2Pipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_krea2.py#L134",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLQwenImage"},{name:"text_encoder",val:": Qwen3VLModel"},{name:"tokenizer",val:": AutoTokenizer"},{name:"transformer",val:": Krea2Transformer2DModel"},{name:"text_encoder_select_layers",val:": tuple[int, ...] | list[int] | None = None"},{name:"is_distilled",val:": bool = False"},{name:"patch_size",val:": int = 2"}],parametersDescription:[{anchor:"diffusers.Krea2Pipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14178/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) — | |
| Euler flow-matching scheduler. The Krea 2 sigma schedule is the resolution-aware exponential time shift, so | |
| the scheduler config is expected to set <code>use_dynamic_shifting=True</code> together with the Krea 2 shift | |
| parameters (<code>base_shift=0.5</code>, <code>max_shift=1.15</code>, <code>base_image_seq_len=256</code>, <code>max_image_seq_len=6400</code>).`,name:"scheduler"},{anchor:"diffusers.Krea2Pipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14178/en/api/models/autoencoderkl_qwenimage#diffusers.AutoencoderKLQwenImage">AutoencoderKLQwenImage</a>) — | |
| The Qwen-Image variational auto-encoder (f8, 16 latent channels) used to decode latents to images.`,name:"vae"},{anchor:"diffusers.Krea2Pipeline.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel" rel="nofollow">PreTrainedModel</a>) — | |
| A Qwen3-VL model (e.g. <code>Qwen3VLModel</code> of <code>Qwen/Qwen3-VL-4B-Instruct</code>). The pipeline consumes a stack of | |
| hidden states tapped from several decoder layers rather than the last hidden state.`,name:"text_encoder"},{anchor:"diffusers.Krea2Pipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer" rel="nofollow">AutoTokenizer</a>) — | |
| The tokenizer paired with the text encoder.`,name:"tokenizer"},{anchor:"diffusers.Krea2Pipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14178/en/api/models/krea2_transformer2d#diffusers.Krea2Transformer2DModel">Krea2Transformer2DModel</a>) — | |
| The Krea 2 single-stream MMDiT that predicts the flow-matching velocity.`,name:"transformer"},{anchor:"diffusers.Krea2Pipeline.text_encoder_select_layers",description:`<strong>text_encoder_select_layers</strong> (<code>tuple[int, ...]</code>, <em>optional</em>) — | |
| Indices into the text encoder’s <code>hidden_states</code> tuple (0 is the embedding output) whose states are stacked | |
| per token as the transformer’s text conditioning. Must have <code>transformer.config.num_text_layers</code> entries.`,name:"text_encoder_select_layers"},{anchor:"diffusers.Krea2Pipeline.is_distilled",description:`<strong>is_distilled</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether the transformer is the few-step distilled (TDM/turbo) checkpoint. When <code>True</code> a fixed timestep | |
| shift <code>mu=1.15</code> is used; otherwise <code>mu</code> is computed from the image resolution.`,name:"is_distilled"},{anchor:"diffusers.Krea2Pipeline.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) — | |
| Side length of the square patches the latents are packed into before entering the transformer. The | |
| effective pixel-to-token downsampling factor is <code>vae_scale_factor * patch_size</code>.`,name:"patch_size"}]});var d=e(M,4),w=n(d);t(w,{name:"__call__",anchor:"diffusers.Krea2Pipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_krea2.py#L445",parameters:[{name:"prompt",val:": str | list[str] | None = None"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"height",val:": int = 1024"},{name:"width",val:": int = 1024"},{name:"num_inference_steps",val:": int = 28"},{name:"sigmas",val:": list[float] | None = None"},{name:"guidance_scale",val:": float = 4.5"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": str | None = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int, dict], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"max_sequence_length",val:": int = 512"}],parametersDescription:[{anchor:"diffusers.Krea2Pipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.Krea2Pipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| The prompt or prompts not to guide the image generation. Ignored when <code>guidance_scale <= 0</code>; defaults | |
| to an empty prompt when guidance is enabled.`,name:"negative_prompt"},{anchor:"diffusers.Krea2Pipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, defaults to 1024) — | |
| The height in pixels of the generated image. Rounded up to a multiple of 16 if needed.`,name:"height"},{anchor:"diffusers.Krea2Pipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, defaults to 1024) — | |
| The width in pixels of the generated image. Rounded up to a multiple of 16 if needed.`,name:"width"},{anchor:"diffusers.Krea2Pipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, defaults to 28) — | |
| The number of denoising steps. Use 28 for the base (midtrain) checkpoint and 8 for the few-step | |
| distilled (TDM) checkpoint.`,name:"num_inference_steps"},{anchor:"diffusers.Krea2Pipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>list[float]</code>, <em>optional</em>) — | |
| Custom sigmas for the scheduler. If not defined, the default <code>linspace(1.0, 1/num_inference_steps, num_inference_steps)</code> grid is used (the resolution-aware shift is applied inside the scheduler).`,name:"sigmas"},{anchor:"diffusers.Krea2Pipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, defaults to 4.5) — | |
| Classifier-free guidance scale, following the Krea 2 convention: the velocity is computed as <code>cond + guidance_scale * (cond - uncond)</code> and guidance is enabled whenever <code>guidance_scale > 0</code> (this equals | |
| the usual CFG formulation with scale <code>1 + guidance_scale</code>). Set to <code>0.0</code> to disable (e.g. for the TDM | |
| checkpoint).`,name:"guidance_scale"},{anchor:"diffusers.Krea2Pipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, defaults to 1) — | |
| The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.Krea2Pipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>) — | |
| One or more <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a> to | |
| make generation deterministic.`,name:"generator"},{anchor:"diffusers.Krea2Pipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated noisy latents in packed form <code>(batch_size, image_seq_len, in_channels)</code>, sampled from a | |
| Gaussian distribution, to be used as inputs for image generation.`,name:"latents"},{anchor:"diffusers.Krea2Pipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings of shape <code>(batch_size, text_seq_len, num_text_layers, text_hidden_dim)</code>. | |
| If not provided, embeddings are generated from <code>prompt</code>.`,name:"prompt_embeds"},{anchor:"diffusers.Krea2Pipeline.__call__.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Boolean mask for <code>prompt_embeds</code>; required when <code>prompt_embeds</code> is passed.`,name:"prompt_embeds_mask"},{anchor:"diffusers.Krea2Pipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings; same layout as <code>prompt_embeds</code>.`,name:"negative_prompt_embeds"},{anchor:"diffusers.Krea2Pipeline.__call__.negative_prompt_embeds_mask",description:`<strong>negative_prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Boolean mask for <code>negative_prompt_embeds</code>; required when <code>negative_prompt_embeds</code> is passed.`,name:"negative_prompt_embeds_mask"},{anchor:"diffusers.Krea2Pipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"pil"</code>) — | |
| The output format of the generated image. Choose between <code>"pil"</code>, <code>"np"</code>, <code>"pt"</code> or <code>"latent"</code>.`,name:"output_type"},{anchor:"diffusers.Krea2Pipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_14178/en/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput">Krea2PipelineOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.Krea2Pipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) — | |
| A function that is called at the end of each denoising step with <code>callback_on_step_end(self, step, timestep, callback_kwargs)</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.Krea2Pipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>list[str]</code>, <em>optional</em>, defaults to <code>["latents"]</code>) — | |
| The list of tensor inputs for the <code>callback_on_step_end</code> function. Must be a subset of | |
| <code>._callback_tensor_inputs</code>.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.Krea2Pipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) — | |
| A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under | |
| <code>self.processor</code> in | |
| <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.Krea2Pipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, defaults to 512) — | |
| Fixed text sequence length consumed by the transformer; prompts are padded or truncated to it.`,name:"max_sequence_length"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput" | |
| >Krea2PipelineOutput</a> if | |
| <code>return_dict</code> is True, otherwise a <code>tuple</code>, whose first element is a list with the generated images.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput" | |
| >Krea2PipelineOutput</a> or <code>tuple</code></p> | |
| `});var P=e(w,4);A(P,{anchor:"diffusers.Krea2Pipeline.__call__.example",children:(o,m)=>{var T=R(),W=e(K(T),2);j(W,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS3JlYTJQaXBlbGluZSUwQSUwQSUyMyUyMExvYWQlMjBmcm9tJTIwYSUyMGxvY2FsJTIwZGlyZWN0b3J5JTIwcHJvZHVjZWQlMjBieSUyMHRoZSUyMEtyZWElMjAyJTIwY29udmVyc2lvbiUyMChubyUyMGh1YiUyMHJlcG8lMjB5ZXQpLiUwQXBpcGUlMjAlM0QlMjBLcmVhMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZrcmVhMi1kaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJhJTIwZm94JTIwaW4lMjB0aGUlMjBzbm93JTIyJTBBJTIzJTIwQmFzZSUyMChtaWR0cmFpbiklMjBjaGVja3BvaW50JTIwZGVmYXVsdHMuJTIwRm9yJTIwdGhlJTIwZmV3LXN0ZXAlMjBkaXN0aWxsZWQlMjAoVERNKSUyMGNoZWNrcG9pbnQlMjB1c2UlMEElMjMlMjAlNjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEOCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEMC4wJTYwJTIwaW5zdGVhZC4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI4JTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q0LjUpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmtyZWEyLnBuZyUyMik=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Krea2Pipeline | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Load from a local directory produced by the Krea 2 conversion (no hub repo yet).</span> | |
| <span class="hljs-meta">>>> </span>pipe = Krea2Pipeline.from_pretrained(<span class="hljs-string">"path/to/krea2-diffusers"</span>, torch_dtype=torch.bfloat16) | |
| <span class="hljs-meta">>>> </span>pipe.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"a fox in the snow"</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Base (midtrain) checkpoint defaults. For the few-step distilled (TDM) checkpoint use</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># \`num_inference_steps=8, guidance_scale=0.0\` instead.</span> | |
| <span class="hljs-meta">>>> </span>image = pipe(prompt, num_inference_steps=<span class="hljs-number">28</span>, guidance_scale=<span class="hljs-number">4.5</span>).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"krea2.png"</span>)`,lang:"py",wrap:!1}),_(o,T)},$$slots:{default:!0}}),s(d);var l=e(d,2),q=n(l);t(q,{name:"encode_prompt",anchor:"diffusers.Krea2Pipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_krea2.py#L263",parameters:[{name:"prompt",val:": str | list[str]"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 512"}],parametersDescription:[{anchor:"diffusers.Krea2Pipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| prompt to be encoded`,name:"prompt"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.device",description:`<strong>device</strong> — (<code>torch.device</code>): | |
| torch device`,name:"device"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) — | |
| number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings of shape <code>(batch_size, text_seq_len, num_text_layers, text_hidden_dim)</code>. | |
| Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not provided, text embeddings will | |
| be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated boolean mask marking valid text tokens, of shape <code>(batch_size, text_seq_len)</code>. Required | |
| when <code>prompt_embeds</code> is passed.`,name:"prompt_embeds_mask"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, defaults to 512) — | |
| Fixed text sequence length consumed by the transformer; prompts are padded or truncated to it.`,name:"max_sequence_length"}]}),s(l);var c=e(l,2),I=n(c);t(I,{name:"get_text_hidden_states",anchor:"diffusers.Krea2Pipeline.get_text_hidden_states",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_krea2.py#L214",parameters:[{name:"prompt",val:": str | list[str]"},{name:"max_sequence_length",val:": int = 512"},{name:"device",val:": typing.Optional[torch.device] = None"}]}),r(4),s(c);var x=e(c,2),Z=n(x);t(Z,{name:"prepare_position_ids",anchor:"diffusers.Krea2Pipeline.prepare_position_ids",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_krea2.py#L381",parameters:[{name:"text_seq_len",val:": int"},{name:"grid_height",val:": int"},{name:"grid_width",val:": int"},{name:"device",val:": device"}]}),r(2),s(x),s(i);var k=e(i,2);a(k,{title:"Krea2PipelineOutput",local:"diffusers.pipelines.krea2.Krea2PipelineOutput",headingTag:"h2"});var p=e(k,2),G=n(p);t(G,{name:"class diffusers.pipelines.krea2.Krea2PipelineOutput",anchor:"diffusers.pipelines.krea2.Krea2PipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/krea2/pipeline_output.py#L24",parameters:[{name:"images",val:": list[PIL.Image.Image] | numpy.ndarray"}],parametersDescription:[{anchor:"diffusers.pipelines.krea2.Krea2PipelineOutput.images",description:`<strong>images</strong> (<code>list[PIL.Image.Image]</code> or <code>np.ndarray</code>) — | |
| List of denoised PIL images of length <code>batch_size</code> or numpy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}]}),r(2),s(p);var Q=e(p,2);E(Q,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/krea2.md"}),r(2),_(J,h),L()}export{ee as component}; | |
Xet Storage Details
- Size:
- 25.2 kB
- Xet hash:
- 949aae1776018964349296384e3502a809329b9d295df3ce47db893af549f362
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.