import{S as hs,i as gs,s as _s,e as n,k as d,w as u,t as s,M as bs,c as a,d as i,m,a as o,x as h,h as r,b as f,G as t,g as p,y as g,q as _,o as b,B as w,v as ws}from"../../../chunks/vendor-hf-doc-builder.js";import{T as ys}from"../../../chunks/Tip-hf-doc-builder.js";import{D as W}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Le}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as S}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function vs(zt){let v,Q,x,J,P;return{c(){v=n("p"),Q=s("There is currently an issue on PyTorch 1.X where the output images are all black or the pixel values become "),x=n("code"),J=s("NaNs"),P=s(". This issue can be mitigated by switching to PyTorch 2.X.")},l(M){v=a(M,"P",{});var E=o(v);Q=r(E,"There is currently an issue on PyTorch 1.X where the output images are all black or the pixel values become "),x=a(E,"CODE",{});var Y=o(x);J=r(Y,"NaNs"),Y.forEach(i),P=r(E,". This issue can be mitigated by switching to PyTorch 2.X."),E.forEach(i)},m(M,E){p(M,v,E),t(v,Q),t(v,x),t(x,J),t(v,P)},d(M){M&&i(v)}}}function Us(zt){let v,Q,x,J,P,M,E,Y,en,Lt,z,tn,ge,nn,an,At,L,on,_e,sn,rn,Ht,Ae,dt,ln,qt,j,pn,be,dn,mn,we,fn,cn,Ot,A,Kt,H,un,ye,hn,gn,ei,X,q,mt,ve,_n,ft,bn,ti,He,wn,ii,D,O,ct,Ue,yn,ut,vn,ni,K,Un,qe,xn,Tn,ai,xe,oi,Oe,Mn,si,ee,Zn,Ke,Jn,In,ri,Te,li,te,En,et,jn,$n,pi,tt,Gn,di,Me,mi,k,ie,ht,Ze,Wn,gt,Pn,fi,it,Xn,ci,Je,ui,U,Dn,_t,kn,Vn,bt,Bn,Nn,wt,Rn,Fn,yt,Cn,Sn,nt,Qn,Yn,hi,V,ne,vt,Ie,zn,Ut,Ln,gi,at,An,_i,Ee,bi,T,Hn,xt,qn,On,Tt,Kn,ea,Mt,ta,ia,ot,na,aa,wi,B,ae,Zt,je,oa,Jt,sa,yi,st,ra,vi,$e,Ui,N,oe,It,Ge,la,Et,pa,xi,rt,da,Ti,We,Mi,R,se,jt,Pe,ma,$t,fa,Zi,c,Xe,ca,Gt,ua,ha,De,ga,lt,_a,ba,wa,re,ke,ya,Wt,va,Ua,le,Ve,xa,Z,Ta,Pt,Ma,Za,Xt,Ja,Ia,Dt,Ea,ja,kt,$a,Ga,Wa,pe,Be,Pa,Vt,Xa,Da,de,Ne,ka,Bt,Va,Ba,me,Re,Na,Nt,Ra,Fa,fe,Fe,Ca,Rt,Sa,Qa,ce,Ce,Ya,Ft,za,La,ue,Se,Aa,Ct,Ha,Ji,F,he,St,Qe,qa,Qt,Oa,Ii,C,Ye,Ka,Yt,eo,Ei;return M=new S({}),A=new ys({props:{warning:!0,$$slots:{default:[vs]},$$scope:{ctx:zt}}}),ve=new S({}),Ue=new S({}),xe=new Le({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwVW5pRGlmZnVzZXJQaXBlbGluZSUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMEFtb2RlbF9pZF9vcl9wYXRoJTIwJTNEJTIwJTIydGh1LW1sJTJGdW5pZGlmZnVzZXItdjElMjIlMEFwaXBlJTIwJTNEJTIwVW5pRGlmZnVzZXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWRfb3JfcGF0aCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlLnRvKGRldmljZSklMEElMEElMjMlMjBVbmNvbmRpdGlvbmFsJTIwaW1hZ2UlMjBhbmQlMjB0ZXh0JTIwZ2VuZXJhdGlvbi4lMjBUaGUlMjBnZW5lcmF0aW9uJTIwdGFzayUyMGlzJTIwYXV0b21hdGljYWxseSUyMGluZmVycmVkLiUwQXNhbXBsZSUyMCUzRCUyMHBpcGUobnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q4LjApJTBBaW1hZ2UlMjAlM0QlMjBzYW1wbGUuaW1hZ2VzJTVCMCU1RCUwQXRleHQlMjAlM0QlMjBzYW1wbGUudGV4dCU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMnVuaWRpZmZ1c2VyX2pvaW50X3NhbXBsZV9pbWFnZS5wbmclMjIpJTBBcHJpbnQodGV4dCk=",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UniDiffuserPipeline

device = <span class="hljs-string">&quot;cuda&quot;</span>
model_id_or_path = <span class="hljs-string">&quot;thu-ml/unidiffuser-v1&quot;</span>
pipe = UniDiffuserPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe.to(device)

<span class="hljs-comment"># Unconditional image and text generation. The generation task is automatically inferred.</span>
sample = pipe(num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
image = sample.images[<span class="hljs-number">0</span>]
text = sample.text[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;unidiffuser_joint_sample_image.png&quot;</span>)
<span class="hljs-built_in">print</span>(text)`}}),Te=new Le({props:{code:"JTIzJTIwRXF1aXZhbGVudCUyMHRvJTIwdGhlJTIwYWJvdmUuJTBBcGlwZS5zZXRfam9pbnRfbW9kZSgpJTBBc2FtcGxlJTIwJTNEJTIwcGlwZShudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjAlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDguMCk=",highlighted:`<span class="hljs-comment"># Equivalent to the above.</span>
pipe.set_joint_mode()
sample = pipe(num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)`}}),Me=new Le({props:{code:"JTIzJTIwVW5saWtlJTIwb3RoZXIlMjBnZW5lcmF0aW9uJTIwdGFza3MlMkMlMjBpbWFnZS1vbmx5JTIwYW5kJTIwdGV4dC1vbmx5JTIwZ2VuZXJhdGlvbiUyMGRvbid0JTIwdXNlJTIwY2xhc3NpZmllci1mcmVlJTIwZ3VpZGFuY2UlMEElMjMlMjBJbWFnZS1vbmx5JTIwZ2VuZXJhdGlvbiUwQXBpcGUuc2V0X2ltYWdlX21vZGUoKSUwQXNhbXBsZV9pbWFnZSUyMCUzRCUyMHBpcGUobnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwKS5pbWFnZXMlNUIwJTVEJTBBJTIzJTIwVGV4dC1vbmx5JTIwZ2VuZXJhdGlvbiUwQXBpcGUuc2V0X3RleHRfbW9kZSgpJTBBc2FtcGxlX3RleHQlMjAlM0QlMjBwaXBlKG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCkudGV4dCU1QjAlNUQ=",highlighted:`<span class="hljs-comment"># Unlike other generation tasks, image-only and text-only generation don&#x27;t use classifier-free guidance</span>
<span class="hljs-comment"># Image-only generation</span>
pipe.set_image_mode()
sample_image = pipe(num_inference_steps=<span class="hljs-number">20</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-comment"># Text-only generation</span>
pipe.set_text_mode()
sample_text = pipe(num_inference_steps=<span class="hljs-number">20</span>).text[<span class="hljs-number">0</span>]`}}),Ze=new S({}),Je=new Le({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwVW5pRGlmZnVzZXJQaXBlbGluZSUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMEFtb2RlbF9pZF9vcl9wYXRoJTIwJTNEJTIwJTIydGh1LW1sJTJGdW5pZGlmZnVzZXItdjElMjIlMEFwaXBlJTIwJTNEJTIwVW5pRGlmZnVzZXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWRfb3JfcGF0aCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlLnRvKGRldmljZSklMEElMEElMjMlMjBUZXh0LXRvLWltYWdlJTIwZ2VuZXJhdGlvbiUwQXByb21wdCUyMCUzRCUyMCUyMmFuJTIwZWxlcGhhbnQlMjB1bmRlciUyMHRoZSUyMHNlYSUyMiUwQSUwQXNhbXBsZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q4LjApJTBBdDJpX2ltYWdlJTIwJTNEJTIwc2FtcGxlLmltYWdlcyU1QjAlNUQlMEF0MmlfaW1hZ2Uuc2F2ZSglMjJ1bmlkaWZmdXNlcl90ZXh0MmltZ19zYW1wbGVfaW1hZ2UucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UniDiffuserPipeline

device = <span class="hljs-string">&quot;cuda&quot;</span>
model_id_or_path = <span class="hljs-string">&quot;thu-ml/unidiffuser-v1&quot;</span>
pipe = UniDiffuserPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe.to(device)

<span class="hljs-comment"># Text-to-image generation</span>
prompt = <span class="hljs-string">&quot;an elephant under the sea&quot;</span>

sample = pipe(prompt=prompt, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
t2i_image = sample.images[<span class="hljs-number">0</span>]
t2i_image.save(<span class="hljs-string">&quot;unidiffuser_text2img_sample_image.png&quot;</span>)`}}),Ie=new S({}),Ee=new Le({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwVW5pRGlmZnVzZXJQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQW1vZGVsX2lkX29yX3BhdGglMjAlM0QlMjAlMjJ0aHUtbWwlMkZ1bmlkaWZmdXNlci12MSUyMiUwQXBpcGUlMjAlM0QlMjBVbmlEaWZmdXNlclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZF9vcl9wYXRoJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUudG8oZGV2aWNlKSUwQSUwQSUyMyUyMEltYWdlLXRvLXRleHQlMjBnZW5lcmF0aW9uJTBBaW1hZ2VfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnVuaWRpZmZ1c2VyJTJGdW5pZGlmZnVzZXJfZXhhbXBsZV9pbWFnZS5qcGclMjIlMEFpbml0X2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZShpbWFnZV91cmwpLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMEElMEFzYW1wbGUlMjAlM0QlMjBwaXBlKGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEOC4wKSUwQWkydF90ZXh0JTIwJTNEJTIwc2FtcGxlLnRleHQlNUIwJTVEJTBBcHJpbnQoaTJ0X3RleHQp",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UniDiffuserPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

device = <span class="hljs-string">&quot;cuda&quot;</span>
model_id_or_path = <span class="hljs-string">&quot;thu-ml/unidiffuser-v1&quot;</span>
pipe = UniDiffuserPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe.to(device)

<span class="hljs-comment"># Image-to-text generation</span>
image_url = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/unidiffuser/unidiffuser_example_image.jpg&quot;</span>
init_image = load_image(image_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

sample = pipe(image=init_image, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
i2t_text = sample.text[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(i2t_text)`}}),je=new S({}),$e=new Le({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwVW5pRGlmZnVzZXJQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQW1vZGVsX2lkX29yX3BhdGglMjAlM0QlMjAlMjJ0aHUtbWwlMkZ1bmlkaWZmdXNlci12MSUyMiUwQXBpcGUlMjAlM0QlMjBVbmlEaWZmdXNlclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZF9vcl9wYXRoJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUudG8oZGV2aWNlKSUwQSUwQSUyMyUyMEltYWdlJTIwdmFyaWF0aW9uJTIwY2FuJTIwYmUlMjBwZXJmb3JtZWQlMjB3aXRoJTIwYSUyMGltYWdlLXRvLXRleHQlMjBnZW5lcmF0aW9uJTIwZm9sbG93ZWQlMjBieSUyMGElMjB0ZXh0LXRvLWltYWdlJTIwZ2VuZXJhdGlvbiUzQSUwQSUyMyUyMDEuJTIwSW1hZ2UtdG8tdGV4dCUyMGdlbmVyYXRpb24lMEFpbWFnZV91cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZoZi1pbnRlcm5hbC10ZXN0aW5nJTJGZGlmZnVzZXJzLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGdW5pZGlmZnVzZXIlMkZ1bmlkaWZmdXNlcl9leGFtcGxlX2ltYWdlLmpwZyUyMiUwQWluaXRfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKGltYWdlX3VybCkucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUwQSUwQXNhbXBsZSUyMCUzRCUyMHBpcGUoaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q4LjApJTBBaTJ0X3RleHQlMjAlM0QlMjBzYW1wbGUudGV4dCU1QjAlNUQlMEFwcmludChpMnRfdGV4dCklMEElMEElMjMlMjAyLiUyMFRleHQtdG8taW1hZ2UlMjBnZW5lcmF0aW9uJTBBc2FtcGxlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0RpMnRfdGV4dCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEOC4wKSUwQWZpbmFsX2ltYWdlJTIwJTNEJTIwc2FtcGxlLmltYWdlcyU1QjAlNUQlMEFmaW5hbF9pbWFnZS5zYXZlKCUyMnVuaWRpZmZ1c2VyX2ltYWdlX3ZhcmlhdGlvbl9zYW1wbGUucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UniDiffuserPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

device = <span class="hljs-string">&quot;cuda&quot;</span>
model_id_or_path = <span class="hljs-string">&quot;thu-ml/unidiffuser-v1&quot;</span>
pipe = UniDiffuserPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe.to(device)

<span class="hljs-comment"># Image variation can be performed with a image-to-text generation followed by a text-to-image generation:</span>
<span class="hljs-comment"># 1. Image-to-text generation</span>
image_url = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/unidiffuser/unidiffuser_example_image.jpg&quot;</span>
init_image = load_image(image_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

sample = pipe(image=init_image, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
i2t_text = sample.text[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(i2t_text)

<span class="hljs-comment"># 2. Text-to-image generation</span>
sample = pipe(prompt=i2t_text, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
final_image = sample.images[<span class="hljs-number">0</span>]
final_image.save(<span class="hljs-string">&quot;unidiffuser_image_variation_sample.png&quot;</span>)`}}),Ge=new S({}),We=new Le({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwVW5pRGlmZnVzZXJQaXBlbGluZSUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMEFtb2RlbF9pZF9vcl9wYXRoJTIwJTNEJTIwJTIydGh1LW1sJTJGdW5pZGlmZnVzZXItdjElMjIlMEFwaXBlJTIwJTNEJTIwVW5pRGlmZnVzZXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWRfb3JfcGF0aCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlLnRvKGRldmljZSklMEElMEElMjMlMjBUZXh0JTIwdmFyaWF0aW9uJTIwY2FuJTIwYmUlMjBwZXJmb3JtZWQlMjB3aXRoJTIwYSUyMHRleHQtdG8taW1hZ2UlMjBnZW5lcmF0aW9uJTIwZm9sbG93ZWQlMjBieSUyMGElMjBpbWFnZS10by10ZXh0JTIwZ2VuZXJhdGlvbiUzQSUwQSUyMyUyMDEuJTIwVGV4dC10by1pbWFnZSUyMGdlbmVyYXRpb24lMEFwcm9tcHQlMjAlM0QlMjAlMjJhbiUyMGVsZXBoYW50JTIwdW5kZXIlMjB0aGUlMjBzZWElMjIlMEElMEFzYW1wbGUlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEOC4wKSUwQXQyaV9pbWFnZSUyMCUzRCUyMHNhbXBsZS5pbWFnZXMlNUIwJTVEJTBBdDJpX2ltYWdlLnNhdmUoJTIydW5pZGlmZnVzZXJfdGV4dDJpbWdfc2FtcGxlX2ltYWdlLnBuZyUyMiklMEElMEElMjMlMjAyLiUyMEltYWdlLXRvLXRleHQlMjBnZW5lcmF0aW9uJTBBc2FtcGxlJTIwJTNEJTIwcGlwZShpbWFnZSUzRHQyaV9pbWFnZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEOC4wKSUwQWZpbmFsX3Byb21wdCUyMCUzRCUyMHNhbXBsZS50ZXh0JTVCMCU1RCUwQXByaW50KGZpbmFsX3Byb21wdCk=",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UniDiffuserPipeline

device = <span class="hljs-string">&quot;cuda&quot;</span>
model_id_or_path = <span class="hljs-string">&quot;thu-ml/unidiffuser-v1&quot;</span>
pipe = UniDiffuserPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe.to(device)

<span class="hljs-comment"># Text variation can be performed with a text-to-image generation followed by a image-to-text generation:</span>
<span class="hljs-comment"># 1. Text-to-image generation</span>
prompt = <span class="hljs-string">&quot;an elephant under the sea&quot;</span>

sample = pipe(prompt=prompt, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
t2i_image = sample.images[<span class="hljs-number">0</span>]
t2i_image.save(<span class="hljs-string">&quot;unidiffuser_text2img_sample_image.png&quot;</span>)

<span class="hljs-comment"># 2. Image-to-text generation</span>
sample = pipe(image=t2i_image, num_inference_steps=<span class="hljs-number">20</span>, guidance_scale=<span class="hljs-number">8.0</span>)
final_prompt = sample.text[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(final_prompt)`}}),Pe=new S({}),Xe=new W({props:{name:"class diffusers.UniDiffuserPipeline",anchor:"diffusers.UniDiffuserPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"image_encoder",val:": CLIPVisionModelWithProjection"},{name:"image_processor",val:": CLIPImageProcessor"},{name:"clip_tokenizer",val:": CLIPTokenizer"},{name:"text_decoder",val:": UniDiffuserTextDecoder"},{name:"text_tokenizer",val:": GPT2Tokenizer"},{name:"unet",val:": UniDiffuserModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"}],parametersDescription:[{anchor:"diffusers.UniDiffuserPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations. This
is part of the UniDiffuser image representation along with the CLIP vision encoding.`,name:"vae"},{anchor:"diffusers.UniDiffuserPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.UniDiffuserPipeline.image_encoder",description:`<strong>image_encoder</strong> (<code>CLIPVisionModel</code>) &#x2014;
A <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPVisionModel" rel="nofollow">CLIPVisionModel</a> to encode images as part of its image representation along with the VAE
latent representation.`,name:"image_encoder"},{anchor:"diffusers.UniDiffuserPipeline.image_processor",description:`<strong>image_processor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor" rel="nofollow">CLIPImageProcessor</a> to preprocess an image before CLIP encoding it with <code>image_encoder</code>.`,name:"image_processor"},{anchor:"diffusers.UniDiffuserPipeline.clip_tokenizer",description:`<strong>clip_tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
A <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a> to tokenize the prompt before encoding it with <code>text_encoder</code>.`,name:"clip_tokenizer"},{anchor:"diffusers.UniDiffuserPipeline.text_decoder",description:`<strong>text_decoder</strong> (<code>UniDiffuserTextDecoder</code>) &#x2014;
Frozen text decoder. This is a GPT-style model which is used to generate text from the UniDiffuser
embedding.`,name:"text_decoder"},{anchor:"diffusers.UniDiffuserPipeline.text_tokenizer",description:`<strong>text_tokenizer</strong> (<code>GPT2Tokenizer</code>) &#x2014;
A <a href="https://huggingface.co/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Tokenizer" rel="nofollow">GPT2Tokenizer</a> to decode text for text generation; used along with the <code>text_decoder</code>.`,name:"text_tokenizer"},{anchor:"diffusers.UniDiffuserPipeline.unet",description:`<strong>unet</strong> (<code>UniDiffuserModel</code>) &#x2014;
A <a href="https://github.com/baofff/U-ViT" rel="nofollow">U-ViT</a> model with UNNet-style skip connections between transformer
layers to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.UniDiffuserPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image and/or text latents. The
original UniDiffuser paper uses the <a href="/docs/diffusers/main/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler">DPMSolverMultistepScheduler</a> scheduler.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L82"}}),ke=new W({props:{name:"__call__",anchor:"diffusers.UniDiffuserPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image, NoneType] = None"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"data_type",val:": typing.Optional[int] = 1"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 8.0"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"num_prompts_per_image",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"vae_latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"clip_latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"}],parametersDescription:[{anchor:"diffusers.UniDiffuserPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide image generation. If not defined, you need to pass <code>prompt_embeds</code>.
Required for text-conditioned image generation (<code>text2img</code>) mode.`,name:"prompt"},{anchor:"diffusers.UniDiffuserPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code>, <em>optional</em>) &#x2014;
<code>Image</code> or tensor representing an image batch. Required for image-conditioned text generation
(<code>img2text</code>) mode.`,name:"image"},{anchor:"diffusers.UniDiffuserPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.UniDiffuserPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.UniDiffuserPipeline.__call__.data_type",description:`<strong>data_type</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The data type (either 0 or 1). Only used if you are loading a checkpoint which supports a data type
embedding; this is added for compatibility with the
<a href="https://huggingface.co/thu-ml/unidiffuser-v1" rel="nofollow">UniDiffuser-v1</a> checkpoint.`,name:"data_type"},{anchor:"diffusers.UniDiffuserPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.UniDiffuserPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 8.0) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.UniDiffuserPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>). Used in
text-conditioned image generation (<code>text2img</code>) mode.`,name:"negative_prompt"},{anchor:"diffusers.UniDiffuserPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt. Used in <code>text2img</code> (text-conditioned image generation) and
<code>img</code> mode. If the mode is joint and both <code>num_images_per_prompt</code> and <code>num_prompts_per_image</code> are
supplied, <code>min(num_images_per_prompt, num_prompts_per_image)</code> samples are generated.`,name:"num_images_per_prompt"},{anchor:"diffusers.UniDiffuserPipeline.__call__.num_prompts_per_image",description:`<strong>num_prompts_per_image</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of prompts to generate per image. Used in <code>img2text</code> (image-conditioned text generation) and
<code>text</code> mode. If the mode is joint and both <code>num_images_per_prompt</code> and <code>num_prompts_per_image</code> are
supplied, <code>min(num_images_per_prompt, num_prompts_per_image)</code> samples are generated.`,name:"num_prompts_per_image"},{anchor:"diffusers.UniDiffuserPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.UniDiffuserPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.UniDiffuserPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for joint
image-text generation. Can be used to tweak the same generation with different prompts. If not
provided, a latents tensor is generated by sampling using the supplied random <code>generator</code>. This assumes
a full set of VAE, CLIP, and text latents, if supplied, overrides the value of <code>prompt_latents</code>,
<code>vae_latents</code>, and <code>clip_latents</code>.`,name:"latents"},{anchor:"diffusers.UniDiffuserPipeline.__call__.prompt_latents",description:`<strong>prompt_latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for text
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"prompt_latents"},{anchor:"diffusers.UniDiffuserPipeline.__call__.vae_latents",description:`<strong>vae_latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"vae_latents"},{anchor:"diffusers.UniDiffuserPipeline.__call__.clip_latents",description:`<strong>clip_latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"clip_latents"},{anchor:"diffusers.UniDiffuserPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument. Used in text-conditioned
image generation (<code>text2img</code>) mode.`,name:"prompt_embeds"},{anchor:"diffusers.UniDiffuserPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are be generated from the <code>negative_prompt</code> input argument. Used
in text-conditioned image generation (<code>text2img</code>) mode.`,name:"negative_prompt_embeds"},{anchor:"diffusers.UniDiffuserPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.UniDiffuserPipeline.__call__.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 <a href="/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.ImageTextPipelineOutput">ImageTextPipelineOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.UniDiffuserPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.UniDiffuserPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function is called. If not specified, the callback is called at
every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L1028",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.ImageTextPipelineOutput"
>ImageTextPipelineOutput</a> is returned, otherwise a
<code>tuple</code> is returned where the first element is a list with the generated images and the second element
is a list of generated texts.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.ImageTextPipelineOutput"
>ImageTextPipelineOutput</a> or <code>tuple</code></p>
`}}),Ve=new W({props:{name:"enable_model_cpu_offload",anchor:"diffusers.UniDiffuserPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L167"}}),Be=new W({props:{name:"reset_mode",anchor:"diffusers.UniDiffuserPipeline.reset_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L292"}}),Ne=new W({props:{name:"set_image_mode",anchor:"diffusers.UniDiffuserPipeline.set_image_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L276"}}),Re=new W({props:{name:"set_image_to_text_mode",anchor:"diffusers.UniDiffuserPipeline.set_image_to_text_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L284"}}),Fe=new W({props:{name:"set_joint_mode",anchor:"diffusers.UniDiffuserPipeline.set_joint_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L288"}}),Ce=new W({props:{name:"set_text_mode",anchor:"diffusers.UniDiffuserPipeline.set_text_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L272"}}),Se=new W({props:{name:"set_text_to_image_mode",anchor:"diffusers.UniDiffuserPipeline.set_text_to_image_mode",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L280"}}),Qe=new S({}),Ye=new W({props:{name:"class diffusers.ImageTextPipelineOutput",anchor:"diffusers.ImageTextPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray, NoneType]"},{name:"text",val:": typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType]"}],parametersDescription:[{anchor:"diffusers.ImageTextPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.ImageTextPipelineOutput.text",description:`<strong>text</strong> (<code>List[str]</code> or <code>List[List[str]]</code>) &#x2014;
List of generated text strings of length <code>batch_size</code> or a list of list of strings whose outer list has
length <code>batch_size</code>.`,name:"text"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py#L65"}}),{c(){v=n("meta"),Q=d(),x=n("h1"),J=n("a"),P=n("span"),u(M.$$.fragment),E=d(),Y=n("span"),en=s("UniDiffuser"),Lt=d(),z=n("p"),tn=s("The UniDiffuser model was proposed in "),ge=n("a"),nn=s("One Transformer Fits All Distributions in Multi-Modal Diffusion at Scale"),an=s(" by Fan Bao, Shen Nie, Kaiwen Xue, Chongxuan Li, Shi Pu, Yaole Wang, Gang Yue, Yue Cao, Hang Su, Jun Zhu."),At=d(),L=n("p"),on=s("The abstract from the "),_e=n("a"),sn=s("paper"),rn=s(" is:"),Ht=d(),Ae=n("p"),dt=n("em"),ln=s("This paper proposes a unified diffusion framework (dubbed UniDiffuser) to fit all distributions relevant to a set of multi-modal data in one model. Our key insight is \u2014 learning diffusion models for marginal, conditional, and joint distributions can be unified as predicting the noise in the perturbed data, where the perturbation levels (i.e. timesteps) can be different for different modalities. Inspired by the unified view, UniDiffuser learns all distributions simultaneously with a minimal modification to the original diffusion model \u2014 perturbs data in all modalities instead of a single modality, inputs individual timesteps in different modalities, and predicts the noise of all modalities instead of a single modality. UniDiffuser is parameterized by a transformer for diffusion models to handle input types of different modalities. Implemented on large-scale paired image-text data, UniDiffuser is able to perform image, text, text-to-image, image-to-text, and image-text pair generation by setting proper timesteps without additional overhead. In particular, UniDiffuser is able to produce perceptually realistic samples in all tasks and its quantitative results (e.g., the FID and CLIP score) are not only superior to existing general-purpose models but also comparable to the bespoken models (e.g., Stable Diffusion and DALL-E 2) in representative tasks (e.g., text-to-image generation)."),qt=d(),j=n("p"),pn=s("You can find the original codebase at "),be=n("a"),dn=s("thu-ml/unidiffuser"),mn=s(" and additional checkpoints at "),we=n("a"),fn=s("thu-ml"),cn=s("."),Ot=d(),u(A.$$.fragment),Kt=d(),H=n("p"),un=s("This pipeline was contributed by "),ye=n("a"),hn=s("dg845"),gn=s(". \u2764\uFE0F"),ei=d(),X=n("h2"),q=n("a"),mt=n("span"),u(ve.$$.fragment),_n=d(),ft=n("span"),bn=s("Usage Examples"),ti=d(),He=n("p"),wn=s("Because the UniDiffuser model is trained to model the joint distribution of (image, text) pairs, it is capable of performing a diverse range of generation tasks:"),ii=d(),D=n("h3"),O=n("a"),ct=n("span"),u(Ue.$$.fragment),yn=d(),ut=n("span"),vn=s("Unconditional Image and Text Generation"),ni=d(),K=n("p"),Un=s("Unconditional generation (where we start from only latents sampled from a standard Gaussian prior) from a "),qe=n("a"),xn=s("UniDiffuserPipeline"),Tn=s(" will produce a (image, text) pair:"),ai=d(),u(xe.$$.fragment),oi=d(),Oe=n("p"),Mn=s("This is also called \u201Cjoint\u201D generation in the UniDiffusers paper, since we are sampling from the joint image-text distribution."),si=d(),ee=n("p"),Zn=s(`Note that the generation task is inferred from the inputs used when calling the pipeline.
It is also possible to manually specify the unconditional generation task (\u201Cmode\u201D) manually with `),Ke=n("a"),Jn=s("UniDiffuserPipeline.set_joint_mode()"),In=s(":"),ri=d(),u(Te.$$.fragment),li=d(),te=n("p"),En=s(`When the mode is set manually, subsequent calls to the pipeline will use the set mode without attempting the infer the mode.
You can reset the mode with `),et=n("a"),jn=s("UniDiffuserPipeline.reset_mode()"),$n=s(", after which the pipeline will once again infer the mode."),pi=d(),tt=n("p"),Gn=s("You can also generate only an image or only text (which the UniDiffuser paper calls \u201Cmarginal\u201D generation since we sample from the marginal distribution of images and text, respectively):"),di=d(),u(Me.$$.fragment),mi=d(),k=n("h3"),ie=n("a"),ht=n("span"),u(Ze.$$.fragment),Wn=d(),gt=n("span"),Pn=s("Text-to-Image Generation"),fi=d(),it=n("p"),Xn=s(`UniDiffuser is also capable of sampling from conditional distributions; that is, the distribution of images conditioned on a text prompt or the distribution of texts conditioned on an image.
Here is an example of sampling from the conditional image distribution (text-to-image generation or text-conditioned image generation):`),ci=d(),u(Je.$$.fragment),ui=d(),U=n("p"),Dn=s("The "),_t=n("code"),kn=s("text2img"),Vn=s(" mode requires that either an input "),bt=n("code"),Bn=s("prompt"),Nn=s(" or "),wt=n("code"),Rn=s("prompt_embeds"),Fn=s(" be supplied. You can set the "),yt=n("code"),Cn=s("text2img"),Sn=s(" mode manually with "),nt=n("a"),Qn=s("UniDiffuserPipeline.set_text_to_image_mode()"),Yn=s("."),hi=d(),V=n("h3"),ne=n("a"),vt=n("span"),u(Ie.$$.fragment),zn=d(),Ut=n("span"),Ln=s("Image-to-Text Generation"),gi=d(),at=n("p"),An=s("Similarly, UniDiffuser can also produce text samples given an image (image-to-text or image-conditioned text generation):"),_i=d(),u(Ee.$$.fragment),bi=d(),T=n("p"),Hn=s("The "),xt=n("code"),qn=s("img2text"),On=s(" mode requires that an input "),Tt=n("code"),Kn=s("image"),ea=s(" be supplied. You can set the "),Mt=n("code"),ta=s("img2text"),ia=s(" mode manually with "),ot=n("a"),na=s("UniDiffuserPipeline.set_image_to_text_mode()"),aa=s("."),wi=d(),B=n("h3"),ae=n("a"),Zt=n("span"),u(je.$$.fragment),oa=d(),Jt=n("span"),sa=s("Image Variation"),yi=d(),st=n("p"),ra=s(`The UniDiffuser authors suggest performing image variation through a \u201Cround-trip\u201D generation method, where given an input image, we first perform an image-to-text generation, and the perform a text-to-image generation on the outputs of the first generation.
This produces a new image which is semantically similar to the input image:`),vi=d(),u($e.$$.fragment),Ui=d(),N=n("h3"),oe=n("a"),It=n("span"),u(Ge.$$.fragment),la=d(),Et=n("span"),pa=s("Text Variation"),xi=d(),rt=n("p"),da=s("Similarly, text variation can be performed on an input prompt with a text-to-image generation followed by a image-to-text generation:"),Ti=d(),u(We.$$.fragment),Mi=d(),R=n("h2"),se=n("a"),jt=n("span"),u(Pe.$$.fragment),ma=d(),$t=n("span"),fa=s("UniDiffuserPipeline"),Zi=d(),c=n("div"),u(Xe.$$.fragment),ca=d(),Gt=n("p"),ua=s(`Pipeline for a bimodal image-text model which supports unconditional text and image generation, text-conditioned
image generation, image-conditioned text generation, and joint image-text generation.`),ha=d(),De=n("p"),ga=s("This model inherits from "),lt=n("a"),_a=s("DiffusionPipeline"),ba=s(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),wa=d(),re=n("div"),u(ke.$$.fragment),ya=d(),Wt=n("p"),va=s("The call function to the pipeline for generation."),Ua=d(),le=n("div"),u(Ve.$$.fragment),xa=d(),Z=n("p"),Ta=s(`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Pt=n("code"),Ma=s("enable_sequential_cpu_offload"),Za=s(", this method moves one whole model at a time to the GPU when its "),Xt=n("code"),Ja=s("forward"),Ia=s(`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Dt=n("code"),Ea=s("enable_sequential_cpu_offload"),ja=s(", but performance is much better due to the iterative execution of the "),kt=n("code"),$a=s("unet"),Ga=s("."),Wa=d(),pe=n("div"),u(Be.$$.fragment),Pa=d(),Vt=n("p"),Xa=s("Removes a manually set mode; after calling this, the pipeline will infer the mode from inputs."),Da=d(),de=n("div"),u(Ne.$$.fragment),ka=d(),Bt=n("p"),Va=s("Manually set the generation mode to unconditional (\u201Cmarginal\u201D) image generation."),Ba=d(),me=n("div"),u(Re.$$.fragment),Na=d(),Nt=n("p"),Ra=s("Manually set the generation mode to image-conditioned text generation."),Fa=d(),fe=n("div"),u(Fe.$$.fragment),Ca=d(),Rt=n("p"),Sa=s("Manually set the generation mode to unconditional joint image-text generation."),Qa=d(),ce=n("div"),u(Ce.$$.fragment),Ya=d(),Ft=n("p"),za=s("Manually set the generation mode to unconditional (\u201Cmarginal\u201D) text generation."),La=d(),ue=n("div"),u(Se.$$.fragment),Aa=d(),Ct=n("p"),Ha=s("Manually set the generation mode to text-conditioned image generation."),Ji=d(),F=n("h2"),he=n("a"),St=n("span"),u(Qe.$$.fragment),qa=d(),Qt=n("span"),Oa=s("ImageTextPipelineOutput"),Ii=d(),C=n("div"),u(Ye.$$.fragment),Ka=d(),Yt=n("p"),eo=s("Output class for joint image-text pipelines."),this.h()},l(e){const l=bs('[data-svelte="svelte-1phssyn"]',document.head);v=a(l,"META",{name:!0,content:!0}),l.forEach(i),Q=m(e),x=a(e,"H1",{class:!0});var ze=o(x);J=a(ze,"A",{id:!0,class:!0,href:!0});var to=o(J);P=a(to,"SPAN",{});var io=o(P);h(M.$$.fragment,io),io.forEach(i),to.forEach(i),E=m(ze),Y=a(ze,"SPAN",{});var no=o(Y);en=r(no,"UniDiffuser"),no.forEach(i),ze.forEach(i),Lt=m(e),z=a(e,"P",{});var ji=o(z);tn=r(ji,"The UniDiffuser model was proposed in "),ge=a(ji,"A",{href:!0,rel:!0});var ao=o(ge);nn=r(ao,"One Transformer Fits All Distributions in Multi-Modal Diffusion at Scale"),ao.forEach(i),an=r(ji," by Fan Bao, Shen Nie, Kaiwen Xue, Chongxuan Li, Shi Pu, Yaole Wang, Gang Yue, Yue Cao, Hang Su, Jun Zhu."),ji.forEach(i),At=m(e),L=a(e,"P",{});var $i=o(L);on=r($i,"The abstract from the "),_e=a($i,"A",{href:!0,rel:!0});var oo=o(_e);sn=r(oo,"paper"),oo.forEach(i),rn=r($i," is:"),$i.forEach(i),Ht=m(e),Ae=a(e,"P",{});var so=o(Ae);dt=a(so,"EM",{});var ro=o(dt);ln=r(ro,"This paper proposes a unified diffusion framework (dubbed UniDiffuser) to fit all distributions relevant to a set of multi-modal data in one model. Our key insight is \u2014 learning diffusion models for marginal, conditional, and joint distributions can be unified as predicting the noise in the perturbed data, where the perturbation levels (i.e. timesteps) can be different for different modalities. Inspired by the unified view, UniDiffuser learns all distributions simultaneously with a minimal modification to the original diffusion model \u2014 perturbs data in all modalities instead of a single modality, inputs individual timesteps in different modalities, and predicts the noise of all modalities instead of a single modality. UniDiffuser is parameterized by a transformer for diffusion models to handle input types of different modalities. Implemented on large-scale paired image-text data, UniDiffuser is able to perform image, text, text-to-image, image-to-text, and image-text pair generation by setting proper timesteps without additional overhead. In particular, UniDiffuser is able to produce perceptually realistic samples in all tasks and its quantitative results (e.g., the FID and CLIP score) are not only superior to existing general-purpose models but also comparable to the bespoken models (e.g., Stable Diffusion and DALL-E 2) in representative tasks (e.g., text-to-image generation)."),ro.forEach(i),so.forEach(i),qt=m(e),j=a(e,"P",{});var pt=o(j);pn=r(pt,"You can find the original codebase at "),be=a(pt,"A",{href:!0,rel:!0});var lo=o(be);dn=r(lo,"thu-ml/unidiffuser"),lo.forEach(i),mn=r(pt," and additional checkpoints at "),we=a(pt,"A",{href:!0,rel:!0});var po=o(we);fn=r(po,"thu-ml"),po.forEach(i),cn=r(pt,"."),pt.forEach(i),Ot=m(e),h(A.$$.fragment,e),Kt=m(e),H=a(e,"P",{});var Gi=o(H);un=r(Gi,"This pipeline was contributed by "),ye=a(Gi,"A",{href:!0,rel:!0});var mo=o(ye);hn=r(mo,"dg845"),mo.forEach(i),gn=r(Gi,". \u2764\uFE0F"),Gi.forEach(i),ei=m(e),X=a(e,"H2",{class:!0});var Wi=o(X);q=a(Wi,"A",{id:!0,class:!0,href:!0});var fo=o(q);mt=a(fo,"SPAN",{});var co=o(mt);h(ve.$$.fragment,co),co.forEach(i),fo.forEach(i),_n=m(Wi),ft=a(Wi,"SPAN",{});var uo=o(ft);bn=r(uo,"Usage Examples"),uo.forEach(i),Wi.forEach(i),ti=m(e),He=a(e,"P",{});var ho=o(He);wn=r(ho,"Because the UniDiffuser model is trained to model the joint distribution of (image, text) pairs, it is capable of performing a diverse range of generation tasks:"),ho.forEach(i),ii=m(e),D=a(e,"H3",{class:!0});var Pi=o(D);O=a(Pi,"A",{id:!0,class:!0,href:!0});var go=o(O);ct=a(go,"SPAN",{});var _o=o(ct);h(Ue.$$.fragment,_o),_o.forEach(i),go.forEach(i),yn=m(Pi),ut=a(Pi,"SPAN",{});var bo=o(ut);vn=r(bo,"Unconditional Image and Text Generation"),bo.forEach(i),Pi.forEach(i),ni=m(e),K=a(e,"P",{});var Xi=o(K);Un=r(Xi,"Unconditional generation (where we start from only latents sampled from a standard Gaussian prior) from a "),qe=a(Xi,"A",{href:!0});var wo=o(qe);xn=r(wo,"UniDiffuserPipeline"),wo.forEach(i),Tn=r(Xi," will produce a (image, text) pair:"),Xi.forEach(i),ai=m(e),h(xe.$$.fragment,e),oi=m(e),Oe=a(e,"P",{});var yo=o(Oe);Mn=r(yo,"This is also called \u201Cjoint\u201D generation in the UniDiffusers paper, since we are sampling from the joint image-text distribution."),yo.forEach(i),si=m(e),ee=a(e,"P",{});var Di=o(ee);Zn=r(Di,`Note that the generation task is inferred from the inputs used when calling the pipeline.
It is also possible to manually specify the unconditional generation task (\u201Cmode\u201D) manually with `),Ke=a(Di,"A",{href:!0});var vo=o(Ke);Jn=r(vo,"UniDiffuserPipeline.set_joint_mode()"),vo.forEach(i),In=r(Di,":"),Di.forEach(i),ri=m(e),h(Te.$$.fragment,e),li=m(e),te=a(e,"P",{});var ki=o(te);En=r(ki,`When the mode is set manually, subsequent calls to the pipeline will use the set mode without attempting the infer the mode.
You can reset the mode with `),et=a(ki,"A",{href:!0});var Uo=o(et);jn=r(Uo,"UniDiffuserPipeline.reset_mode()"),Uo.forEach(i),$n=r(ki,", after which the pipeline will once again infer the mode."),ki.forEach(i),pi=m(e),tt=a(e,"P",{});var xo=o(tt);Gn=r(xo,"You can also generate only an image or only text (which the UniDiffuser paper calls \u201Cmarginal\u201D generation since we sample from the marginal distribution of images and text, respectively):"),xo.forEach(i),di=m(e),h(Me.$$.fragment,e),mi=m(e),k=a(e,"H3",{class:!0});var Vi=o(k);ie=a(Vi,"A",{id:!0,class:!0,href:!0});var To=o(ie);ht=a(To,"SPAN",{});var Mo=o(ht);h(Ze.$$.fragment,Mo),Mo.forEach(i),To.forEach(i),Wn=m(Vi),gt=a(Vi,"SPAN",{});var Zo=o(gt);Pn=r(Zo,"Text-to-Image Generation"),Zo.forEach(i),Vi.forEach(i),fi=m(e),it=a(e,"P",{});var Jo=o(it);Xn=r(Jo,`UniDiffuser is also capable of sampling from conditional distributions; that is, the distribution of images conditioned on a text prompt or the distribution of texts conditioned on an image.
Here is an example of sampling from the conditional image distribution (text-to-image generation or text-conditioned image generation):`),Jo.forEach(i),ci=m(e),h(Je.$$.fragment,e),ui=m(e),U=a(e,"P",{});var I=o(U);Dn=r(I,"The "),_t=a(I,"CODE",{});var Io=o(_t);kn=r(Io,"text2img"),Io.forEach(i),Vn=r(I," mode requires that either an input "),bt=a(I,"CODE",{});var Eo=o(bt);Bn=r(Eo,"prompt"),Eo.forEach(i),Nn=r(I," or "),wt=a(I,"CODE",{});var jo=o(wt);Rn=r(jo,"prompt_embeds"),jo.forEach(i),Fn=r(I," be supplied. You can set the "),yt=a(I,"CODE",{});var $o=o(yt);Cn=r($o,"text2img"),$o.forEach(i),Sn=r(I," mode manually with "),nt=a(I,"A",{href:!0});var Go=o(nt);Qn=r(Go,"UniDiffuserPipeline.set_text_to_image_mode()"),Go.forEach(i),Yn=r(I,"."),I.forEach(i),hi=m(e),V=a(e,"H3",{class:!0});var Bi=o(V);ne=a(Bi,"A",{id:!0,class:!0,href:!0});var Wo=o(ne);vt=a(Wo,"SPAN",{});var Po=o(vt);h(Ie.$$.fragment,Po),Po.forEach(i),Wo.forEach(i),zn=m(Bi),Ut=a(Bi,"SPAN",{});var Xo=o(Ut);Ln=r(Xo,"Image-to-Text Generation"),Xo.forEach(i),Bi.forEach(i),gi=m(e),at=a(e,"P",{});var Do=o(at);An=r(Do,"Similarly, UniDiffuser can also produce text samples given an image (image-to-text or image-conditioned text generation):"),Do.forEach(i),_i=m(e),h(Ee.$$.fragment,e),bi=m(e),T=a(e,"P",{});var $=o(T);Hn=r($,"The "),xt=a($,"CODE",{});var ko=o(xt);qn=r(ko,"img2text"),ko.forEach(i),On=r($," mode requires that an input "),Tt=a($,"CODE",{});var Vo=o(Tt);Kn=r(Vo,"image"),Vo.forEach(i),ea=r($," be supplied. You can set the "),Mt=a($,"CODE",{});var Bo=o(Mt);ta=r(Bo,"img2text"),Bo.forEach(i),ia=r($," mode manually with "),ot=a($,"A",{href:!0});var No=o(ot);na=r(No,"UniDiffuserPipeline.set_image_to_text_mode()"),No.forEach(i),aa=r($,"."),$.forEach(i),wi=m(e),B=a(e,"H3",{class:!0});var Ni=o(B);ae=a(Ni,"A",{id:!0,class:!0,href:!0});var Ro=o(ae);Zt=a(Ro,"SPAN",{});var Fo=o(Zt);h(je.$$.fragment,Fo),Fo.forEach(i),Ro.forEach(i),oa=m(Ni),Jt=a(Ni,"SPAN",{});var Co=o(Jt);sa=r(Co,"Image Variation"),Co.forEach(i),Ni.forEach(i),yi=m(e),st=a(e,"P",{});var So=o(st);ra=r(So,`The UniDiffuser authors suggest performing image variation through a \u201Cround-trip\u201D generation method, where given an input image, we first perform an image-to-text generation, and the perform a text-to-image generation on the outputs of the first generation.
This produces a new image which is semantically similar to the input image:`),So.forEach(i),vi=m(e),h($e.$$.fragment,e),Ui=m(e),N=a(e,"H3",{class:!0});var Ri=o(N);oe=a(Ri,"A",{id:!0,class:!0,href:!0});var Qo=o(oe);It=a(Qo,"SPAN",{});var Yo=o(It);h(Ge.$$.fragment,Yo),Yo.forEach(i),Qo.forEach(i),la=m(Ri),Et=a(Ri,"SPAN",{});var zo=o(Et);pa=r(zo,"Text Variation"),zo.forEach(i),Ri.forEach(i),xi=m(e),rt=a(e,"P",{});var Lo=o(rt);da=r(Lo,"Similarly, text variation can be performed on an input prompt with a text-to-image generation followed by a image-to-text generation:"),Lo.forEach(i),Ti=m(e),h(We.$$.fragment,e),Mi=m(e),R=a(e,"H2",{class:!0});var Fi=o(R);se=a(Fi,"A",{id:!0,class:!0,href:!0});var Ao=o(se);jt=a(Ao,"SPAN",{});var Ho=o(jt);h(Pe.$$.fragment,Ho),Ho.forEach(i),Ao.forEach(i),ma=m(Fi),$t=a(Fi,"SPAN",{});var qo=o($t);fa=r(qo,"UniDiffuserPipeline"),qo.forEach(i),Fi.forEach(i),Zi=m(e),c=a(e,"DIV",{class:!0});var y=o(c);h(Xe.$$.fragment,y),ca=m(y),Gt=a(y,"P",{});var Oo=o(Gt);ua=r(Oo,`Pipeline for a bimodal image-text model which supports unconditional text and image generation, text-conditioned
image generation, image-conditioned text generation, and joint image-text generation.`),Oo.forEach(i),ha=m(y),De=a(y,"P",{});var Ci=o(De);ga=r(Ci,"This model inherits from "),lt=a(Ci,"A",{href:!0});var Ko=o(lt);_a=r(Ko,"DiffusionPipeline"),Ko.forEach(i),ba=r(Ci,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ci.forEach(i),wa=m(y),re=a(y,"DIV",{class:!0});var Si=o(re);h(ke.$$.fragment,Si),ya=m(Si),Wt=a(Si,"P",{});var es=o(Wt);va=r(es,"The call function to the pipeline for generation."),es.forEach(i),Si.forEach(i),Ua=m(y),le=a(y,"DIV",{class:!0});var Qi=o(le);h(Ve.$$.fragment,Qi),xa=m(Qi),Z=a(Qi,"P",{});var G=o(Z);Ta=r(G,`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Pt=a(G,"CODE",{});var ts=o(Pt);Ma=r(ts,"enable_sequential_cpu_offload"),ts.forEach(i),Za=r(G,", this method moves one whole model at a time to the GPU when its "),Xt=a(G,"CODE",{});var is=o(Xt);Ja=r(is,"forward"),is.forEach(i),Ia=r(G,`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Dt=a(G,"CODE",{});var ns=o(Dt);Ea=r(ns,"enable_sequential_cpu_offload"),ns.forEach(i),ja=r(G,", but performance is much better due to the iterative execution of the "),kt=a(G,"CODE",{});var as=o(kt);$a=r(as,"unet"),as.forEach(i),Ga=r(G,"."),G.forEach(i),Qi.forEach(i),Wa=m(y),pe=a(y,"DIV",{class:!0});var Yi=o(pe);h(Be.$$.fragment,Yi),Pa=m(Yi),Vt=a(Yi,"P",{});var os=o(Vt);Xa=r(os,"Removes a manually set mode; after calling this, the pipeline will infer the mode from inputs."),os.forEach(i),Yi.forEach(i),Da=m(y),de=a(y,"DIV",{class:!0});var zi=o(de);h(Ne.$$.fragment,zi),ka=m(zi),Bt=a(zi,"P",{});var ss=o(Bt);Va=r(ss,"Manually set the generation mode to unconditional (\u201Cmarginal\u201D) image generation."),ss.forEach(i),zi.forEach(i),Ba=m(y),me=a(y,"DIV",{class:!0});var Li=o(me);h(Re.$$.fragment,Li),Na=m(Li),Nt=a(Li,"P",{});var rs=o(Nt);Ra=r(rs,"Manually set the generation mode to image-conditioned text generation."),rs.forEach(i),Li.forEach(i),Fa=m(y),fe=a(y,"DIV",{class:!0});var Ai=o(fe);h(Fe.$$.fragment,Ai),Ca=m(Ai),Rt=a(Ai,"P",{});var ls=o(Rt);Sa=r(ls,"Manually set the generation mode to unconditional joint image-text generation."),ls.forEach(i),Ai.forEach(i),Qa=m(y),ce=a(y,"DIV",{class:!0});var Hi=o(ce);h(Ce.$$.fragment,Hi),Ya=m(Hi),Ft=a(Hi,"P",{});var ps=o(Ft);za=r(ps,"Manually set the generation mode to unconditional (\u201Cmarginal\u201D) text generation."),ps.forEach(i),Hi.forEach(i),La=m(y),ue=a(y,"DIV",{class:!0});var qi=o(ue);h(Se.$$.fragment,qi),Aa=m(qi),Ct=a(qi,"P",{});var ds=o(Ct);Ha=r(ds,"Manually set the generation mode to text-conditioned image generation."),ds.forEach(i),qi.forEach(i),y.forEach(i),Ji=m(e),F=a(e,"H2",{class:!0});var Oi=o(F);he=a(Oi,"A",{id:!0,class:!0,href:!0});var ms=o(he);St=a(ms,"SPAN",{});var fs=o(St);h(Qe.$$.fragment,fs),fs.forEach(i),ms.forEach(i),qa=m(Oi),Qt=a(Oi,"SPAN",{});var cs=o(Qt);Oa=r(cs,"ImageTextPipelineOutput"),cs.forEach(i),Oi.forEach(i),Ii=m(e),C=a(e,"DIV",{class:!0});var Ki=o(C);h(Ye.$$.fragment,Ki),Ka=m(Ki),Yt=a(Ki,"P",{});var us=o(Yt);eo=r(us,"Output class for joint image-text pipelines."),us.forEach(i),Ki.forEach(i),this.h()},h(){f(v,"name","hf:doc:metadata"),f(v,"content",JSON.stringify(xs)),f(J,"id","unidiffuser"),f(J,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(J,"href","#unidiffuser"),f(x,"class","relative group"),f(ge,"href","https://huggingface.co/papers/2303.06555"),f(ge,"rel","nofollow"),f(_e,"href","https://arxiv.org/abs/2303.06555"),f(_e,"rel","nofollow"),f(be,"href","https://github.com/thu-ml/unidiffuser"),f(be,"rel","nofollow"),f(we,"href","https://huggingface.co/thu-ml"),f(we,"rel","nofollow"),f(ye,"href","https://github.com/dg845"),f(ye,"rel","nofollow"),f(q,"id","usage-examples"),f(q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(q,"href","#usage-examples"),f(X,"class","relative group"),f(O,"id","unconditional-image-and-text-generation"),f(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(O,"href","#unconditional-image-and-text-generation"),f(D,"class","relative group"),f(qe,"href","/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.UniDiffuserPipeline"),f(Ke,"href","/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.UniDiffuserPipeline.set_joint_mode"),f(et,"href","/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.UniDiffuserPipeline.reset_mode"),f(ie,"id","texttoimage-generation"),f(ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(ie,"href","#texttoimage-generation"),f(k,"class","relative group"),f(nt,"href","/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.UniDiffuserPipeline.set_text_to_image_mode"),f(ne,"id","imagetotext-generation"),f(ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(ne,"href","#imagetotext-generation"),f(V,"class","relative group"),f(ot,"href","/docs/diffusers/main/en/api/pipelines/unidiffuser#diffusers.UniDiffuserPipeline.set_image_to_text_mode"),f(ae,"id","image-variation"),f(ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(ae,"href","#image-variation"),f(B,"class","relative group"),f(oe,"id","text-variation"),f(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(oe,"href","#text-variation"),f(N,"class","relative group"),f(se,"id","diffusers.UniDiffuserPipeline"),f(se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(se,"href","#diffusers.UniDiffuserPipeline"),f(R,"class","relative group"),f(lt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),f(re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(he,"id","diffusers.ImageTextPipelineOutput"),f(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(he,"href","#diffusers.ImageTextPipelineOutput"),f(F,"class","relative group"),f(C,"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,l){t(document.head,v),p(e,Q,l),p(e,x,l),t(x,J),t(J,P),g(M,P,null),t(x,E),t(x,Y),t(Y,en),p(e,Lt,l),p(e,z,l),t(z,tn),t(z,ge),t(ge,nn),t(z,an),p(e,At,l),p(e,L,l),t(L,on),t(L,_e),t(_e,sn),t(L,rn),p(e,Ht,l),p(e,Ae,l),t(Ae,dt),t(dt,ln),p(e,qt,l),p(e,j,l),t(j,pn),t(j,be),t(be,dn),t(j,mn),t(j,we),t(we,fn),t(j,cn),p(e,Ot,l),g(A,e,l),p(e,Kt,l),p(e,H,l),t(H,un),t(H,ye),t(ye,hn),t(H,gn),p(e,ei,l),p(e,X,l),t(X,q),t(q,mt),g(ve,mt,null),t(X,_n),t(X,ft),t(ft,bn),p(e,ti,l),p(e,He,l),t(He,wn),p(e,ii,l),p(e,D,l),t(D,O),t(O,ct),g(Ue,ct,null),t(D,yn),t(D,ut),t(ut,vn),p(e,ni,l),p(e,K,l),t(K,Un),t(K,qe),t(qe,xn),t(K,Tn),p(e,ai,l),g(xe,e,l),p(e,oi,l),p(e,Oe,l),t(Oe,Mn),p(e,si,l),p(e,ee,l),t(ee,Zn),t(ee,Ke),t(Ke,Jn),t(ee,In),p(e,ri,l),g(Te,e,l),p(e,li,l),p(e,te,l),t(te,En),t(te,et),t(et,jn),t(te,$n),p(e,pi,l),p(e,tt,l),t(tt,Gn),p(e,di,l),g(Me,e,l),p(e,mi,l),p(e,k,l),t(k,ie),t(ie,ht),g(Ze,ht,null),t(k,Wn),t(k,gt),t(gt,Pn),p(e,fi,l),p(e,it,l),t(it,Xn),p(e,ci,l),g(Je,e,l),p(e,ui,l),p(e,U,l),t(U,Dn),t(U,_t),t(_t,kn),t(U,Vn),t(U,bt),t(bt,Bn),t(U,Nn),t(U,wt),t(wt,Rn),t(U,Fn),t(U,yt),t(yt,Cn),t(U,Sn),t(U,nt),t(nt,Qn),t(U,Yn),p(e,hi,l),p(e,V,l),t(V,ne),t(ne,vt),g(Ie,vt,null),t(V,zn),t(V,Ut),t(Ut,Ln),p(e,gi,l),p(e,at,l),t(at,An),p(e,_i,l),g(Ee,e,l),p(e,bi,l),p(e,T,l),t(T,Hn),t(T,xt),t(xt,qn),t(T,On),t(T,Tt),t(Tt,Kn),t(T,ea),t(T,Mt),t(Mt,ta),t(T,ia),t(T,ot),t(ot,na),t(T,aa),p(e,wi,l),p(e,B,l),t(B,ae),t(ae,Zt),g(je,Zt,null),t(B,oa),t(B,Jt),t(Jt,sa),p(e,yi,l),p(e,st,l),t(st,ra),p(e,vi,l),g($e,e,l),p(e,Ui,l),p(e,N,l),t(N,oe),t(oe,It),g(Ge,It,null),t(N,la),t(N,Et),t(Et,pa),p(e,xi,l),p(e,rt,l),t(rt,da),p(e,Ti,l),g(We,e,l),p(e,Mi,l),p(e,R,l),t(R,se),t(se,jt),g(Pe,jt,null),t(R,ma),t(R,$t),t($t,fa),p(e,Zi,l),p(e,c,l),g(Xe,c,null),t(c,ca),t(c,Gt),t(Gt,ua),t(c,ha),t(c,De),t(De,ga),t(De,lt),t(lt,_a),t(De,ba),t(c,wa),t(c,re),g(ke,re,null),t(re,ya),t(re,Wt),t(Wt,va),t(c,Ua),t(c,le),g(Ve,le,null),t(le,xa),t(le,Z),t(Z,Ta),t(Z,Pt),t(Pt,Ma),t(Z,Za),t(Z,Xt),t(Xt,Ja),t(Z,Ia),t(Z,Dt),t(Dt,Ea),t(Z,ja),t(Z,kt),t(kt,$a),t(Z,Ga),t(c,Wa),t(c,pe),g(Be,pe,null),t(pe,Pa),t(pe,Vt),t(Vt,Xa),t(c,Da),t(c,de),g(Ne,de,null),t(de,ka),t(de,Bt),t(Bt,Va),t(c,Ba),t(c,me),g(Re,me,null),t(me,Na),t(me,Nt),t(Nt,Ra),t(c,Fa),t(c,fe),g(Fe,fe,null),t(fe,Ca),t(fe,Rt),t(Rt,Sa),t(c,Qa),t(c,ce),g(Ce,ce,null),t(ce,Ya),t(ce,Ft),t(Ft,za),t(c,La),t(c,ue),g(Se,ue,null),t(ue,Aa),t(ue,Ct),t(Ct,Ha),p(e,Ji,l),p(e,F,l),t(F,he),t(he,St),g(Qe,St,null),t(F,qa),t(F,Qt),t(Qt,Oa),p(e,Ii,l),p(e,C,l),g(Ye,C,null),t(C,Ka),t(C,Yt),t(Yt,eo),Ei=!0},p(e,[l]){const ze={};l&2&&(ze.$$scope={dirty:l,ctx:e}),A.$set(ze)},i(e){Ei||(_(M.$$.fragment,e),_(A.$$.fragment,e),_(ve.$$.fragment,e),_(Ue.$$.fragment,e),_(xe.$$.fragment,e),_(Te.$$.fragment,e),_(Me.$$.fragment,e),_(Ze.$$.fragment,e),_(Je.$$.fragment,e),_(Ie.$$.fragment,e),_(Ee.$$.fragment,e),_(je.$$.fragment,e),_($e.$$.fragment,e),_(Ge.$$.fragment,e),_(We.$$.fragment,e),_(Pe.$$.fragment,e),_(Xe.$$.fragment,e),_(ke.$$.fragment,e),_(Ve.$$.fragment,e),_(Be.$$.fragment,e),_(Ne.$$.fragment,e),_(Re.$$.fragment,e),_(Fe.$$.fragment,e),_(Ce.$$.fragment,e),_(Se.$$.fragment,e),_(Qe.$$.fragment,e),_(Ye.$$.fragment,e),Ei=!0)},o(e){b(M.$$.fragment,e),b(A.$$.fragment,e),b(ve.$$.fragment,e),b(Ue.$$.fragment,e),b(xe.$$.fragment,e),b(Te.$$.fragment,e),b(Me.$$.fragment,e),b(Ze.$$.fragment,e),b(Je.$$.fragment,e),b(Ie.$$.fragment,e),b(Ee.$$.fragment,e),b(je.$$.fragment,e),b($e.$$.fragment,e),b(Ge.$$.fragment,e),b(We.$$.fragment,e),b(Pe.$$.fragment,e),b(Xe.$$.fragment,e),b(ke.$$.fragment,e),b(Ve.$$.fragment,e),b(Be.$$.fragment,e),b(Ne.$$.fragment,e),b(Re.$$.fragment,e),b(Fe.$$.fragment,e),b(Ce.$$.fragment,e),b(Se.$$.fragment,e),b(Qe.$$.fragment,e),b(Ye.$$.fragment,e),Ei=!1},d(e){i(v),e&&i(Q),e&&i(x),w(M),e&&i(Lt),e&&i(z),e&&i(At),e&&i(L),e&&i(Ht),e&&i(Ae),e&&i(qt),e&&i(j),e&&i(Ot),w(A,e),e&&i(Kt),e&&i(H),e&&i(ei),e&&i(X),w(ve),e&&i(ti),e&&i(He),e&&i(ii),e&&i(D),w(Ue),e&&i(ni),e&&i(K),e&&i(ai),w(xe,e),e&&i(oi),e&&i(Oe),e&&i(si),e&&i(ee),e&&i(ri),w(Te,e),e&&i(li),e&&i(te),e&&i(pi),e&&i(tt),e&&i(di),w(Me,e),e&&i(mi),e&&i(k),w(Ze),e&&i(fi),e&&i(it),e&&i(ci),w(Je,e),e&&i(ui),e&&i(U),e&&i(hi),e&&i(V),w(Ie),e&&i(gi),e&&i(at),e&&i(_i),w(Ee,e),e&&i(bi),e&&i(T),e&&i(wi),e&&i(B),w(je),e&&i(yi),e&&i(st),e&&i(vi),w($e,e),e&&i(Ui),e&&i(N),w(Ge),e&&i(xi),e&&i(rt),e&&i(Ti),w(We,e),e&&i(Mi),e&&i(R),w(Pe),e&&i(Zi),e&&i(c),w(Xe),w(ke),w(Ve),w(Be),w(Ne),w(Re),w(Fe),w(Ce),w(Se),e&&i(Ji),e&&i(F),w(Qe),e&&i(Ii),e&&i(C),w(Ye)}}}const xs={local:"unidiffuser",sections:[{local:"usage-examples",sections:[{local:"unconditional-image-and-text-generation",title:"Unconditional Image and Text Generation"},{local:"texttoimage-generation",title:"Text-to-Image Generation"},{local:"imagetotext-generation",title:"Image-to-Text Generation"},{local:"image-variation",title:"Image Variation"},{local:"text-variation",title:"Text Variation"}],title:"Usage Examples"},{local:"diffusers.UniDiffuserPipeline",title:"UniDiffuserPipeline"},{local:"diffusers.ImageTextPipelineOutput",title:"ImageTextPipelineOutput"}],title:"UniDiffuser"};function Ts(zt){return ws(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class js extends hs{constructor(v){super();gs(this,v,Ts,Us,_s,{})}}export{js as default,xs as metadata};
