Buckets:

download
raw
13.3 kB
import"../chunks/DsnmJJEf.js";import{i as H,h as x,C as w,H as r,a as k,D as t,E as z,s as J}from"../chunks/BtE7mKSK.js";import{p as j,o as Z,s as e,f as I,a as y,b as N,c as s,d as T,n as d,r as a}from"../chunks/jDjavuwI.js";const R='{"title":"HunyuanVideoTransformer3DModel","local":"hunyuanvideotransformer3dmodel","sections":[{"title":"HunyuanVideoTransformer3DModel","local":"diffusers.HunyuanVideoTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';var W=T('<meta name="hf:doc:metadata"/>'),G=T('<p></p> <!> <!> <p>A Diffusion Transformer model for 3D video-like data was introduced in <a href="https://huggingface.co/papers/2412.03603" rel="nofollow">HunyuanVideo: A Systematic Framework For Large Video Generative Models</a> by Tencent.</p> <p>The model can be loaded with the following code snippet.</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>A Transformer model for video-like data used in <a href="https://huggingface.co/tencent/HunyuanVideo" rel="nofollow">HunyuanVideo</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_13966/en/api/models/hunyuan_video_transformer_3d#diffusers.HunyuanVideoTransformer3DModel">HunyuanVideoTransformer3DModel</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_13966/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.</p></div> <!> <p></p>',1);function O(b,v){j(v,!1),Z(()=>{new URLSearchParams(window.location.search).get("fw")}),H();var i=G();x("16fsivv",_=>{var g=W();J(g,"content",R),y(_,g)});var c=e(I(i),2);w(c,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var u=e(c,2);r(u,{title:"HunyuanVideoTransformer3DModel",local:"hunyuanvideotransformer3dmodel",headingTag:"h1"});var m=e(u,6);k(m,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEh1bnl1YW5WaWRlb1RyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwSHVueXVhblZpZGVvVHJhbnNmb3JtZXIzRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJodW55dWFudmlkZW8tY29tbXVuaXR5JTJGSHVueXVhblZpZGVvJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanVideoTransformer3DModel
transformer = HunyuanVideoTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;hunyuanvideo-community/HunyuanVideo&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,lang:"python",wrap:!1});var l=e(m,2);r(l,{title:"HunyuanVideoTransformer3DModel",local:"diffusers.HunyuanVideoTransformer3DModel",headingTag:"h2"});var o=e(l,2),f=s(o);t(f,{name:"class diffusers.HunyuanVideoTransformer3DModel",anchor:"diffusers.HunyuanVideoTransformer3DModel",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_hunyuan_video.py#L841",parameters:[{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": int = 16"},{name:"num_attention_heads",val:": int = 24"},{name:"attention_head_dim",val:": int = 128"},{name:"num_layers",val:": int = 20"},{name:"num_single_layers",val:": int = 40"},{name:"num_refiner_layers",val:": int = 2"},{name:"mlp_ratio",val:": float = 4.0"},{name:"patch_size",val:": int = 2"},{name:"patch_size_t",val:": int = 1"},{name:"qk_norm",val:": str = 'rms_norm'"},{name:"guidance_embeds",val:": bool = True"},{name:"text_embed_dim",val:": int = 4096"},{name:"pooled_projection_dim",val:": int = 768"},{name:"rope_theta",val:": float = 256.0"},{name:"rope_axes_dim",val:": tuple = (16, 56, 56)"},{name:"image_condition_type",val:": str | None = None"}],parametersDescription:[{anchor:"diffusers.HunyuanVideoTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>24</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>20</code>) &#x2014;
The number of layers of dual-stream blocks to use.`,name:"num_layers"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.num_single_layers",description:`<strong>num_single_layers</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
The number of layers of single-stream blocks to use.`,name:"num_single_layers"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.num_refiner_layers",description:`<strong>num_refiner_layers</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The number of layers of refiner blocks to use.`,name:"num_refiner_layers"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, defaults to <code>4.0</code>) &#x2014;
The ratio of the hidden layer size to the input size in the feedforward network.`,name:"mlp_ratio"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The size of the spatial patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.patch_size_t",description:`<strong>patch_size_t</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
The size of the tmeporal patches to use in the patch embedding layer.`,name:"patch_size_t"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, defaults to <code>rms_norm</code>) &#x2014;
The normalization to use for the query and key projections in the attention layers.`,name:"qk_norm"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.guidance_embeds",description:`<strong>guidance_embeds</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use guidance embeddings in the model.`,name:"guidance_embeds"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.text_embed_dim",description:`<strong>text_embed_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
Input dimension of text embeddings from the text encoder.`,name:"text_embed_dim"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, defaults to <code>768</code>) &#x2014;
The dimension of the pooled projection of the text embeddings.`,name:"pooled_projection_dim"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.rope_theta",description:`<strong>rope_theta</strong> (<code>float</code>, defaults to <code>256.0</code>) &#x2014;
The value of theta to use in the RoPE layer.`,name:"rope_theta"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.rope_axes_dim",description:`<strong>rope_axes_dim</strong> (<code>tuple[int]</code>, defaults to <code>(16, 56, 56)</code>) &#x2014;
The dimensions of the axes to use in the RoPE layer.`,name:"rope_axes_dim"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.image_condition_type",description:`<strong>image_condition_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The type of image conditioning to use. If <code>None</code>, no image conditioning is used. If <code>latent_concat</code>, the
image is concatenated to the latent stream. If <code>token_replace</code>, the image is used to replace first-frame
tokens in the latent stream and apply conditioning.`,name:"image_condition_type"}]});var p=e(f,4),M=s(p);t(M,{name:"forward",anchor:"diffusers.HunyuanVideoTransformer3DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_hunyuan_video.py#L994",parameters:[{name:"hidden_states",val:": Tensor"},{name:"timestep",val:": LongTensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"encoder_attention_mask",val:": Tensor"},{name:"pooled_projections",val:": Tensor"},{name:"guidance",val:": Tensor = None"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HunyuanVideoTransformer3DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, num_frames, height, width)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_len, embed_dims)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.Tensor</code>) &#x2014;
Mask applied to <code>encoder_hidden_states</code> during attention.`,name:"encoder_attention_mask"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.forward.pooled_projections",description:`<strong>pooled_projections</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, projection_dim)</code>) &#x2014;
Embeddings projected from the embeddings of input conditions.`,name:"pooled_projections"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.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.HunyuanVideoTransformer3DModel.forward.attention_kwargs",description:`<strong>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:"attention_kwargs"},{anchor:"diffusers.HunyuanVideoTransformer3DModel.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"}],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.</p>
`}),d(2),a(p),a(o);var h=e(o,2);r(h,{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"});var n=e(h,2),D=s(n);t(D,{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/modeling_outputs.py#L21",parameters:[{name:"sample",val:": torch.Tensor"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>(batch size, num_vector_embeds - 1, num_latent_pixels)</code> if <a href="/docs/diffusers/pr_13966/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input. If discrete, returns probability
distributions for the unnoised latent pixels.`,name:"sample"}]}),d(2),a(n);var V=e(n,2);z(V,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuan_video_transformer_3d.md"}),d(2),y(b,i),N()}export{O as component};

Xet Storage Details

Size:
13.3 kB
·
Xet hash:
38204fe63152f44ab4cfb9ec41f7810ea95688fca1490b447bb595846038b0c7

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