import{s as B,n as Q,o as A}from"../chunks/scheduler.8c3d61f6.js";import{S as K,i as ee,g as d,s,r as y,A as ne,h as m,f as t,c as i,j as S,u as w,x as C,k as U,y as q,a as o,v as M,d as G,t as x,w as $}from"../chunks/index.da70eac4.js";import{D as te}from"../chunks/Docstring.dcbc19b1.js";import{C as oe}from"../chunks/CodeBlock.a9c4becf.js";import{H as F,E as se}from"../chunks/getInferenceSnippets.86beaec3.js";function ie(H){let a,O,T,D,l,k,c,N='A Transformer model that accepts multimodal instructions to generate images for <a href="https://github.com/VectorSpaceLab/OmniGen/" rel="nofollow">OmniGen</a>.',z,f,V="The abstract from the paper is:",J,p,X='<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>',L,u,R,h,W,r,_,I,b,Y='The Transformer model introduced in OmniGen (<a href="https://huggingface.co/papers/2409.11340" rel="nofollow">https://huggingface.co/papers/2409.11340</a>).',E,g,P,v,Z;return l=new F({props:{title:"OmniGenTransformer2DModel",local:"omnigentransformer2dmodel",headingTag:"h1"}}),u=new oe({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}}),h=new F({props:{title:"OmniGenTransformer2DModel",local:"diffusers.OmniGenTransformer2DModel",headingTag:"h2"}}),_=new te({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"}}),g=new se({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/omnigen_transformer.md"}}),{c(){a=d("meta"),O=s(),T=d("p"),D=s(),y(l.$$.fragment),k=s(),c=d("p"),c.innerHTML=N,z=s(),f=d("p"),f.textContent=V,J=s(),p=d("p"),p.innerHTML=X,L=s(),y(u.$$.fragment),R=s(),y(h.$$.fragment),W=s(),r=d("div"),y(_.$$.fragment),I=s(),b=d("p"),b.innerHTML=Y,E=s(),y(g.$$.fragment),P=s(),v=d("p"),this.h()},l(e){const n=ne("svelte-u9bgzb",document.head);a=m(n,"META",{name:!0,content:!0}),n.forEach(t),O=i(e),T=m(e,"P",{}),S(T).forEach(t),D=i(e),w(l.$$.fragment,e),k=i(e),c=m(e,"P",{"data-svelte-h":!0}),C(c)!=="svelte-1swjw0u"&&(c.innerHTML=N),z=i(e),f=m(e,"P",{"data-svelte-h":!0}),C(f)!=="svelte-1cwsb16"&&(f.textContent=V),J=i(e),p=m(e,"P",{"data-svelte-h":!0}),C(p)!=="svelte-o0h1ee"&&(p.innerHTML=X),L=i(e),w(u.$$.fragment,e),R=i(e),w(h.$$.fragment,e),W=i(e),r=m(e,"DIV",{class:!0});var j=S(r);w(_.$$.fragment,j),I=i(j),b=m(j,"P",{"data-svelte-h":!0}),C(b)!=="svelte-9nr9pm"&&(b.innerHTML=Y),j.forEach(t),E=i(e),w(g.$$.fragment,e),P=i(e),v=m(e,"P",{}),S(v).forEach(t),this.h()},h(){U(a,"name","hf:doc:metadata"),U(a,"content",ae),U(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){q(document.head,a),o(e,O,n),o(e,T,n),o(e,D,n),M(l,e,n),o(e,k,n),o(e,c,n),o(e,z,n),o(e,f,n),o(e,J,n),o(e,p,n),o(e,L,n),M(u,e,n),o(e,R,n),M(h,e,n),o(e,W,n),o(e,r,n),M(_,r,null),q(r,I),q(r,b),o(e,E,n),M(g,e,n),o(e,P,n),o(e,v,n),Z=!0},p:Q,i(e){Z||(G(l.$$.fragment,e),G(u.$$.fragment,e),G(h.$$.fragment,e),G(_.$$.fragment,e),G(g.$$.fragment,e),Z=!0)},o(e){x(l.$$.fragment,e),x(u.$$.fragment,e),x(h.$$.fragment,e),x(_.$$.fragment,e),x(g.$$.fragment,e),Z=!1},d(e){e&&(t(O),t(T),t(D),t(k),t(c),t(z),t(f),t(J),t(p),t(L),t(R),t(W),t(r),t(E),t(P),t(v)),t(a),$(l,e),$(u,e),$(h,e),$(_),$(g,e)}}}const ae='{"title":"OmniGenTransformer2DModel","local":"omnigentransformer2dmodel","sections":[{"title":"OmniGenTransformer2DModel","local":"diffusers.OmniGenTransformer2DModel","sections":[],"depth":2}],"depth":1}';function re(H){return A(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pe extends K{constructor(a){super(),ee(this,a,re,ie,B,{})}}export{pe as component};
