Buckets:
| import{s as le,n as me,o as fe}from"../chunks/scheduler.53228c21.js";import{S as ue,i as pe,e as d,s as n,c as p,h as he,a as i,d as o,b as r,f as V,g as h,j as q,k as z,l as c,m as s,n as _,t as g,o as x,p as T}from"../chunks/index.cac5d66a.js";import{C as _e}from"../chunks/CopyLLMTxtMenu.0ef49226.js";import{D as oe}from"../chunks/Docstring.9de32ff4.js";import{H as ne,E as ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.48d5cb47.js";function xe(re){let l,H,O,K,v,E,b,I,$,se='A Transformer model for image-like data from <a href="https://hf.co/black-forest-labs/FLUX.2-dev" rel="nofollow">Flux2</a>.',W,D,A,a,M,Q,C,ae="The Transformer model introduced in Flux 2.",Y,j,de='Reference: <a href="https://blackforestlabs.ai/announcing-black-forest-labs/" rel="nofollow">https://blackforestlabs.ai/announcing-black-forest-labs/</a>',Z,f,F,ee,N,ie='The <a href="/docs/diffusers/pr_13921/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a> forward method.',S,w,U,m,k,te,L,ce='The output of <a href="/docs/diffusers/pr_13921/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a>.',G,y,R,P,X;return v=new _e({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new ne({props:{title:"Flux2Transformer2DModel",local:"flux2transformer2dmodel",headingTag:"h1"}}),D=new ne({props:{title:"Flux2Transformer2DModel",local:"diffusers.Flux2Transformer2DModel",headingTag:"h2"}}),M=new oe({props:{name:"class diffusers.Flux2Transformer2DModel",anchor:"diffusers.Flux2Transformer2DModel",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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| The dimensions to use for the rotary positional embeddings.`,name:"axes_dims_rope"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/transformer_flux2.py#L1039"}}),F=new oe({props:{name:"forward",anchor:"diffusers.Flux2Transformer2DModel.forward",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>) — | |
| 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>) — | |
| 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>) — | |
| Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.Flux2Transformer2DModel.forward.img_ids",description:`<strong>img_ids</strong> (<code>torch.Tensor</code>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| KV cache for reference image tokens. When <code>kv_cache_mode</code> is “extract”, a new cache is created and | |
| returned. When “cached”, 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>) — | |
| One of “extract” (first step with ref tokens) or “cached” (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>) — | |
| Number of reference image tokens prepended to <code>hidden_states</code> (only used when | |
| <code>kv_cache_mode="extract"</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>) — | |
| Fixed timestep for reference token modulation (only used when <code>kv_cache_mode="extract"</code>).`,name:"ref_fixed_timestep"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/transformer_flux2.py#L1177",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> | |
| `}}),w=new ne({props:{title:"Flux2Transformer2DModelOutput",local:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",headingTag:"h2"}}),k=new oe({props:{name:"class diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",anchor:"diffusers.models.transformers.transformer_flux2.Flux2Transformer2DModelOutput",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>) — | |
| 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>) — | |
| The populated KV cache for reference image tokens. Only returned when <code>kv_cache_mode="extract"</code>.`,name:"kv_cache"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/transformer_flux2.py#L45"}}),y=new ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/flux2_transformer.md"}}),{c(){l=d("meta"),H=n(),O=d("p"),K=n(),p(v.$$.fragment),E=n(),p(b.$$.fragment),I=n(),$=d("p"),$.innerHTML=se,W=n(),p(D.$$.fragment),A=n(),a=d("div"),p(M.$$.fragment),Q=n(),C=d("p"),C.textContent=ae,Y=n(),j=d("p"),j.innerHTML=de,Z=n(),f=d("div"),p(F.$$.fragment),ee=n(),N=d("p"),N.innerHTML=ie,S=n(),p(w.$$.fragment),U=n(),m=d("div"),p(k.$$.fragment),te=n(),L=d("p"),L.innerHTML=ce,G=n(),p(y.$$.fragment),R=n(),P=d("p"),this.h()},l(e){const t=he("svelte-u9bgzb",document.head);l=i(t,"META",{name:!0,content:!0}),t.forEach(o),H=r(e),O=i(e,"P",{}),V(O).forEach(o),K=r(e),h(v.$$.fragment,e),E=r(e),h(b.$$.fragment,e),I=r(e),$=i(e,"P",{"data-svelte-h":!0}),q($)!=="svelte-89orn1"&&($.innerHTML=se),W=r(e),h(D.$$.fragment,e),A=r(e),a=i(e,"DIV",{class:!0});var u=V(a);h(M.$$.fragment,u),Q=r(u),C=i(u,"P",{"data-svelte-h":!0}),q(C)!=="svelte-1qdlpc6"&&(C.textContent=ae),Y=r(u),j=i(u,"P",{"data-svelte-h":!0}),q(j)!=="svelte-mxgguy"&&(j.innerHTML=de),Z=r(u),f=i(u,"DIV",{class:!0});var B=V(f);h(F.$$.fragment,B),ee=r(B),N=i(B,"P",{"data-svelte-h":!0}),q(N)!=="svelte-zjkeig"&&(N.innerHTML=ie),B.forEach(o),u.forEach(o),S=r(e),h(w.$$.fragment,e),U=r(e),m=i(e,"DIV",{class:!0});var J=V(m);h(k.$$.fragment,J),te=r(J),L=i(J,"P",{"data-svelte-h":!0}),q(L)!=="svelte-raxtjw"&&(L.innerHTML=ce),J.forEach(o),G=r(e),h(y.$$.fragment,e),R=r(e),P=i(e,"P",{}),V(P).forEach(o),this.h()},h(){z(l,"name","hf:doc:metadata"),z(l,"content",Te),z(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(m,"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){c(document.head,l),s(e,H,t),s(e,O,t),s(e,K,t),_(v,e,t),s(e,E,t),_(b,e,t),s(e,I,t),s(e,$,t),s(e,W,t),_(D,e,t),s(e,A,t),s(e,a,t),_(M,a,null),c(a,Q),c(a,C),c(a,Y),c(a,j),c(a,Z),c(a,f),_(F,f,null),c(f,ee),c(f,N),s(e,S,t),_(w,e,t),s(e,U,t),s(e,m,t),_(k,m,null),c(m,te),c(m,L),s(e,G,t),_(y,e,t),s(e,R,t),s(e,P,t),X=!0},p:me,i(e){X||(g(v.$$.fragment,e),g(b.$$.fragment,e),g(D.$$.fragment,e),g(M.$$.fragment,e),g(F.$$.fragment,e),g(w.$$.fragment,e),g(k.$$.fragment,e),g(y.$$.fragment,e),X=!0)},o(e){x(v.$$.fragment,e),x(b.$$.fragment,e),x(D.$$.fragment,e),x(M.$$.fragment,e),x(F.$$.fragment,e),x(w.$$.fragment,e),x(k.$$.fragment,e),x(y.$$.fragment,e),X=!1},d(e){e&&(o(H),o(O),o(K),o(E),o(I),o($),o(W),o(A),o(a),o(S),o(U),o(m),o(G),o(R),o(P)),o(l),T(v,e),T(b,e),T(D,e),T(M),T(F),T(w,e),T(k),T(y,e)}}}const Te='{"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}';function ve(re){return fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class we extends ue{constructor(l){super(),pe(this,l,ve,xe,le,{})}}export{we as component}; | |
Xet Storage Details
- Size:
- 14.7 kB
- Xet hash:
- 8792b0210f7a78b05b26c1f663b2681a1c81f20aa0849d26fd334293697e4d33
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.