Buckets:

download
raw
13.4 kB
import"../chunks/DsnmJJEf.js";import{i as q,h as N,C as j,H as b,D as n,E as L,s as C}from"../chunks/CmJXCtRL.js";import{p as A,o as P,s as e,f as E,a as y,b as I,c as o,d as D,n as t,r as a}from"../chunks/DK803DsY.js";const S='{"title":"HunyuanDiT2DModel","local":"hunyuandit2dmodel","sections":[{"title":"HunyuanDiT2DModel","local":"diffusers.HunyuanDiT2DModel","sections":[],"depth":2}],"depth":1}';var F=D('<meta name="hf:doc:metadata"/>'),W=D(`<p></p> <!> <!> <p>A Diffusion Transformer model for 2D data from <a href="https://github.com/Tencent/HunyuanDiT" rel="nofollow">Hunyuan-DiT</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>HunYuanDiT: Diffusion model with a Transformer backbone.</p> <p>Inherit ModelMixin and ConfigMixin to be compatible with the sampler StableDiffusionPipeline of diffusers.</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>Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.</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>The <a href="/docs/diffusers/pr_13881/en/api/models/hunyuan_transformer2d#diffusers.HunyuanDiT2DModel">HunyuanDiT2DModel</a> forward method.</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>Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.</p> <blockquote class="warning"><p>> This API is 🧪 experimental.</p></blockquote></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>Disables custom attention processors and sets the default attention implementation.</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>Disables the fused QKV projection if enabled.</p> <blockquote class="warning"><p>> This API is 🧪 experimental.</p></blockquote></div></div> <!> <p></p>`,1);function U(T,v){A(v,!1),P(()=>{new URLSearchParams(window.location.search).get("fw")}),q();var m=W();N("rs1lo5",p=>{var g=F();C(g,"content",S),y(p,g)});var l=e(E(m),2);j(l,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var u=e(l,2);b(u,{title:"HunyuanDiT2DModel",local:"hunyuandit2dmodel",headingTag:"h1"});var f=e(u,4);b(f,{title:"HunyuanDiT2DModel",local:"diffusers.HunyuanDiT2DModel",headingTag:"h2"});var i=e(f,2),_=o(i);n(_,{name:"class diffusers.HunyuanDiT2DModel",anchor:"diffusers.HunyuanDiT2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L201",parameters:[{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 88"},{name:"in_channels",val:": int | None = None"},{name:"patch_size",val:": int | None = None"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"sample_size",val:" = 32"},{name:"hidden_size",val:" = 1152"},{name:"num_layers",val:": int = 28"},{name:"mlp_ratio",val:": float = 4.0"},{name:"learn_sigma",val:": bool = True"},{name:"cross_attention_dim",val:": int = 1024"},{name:"norm_type",val:": str = 'layer_norm'"},{name:"cross_attention_dim_t5",val:": int = 2048"},{name:"pooled_projection_dim",val:": int = 1024"},{name:"text_len",val:": int = 77"},{name:"text_len_t5",val:": int = 256"},{name:"use_style_cond_and_image_meta_size",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.HunyuanDiT2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 88) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.HunyuanDiT2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of channels in the input and output (specify if the input is <strong>continuous</strong>).`,name:"in_channels"},{anchor:"diffusers.HunyuanDiT2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of the patch to use for the input.`,name:"patch_size"},{anchor:"diffusers.HunyuanDiT2DModel.activation_fn",description:`<strong>activation_fn</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;geglu&quot;</code>) &#x2014;
Activation function to use in feed-forward.`,name:"activation_fn"},{anchor:"diffusers.HunyuanDiT2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The width of the latent images. This is fixed during training since it is used to learn a number of
position embeddings.`,name:"sample_size"},{anchor:"diffusers.HunyuanDiT2DModel.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability to use.`,name:"dropout"},{anchor:"diffusers.HunyuanDiT2DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of dimension in the clip text embedding.`,name:"cross_attention_dim"},{anchor:"diffusers.HunyuanDiT2DModel.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of hidden layer in the conditioning embedding layers.`,name:"hidden_size"},{anchor:"diffusers.HunyuanDiT2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.HunyuanDiT2DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
The ratio of the hidden layer size to the input size.`,name:"mlp_ratio"},{anchor:"diffusers.HunyuanDiT2DModel.learn_sigma",description:`<strong>learn_sigma</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to predict variance.`,name:"learn_sigma"},{anchor:"diffusers.HunyuanDiT2DModel.cross_attention_dim_t5",description:`<strong>cross_attention_dim_t5</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number dimensions in t5 text embedding.`,name:"cross_attention_dim_t5"},{anchor:"diffusers.HunyuanDiT2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of the pooled projection.`,name:"pooled_projection_dim"},{anchor:"diffusers.HunyuanDiT2DModel.text_len",description:`<strong>text_len</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the clip text embedding.`,name:"text_len"},{anchor:"diffusers.HunyuanDiT2DModel.text_len_t5",description:`<strong>text_len_t5</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the T5 text embedding.`,name:"text_len_t5"},{anchor:"diffusers.HunyuanDiT2DModel.use_style_cond_and_image_meta_size",description:`<strong>use_style_cond_and_image_meta_size</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to use style condition and image meta size. True for version &lt;=1.1, False for version &gt;= 1.2`,name:"use_style_cond_and_image_meta_size"}]});var s=e(_,6),x=o(s);n(x,{name:"enable_forward_chunking",anchor:"diffusers.HunyuanDiT2DModel.enable_forward_chunking",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L472",parameters:[{name:"chunk_size",val:": int | None = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.enable_forward_chunking.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The chunk size of the feed-forward layers. If not specified, will run feed-forward layer individually
over each tensor of dim=<code>dim</code>.`,name:"chunk_size"},{anchor:"diffusers.HunyuanDiT2DModel.enable_forward_chunking.dim",description:`<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
The dimension over which the feed-forward computation should be chunked. Choose between dim=0 (batch)
or dim=1 (sequence length).`,name:"dim"}]}),t(2),a(s);var r=e(s,2),M=o(r);n(M,{name:"forward",anchor:"diffusers.HunyuanDiT2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L357",parameters:[{name:"hidden_states",val:""},{name:"timestep",val:""},{name:"encoder_hidden_states",val:" = None"},{name:"text_embedding_mask",val:" = None"},{name:"encoder_hidden_states_t5",val:" = None"},{name:"text_embedding_mask_t5",val:" = None"},{name:"image_meta_size",val:" = None"},{name:"style",val:" = None"},{name:"image_rotary_emb",val:" = None"},{name:"controlnet_block_samples",val:" = None"},{name:"return_dict",val:" = True"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch size, dim, height, width)</code>) &#x2014;
The input tensor.`,name:"hidden_states"},{anchor:"diffusers.HunyuanDiT2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.HunyuanDiT2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of <code>BertModel</code>.`,name:"encoder_hidden_states"},{anchor:"diffusers.HunyuanDiT2DModel.forward.text_embedding_mask",description:`<strong>text_embedding_mask</strong> &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of <code>BertModel</code>.`,name:"text_embedding_mask"},{anchor:"diffusers.HunyuanDiT2DModel.forward.encoder_hidden_states_t5",description:`<strong>encoder_hidden_states_t5</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of T5 Text Encoder.`,name:"encoder_hidden_states_t5"},{anchor:"diffusers.HunyuanDiT2DModel.forward.text_embedding_mask_t5",description:`<strong>text_embedding_mask_t5</strong> &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of T5 Text Encoder.`,name:"text_embedding_mask_t5"},{anchor:"diffusers.HunyuanDiT2DModel.forward.image_meta_size",description:`<strong>image_meta_size</strong> (torch.Tensor) &#x2014;
Conditional embedding indicate the image sizes`,name:"image_meta_size"},{anchor:"diffusers.HunyuanDiT2DModel.forward.style",description:`<strong>style</strong> &#x2014; torch.Tensor:
Conditional embedding indicate the style`,name:"style"},{anchor:"diffusers.HunyuanDiT2DModel.forward.image_rotary_emb",description:`<strong>image_rotary_emb</strong> (<code>torch.Tensor</code>) &#x2014;
The image rotary embeddings to apply on query and key tensors during attention calculation.`,name:"image_rotary_emb"},{anchor:"diffusers.HunyuanDiT2DModel.forward.controlnet_block_samples",description:`<strong>controlnet_block_samples</strong> (<code>list</code> of <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
A list of tensors that if specified are added to the residuals of transformer blocks.`,name:"controlnet_block_samples"},{anchor:"diffusers.HunyuanDiT2DModel.forward.return_dict",description:`<strong>return_dict</strong> &#x2014; bool
Whether to return a dictionary.`,name:"return_dict"}]}),t(2),a(r);var d=e(r,2),H=o(d);n(H,{name:"fuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.fuse_qkv_projections",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L320",parameters:[]}),t(4),a(d);var c=e(d,2),k=o(c);n(k,{name:"set_default_attn_processor",anchor:"diffusers.HunyuanDiT2DModel.set_default_attn_processor",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L351",parameters:[]}),t(2),a(c);var h=e(c,2),w=o(h);n(w,{name:"unfuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.unfuse_qkv_projections",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L342",parameters:[]}),t(4),a(h),a(i);var z=e(i,2);L(z,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuan_transformer2d.md"}),t(2),y(T,m),I()}export{U as component};

Xet Storage Details

Size:
13.4 kB
·
Xet hash:
22b228804d1727dd0196bd6ea647834fa128bde2979cb36cd540509357a55283

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