import{s as A,n as K,o as ee}from"../chunks/scheduler.53228c21.js";import{S as ne,i as te,e as m,s as i,c as v,h as oe,a as d,d as t,b as s,f as q,g as y,j as I,k as H,l as N,m as o,n as M,t as w,o as $,p as x}from"../chunks/index.100fac89.js";import{C as ie}from"../chunks/CopyLLMTxtMenu.999d3d86.js";import{D as se}from"../chunks/Docstring.46d0934e.js";import{C as ae}from"../chunks/CodeBlock.d30a6509.js";import{H as Q,E as re}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d27ae4df.js";function me(V){let a,D,G,k,l,z,f,L,c,X='A Transformer model that accepts multimodal instructions to generate images for <a href="https://github.com/VectorSpaceLab/OmniGen/" rel="nofollow">OmniGen</a>.',J,p,Y="The abstract from the paper is:",R,u,F='<em>The emergence of Large Language Models (LLMs) has unified language  generation tasks and revolutionized human-machine interaction.  However, in the realm of image generation, a unified model capable of handling various tasks within a single framework remains largely unexplored. In this work, we introduce OmniGen, a new diffusion model for unified image generation. OmniGen is characterized by the following features: 1) Unification: OmniGen not only demonstrates text-to-image generation capabilities but also inherently supports various downstream tasks, such as image editing, subject-driven generation, and visual conditional generation. 2) Simplicity: The architecture of OmniGen is highly simplified, eliminating the need for additional plugins. Moreover, compared to existing diffusion models, it is more user-friendly and can complete complex tasks end-to-end through instructions without the need for extra intermediate steps, greatly simplifying the image generation workflow. 3) Knowledge Transfer: Benefit from learning in a unified format, OmniGen effectively transfers knowledge across different tasks, manages unseen tasks and domains, and exhibits novel capabilities. We also explore the model’s reasoning capabilities and potential applications of the chain-of-thought mechanism.  This work represents the first attempt at a general-purpose image generation model,  and we will release our resources at <a href="https://github.com/VectorSpaceLab/OmniGen" rel="nofollow">https://github.com/VectorSpaceLab/OmniGen</a> to foster future advancements.</em>',W,h,C,_,E,r,g,U,T,B='The Transformer model introduced in OmniGen (<a href="https://huggingface.co/papers/2409.11340" rel="nofollow">https://huggingface.co/papers/2409.11340</a>).',P,b,S,O,Z;return l=new ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new Q({props:{title:"OmniGenTransformer2DModel",local:"omnigentransformer2dmodel",headingTag:"h1"}}),h=new ae({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwT21uaUdlblRyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwT21uaUdlblRyYW5zZm9ybWVyMkRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyU2hpdGFvJTJGT21uaUdlbi12MS1kaWZmdXNlcnMlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> OmniGenTransformer2DModel

transformer = OmniGenTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;Shitao/OmniGen-v1-diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),_=new Q({props:{title:"OmniGenTransformer2DModel",local:"diffusers.OmniGenTransformer2DModel",headingTag:"h2"}}),g=new se({props:{name:"class diffusers.OmniGenTransformer2DModel",anchor:"diffusers.OmniGenTransformer2DModel",parameters:[{name:"in_channels",val:": int = 4"},{name:"patch_size",val:": int = 2"},{name:"hidden_size",val:": int = 3072"},{name:"rms_norm_eps",val:": float = 1e-05"},{name:"num_attention_heads",val:": int = 32"},{name:"num_key_value_heads",val:": int = 32"},{name:"intermediate_size",val:": int = 8192"},{name:"num_layers",val:": int = 32"},{name:"pad_token_id",val:": int = 32000"},{name:"vocab_size",val:": int = 32064"},{name:"max_position_embeddings",val:": int = 131072"},{name:"original_max_position_embeddings",val:": int = 4096"},{name:"rope_base",val:": int = 10000"},{name:"rope_scaling",val:": typing.Dict = None"},{name:"pos_embed_max_size",val:": int = 192"},{name:"time_step_dim",val:": int = 256"},{name:"flip_sin_to_cos",val:": bool = True"},{name:"downscale_freq_shift",val:": int = 0"},{name:"timestep_activation_fn",val:": str = 'silu'"}],parametersDescription:[{anchor:"diffusers.OmniGenTransformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.OmniGenTransformer2DModel.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.OmniGenTransformer2DModel.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, defaults to <code>3072</code>) &#x2014;
The dimensionality of the hidden layers in the model.`,name:"hidden_size"},{anchor:"diffusers.OmniGenTransformer2DModel.rms_norm_eps",description:`<strong>rms_norm_eps</strong> (<code>float</code>, defaults to <code>1e-5</code>) &#x2014;
Eps for RMSNorm layer.`,name:"rms_norm_eps"},{anchor:"diffusers.OmniGenTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.OmniGenTransformer2DModel.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The number of heads to use for keys and values in multi-head attention.`,name:"num_key_value_heads"},{anchor:"diffusers.OmniGenTransformer2DModel.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, defaults to <code>8192</code>) &#x2014;
Dimension of the hidden layer in FeedForward layers.`,name:"intermediate_size"},{anchor:"diffusers.OmniGenTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, default to <code>32</code>) &#x2014;
The number of layers of transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.OmniGenTransformer2DModel.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, default to <code>32000</code>) &#x2014;
The id of the padding token.`,name:"pad_token_id"},{anchor:"diffusers.OmniGenTransformer2DModel.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, default to <code>32064</code>) &#x2014;
The size of the vocabulary of the embedding vocabulary.`,name:"vocab_size"},{anchor:"diffusers.OmniGenTransformer2DModel.rope_base",description:`<strong>rope_base</strong> (<code>int</code>, default to <code>10000</code>) &#x2014;
The default theta value to use when creating RoPE.`,name:"rope_base"},{anchor:"diffusers.OmniGenTransformer2DModel.rope_scaling",description:`<strong>rope_scaling</strong> (<code>Dict</code>, optional) &#x2014;
The scaling factors for the RoPE. Must contain <code>short_factor</code> and <code>long_factor</code>.`,name:"rope_scaling"},{anchor:"diffusers.OmniGenTransformer2DModel.pos_embed_max_size",description:`<strong>pos_embed_max_size</strong> (<code>int</code>, default to <code>192</code>) &#x2014;
The maximum size of the positional embeddings.`,name:"pos_embed_max_size"},{anchor:"diffusers.OmniGenTransformer2DModel.time_step_dim",description:`<strong>time_step_dim</strong> (<code>int</code>, default to <code>256</code>) &#x2014;
Output dimension of timestep embeddings.`,name:"time_step_dim"},{anchor:"diffusers.OmniGenTransformer2DModel.flip_sin_to_cos",description:`<strong>flip_sin_to_cos</strong> (<code>bool</code>, default to <code>True</code>) &#x2014;
Whether to flip the sin and cos in the positional embeddings when preparing timestep embeddings.`,name:"flip_sin_to_cos"},{anchor:"diffusers.OmniGenTransformer2DModel.downscale_freq_shift",description:`<strong>downscale_freq_shift</strong> (<code>int</code>, default to <code>0</code>) &#x2014;
The frequency shift to use when downscaling the timestep embeddings.`,name:"downscale_freq_shift"},{anchor:"diffusers.OmniGenTransformer2DModel.timestep_activation_fn",description:`<strong>timestep_activation_fn</strong> (<code>str</code>, default to <code>silu</code>) &#x2014;
The activation function to use for the timestep embeddings.`,name:"timestep_activation_fn"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_omnigen.py#L284"}}),b=new re({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/omnigen_transformer.md"}}),{c(){a=m("meta"),D=i(),G=m("p"),k=i(),v(l.$$.fragment),z=i(),v(f.$$.fragment),L=i(),c=m("p"),c.innerHTML=X,J=i(),p=m("p"),p.textContent=Y,R=i(),u=m("p"),u.innerHTML=F,W=i(),v(h.$$.fragment),C=i(),v(_.$$.fragment),E=i(),r=m("div"),v(g.$$.fragment),U=i(),T=m("p"),T.innerHTML=B,P=i(),v(b.$$.fragment),S=i(),O=m("p"),this.h()},l(e){const n=oe("svelte-u9bgzb",document.head);a=d(n,"META",{name:!0,content:!0}),n.forEach(t),D=s(e),G=d(e,"P",{}),q(G).forEach(t),k=s(e),y(l.$$.fragment,e),z=s(e),y(f.$$.fragment,e),L=s(e),c=d(e,"P",{"data-svelte-h":!0}),I(c)!=="svelte-1swjw0u"&&(c.innerHTML=X),J=s(e),p=d(e,"P",{"data-svelte-h":!0}),I(p)!=="svelte-1cwsb16"&&(p.textContent=Y),R=s(e),u=d(e,"P",{"data-svelte-h":!0}),I(u)!=="svelte-o0h1ee"&&(u.innerHTML=F),W=s(e),y(h.$$.fragment,e),C=s(e),y(_.$$.fragment,e),E=s(e),r=d(e,"DIV",{class:!0});var j=q(r);y(g.$$.fragment,j),U=s(j),T=d(j,"P",{"data-svelte-h":!0}),I(T)!=="svelte-9nr9pm"&&(T.innerHTML=B),j.forEach(t),P=s(e),y(b.$$.fragment,e),S=s(e),O=d(e,"P",{}),q(O).forEach(t),this.h()},h(){H(a,"name","hf:doc:metadata"),H(a,"content",de),H(r,"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,n){N(document.head,a),o(e,D,n),o(e,G,n),o(e,k,n),M(l,e,n),o(e,z,n),M(f,e,n),o(e,L,n),o(e,c,n),o(e,J,n),o(e,p,n),o(e,R,n),o(e,u,n),o(e,W,n),M(h,e,n),o(e,C,n),M(_,e,n),o(e,E,n),o(e,r,n),M(g,r,null),N(r,U),N(r,T),o(e,P,n),M(b,e,n),o(e,S,n),o(e,O,n),Z=!0},p:K,i(e){Z||(w(l.$$.fragment,e),w(f.$$.fragment,e),w(h.$$.fragment,e),w(_.$$.fragment,e),w(g.$$.fragment,e),w(b.$$.fragment,e),Z=!0)},o(e){$(l.$$.fragment,e),$(f.$$.fragment,e),$(h.$$.fragment,e),$(_.$$.fragment,e),$(g.$$.fragment,e),$(b.$$.fragment,e),Z=!1},d(e){e&&(t(D),t(G),t(k),t(z),t(L),t(c),t(J),t(p),t(R),t(u),t(W),t(C),t(E),t(r),t(P),t(S),t(O)),t(a),x(l,e),x(f,e),x(h,e),x(_,e),x(g),x(b,e)}}}const de='{"title":"OmniGenTransformer2DModel","local":"omnigentransformer2dmodel","sections":[{"title":"OmniGenTransformer2DModel","local":"diffusers.OmniGenTransformer2DModel","sections":[],"depth":2}],"depth":1}';function le(V){return ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ge extends ne{constructor(a){super(),te(this,a,le,me,A,{})}}export{ge as component};
