Buckets:
| import"../chunks/DsnmJJEf.js";import{i as x,h as I,C as Q,H as t,a as k,D as s,E as N,s as J}from"../chunks/BtE7mKSK.js";import{p as z,o as U,s as e,f as Z,a as b,b as R,c as r,d as T,n as a,r as d}from"../chunks/jDjavuwI.js";const j='{"title":"QwenImageTransformer2DModel","local":"qwenimagetransformer2dmodel","sections":[{"title":"QwenImageTransformer2DModel","local":"diffusers.QwenImageTransformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';var W=T('<meta name="hf:doc:metadata"/>'),q=T('<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 Qwen.</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 <code>QwenTransformer2DModel</code> 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(w,v){z(v,!1),U(()=>{new URLSearchParams(window.location.search).get("fw")}),x();var i=q();I("1acw1m3",g=>{var _=W();J(_,"content",j),b(g,_)});var c=e(Z(i),2);Q(c,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var m=e(c,2);t(m,{title:"QwenImageTransformer2DModel",local:"qwenimagetransformer2dmodel",headingTag:"h1"});var l=e(m,4);k(l,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFF3ZW5JbWFnZVRyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwUXdlbkltYWdlVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJRd2VuJTJGUXdlbkltYWdlLTIwQiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> QwenImageTransformer2DModel | |
| transformer = QwenImageTransformer2DModel.from_pretrained(<span class="hljs-string">"Qwen/QwenImage-20B"</span>, subfolder=<span class="hljs-string">"transformer"</span>, torch_dtype=torch.bfloat16)`,lang:"python",wrap:!1});var f=e(l,2);t(f,{title:"QwenImageTransformer2DModel",local:"diffusers.QwenImageTransformer2DModel",headingTag:"h2"});var o=e(f,2),u=r(o);s(u,{name:"class diffusers.QwenImageTransformer2DModel",anchor:"diffusers.QwenImageTransformer2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_qwenimage.py#L745",parameters:[{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": int | None = 16"},{name:"num_layers",val:": int = 60"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 24"},{name:"joint_attention_dim",val:": int = 3584"},{name:"guidance_embeds",val:": bool = False"},{name:"axes_dims_rope",val:": tuple = (16, 56, 56)"},{name:"zero_cond_t",val:": bool = False"},{name:"use_additional_t_cond",val:": bool = False"},{name:"use_layer3d_rope",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.QwenImageTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) — | |
| Patch size to turn the input data into small patches.`,name:"patch_size"},{anchor:"diffusers.QwenImageTransformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>64</code>) — | |
| The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.QwenImageTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| The number of channels in the output. If not specified, it defaults to <code>in_channels</code>.`,name:"out_channels"},{anchor:"diffusers.QwenImageTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>60</code>) — | |
| The number of layers of dual stream DiT blocks to use.`,name:"num_layers"},{anchor:"diffusers.QwenImageTransformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) — | |
| The number of dimensions to use for each attention head.`,name:"attention_head_dim"},{anchor:"diffusers.QwenImageTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>24</code>) — | |
| The number of attention heads to use.`,name:"num_attention_heads"},{anchor:"diffusers.QwenImageTransformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>3584</code>) — | |
| 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.QwenImageTransformer2DModel.guidance_embeds",description:`<strong>guidance_embeds</strong> (<code>bool</code>, defaults to <code>False</code>) — | |
| Whether to use guidance embeddings for guidance-distilled variant of the model.`,name:"guidance_embeds"},{anchor:"diffusers.QwenImageTransformer2DModel.axes_dims_rope",description:`<strong>axes_dims_rope</strong> (<code>tuple[int]</code>, defaults to <code>(16, 56, 56)</code>) — | |
| The dimensions to use for the rotary positional embeddings.`,name:"axes_dims_rope"}]});var p=e(u,4),M=r(p);s(M,{name:"forward",anchor:"diffusers.QwenImageTransformer2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/models/transformers/transformer_qwenimage.py#L846",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"encoder_hidden_states_mask",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"img_shapes",val:": list[tuple[int, int, int]] | None = None"},{name:"guidance",val:": Tensor = None"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"controlnet_block_samples",val:" = None"},{name:"additional_t_cond",val:" = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.QwenImageTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_sequence_length, in_channels)</code>) — | |
| Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.QwenImageTransformer2DModel.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>) — | |
| Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.encoder_hidden_states_mask",description:`<strong>encoder_hidden_states_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_sequence_length)</code>, <em>optional</em>) — | |
| Mask for the encoder hidden states. Expected to have 1.0 for valid tokens and 0.0 for padding tokens. | |
| Used in the attention processor to prevent attending to padding tokens. The mask can have any pattern | |
| (not just contiguous valid tokens followed by padding) since it’s applied element-wise in attention.`,name:"encoder_hidden_states_mask"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) — | |
| Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.img_shapes",description:`<strong>img_shapes</strong> (<code>list[tuple[int, int, int]]</code>, <em>optional</em>) — | |
| Image shapes for RoPE computation.`,name:"img_shapes"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.guidance",description:`<strong>guidance</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Guidance tensor for conditional generation.`,name:"guidance"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) — | |
| 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.QwenImageTransformer2DModel.forward.controlnet_block_samples",description:`<strong>controlnet_block_samples</strong> (<em>optional</em>) — | |
| ControlNet block samples to add to the transformer blocks.`,name:"controlnet_block_samples"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.additional_t_cond",description:`<strong>additional_t_cond</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Additional timestep conditioning added to the timestep embedding.`,name:"additional_t_cond"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| 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> | |
| `}),a(2),d(p),d(o);var h=e(o,2);t(h,{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"});var n=e(h,2),D=r(n);s(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) — | |
| 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"}]}),a(2),d(n);var y=e(n,2);N(y,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/qwenimage_transformer2d.md"}),a(2),b(w,i),R()}export{O as component}; | |
Xet Storage Details
- Size:
- 11.3 kB
- Xet hash:
- 87d7787a29cda735f5cc170c713be1e32b53ca4ebf4a56cc380cbef76f699c22
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.