Buckets:
| import{s as re,n as ae,o as ie}from"../chunks/scheduler.53228c21.js";import{S as de,i as me,e as m,s,c,h as le,a as l,d as t,b as r,f as q,g as f,j as B,k as Q,l as N,m as n,n as u,t as p,o as _,p as h}from"../chunks/index.cac5d66a.js";import{C as ce}from"../chunks/CopyLLMTxtMenu.4912207d.js";import{D as se}from"../chunks/Docstring.1e7ac4f3.js";import{C as fe}from"../chunks/CodeBlock.606cbaf4.js";import{H as Y,E as ue}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.323ee77a.js";function pe(K){let a,J,z,Z,g,L,T,E,b,ee='A Diffusion Transformer model for 3D video-like data was introduced in <a href="https://huggingface.co/papers/2501.03575" rel="nofollow">Cosmos World Foundation Model Platform for Physical AI</a> by NVIDIA.',j,x,oe="The model can be loaded with the following code snippet.",H,v,P,$,R,i,M,X,w,te='A Transformer model for video-like data used in <a href="https://github.com/NVIDIA/Cosmos" rel="nofollow">Cosmos</a>.',V,y,W,d,D,F,k,ne='The output of <a href="/docs/diffusers/pr_13745/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',U,C,A,I,O;return g=new ce({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new Y({props:{title:"CosmosTransformer3DModel",local:"cosmostransformer3dmodel",headingTag:"h1"}}),v=new fe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvc21vc1RyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQ29zbW9zVHJhbnNmb3JtZXIzRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZDb3Ntb3MtMS4wLURpZmZ1c2lvbi03Qi1UZXh0MldvcmxkJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CosmosTransformer3DModel | |
| transformer = CosmosTransformer3DModel.from_pretrained(<span class="hljs-string">"nvidia/Cosmos-1.0-Diffusion-7B-Text2World"</span>, subfolder=<span class="hljs-string">"transformer"</span>, torch_dtype=torch.bfloat16)`,lang:"python",wrap:!1}}),$=new Y({props:{title:"CosmosTransformer3DModel",local:"diffusers.CosmosTransformer3DModel",headingTag:"h2"}}),M=new se({props:{name:"class diffusers.CosmosTransformer3DModel",anchor:"diffusers.CosmosTransformer3DModel",parameters:[{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": int = 16"},{name:"num_attention_heads",val:": int = 32"},{name:"attention_head_dim",val:": int = 128"},{name:"num_layers",val:": int = 28"},{name:"mlp_ratio",val:": float = 4.0"},{name:"text_embed_dim",val:": int = 1024"},{name:"adaln_lora_dim",val:": int = 256"},{name:"max_size",val:": tuple = (128, 240, 240)"},{name:"patch_size",val:": tuple = (1, 2, 2)"},{name:"rope_scale",val:": tuple = (2.0, 1.0, 1.0)"},{name:"concat_padding_mask",val:": bool = True"},{name:"extra_pos_embed_type",val:": str | None = 'learnable'"},{name:"use_crossattn_projection",val:": bool = False"},{name:"crossattn_proj_in_channels",val:": int = 1024"},{name:"encoder_hidden_states_channels",val:": int = 1024"},{name:"controlnet_block_every_n",val:": int | None = None"},{name:"img_context_dim_in",val:": int | None = None"},{name:"img_context_num_tokens",val:": int = 256"},{name:"img_context_dim_out",val:": int = 2048"}],parametersDescription:[{anchor:"diffusers.CosmosTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) — | |
| The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.CosmosTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) — | |
| The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CosmosTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>32</code>) — | |
| The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CosmosTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) — | |
| The number of channels in each attention head.`,name:"attention_head_dim"},{anchor:"diffusers.CosmosTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>28</code>) — | |
| The number of layers of transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.CosmosTransformer3DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, defaults to <code>4.0</code>) — | |
| The ratio of the hidden layer size to the input size in the feedforward network.`,name:"mlp_ratio"},{anchor:"diffusers.CosmosTransformer3DModel.text_embed_dim",description:`<strong>text_embed_dim</strong> (<code>int</code>, defaults to <code>4096</code>) — | |
| Input dimension of text embeddings from the text encoder.`,name:"text_embed_dim"},{anchor:"diffusers.CosmosTransformer3DModel.adaln_lora_dim",description:`<strong>adaln_lora_dim</strong> (<code>int</code>, defaults to <code>256</code>) — | |
| The hidden dimension of the Adaptive LayerNorm LoRA layer.`,name:"adaln_lora_dim"},{anchor:"diffusers.CosmosTransformer3DModel.max_size",description:`<strong>max_size</strong> (<code>tuple[int, int, int]</code>, defaults to <code>(128, 240, 240)</code>) — | |
| The maximum size of the input latent tensors in the temporal, height, and width dimensions.`,name:"max_size"},{anchor:"diffusers.CosmosTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>tuple[int, int, int]</code>, defaults to <code>(1, 2, 2)</code>) — | |
| The patch size to use for patchifying the input latent tensors in the temporal, height, and width | |
| dimensions.`,name:"patch_size"},{anchor:"diffusers.CosmosTransformer3DModel.rope_scale",description:`<strong>rope_scale</strong> (<code>tuple[float, float, float]</code>, defaults to <code>(2.0, 1.0, 1.0)</code>) — | |
| The scaling factor to use for RoPE in the temporal, height, and width dimensions.`,name:"rope_scale"},{anchor:"diffusers.CosmosTransformer3DModel.concat_padding_mask",description:`<strong>concat_padding_mask</strong> (<code>bool</code>, defaults to <code>True</code>) — | |
| Whether to concatenate the padding mask to the input latent tensors.`,name:"concat_padding_mask"},{anchor:"diffusers.CosmosTransformer3DModel.extra_pos_embed_type",description:`<strong>extra_pos_embed_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>learnable</code>) — | |
| The type of extra positional embeddings to use. Can be one of <code>None</code> or <code>learnable</code>.`,name:"extra_pos_embed_type"},{anchor:"diffusers.CosmosTransformer3DModel.controlnet_block_every_n",description:`<strong>controlnet_block_every_n</strong> (<code>int</code>, <em>optional</em>) — | |
| Interval between transformer blocks that should receive control residuals (for example, <code>7</code> to inject after | |
| every seventh block). Required for Cosmos Transfer2.5.`,name:"controlnet_block_every_n"},{anchor:"diffusers.CosmosTransformer3DModel.img_context_dim_in",description:`<strong>img_context_dim_in</strong> (<code>int</code>, <em>optional</em>) — | |
| The dimension of the input image context feature vector, i.e. it is the D in [B, N, D].`,name:"img_context_dim_in"},{anchor:"diffusers.CosmosTransformer3DModel.img_context_num_tokens",description:`<strong>img_context_num_tokens</strong> (<code>int</code>) — | |
| The number of tokens in the image context feature vector, i.e. it is the N in [B, N, D]. If | |
| <code>img_context_dim_in</code> is not provided, then this parameter is ignored.`,name:"img_context_num_tokens"},{anchor:"diffusers.CosmosTransformer3DModel.img_context_dim_out",description:`<strong>img_context_dim_out</strong> (<code>int</code>) — | |
| The output dimension of the image context projection layer. If <code>img_context_dim_in</code> is not provided, then | |
| this parameter is ignored.`,name:"img_context_dim_out"}],source:"https://github.com/huggingface/diffusers/blob/vr_13745/src/diffusers/models/transformers/transformer_cosmos.py#L554"}}),y=new Y({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),D=new se({props:{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",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_13745/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) — | |
| 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"}],source:"https://github.com/huggingface/diffusers/blob/vr_13745/src/diffusers/models/modeling_outputs.py#L21"}}),C=new ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cosmos_transformer3d.md"}}),{c(){a=m("meta"),J=s(),z=m("p"),Z=s(),c(g.$$.fragment),L=s(),c(T.$$.fragment),E=s(),b=m("p"),b.innerHTML=ee,j=s(),x=m("p"),x.textContent=oe,H=s(),c(v.$$.fragment),P=s(),c($.$$.fragment),R=s(),i=m("div"),c(M.$$.fragment),X=s(),w=m("p"),w.innerHTML=te,V=s(),c(y.$$.fragment),W=s(),d=m("div"),c(D.$$.fragment),F=s(),k=m("p"),k.innerHTML=ne,U=s(),c(C.$$.fragment),A=s(),I=m("p"),this.h()},l(e){const o=le("svelte-u9bgzb",document.head);a=l(o,"META",{name:!0,content:!0}),o.forEach(t),J=r(e),z=l(e,"P",{}),q(z).forEach(t),Z=r(e),f(g.$$.fragment,e),L=r(e),f(T.$$.fragment,e),E=r(e),b=l(e,"P",{"data-svelte-h":!0}),B(b)!=="svelte-1pjw3fi"&&(b.innerHTML=ee),j=r(e),x=l(e,"P",{"data-svelte-h":!0}),B(x)!=="svelte-1vuni30"&&(x.textContent=oe),H=r(e),f(v.$$.fragment,e),P=r(e),f($.$$.fragment,e),R=r(e),i=l(e,"DIV",{class:!0});var S=q(i);f(M.$$.fragment,S),X=r(S),w=l(S,"P",{"data-svelte-h":!0}),B(w)!=="svelte-y8uhes"&&(w.innerHTML=te),S.forEach(t),V=r(e),f(y.$$.fragment,e),W=r(e),d=l(e,"DIV",{class:!0});var G=q(d);f(D.$$.fragment,G),F=r(G),k=l(G,"P",{"data-svelte-h":!0}),B(k)!=="svelte-clyat2"&&(k.innerHTML=ne),G.forEach(t),U=r(e),f(C.$$.fragment,e),A=r(e),I=l(e,"P",{}),q(I).forEach(t),this.h()},h(){Q(a,"name","hf:doc:metadata"),Q(a,"content",_e),Q(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Q(d,"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,o){N(document.head,a),n(e,J,o),n(e,z,o),n(e,Z,o),u(g,e,o),n(e,L,o),u(T,e,o),n(e,E,o),n(e,b,o),n(e,j,o),n(e,x,o),n(e,H,o),u(v,e,o),n(e,P,o),u($,e,o),n(e,R,o),n(e,i,o),u(M,i,null),N(i,X),N(i,w),n(e,V,o),u(y,e,o),n(e,W,o),n(e,d,o),u(D,d,null),N(d,F),N(d,k),n(e,U,o),u(C,e,o),n(e,A,o),n(e,I,o),O=!0},p:ae,i(e){O||(p(g.$$.fragment,e),p(T.$$.fragment,e),p(v.$$.fragment,e),p($.$$.fragment,e),p(M.$$.fragment,e),p(y.$$.fragment,e),p(D.$$.fragment,e),p(C.$$.fragment,e),O=!0)},o(e){_(g.$$.fragment,e),_(T.$$.fragment,e),_(v.$$.fragment,e),_($.$$.fragment,e),_(M.$$.fragment,e),_(y.$$.fragment,e),_(D.$$.fragment,e),_(C.$$.fragment,e),O=!1},d(e){e&&(t(J),t(z),t(Z),t(L),t(E),t(b),t(j),t(x),t(H),t(P),t(R),t(i),t(V),t(W),t(d),t(U),t(A),t(I)),t(a),h(g,e),h(T,e),h(v,e),h($,e),h(M),h(y,e),h(D),h(C,e)}}}const _e='{"title":"CosmosTransformer3DModel","local":"cosmostransformer3dmodel","sections":[{"title":"CosmosTransformer3DModel","local":"diffusers.CosmosTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function he(K){return ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Me extends de{constructor(a){super(),me(this,a,he,pe,re,{})}}export{Me as component}; | |
Xet Storage Details
- Size:
- 12.1 kB
- Xet hash:
- f74f4769b02e87daa6bbe1e84210b40d58a0fc728271a178162e67e115cee600
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.