Buckets:

download
raw
29 kB
import{s as Ve,o as Se,n as He}from"../chunks/scheduler.53228c21.js";import{S as De,i as Ye,e as i,s,c as u,h as Ae,a as l,d as n,b as a,f as P,g as f,j as x,k as J,l as r,m as o,n as _,t as h,o as g,p as b}from"../chunks/index.cac5d66a.js";import{C as Xe}from"../chunks/CopyLLMTxtMenu.0a7e0e29.js";import{D as ne}from"../chunks/Docstring.ef3c6a7f.js";import{C as ze}from"../chunks/CodeBlock.606cbaf4.js";import{E as Re}from"../chunks/ExampleCodeBlock.76765dc9.js";import{H as Me,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d66c5a2f.js";function Oe(ae){let p,U="Examples:",y,v,M;return v=new ze({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS3JlYTJQaXBlbGluZSUwQSUwQSUyMyUyMExvYWQlMjBmcm9tJTIwYSUyMGxvY2FsJTIwZGlyZWN0b3J5JTIwcHJvZHVjZWQlMjBieSUyMHRoZSUyMEtyZWElMjAyJTIwY29udmVyc2lvbiUyMChubyUyMGh1YiUyMHJlcG8lMjB5ZXQpLiUwQXBpcGUlMjAlM0QlMjBLcmVhMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZrcmVhMi1kaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJhJTIwZm94JTIwaW4lMjB0aGUlMjBzbm93JTIyJTBBJTIzJTIwQmFzZSUyMChtaWR0cmFpbiklMjBjaGVja3BvaW50JTIwZGVmYXVsdHMuJTIwRm9yJTIwdGhlJTIwZmV3LXN0ZXAlMjBkaXN0aWxsZWQlMjAoVERNKSUyMGNoZWNrcG9pbnQlMjB1c2UlMEElMjMlMjAlNjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEOCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEMC4wJTYwJTIwaW5zdGVhZC4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI4JTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q0LjUpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmtyZWEyLnBuZyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Krea2Pipeline
<span class="hljs-meta">&gt;&gt;&gt; </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">&gt;&gt;&gt; </span>pipe = Krea2Pipeline.from_pretrained(<span class="hljs-string">&quot;path/to/krea2-diffusers&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;a fox in the snow&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Base (midtrain) checkpoint defaults. For the few-step distilled (TDM) checkpoint use</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># \`num_inference_steps=8, guidance_scale=0.0\` instead.</span>
<span class="hljs-meta">&gt;&gt;&gt; </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">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;krea2.png&quot;</span>)`,lang:"py",wrap:!1}}),{c(){p=i("p"),p.textContent=U,y=s(),u(v.$$.fragment)},l(d){p=l(d,"P",{"data-svelte-h":!0}),x(p)!=="svelte-kvfsh7"&&(p.textContent=U),y=a(d),f(v.$$.fragment,d)},m(d,w){o(d,p,w),o(d,y,w),_(v,d,w),M=!0},p:He,i(d){M||(h(v.$$.fragment,d),M=!0)},o(d){g(v.$$.fragment,d),M=!1},d(d){d&&(n(p),n(y)),b(v,d)}}}function et(ae){let p,U,y,v,M,d,w,oe,C,Ce=`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.`,re,I,Ie="Two checkpoints are released, sharing the same architecture but with different recommended sampler settings:",ie,q,qe=`<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>`,le,Z,Ze=`<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 &gt; 0</code> (this equals the usual CFG formulation with scale
<code>1 + guidance_scale</code>).`,de,N,pe,G,ce,Q,me,c,E,we,D,Ne="The Krea 2 pipeline for text-to-image generation.",xe,$,W,ye,Y,Ge="Function invoked when calling the pipeline for generation.",$e,j,ke,A,B,Te,k,L,je,X,Qe="Tokenize <code>prompt</code> into the fixed-length Krea 2 layout and tap the selected encoder hidden states.",Ke,R,Ee="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).",Pe,K,z,Je,F,We=`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.`,ue,V,fe,T,S,Ue,O,Be="Output class for the Krea 2 pipeline.",_e,H,he,se,ge;return M=new Xe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new Me({props:{title:"Krea 2",local:"krea-2",headingTag:"h1"}}),N=new Me({props:{title:"Text-to-image",local:"text-to-image",headingTag:"h2"}}),G=new ze({props:{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">&quot;path/to/krea2-diffusers&quot;</span>, torch_dtype=torch.bfloat16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;a fox in the snow&quot;</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">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>),
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;krea2.png&quot;</span>)`,lang:"python",wrap:!1}}),Q=new Me({props:{title:"Krea2Pipeline",local:"diffusers.Krea2Pipeline",headingTag:"h2"}}),E=new ne({props:{name:"class diffusers.Krea2Pipeline",anchor:"diffusers.Krea2Pipeline",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_14047/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) &#x2014;
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_14047/en/api/models/autoencoderkl_qwenimage#diffusers.AutoencoderKLQwenImage">AutoencoderKLQwenImage</a>) &#x2014;
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>) &#x2014;
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>) &#x2014;
The tokenizer paired with the text encoder.`,name:"tokenizer"},{anchor:"diffusers.Krea2Pipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14047/en/api/models/krea2_transformer2d#diffusers.Krea2Transformer2DModel">Krea2Transformer2DModel</a>) &#x2014;
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>) &#x2014;
Indices into the text encoder&#x2019;s <code>hidden_states</code> tuple (0 is the embedding output) whose states are stacked
per token as the transformer&#x2019;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>) &#x2014;
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) &#x2014;
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"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_krea2.py#L133"}}),W=new ne({props:{name:"__call__",anchor:"diffusers.Krea2Pipeline.__call__",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:": torch._C.Generator | list[torch._C.Generator] | None = None"},{name:"latents",val:": torch.Tensor | None = None"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds_mask",val:": torch.Tensor | None = 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:"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>) &#x2014;
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>) &#x2014;
The prompt or prompts not to guide the image generation. Ignored when <code>guidance_scale &lt;= 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) &#x2014;
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) &#x2014;
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) &#x2014;
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>) &#x2014;
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) &#x2014;
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 &gt; 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) &#x2014;
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>) &#x2014;
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>) &#x2014;
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>) &#x2014;
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>) &#x2014;
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>) &#x2014;
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>) &#x2014;
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>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>&quot;pil&quot;</code>, <code>&quot;np&quot;</code>, <code>&quot;pt&quot;</code> or <code>&quot;latent&quot;</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>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/pr_14047/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>) &#x2014;
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>[&quot;latents&quot;]</code>) &#x2014;
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__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, defaults to 512) &#x2014;
Fixed text sequence length consumed by the transformer; prompts are padded or truncated to it.`,name:"max_sequence_length"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_krea2.py#L440",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/diffusers/pr_14047/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_14047/en/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput"
>Krea2PipelineOutput</a> or <code>tuple</code></p>
`}}),j=new Re({props:{anchor:"diffusers.Krea2Pipeline.__call__.example",$$slots:{default:[Oe]},$$scope:{ctx:ae}}}),B=new ne({props:{name:"encode_prompt",anchor:"diffusers.Krea2Pipeline.encode_prompt",parameters:[{name:"prompt",val:": str | list[str]"},{name:"device",val:": torch.device | None = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = 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>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.Krea2Pipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<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>) &#x2014;
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>) &#x2014;
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>) &#x2014;
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) &#x2014;
Fixed text sequence length consumed by the transformer; prompts are padded or truncated to it.`,name:"max_sequence_length"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_krea2.py#L262"}}),L=new ne({props:{name:"get_text_hidden_states",anchor:"diffusers.Krea2Pipeline.get_text_hidden_states",parameters:[{name:"prompt",val:": str | list[str]"},{name:"max_sequence_length",val:": int = 512"},{name:"device",val:": torch.device | None = None"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_krea2.py#L213"}}),z=new ne({props:{name:"prepare_position_ids",anchor:"diffusers.Krea2Pipeline.prepare_position_ids",parameters:[{name:"text_seq_len",val:": int"},{name:"grid_height",val:": int"},{name:"grid_width",val:": int"},{name:"device",val:": device"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_krea2.py#L380"}}),V=new Me({props:{title:"Krea2PipelineOutput",local:"diffusers.pipelines.krea2.Krea2PipelineOutput",headingTag:"h2"}}),S=new ne({props:{name:"class diffusers.pipelines.krea2.Krea2PipelineOutput",anchor:"diffusers.pipelines.krea2.Krea2PipelineOutput",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>) &#x2014;
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"}],source:"https://github.com/huggingface/diffusers/blob/vr_14047/src/diffusers/pipelines/krea2/pipeline_output.py#L24"}}),H=new Fe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/krea2.md"}}),{c(){p=i("meta"),U=s(),y=i("p"),v=s(),u(M.$$.fragment),d=s(),u(w.$$.fragment),oe=s(),C=i("p"),C.textContent=Ce,re=s(),I=i("p"),I.textContent=Ie,ie=s(),q=i("ul"),q.innerHTML=qe,le=s(),Z=i("p"),Z.innerHTML=Ze,de=s(),u(N.$$.fragment),pe=s(),u(G.$$.fragment),ce=s(),u(Q.$$.fragment),me=s(),c=i("div"),u(E.$$.fragment),we=s(),D=i("p"),D.textContent=Ne,xe=s(),$=i("div"),u(W.$$.fragment),ye=s(),Y=i("p"),Y.textContent=Ge,$e=s(),u(j.$$.fragment),ke=s(),A=i("div"),u(B.$$.fragment),Te=s(),k=i("div"),u(L.$$.fragment),je=s(),X=i("p"),X.innerHTML=Qe,Ke=s(),R=i("p"),R.innerHTML=Ee,Pe=s(),K=i("div"),u(z.$$.fragment),Je=s(),F=i("p"),F.innerHTML=We,ue=s(),u(V.$$.fragment),fe=s(),T=i("div"),u(S.$$.fragment),Ue=s(),O=i("p"),O.textContent=Be,_e=s(),u(H.$$.fragment),he=s(),se=i("p"),this.h()},l(e){const t=Ae("svelte-u9bgzb",document.head);p=l(t,"META",{name:!0,content:!0}),t.forEach(n),U=a(e),y=l(e,"P",{}),P(y).forEach(n),v=a(e),f(M.$$.fragment,e),d=a(e),f(w.$$.fragment,e),oe=a(e),C=l(e,"P",{"data-svelte-h":!0}),x(C)!=="svelte-sa0e4h"&&(C.textContent=Ce),re=a(e),I=l(e,"P",{"data-svelte-h":!0}),x(I)!=="svelte-190us3u"&&(I.textContent=Ie),ie=a(e),q=l(e,"UL",{"data-svelte-h":!0}),x(q)!=="svelte-16nwefa"&&(q.innerHTML=qe),le=a(e),Z=l(e,"P",{"data-svelte-h":!0}),x(Z)!=="svelte-1fnalsl"&&(Z.innerHTML=Ze),de=a(e),f(N.$$.fragment,e),pe=a(e),f(G.$$.fragment,e),ce=a(e),f(Q.$$.fragment,e),me=a(e),c=l(e,"DIV",{class:!0});var m=P(c);f(E.$$.fragment,m),we=a(m),D=l(m,"P",{"data-svelte-h":!0}),x(D)!=="svelte-vilnme"&&(D.textContent=Ne),xe=a(m),$=l(m,"DIV",{class:!0});var ee=P($);f(W.$$.fragment,ee),ye=a(ee),Y=l(ee,"P",{"data-svelte-h":!0}),x(Y)!=="svelte-v78lg8"&&(Y.textContent=Ge),$e=a(ee),f(j.$$.fragment,ee),ee.forEach(n),ke=a(m),A=l(m,"DIV",{class:!0});var Le=P(A);f(B.$$.fragment,Le),Le.forEach(n),Te=a(m),k=l(m,"DIV",{class:!0});var te=P(k);f(L.$$.fragment,te),je=a(te),X=l(te,"P",{"data-svelte-h":!0}),x(X)!=="svelte-1ccjvo3"&&(X.innerHTML=Qe),Ke=a(te),R=l(te,"P",{"data-svelte-h":!0}),x(R)!=="svelte-1gi9wj"&&(R.innerHTML=Ee),te.forEach(n),Pe=a(m),K=l(m,"DIV",{class:!0});var be=P(K);f(z.$$.fragment,be),Je=a(be),F=l(be,"P",{"data-svelte-h":!0}),x(F)!=="svelte-150799n"&&(F.innerHTML=We),be.forEach(n),m.forEach(n),ue=a(e),f(V.$$.fragment,e),fe=a(e),T=l(e,"DIV",{class:!0});var ve=P(T);f(S.$$.fragment,ve),Ue=a(ve),O=l(ve,"P",{"data-svelte-h":!0}),x(O)!=="svelte-bv55o2"&&(O.textContent=Be),ve.forEach(n),_e=a(e),f(H.$$.fragment,e),he=a(e),se=l(e,"P",{}),P(se).forEach(n),this.h()},h(){J(p,"name","hf:doc:metadata"),J(p,"content",tt),J($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){r(document.head,p),o(e,U,t),o(e,y,t),o(e,v,t),_(M,e,t),o(e,d,t),_(w,e,t),o(e,oe,t),o(e,C,t),o(e,re,t),o(e,I,t),o(e,ie,t),o(e,q,t),o(e,le,t),o(e,Z,t),o(e,de,t),_(N,e,t),o(e,pe,t),_(G,e,t),o(e,ce,t),_(Q,e,t),o(e,me,t),o(e,c,t),_(E,c,null),r(c,we),r(c,D),r(c,xe),r(c,$),_(W,$,null),r($,ye),r($,Y),r($,$e),_(j,$,null),r(c,ke),r(c,A),_(B,A,null),r(c,Te),r(c,k),_(L,k,null),r(k,je),r(k,X),r(k,Ke),r(k,R),r(c,Pe),r(c,K),_(z,K,null),r(K,Je),r(K,F),o(e,ue,t),_(V,e,t),o(e,fe,t),o(e,T,t),_(S,T,null),r(T,Ue),r(T,O),o(e,_e,t),_(H,e,t),o(e,he,t),o(e,se,t),ge=!0},p(e,[t]){const m={};t&2&&(m.$$scope={dirty:t,ctx:e}),j.$set(m)},i(e){ge||(h(M.$$.fragment,e),h(w.$$.fragment,e),h(N.$$.fragment,e),h(G.$$.fragment,e),h(Q.$$.fragment,e),h(E.$$.fragment,e),h(W.$$.fragment,e),h(j.$$.fragment,e),h(B.$$.fragment,e),h(L.$$.fragment,e),h(z.$$.fragment,e),h(V.$$.fragment,e),h(S.$$.fragment,e),h(H.$$.fragment,e),ge=!0)},o(e){g(M.$$.fragment,e),g(w.$$.fragment,e),g(N.$$.fragment,e),g(G.$$.fragment,e),g(Q.$$.fragment,e),g(E.$$.fragment,e),g(W.$$.fragment,e),g(j.$$.fragment,e),g(B.$$.fragment,e),g(L.$$.fragment,e),g(z.$$.fragment,e),g(V.$$.fragment,e),g(S.$$.fragment,e),g(H.$$.fragment,e),ge=!1},d(e){e&&(n(U),n(y),n(v),n(d),n(oe),n(C),n(re),n(I),n(ie),n(q),n(le),n(Z),n(de),n(pe),n(ce),n(me),n(c),n(ue),n(fe),n(T),n(_e),n(he),n(se)),n(p),b(M,e),b(w,e),b(N,e),b(G,e),b(Q,e),b(E),b(W),b(j),b(B),b(L),b(z),b(V,e),b(S),b(H,e)}}}const tt='{"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}';function nt(ae){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pt extends De{constructor(p){super(),Ye(this,p,nt,et,Ve,{})}}export{pt as component};

Xet Storage Details

Size:
29 kB
·
Xet hash:
b9cef3e49c24bfff54da95c4e8a1f5ee7f3862f968fa3b14a6e1cfc041c971c0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.