Buckets:

HuggingFaceDocBuilder's picture
download
raw
8.53 kB
import"../chunks/DsnmJJEf.js";import{i as I,h as D,C as M,H as l,a as x,D as f,E as O,s as w}from"../chunks/BtE7mKSK.js";import{p as J,o as Z,s as e,f as j,a as h,b as U,c as g,d as _,n as p,r as u}from"../chunks/jDjavuwI.js";const k='{"title":"OvisImageTransformer2DModel","local":"ovisimagetransformer2dmodel","sections":[{"title":"OvisImageTransformer2DModel","local":"diffusers.OvisImageTransformer2DModel","sections":[],"depth":2}],"depth":1}';var N=_('<meta name="hf:doc:metadata"/>'),R=_('<p></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>The Transformer model introduced in Ovis-Image.</p> <p>Reference: <a href="https://github.com/AIDC-AI/Ovis-Image" rel="nofollow">https://github.com/AIDC-AI/Ovis-Image</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/ovisimage_transformer2d#diffusers.OvisImageTransformer2DModel">OvisImageTransformer2DModel</a> forward method.</p></div></div> <!> <p></p>',1);function A(v,T){J(T,!1),Z(()=>{new URLSearchParams(window.location.search).get("fw")}),I();var n=R();D("1vnx4th",m=>{var c=N();w(c,"content",k),h(m,c)});var s=e(j(n),2);M(s,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var r=e(s,2);l(r,{title:"OvisImageTransformer2DModel",local:"ovisimagetransformer2dmodel",headingTag:"h1"});var t=e(r,4);x(t,{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)`,lang:"python",wrap:!1});var a=e(t,2);l(a,{title:"OvisImageTransformer2DModel",local:"diffusers.OvisImageTransformer2DModel",headingTag:"h2"});var o=e(a,2),i=g(o);f(i,{name:"class diffusers.OvisImageTransformer2DModel",anchor:"diffusers.OvisImageTransformer2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_ovis_image.py#L384",parameters:[{name:"patch_size",val:": int = 1"},{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": int | None = 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:": tuple = (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"}]});var d=e(i,6),b=g(d);f(b,{name:"forward",anchor:"diffusers.OvisImageTransformer2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_ovis_image.py#L476",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:"joint_attention_kwargs",val:": dict[str, typing.Any] | None = 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.joint_attention_kwargs",description:`<strong>joint_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:"joint_attention_kwargs"},{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"}],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>
`}),p(2),u(d),u(o);var y=e(o,2);O(y,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/ovisimage_transformer2d.md"}),p(2),h(v,n),U()}export{A as component};

Xet Storage Details

Size:
8.53 kB
·
Xet hash:
9d87356b8fdbe2a9c266c7e26690c1eede00e79a72d59c0ad0cd546064249b07

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