import{s as oe,n as se,o as re}from"../chunks/scheduler.53228c21.js";import{S as ae,i as ie,e as d,s,c as $,h as de,a as m,d as n,b as r,f as G,g as y,j as V,k as q,l,m as a,n as I,t as x,o as M,p as D}from"../chunks/index.100fac89.js";import{C as me}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as te}from"../chunks/Docstring.49101787.js";import{C as le}from"../chunks/CodeBlock.d30a6509.js";import{H as ne,E as ce}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function fe(X){let i,U,J,z,u,R,p,j,h,B="The model can be loaded with the following code snippet.",L,g,k,_,E,o,v,S,O,F="The Transformer model introduced in Ovis-Image.",A,w,K='Reference: <a href="https://github.com/AIDC-AI/Ovis-Image" rel="nofollow">https://github.com/AIDC-AI/Ovis-Image</a>',Y,c,T,Q,C,ee='The <a href="/docs/diffusers/main/en/api/models/ovisimage_transformer2d#diffusers.OvisImageTransformer2DModel">OvisImageTransformer2DModel</a> forward method.',H,b,N,Z,P;return u=new me({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),p=new ne({props:{title:"OvisImageTransformer2DModel",local:"ovisimagetransformer2dmodel",headingTag:"h1"}}),g=new le({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyME92aXNJbWFnZVRyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwT3Zpc0ltYWdlVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJBSURDLUFJJTJGT3Zpcy1JbWFnZS03QiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> OvisImageTransformer2DModel

transformer = OvisImageTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;AIDC-AI/Ovis-Image-7B&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),_=new ne({props:{title:"OvisImageTransformer2DModel",local:"diffusers.OvisImageTransformer2DModel",headingTag:"h2"}}),v=new te({props:{name:"class diffusers.OvisImageTransformer2DModel",anchor:"diffusers.OvisImageTransformer2DModel",parameters:[{name:"patch_size",val:": int = 1"},{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": typing.Optional[int] = 64"},{name:"num_layers",val:": int = 6"},{name:"num_single_layers",val:": int = 27"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 24"},{name:"joint_attention_dim",val:": int = 2048"},{name:"axes_dims_rope",val:": typing.Tuple[int, int, int] = (16, 56, 56)"}],parametersDescription:[{anchor:"diffusers.OvisImageTransformer2DModel.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.OvisImageTransformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.OvisImageTransformer2DModel.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.OvisImageTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>6</code>) &#x2014;
The number of layers of dual stream DiT blocks to use.`,name:"num_layers"},{anchor:"diffusers.OvisImageTransformer2DModel.num_single_layers",description:`<strong>num_single_layers</strong> (<code>int</code>, defaults to <code>27</code>) &#x2014;
The number of layers of single stream DiT blocks to use.`,name:"num_single_layers"},{anchor:"diffusers.OvisImageTransformer2DModel.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.OvisImageTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>24</code>) &#x2014;
The number of attention heads to use.`,name:"num_attention_heads"},{anchor:"diffusers.OvisImageTransformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>2048</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.OvisImageTransformer2DModel.axes_dims_rope",description:`<strong>axes_dims_rope</strong> (<code>Tuple[int]</code>, defaults to <code>(16, 56, 56)</code>) &#x2014;
The dimensions to use for the rotary positional embeddings.`,name:"axes_dims_rope"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_ovis_image.py#L386"}}),T=new te({props:{name:"forward",anchor:"diffusers.OvisImageTransformer2DModel.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:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.OvisImageTransformer2DModel.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.OvisImageTransformer2DModel.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.OvisImageTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.OvisImageTransformer2DModel.forward.img_ids",description:`<strong>img_ids</strong> &#x2014; (<code>torch.Tensor</code>):
The position ids for image tokens.`,name:"img_ids"},{anchor:"diffusers.OvisImageTransformer2DModel.forward.txt_ids",description:`<strong>txt_ids</strong> (<code>torch.Tensor</code>) &#x2014;
The position ids for text tokens.`,name:"txt_ids"},{anchor:"diffusers.OvisImageTransformer2DModel.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_ovis_image.py#L478",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>
`}}),b=new ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/ovisimage_transformer2d.md"}}),{c(){i=d("meta"),U=s(),J=d("p"),z=s(),$(u.$$.fragment),R=s(),$(p.$$.fragment),j=s(),h=d("p"),h.textContent=B,L=s(),$(g.$$.fragment),k=s(),$(_.$$.fragment),E=s(),o=d("div"),$(v.$$.fragment),S=s(),O=d("p"),O.textContent=F,A=s(),w=d("p"),w.innerHTML=K,Y=s(),c=d("div"),$(T.$$.fragment),Q=s(),C=d("p"),C.innerHTML=ee,H=s(),$(b.$$.fragment),N=s(),Z=d("p"),this.h()},l(e){const t=de("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),U=r(e),J=m(e,"P",{}),G(J).forEach(n),z=r(e),y(u.$$.fragment,e),R=r(e),y(p.$$.fragment,e),j=r(e),h=m(e,"P",{"data-svelte-h":!0}),V(h)!=="svelte-1vuni30"&&(h.textContent=B),L=r(e),y(g.$$.fragment,e),k=r(e),y(_.$$.fragment,e),E=r(e),o=m(e,"DIV",{class:!0});var f=G(o);y(v.$$.fragment,f),S=r(f),O=m(f,"P",{"data-svelte-h":!0}),V(O)!=="svelte-pz7q0m"&&(O.textContent=F),A=r(f),w=m(f,"P",{"data-svelte-h":!0}),V(w)!=="svelte-fb5wma"&&(w.innerHTML=K),Y=r(f),c=m(f,"DIV",{class:!0});var W=G(c);y(T.$$.fragment,W),Q=r(W),C=m(W,"P",{"data-svelte-h":!0}),V(C)!=="svelte-1icykb9"&&(C.innerHTML=ee),W.forEach(n),f.forEach(n),H=r(e),y(b.$$.fragment,e),N=r(e),Z=m(e,"P",{}),G(Z).forEach(n),this.h()},h(){q(i,"name","hf:doc:metadata"),q(i,"content",ue),q(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(o,"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){l(document.head,i),a(e,U,t),a(e,J,t),a(e,z,t),I(u,e,t),a(e,R,t),I(p,e,t),a(e,j,t),a(e,h,t),a(e,L,t),I(g,e,t),a(e,k,t),I(_,e,t),a(e,E,t),a(e,o,t),I(v,o,null),l(o,S),l(o,O),l(o,A),l(o,w),l(o,Y),l(o,c),I(T,c,null),l(c,Q),l(c,C),a(e,H,t),I(b,e,t),a(e,N,t),a(e,Z,t),P=!0},p:se,i(e){P||(x(u.$$.fragment,e),x(p.$$.fragment,e),x(g.$$.fragment,e),x(_.$$.fragment,e),x(v.$$.fragment,e),x(T.$$.fragment,e),x(b.$$.fragment,e),P=!0)},o(e){M(u.$$.fragment,e),M(p.$$.fragment,e),M(g.$$.fragment,e),M(_.$$.fragment,e),M(v.$$.fragment,e),M(T.$$.fragment,e),M(b.$$.fragment,e),P=!1},d(e){e&&(n(U),n(J),n(z),n(R),n(j),n(h),n(L),n(k),n(E),n(o),n(H),n(N),n(Z)),n(i),D(u,e),D(p,e),D(g,e),D(_,e),D(v),D(T),D(b,e)}}}const ue='{"title":"OvisImageTransformer2DModel","local":"ovisimagetransformer2dmodel","sections":[{"title":"OvisImageTransformer2DModel","local":"diffusers.OvisImageTransformer2DModel","sections":[],"depth":2}],"depth":1}';function pe(X){return re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $e extends ae{constructor(i){super(),ie(this,i,pe,fe,oe,{})}}export{$e as component};
