Buckets:

download
raw
12.3 kB
import"../chunks/DsnmJJEf.js";import{i as M,h as k,C as w,H as n,D as t,E as y,s as N}from"../chunks/BtE7mKSK.js";import{p as j,o as O,s as e,f as C,a as g,b as K,c as s,d as x,n as a,r as d}from"../chunks/jDjavuwI.js";const V='{"title":"Flux2Transformer2DModel","local":"flux2transformer2dmodel","sections":[{"title":"Flux2Transformer2DModel","local":"diffusers.Flux2Transformer2DModel","sections":[],"depth":2},{"title":"Flux2Transformer2DModelOutput","local":"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';var q=x('<meta name="hf:doc:metadata"/>'),z=x('<p></p> <!> <!> <p>A Transformer model for image-like data from <a href="https://hf.co/black-forest-labs/FLUX.2-dev" rel="nofollow">Flux2</a>.</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 Transformer model introduced in Flux 2.</p> <p>Reference: <a href="https://blackforestlabs.ai/announcing-black-forest-labs/" rel="nofollow">https://blackforestlabs.ai/announcing-black-forest-labs/</a></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 <a href="/docs/diffusers/pr_14261/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a> forward method.</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>The output of <a href="/docs/diffusers/pr_14261/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a>.</p></div> <!> <p></p>',1);function A(T,v){j(v,!1),O(()=>{new URLSearchParams(window.location.search).get("fw")}),M();var i=z();k("136e0lw",_=>{var p=q();N(p,"content",V),g(_,p)});var c=e(C(i),2);w(c,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var l=e(c,2);n(l,{title:"Flux2Transformer2DModel",local:"flux2transformer2dmodel",headingTag:"h1"});var f=e(l,4);n(f,{title:"Flux2Transformer2DModel",local:"diffusers.Flux2Transformer2DModel",headingTag:"h2"});var o=e(f,2),m=s(o);t(m,{name:"class diffusers.Flux2Transformer2DModel",anchor:"diffusers.Flux2Transformer2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/transformers/transformer_flux2.py#L1039",parameters:[{name:"patch_size",val:": int = 1"},{name:"in_channels",val:": int = 128"},{name:"out_channels",val:": int | None = None"},{name:"num_layers",val:": int = 8"},{name:"num_single_layers",val:": int = 48"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 48"},{name:"joint_attention_dim",val:": int = 15360"},{name:"timestep_guidance_channels",val:": int = 256"},{name:"mlp_ratio",val:": float = 3.0"},{name:"axes_dims_rope",val:": tuple = (32, 32, 32, 32)"},{name:"rope_theta",val:": int = 2000"},{name:"eps",val:": float = 1e-06"},{name:"guidance_embeds",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.Flux2Transformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
Patch size to turn the input data into small patches.`,name:"patch_size"},{anchor:"diffusers.Flux2Transformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.Flux2Transformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The number of channels in the output. If not specified, it defaults to <code>in_channels</code>.`,name:"out_channels"},{anchor:"diffusers.Flux2Transformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>8</code>) &#x2014;
The number of layers of dual stream DiT blocks to use.`,name:"num_layers"},{anchor:"diffusers.Flux2Transformer2DModel.num_single_layers",description:`<strong>num_single_layers</strong> (<code>int</code>, defaults to <code>48</code>) &#x2014;
The number of layers of single stream DiT blocks to use.`,name:"num_single_layers"},{anchor:"diffusers.Flux2Transformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of dimensions to use for each attention head.`,name:"attention_head_dim"},{anchor:"diffusers.Flux2Transformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>48</code>) &#x2014;
The number of attention heads to use.`,name:"num_attention_heads"},{anchor:"diffusers.Flux2Transformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>15360</code>) &#x2014;
The number of dimensions to use for the joint attention (embedding/channel dimension of
<code>encoder_hidden_states</code>).`,name:"joint_attention_dim"},{anchor:"diffusers.Flux2Transformer2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, defaults to <code>768</code>) &#x2014;
The number of dimensions to use for the pooled projection.`,name:"pooled_projection_dim"},{anchor:"diffusers.Flux2Transformer2DModel.guidance_embeds",description:`<strong>guidance_embeds</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use guidance embeddings for guidance-distilled variant of the model.`,name:"guidance_embeds"},{anchor:"diffusers.Flux2Transformer2DModel.axes_dims_rope",description:`<strong>axes_dims_rope</strong> (<code>tuple[int]</code>, defaults to <code>(32, 32, 32, 32)</code>) &#x2014;
The dimensions to use for the rotary positional embeddings.`,name:"axes_dims_rope"}]});var u=e(m,6),b=s(u);t(b,{name:"forward",anchor:"diffusers.Flux2Transformer2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/transformers/transformer_flux2.py#L1177",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"img_ids",val:": Tensor = None"},{name:"txt_ids",val:": Tensor = None"},{name:"guidance",val:": Tensor = None"},{name:"joint_attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"return_dict",val:": bool = True"},{name:"kv_cache",val:": Flux2KVCache | None = None"},{name:"kv_cache_mode",val:": str | None = None"},{name:"num_ref_tokens",val:": int = 0"},{name:"ref_fixed_timestep",val:": float = 0.0"}],parametersDescription:[{anchor:"diffusers.Flux2Transformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_sequence_length, in_channels)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.Flux2Transformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_sequence_length, joint_attention_dim)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.Flux2Transformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.Flux2Transformer2DModel.forward.img_ids",description:`<strong>img_ids</strong> (<code>torch.Tensor</code>) &#x2014;
Image position ids used to compute the rotary positional embeddings.`,name:"img_ids"},{anchor:"diffusers.Flux2Transformer2DModel.forward.txt_ids",description:`<strong>txt_ids</strong> (<code>torch.Tensor</code>) &#x2014;
Text position ids used to compute the rotary positional embeddings.`,name:"txt_ids"},{anchor:"diffusers.Flux2Transformer2DModel.forward.guidance",description:`<strong>guidance</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Guidance scale embedding used for guidance-distilled variants of the model.`,name:"guidance"},{anchor:"diffusers.Flux2Transformer2DModel.forward.joint_attention_kwargs",description:`<strong>joint_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
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:"joint_attention_kwargs"},{anchor:"diffusers.Flux2Transformer2DModel.forward.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 <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"},{anchor:"diffusers.Flux2Transformer2DModel.forward.kv_cache",description:`<strong>kv_cache</strong> (<code>Flux2KVCache</code>, <em>optional</em>) &#x2014;
KV cache for reference image tokens. When <code>kv_cache_mode</code> is &#x201C;extract&#x201D;, a new cache is created and
returned. When &#x201C;cached&#x201D;, the provided cache is used to inject ref K/V during attention.`,name:"kv_cache"},{anchor:"diffusers.Flux2Transformer2DModel.forward.kv_cache_mode",description:`<strong>kv_cache_mode</strong> (<code>str</code>, <em>optional</em>) &#x2014;
One of &#x201C;extract&#x201D; (first step with ref tokens) or &#x201C;cached&#x201D; (subsequent steps using cached ref K/V). When
<code>None</code>, standard forward pass without KV caching.`,name:"kv_cache_mode"},{anchor:"diffusers.Flux2Transformer2DModel.forward.num_ref_tokens",description:`<strong>num_ref_tokens</strong> (<code>int</code>, defaults to <code>0</code>) &#x2014;
Number of reference image tokens prepended to <code>hidden_states</code> (only used when
<code>kv_cache_mode=&quot;extract&quot;</code>).`,name:"num_ref_tokens"},{anchor:"diffusers.Flux2Transformer2DModel.forward.ref_fixed_timestep",description:`<strong>ref_fixed_timestep</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
Fixed timestep for reference token modulation (only used when <code>kv_cache_mode=&quot;extract&quot;</code>).`,name:"ref_fixed_timestep"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a
<code>tuple</code> where the first element is the sample tensor. When <code>kv_cache_mode="extract"</code>, also returns the
populated <code>Flux2KVCache</code>.</p>
`}),a(2),d(u),d(o);var h=e(o,2);n(h,{title:"Flux2Transformer2DModelOutput",local:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",headingTag:"h2"});var r=e(h,2),D=s(r);t(D,{name:"class diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",anchor:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/transformers/transformer_flux2.py#L45",parameters:[{name:"sample",val:": torch.Tensor"},{name:"kv_cache",val:": Flux2KVCache | None = None"}],parametersDescription:[{anchor:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input.`,name:"sample"},{anchor:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput.kv_cache",description:`<strong>kv_cache</strong> (<code>Flux2KVCache</code>, <em>optional</em>) &#x2014;
The populated KV cache for reference image tokens. Only returned when <code>kv_cache_mode=&quot;extract&quot;</code>.`,name:"kv_cache"}]}),a(2),d(r);var F=e(r,2);y(F,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/flux2_transformer.md"}),a(2),g(T,i),K()}export{A as component};

Xet Storage Details

Size:
12.3 kB
·
Xet hash:
24d0c79eaaba1c27bf386edb1680f6b841c943a63c06290aa3f73babda5a435f

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