import{s as ql,o as Ll,n as j}from"../chunks/scheduler.182ea377.js";import{S as Dl,i as Pl,g,s as o,r as d,A as Al,h as k,f as i,c,j as Kl,u as y,x as w,k as G,y as Ol,a as p,v as u,d as M,t as f,w as h}from"../chunks/index.abf12888.js";import{T as St}from"../chunks/Tip.230e2334.js";import{C as T}from"../chunks/CodeBlock.57fe6e13.js";import{D as en}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as B}from"../chunks/Heading.16916d63.js";import{H as _,a as $}from"../chunks/HfOption.fc88c804.js";function sn(b){let t,m="Kandinsky 2.1 and 2.2 usage is very similar! The only difference is Kandinsky 2.2 doesn’t accept <code>prompt</code> as an input when decoding the latents. Instead, Kandinsky 2.2 only accepts <code>image_embeds</code> during decoding.";return{c(){t=g("p"),t.innerHTML=m},l(s){t=k(s,"P",{"data-svelte-h":!0}),w(t)!=="svelte-enep6a"&&(t.innerHTML=m)},m(s,r){p(s,t,r)},p:j,d(s){s&&i(t)}}}function tn(b){let t,m,s,r='Now pass all the prompts and embeddings to the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky#diffusers.KandinskyPipeline">KandinskyPipeline</a> to generate an image:',l,n,J,Z,I='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-docs/cheeseburger.png"/>',V;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVByaW9yUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lQaXBlbGluZSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBcHJpb3JfcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lQcmlvclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMS1wcmlvciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwYWxpZW4lMjBjaGVlc2VidXJnZXIlMjBjcmVhdHVyZSUyMGVhdGluZyUyMGl0c2VsZiUyQyUyMGNsYXltYXRpb24lMkMlMjBjaW5lbWF0aWMlMkMlMjBtb29keSUyMGxpZ2h0aW5nJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIybG93JTIwcXVhbGl0eSUyQyUyMGJhZCUyMHF1YWxpdHklMjIlMjAlMjMlMjBvcHRpb25hbCUyMHRvJTIwaW5jbHVkZSUyMGElMjBuZWdhdGl2ZSUyMHByb21wdCUyQyUyMGJ1dCUyMHJlc3VsdHMlMjBhcmUlMjB1c3VhbGx5JTIwYmV0dGVyJTBBaW1hZ2VfZW1iZWRzJTJDJTIwbmVnYXRpdmVfaW1hZ2VfZW1iZWRzJTIwJTNEJTIwcHJpb3JfcGlwZWxpbmUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0QxLjApLnRvX3R1cGxlKCk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyPriorPipeline, KandinskyPipeline
<span class="hljs-keyword">import</span> torch

prior_pipeline = KandinskyPriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-prior&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span> <span class="hljs-comment"># optional to include a negative prompt, but results are usually better</span>
image_embeds, negative_image_embeds = prior_pipeline(prompt, negative_prompt, guidance_scale=<span class="hljs-number">1.0</span>).to_tuple()`,wrap:!1}}),n=new T({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBpbWFnZV9lbWJlZHMlM0RpbWFnZV9lbWJlZHMlMkMlMjBuZWdhdGl2ZV9wcm9tcHQlM0RuZWdhdGl2ZV9wcm9tcHQlMkMlMjBuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlM0RuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlMkMlMjBoZWlnaHQlM0Q3NjglMkMlMjB3aWR0aCUzRDc2OCkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`image = pipeline(prompt, image_embeds=image_embeds, negative_prompt=negative_prompt, negative_image_embeds=negative_image_embeds, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("p"),s.innerHTML=r,l=o(),d(n.$$.fragment),J=o(),Z=g("div"),Z.innerHTML=I,this.h()},l(U){y(t.$$.fragment,U),m=c(U),s=k(U,"P",{"data-svelte-h":!0}),w(s)!=="svelte-fnb5ou"&&(s.innerHTML=r),l=c(U),y(n.$$.fragment,U),J=c(U),Z=k(U,"DIV",{class:!0,"data-svelte-h":!0}),w(Z)!=="svelte-i75i2v"&&(Z.innerHTML=I),this.h()},h(){G(Z,"class","flex justify-center")},m(U,W){u(t,U,W),p(U,m,W),p(U,s,W),p(U,l,W),u(n,U,W),p(U,J,W),p(U,Z,W),V=!0},p:j,i(U){V||(M(t.$$.fragment,U),M(n.$$.fragment,U),V=!0)},o(U){f(t.$$.fragment,U),f(n.$$.fragment,U),V=!1},d(U){U&&(i(m),i(s),i(l),i(J),i(Z)),h(t,U),h(n,U)}}}function ln(b){let t,m,s,r='Pass the <code>image_embeds</code> and <code>negative_image_embeds</code> to the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22Pipeline">KandinskyV22Pipeline</a> to generate an image:',l,n,J,Z,I='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-text-to-image.png"/>',V;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lWMjJQaXBlbGluZSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBcHJpb3JfcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lWMjJQcmlvclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1wcmlvciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVYyMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1kZWNvZGVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBhbGllbiUyMGNoZWVzZWJ1cmdlciUyMGNyZWF0dXJlJTIwZWF0aW5nJTIwaXRzZWxmJTJDJTIwY2xheW1hdGlvbiUyQyUyMGNpbmVtYXRpYyUyQyUyMG1vb2R5JTIwbGlnaHRpbmclMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAlMjJsb3clMjBxdWFsaXR5JTJDJTIwYmFkJTIwcXVhbGl0eSUyMiUyMCUyMyUyMG9wdGlvbmFsJTIwdG8lMjBpbmNsdWRlJTIwYSUyMG5lZ2F0aXZlJTIwcHJvbXB0JTJDJTIwYnV0JTIwcmVzdWx0cyUyMGFyZSUyMHVzdWFsbHklMjBiZXR0ZXIlMEFpbWFnZV9lbWJlZHMlMkMlMjBuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlMjAlM0QlMjBwcmlvcl9waXBlbGluZShwcm9tcHQlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDEuMCkudG9fdHVwbGUoKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22PriorPipeline, KandinskyV22Pipeline
<span class="hljs-keyword">import</span> torch

prior_pipeline = KandinskyV22PriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyV22Pipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span> <span class="hljs-comment"># optional to include a negative prompt, but results are usually better</span>
image_embeds, negative_image_embeds = prior_pipeline(prompt, guidance_scale=<span class="hljs-number">1.0</span>).to_tuple()`,wrap:!1}}),n=new T({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShpbWFnZV9lbWJlZHMlM0RpbWFnZV9lbWJlZHMlMkMlMjBuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlM0RuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlMkMlMjBoZWlnaHQlM0Q3NjglMkMlMjB3aWR0aCUzRDc2OCkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`image = pipeline(image_embeds=image_embeds, negative_image_embeds=negative_image_embeds, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("p"),s.innerHTML=r,l=o(),d(n.$$.fragment),J=o(),Z=g("div"),Z.innerHTML=I,this.h()},l(U){y(t.$$.fragment,U),m=c(U),s=k(U,"P",{"data-svelte-h":!0}),w(s)!=="svelte-h1vaih"&&(s.innerHTML=r),l=c(U),y(n.$$.fragment,U),J=c(U),Z=k(U,"DIV",{class:!0,"data-svelte-h":!0}),w(Z)!=="svelte-kkab9k"&&(Z.innerHTML=I),this.h()},h(){G(Z,"class","flex justify-center")},m(U,W){u(t,U,W),p(U,m,W),p(U,s,W),p(U,l,W),u(n,U,W),p(U,J,W),p(U,Z,W),V=!0},p:j,i(U){V||(M(t.$$.fragment,U),M(n.$$.fragment,U),V=!0)},o(U){f(t.$$.fragment,U),f(n.$$.fragment,U),V=!1},d(U){U&&(i(m),i(s),i(l),i(J),i(Z)),h(t,U),h(n,U)}}}function nn(b){let t,m,s,r;return t=new $({props:{id:"text-to-image",option:"Kandinsky 2.1",$$slots:{default:[tn]},$$scope:{ctx:b}}}),s=new $({props:{id:"text-to-image",option:"Kandinsky 2.2",$$slots:{default:[ln]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function an(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTElMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwYWxpZW4lMjBjaGVlc2VidXJnZXIlMjBjcmVhdHVyZSUyMGVhdGluZyUyMGl0c2VsZiUyQyUyMGNsYXltYXRpb24lMkMlMjBjaW5lbWF0aWMlMkMlMjBtb29keSUyMGxpZ2h0aW5nJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIybG93JTIwcXVhbGl0eSUyQyUyMGJhZCUyMHF1YWxpdHklMjIlMEElMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUzRHByb21wdCUyQyUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3Byb21wdCUyQyUyMHByaW9yX2d1aWRhbmNlX3NjYWxlJTNEMS4wJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q0LjAlMkMlMjBoZWlnaHQlM0Q3NjglMkMlMjB3aWR0aCUzRDc2OCkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, torch_dtype=torch.float16)
pipeline.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span>

image = pipeline(prompt=prompt, negative_prompt=negative_prompt, prior_guidance_scale=<span class="hljs-number">1.0</span>, guidance_scale=<span class="hljs-number">4.0</span>, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function pn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTItZGVjb2RlciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlbGluZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBhbGllbiUyMGNoZWVzZWJ1cmdlciUyMGNyZWF0dXJlJTIwZWF0aW5nJTIwaXRzZWxmJTJDJTIwY2xheW1hdGlvbiUyQyUyMGNpbmVtYXRpYyUyQyUyMG1vb2R5JTIwbGlnaHRpbmclMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAlMjJsb3clMjBxdWFsaXR5JTJDJTIwYmFkJTIwcXVhbGl0eSUyMiUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwcHJpb3JfZ3VpZGFuY2Vfc2NhbGUlM0QxLjAlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDQuMCUyQyUyMGhlaWdodCUzRDc2OCUyQyUyMHdpZHRoJTNENzY4KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder&quot;</span>, torch_dtype=torch.float16)
pipeline.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A alien cheeseburger creature eating itself, claymation, cinematic, moody lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span>

image = pipeline(prompt=prompt, negative_prompt=negative_prompt, prior_guidance_scale=<span class="hljs-number">1.0</span>, guidance_scale=<span class="hljs-number">4.0</span>, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function mn(b){let t,m,s,r;return t=new $({props:{id:"text-to-image",option:"Kandinsky 2.1",$$slots:{default:[an]},$$scope:{ctx:b}}}),s=new $({props:{id:"text-to-image",option:"Kandinsky 2.2",$$slots:{default:[pn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function rn(b){let t,m;return t=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS2FuZGluc2t5SW1nMkltZ1BpcGVsaW5lJTJDJTIwS2FuZGluc2t5UHJpb3JQaXBlbGluZSUwQSUwQXByaW9yX3BpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5UHJpb3JQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTEtcHJpb3IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5SW1nMkltZ1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyImg2ImgPipeline, KandinskyPriorPipeline

prior_pipeline = KandinskyPriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyImg2ImgPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function on(b){let t,m;return t=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS2FuZGluc2t5VjIySW1nMkltZ1BpcGVsaW5lJTJDJTIwS2FuZGluc2t5UHJpb3JQaXBlbGluZSUwQSUwQXByaW9yX3BpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5UHJpb3JQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTItcHJpb3IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5VjIySW1nMkltZ1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1kZWNvZGVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22Img2ImgPipeline, KandinskyPriorPipeline

prior_pipeline = KandinskyPriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyV22Img2ImgPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function cn(b){let t,m,s,r;return t=new $({props:{id:"image-to-image",option:"Kandinsky 2.1",$$slots:{default:[rn]},$$scope:{ctx:b}}}),s=new $({props:{id:"image-to-image",option:"Kandinsky 2.2",$$slots:{default:[on]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function dn(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-docs/img2img_fantasyland.png"/>',l;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMG1ha2VfaW1hZ2VfZ3JpZCUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwaW1hZ2UlM0RvcmlnaW5hbF9pbWFnZSUyQyUyMGltYWdlX2VtYmVkcyUzRGltYWdlX2VtYmVkcyUyQyUyMG5lZ2F0aXZlX2ltYWdlX2VtYmVkcyUzRG5lZ2F0aXZlX2ltYWdlX2VtYmVkcyUyQyUyMGhlaWdodCUzRDc2OCUyQyUyMHdpZHRoJTNENzY4JTJDJTIwc3RyZW5ndGglM0QwLjMpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCb3JpZ2luYWxfaW1hZ2UucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUyQyUyMGltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid

image = pipeline(prompt, negative_prompt=negative_prompt, image=original_image, image_embeds=image_embeds, negative_image_embeds=negative_image_embeds, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>, strength=<span class="hljs-number">0.3</span>).images[<span class="hljs-number">0</span>]
make_image_grid([original_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)), image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-1vh4dwd"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function yn(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-image-to-image.png"/>',l;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMG1ha2VfaW1hZ2VfZ3JpZCUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoaW1hZ2UlM0RvcmlnaW5hbF9pbWFnZSUyQyUyMGltYWdlX2VtYmVkcyUzRGltYWdlX2VtYmVkcyUyQyUyMG5lZ2F0aXZlX2ltYWdlX2VtYmVkcyUzRG5lZ2F0aXZlX2ltYWdlX2VtYmVkcyUyQyUyMGhlaWdodCUzRDc2OCUyQyUyMHdpZHRoJTNENzY4JTJDJTIwc3RyZW5ndGglM0QwLjMpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCb3JpZ2luYWxfaW1hZ2UucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUyQyUyMGltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid

image = pipeline(image=original_image, image_embeds=image_embeds, negative_image_embeds=negative_image_embeds, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>, strength=<span class="hljs-number">0.3</span>).images[<span class="hljs-number">0</span>]
make_image_grid([original_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)), image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-1vux4a0"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function un(b){let t,m,s,r;return t=new $({props:{id:"image-to-image",option:"Kandinsky 2.1",$$slots:{default:[dn]},$$scope:{ctx:b}}}),s=new $({props:{id:"image-to-image",option:"Kandinsky 2.2",$$slots:{default:[yn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function Mn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMG1ha2VfaW1hZ2VfZ3JpZCUyQyUyMGxvYWRfaW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSklMEFwaXBlbGluZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBmYW50YXN5JTIwbGFuZHNjYXBlJTJDJTIwQ2luZW1hdGljJTIwbGlnaHRpbmclMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAlMjJsb3clMjBxdWFsaXR5JTJDJTIwYmFkJTIwcXVhbGl0eSUyMiUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSUyRkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uJTJGbWFpbiUyRmFzc2V0cyUyRnN0YWJsZS1zYW1wbGVzJTJGaW1nMmltZyUyRnNrZXRjaC1tb3VudGFpbnMtaW5wdXQuanBnJTIyJTBBb3JpZ2luYWxfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKHVybCklMEElMEFvcmlnaW5hbF9pbWFnZS50aHVtYm5haWwoKDc2OCUyQyUyMDc2OCkpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBuZWdhdGl2ZV9wcm9tcHQlM0RuZWdhdGl2ZV9wcm9tcHQlMkMlMjBpbWFnZSUzRG9yaWdpbmFsX2ltYWdlJTJDJTIwc3RyZW5ndGglM0QwLjMpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCb3JpZ2luYWxfaW1hZ2UucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUyQyUyMGltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid, load_image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForImage2Image.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
pipeline.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A fantasy landscape, Cinematic lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span>

url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
original_image = load_image(url)

original_image.thumbnail((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

image = pipeline(prompt=prompt, negative_prompt=negative_prompt, image=original_image, strength=<span class="hljs-number">0.3</span>).images[<span class="hljs-number">0</span>]
make_image_grid([original_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)), image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function fn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMG1ha2VfaW1hZ2VfZ3JpZCUyQyUyMGxvYWRfaW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLWRlY29kZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwZmFudGFzeSUyMGxhbmRzY2FwZSUyQyUyMENpbmVtYXRpYyUyMGxpZ2h0aW5nJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIybG93JTIwcXVhbGl0eSUyQyUyMGJhZCUyMHF1YWxpdHklMjIlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZDb21wVmlzJTJGc3RhYmxlLWRpZmZ1c2lvbiUyRm1haW4lMkZhc3NldHMlMkZzdGFibGUtc2FtcGxlcyUyRmltZzJpbWclMkZza2V0Y2gtbW91bnRhaW5zLWlucHV0LmpwZyUyMiUwQW9yaWdpbmFsX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSh1cmwpJTBBJTBBb3JpZ2luYWxfaW1hZ2UudGh1bWJuYWlsKCg3NjglMkMlMjA3NjgpKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwaW1hZ2UlM0RvcmlnaW5hbF9pbWFnZSUyQyUyMHN0cmVuZ3RoJTNEMC4zKS5pbWFnZXMlNUIwJTVEJTBBbWFrZV9pbWFnZV9ncmlkKCU1Qm9yaWdpbmFsX2ltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMkMlMjBpbWFnZS5yZXNpemUoKDUxMiUyQyUyMDUxMikpJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid, load_image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForImage2Image.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder&quot;</span>, torch_dtype=torch.float16)
pipeline.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A fantasy landscape, Cinematic lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span>

url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
original_image = load_image(url)

original_image.thumbnail((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

image = pipeline(prompt=prompt, negative_prompt=negative_prompt, image=original_image, strength=<span class="hljs-number">0.3</span>).images[<span class="hljs-number">0</span>]
make_image_grid([original_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)), image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function hn(b){let t,m,s,r;return t=new $({props:{id:"image-to-image",option:"Kandinsky 2.1",$$slots:{default:[Mn]},$$scope:{ctx:b}}}),s=new $({props:{id:"image-to-image",option:"Kandinsky 2.2",$$slots:{default:[fn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function Jn(b){let t,m='⚠️ The Kandinsky models use ⬜️ <strong>white pixels</strong> to represent the masked area now instead of black pixels. If you are using <a href="/docs/diffusers/main/en/api/pipelines/kandinsky#diffusers.KandinskyInpaintPipeline">KandinskyInpaintPipeline</a> in production, you need to change the mask to use white pixels:',s,r,l;return r=new T({props:{code:"JTIzJTIwRm9yJTIwUElMJTIwaW5wdXQlMEFpbXBvcnQlMjBQSUwuSW1hZ2VPcHMlMEFtYXNrJTIwJTNEJTIwUElMLkltYWdlT3BzLmludmVydChtYXNrKSUwQSUwQSUyMyUyMEZvciUyMFB5VG9yY2glMjBhbmQlMjBOdW1QeSUyMGlucHV0JTBBbWFzayUyMCUzRCUyMDElMjAtJTIwbWFzaw==",highlighted:`<span class="hljs-comment"># For PIL input</span>
<span class="hljs-keyword">import</span> PIL.ImageOps
mask = PIL.ImageOps.invert(mask)

<span class="hljs-comment"># For PyTorch and NumPy input</span>
mask = <span class="hljs-number">1</span> - mask`,wrap:!1}}),{c(){t=g("p"),t.innerHTML=m,s=o(),d(r.$$.fragment)},l(n){t=k(n,"P",{"data-svelte-h":!0}),w(t)!=="svelte-nmwstu"&&(t.innerHTML=m),s=c(n),y(r.$$.fragment,n)},m(n,J){p(n,t,J),p(n,s,J),u(r,n,J),l=!0},p:j,i(n){l||(M(r.$$.fragment,n),l=!0)},o(n){f(r.$$.fragment,n),l=!1},d(n){n&&(i(t),i(s)),h(r,n)}}}function bn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreUlucGFpbnRQaXBlbGluZSUyQyUyMEthbmRpbnNreVByaW9yUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUyQyUyMG1ha2VfaW1hZ2VfZ3JpZCUwQWltcG9ydCUyMHRvcmNoJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBcHJpb3JfcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lQcmlvclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMS1wcmlvciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lJbnBhaW50UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xLWlucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyInpaintPipeline, KandinskyPriorPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

prior_pipeline = KandinskyPriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyInpaintPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-inpaint&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function gn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVYyMklucGFpbnRQaXBlbGluZSUyQyUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUyQyUyMG1ha2VfaW1hZ2VfZ3JpZCUwQWltcG9ydCUyMHRvcmNoJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBcHJpb3JfcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lWMjJQcmlvclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1wcmlvciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lWMjJJbnBhaW50UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLWRlY29kZXItaW5wYWludCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22InpaintPipeline, KandinskyV22PriorPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

prior_pipeline = KandinskyV22PriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline = KandinskyV22InpaintPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder-inpaint&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function kn(b){let t,m,s,r;return t=new $({props:{id:"inpaint",option:"Kandinsky 2.1",$$slots:{default:[bn]},$$scope:{ctx:b}}}),s=new $({props:{id:"inpaint",option:"Kandinsky 2.2",$$slots:{default:[gn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function wn(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-docs/inpaint_cat_hat.png"/>',l;return t=new T({props:{code:"b3V0cHV0X2ltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2slMkMlMjAqKnByaW9yX291dHB1dCUyQyUyMGhlaWdodCUzRDc2OCUyQyUyMHdpZHRoJTNENzY4JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDE1MCkuaW1hZ2VzJTVCMCU1RCUwQW1hc2slMjAlM0QlMjBJbWFnZS5mcm9tYXJyYXkoKG1hc2sqMjU1KS5hc3R5cGUoJ3VpbnQ4JyklMkMlMjAnTCcpJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBtYXNrJTJDJTIwb3V0cHV0X2ltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMyk=",highlighted:`output_image = pipeline(prompt, image=init_image, mask_image=mask, **prior_output, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>, num_inference_steps=<span class="hljs-number">150</span>).images[<span class="hljs-number">0</span>]
mask = Image.fromarray((mask*<span class="hljs-number">255</span>).astype(<span class="hljs-string">&#x27;uint8&#x27;</span>), <span class="hljs-string">&#x27;L&#x27;</span>)
make_image_grid([init_image, mask, output_image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-1d04i1f"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function Un(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinskyv22-inpaint.png"/>',l;return t=new T({props:{code:"b3V0cHV0X2ltYWdlJTIwJTNEJTIwcGlwZWxpbmUoaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2slMkMlMjAqKnByaW9yX291dHB1dCUyQyUyMGhlaWdodCUzRDc2OCUyQyUyMHdpZHRoJTNENzY4JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDE1MCkuaW1hZ2VzJTVCMCU1RCUwQW1hc2slMjAlM0QlMjBJbWFnZS5mcm9tYXJyYXkoKG1hc2sqMjU1KS5hc3R5cGUoJ3VpbnQ4JyklMkMlMjAnTCcpJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBtYXNrJTJDJTIwb3V0cHV0X2ltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMyk=",highlighted:`output_image = pipeline(image=init_image, mask_image=mask, **prior_output, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>, num_inference_steps=<span class="hljs-number">150</span>).images[<span class="hljs-number">0</span>]
mask = Image.fromarray((mask*<span class="hljs-number">255</span>).astype(<span class="hljs-string">&#x27;uint8&#x27;</span>), <span class="hljs-string">&#x27;L&#x27;</span>)
make_image_grid([init_image, mask, output_image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-1ajezuw"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function Zn(b){let t,m,s,r;return t=new $({props:{id:"inpaint",option:"Kandinsky 2.1",$$slots:{default:[wn]},$$scope:{ctx:b}}}),s=new $({props:{id:"inpaint",option:"Kandinsky 2.2",$$slots:{default:[Un]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function Tn(b){let t,m;return t=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZSUyMCUzRCUyMEF1dG9QaXBlbGluZUZvcklucGFpbnRpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xLWlucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUwQWluaXRfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZrYW5kaW5za3klMkZjYXQucG5nJTIyKSUwQW1hc2slMjAlM0QlMjBucC56ZXJvcygoNzY4JTJDJTIwNzY4KSUyQyUyMGR0eXBlJTNEbnAuZmxvYXQzMiklMEElMjMlMjBtYXNrJTIwYXJlYSUyMGFib3ZlJTIwY2F0J3MlMjBoZWFkJTBBbWFzayU1QiUzQTI1MCUyQyUyMDI1MCUzQS0yNTAlNUQlMjAlM0QlMjAxJTBBcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGhhdCUyMiUwQSUwQW91dHB1dF9pbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2spLmltYWdlcyU1QjAlNUQlMEFtYXNrJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KChtYXNrKjI1NSkuYXN0eXBlKCd1aW50OCcpJTJDJTIwJ0wnKSUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbml0X2ltYWdlJTJDJTIwbWFzayUyQyUyMG91dHB1dF9pbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDMp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipe = AutoPipelineForInpainting.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-inpaint&quot;</span>, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload()

init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png&quot;</span>)
mask = np.zeros((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>), dtype=np.float32)
<span class="hljs-comment"># mask area above cat&#x27;s head</span>
mask[:<span class="hljs-number">250</span>, <span class="hljs-number">250</span>:-<span class="hljs-number">250</span>] = <span class="hljs-number">1</span>
prompt = <span class="hljs-string">&quot;a hat&quot;</span>

output_image = pipe(prompt=prompt, image=init_image, mask_image=mask).images[<span class="hljs-number">0</span>]
mask = Image.fromarray((mask*<span class="hljs-number">255</span>).astype(<span class="hljs-string">&#x27;uint8&#x27;</span>), <span class="hljs-string">&#x27;L&#x27;</span>)
make_image_grid([init_image, mask, output_image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function Wn(b){let t,m;return t=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZSUyMCUzRCUyMEF1dG9QaXBlbGluZUZvcklucGFpbnRpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLWRlY29kZXItaW5wYWludCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTBBaW5pdF9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmthbmRpbnNreSUyRmNhdC5wbmclMjIpJTBBbWFzayUyMCUzRCUyMG5wLnplcm9zKCg3NjglMkMlMjA3NjgpJTJDJTIwZHR5cGUlM0RucC5mbG9hdDMyKSUwQSUyMyUyMG1hc2slMjBhcmVhJTIwYWJvdmUlMjBjYXQncyUyMGhlYWQlMEFtYXNrJTVCJTNBMjUwJTJDJTIwMjUwJTNBLTI1MCU1RCUyMCUzRCUyMDElMEFwcm9tcHQlMjAlM0QlMjAlMjJhJTIwaGF0JTIyJTBBJTBBb3V0cHV0X2ltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRG9yaWdpbmFsX2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2spLmltYWdlcyU1QjAlNUQlMEFtYXNrJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KChtYXNrKjI1NSkuYXN0eXBlKCd1aW50OCcpJTJDJTIwJ0wnKSUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbml0X2ltYWdlJTJDJTIwbWFzayUyQyUyMG91dHB1dF9pbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDMp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipe = AutoPipelineForInpainting.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder-inpaint&quot;</span>, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload()

init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png&quot;</span>)
mask = np.zeros((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>), dtype=np.float32)
<span class="hljs-comment"># mask area above cat&#x27;s head</span>
mask[:<span class="hljs-number">250</span>, <span class="hljs-number">250</span>:-<span class="hljs-number">250</span>] = <span class="hljs-number">1</span>
prompt = <span class="hljs-string">&quot;a hat&quot;</span>

output_image = pipe(prompt=prompt, image=original_image, mask_image=mask).images[<span class="hljs-number">0</span>]
mask = Image.fromarray((mask*<span class="hljs-number">255</span>).astype(<span class="hljs-string">&#x27;uint8&#x27;</span>), <span class="hljs-string">&#x27;L&#x27;</span>)
make_image_grid([init_image, mask, output_image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function jn(b){let t,m,s,r;return t=new $({props:{id:"inpaint",option:"Kandinsky 2.1",$$slots:{default:[Tn]},$$scope:{ctx:b}}}),s=new $({props:{id:"inpaint",option:"Kandinsky 2.2",$$slots:{default:[Wn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function $n(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVByaW9yUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwcmlvcl9waXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVByaW9yUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xLXByaW9yJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMiklMEFpbWdfMSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmthbmRpbnNreSUyRmNhdC5wbmclMjIpJTBBaW1nXzIlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZrYW5kaW5za3klMkZzdGFycnlfbmlnaHQuanBlZyUyMiklMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW1nXzEucmVzaXplKCg1MTIlMkM1MTIpKSUyQyUyMGltZ18yLnJlc2l6ZSgoNTEyJTJDNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyPriorPipeline, KandinskyPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid
<span class="hljs-keyword">import</span> torch

prior_pipeline = KandinskyPriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
img_1 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png&quot;</span>)
img_2 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/starry_night.jpeg&quot;</span>)
make_image_grid([img_1.resize((<span class="hljs-number">512</span>,<span class="hljs-number">512</span>)), img_2.resize((<span class="hljs-number">512</span>,<span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function Gn(b){let t,m;return t=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lWMjJQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwcmlvcl9waXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLXByaW9yJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMiklMEFpbWdfMSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmthbmRpbnNreSUyRmNhdC5wbmclMjIpJTBBaW1nXzIlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZrYW5kaW5za3klMkZzdGFycnlfbmlnaHQuanBlZyUyMiklMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW1nXzEucmVzaXplKCg1MTIlMkM1MTIpKSUyQyUyMGltZ18yLnJlc2l6ZSgoNTEyJTJDNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22PriorPipeline, KandinskyV22Pipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid
<span class="hljs-keyword">import</span> torch

prior_pipeline = KandinskyV22PriorPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
img_1 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png&quot;</span>)
img_2 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/starry_night.jpeg&quot;</span>)
make_image_grid([img_1.resize((<span class="hljs-number">512</span>,<span class="hljs-number">512</span>)), img_2.resize((<span class="hljs-number">512</span>,<span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){d(t.$$.fragment)},l(s){y(t.$$.fragment,s)},m(s,r){u(t,s,r),m=!0},p:j,i(s){m||(M(t.$$.fragment,s),m=!0)},o(s){f(t.$$.fragment,s),m=!1},d(s){h(t,s)}}}function In(b){let t,m,s,r;return t=new $({props:{id:"interpolate",option:"Kandinsky 2.1",$$slots:{default:[$n]},$$scope:{ctx:b}}}),s=new $({props:{id:"interpolate",option:"Kandinsky 2.2",$$slots:{default:[Gn]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function Vn(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinsky-docs/starry_cat.png"/>',l;return t=new T({props:{code:"JTIzJTIwcHJvbXB0JTIwY2FuJTIwYmUlMjBsZWZ0JTIwZW1wdHklMEFwcm9tcHQlMjAlM0QlMjAlMjIlMjIlMEFwcmlvcl9vdXQlMjAlM0QlMjBwcmlvcl9waXBlbGluZS5pbnRlcnBvbGF0ZShpbWFnZXNfdGV4dHMlMkMlMjB3ZWlnaHRzKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUyQyUyMCoqcHJpb3Jfb3V0JTJDJTIwaGVpZ2h0JTNENzY4JTJDJTIwd2lkdGglM0Q3NjgpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-comment"># prompt can be left empty</span>
prompt = <span class="hljs-string">&quot;&quot;</span>
prior_out = prior_pipeline.interpolate(images_texts, weights)

pipeline = KandinskyPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipeline(prompt, **prior_out, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-twgci5"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function _n(b){let t,m,s,r='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/kandinskyv22-interpolate.png"/>',l;return t=new T({props:{code:"JTIzJTIwcHJvbXB0JTIwY2FuJTIwYmUlMjBsZWZ0JTIwZW1wdHklMEFwcm9tcHQlMjAlM0QlMjAlMjIlMjIlMEFwcmlvcl9vdXQlMjAlM0QlMjBwcmlvcl9waXBlbGluZS5pbnRlcnBvbGF0ZShpbWFnZXNfdGV4dHMlMkMlMjB3ZWlnaHRzKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5VjIyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLWRlY29kZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwKipwcmlvcl9vdXQlMkMlMjBoZWlnaHQlM0Q3NjglMkMlMjB3aWR0aCUzRDc2OCkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`<span class="hljs-comment"># prompt can be left empty</span>
prompt = <span class="hljs-string">&quot;&quot;</span>
prior_out = prior_pipeline.interpolate(images_texts, weights)

pipeline = KandinskyV22Pipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipeline(prompt, **prior_out, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){d(t.$$.fragment),m=o(),s=g("div"),s.innerHTML=r,this.h()},l(n){y(t.$$.fragment,n),m=c(n),s=k(n,"DIV",{class:!0,"data-svelte-h":!0}),w(s)!=="svelte-2ur4ou"&&(s.innerHTML=r),this.h()},h(){G(s,"class","flex justify-center")},m(n,J){u(t,n,J),p(n,m,J),p(n,s,J),l=!0},p:j,i(n){l||(M(t.$$.fragment,n),l=!0)},o(n){f(t.$$.fragment,n),l=!1},d(n){n&&(i(m),i(s)),h(t,n)}}}function Bn(b){let t,m,s,r;return t=new $({props:{id:"interpolate",option:"Kandinsky 2.1",$$slots:{default:[Vn]},$$scope:{ctx:b}}}),s=new $({props:{id:"interpolate",option:"Kandinsky 2.2",$$slots:{default:[_n]},$$scope:{ctx:b}}}),{c(){d(t.$$.fragment),m=o(),d(s.$$.fragment)},l(l){y(t.$$.fragment,l),m=c(l),y(s.$$.fragment,l)},m(l,n){u(t,l,n),p(l,m,n),u(s,l,n),r=!0},p(l,n){const J={};n&2&&(J.$$scope={dirty:n,ctx:l}),t.$set(J);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:l}),s.$set(Z)},i(l){r||(M(t.$$.fragment,l),M(s.$$.fragment,l),r=!0)},o(l){f(t.$$.fragment,l),f(s.$$.fragment,l),r=!1},d(l){l&&i(m),h(t,l),h(s,l)}}}function Xn(b){let t,m="⚠️ ControlNet is only supported for Kandinsky 2.2!";return{c(){t=g("p"),t.textContent=m},l(s){t=k(s,"P",{"data-svelte-h":!0}),w(t)!=="svelte-ms5sxh"&&(t.textContent=m)},m(s,r){p(s,t,r)},p:j,d(s){s&&i(t)}}}function Rn(b){let t,m,s,r,l,n,J,Z,I,V="The Kandinsky models are a series of multilingual text-to-image generation models. The Kandinsky 2.0 model uses two multilingual text encoders and concatenates those results for the UNet.",U,W,zt='<a href="../api/pipelines/kandinsky">Kandinsky 2.1</a> changes the architecture to include an image prior model (<a href="https://huggingface.co/docs/transformers/model_doc/clip" rel="nofollow"><code>CLIP</code></a>) to generate a mapping between text and image embeddings. The mapping provides better text-image alignment and it is used with the text embeddings during training, leading to higher quality results. Finally, Kandinsky 2.1 uses a <a href="https://huggingface.co/papers/2209.09002" rel="nofollow">Modulating Quantized Vectors (MoVQ)</a> decoder - which adds a spatial conditional normalization layer to increase photorealism - to decode the latents into images.',cs,se,xt='<a href="../api/pipelines/kandinsky_v22">Kandinsky 2.2</a> improves on the previous model by replacing the image encoder of the image prior model with a larger CLIP-ViT-G model to improve quality. The image prior model was also retrained on images with different resolutions and aspect ratios to generate higher-resolution images and different image sizes.',ds,te,Et="This guide will show you how to use the Kandinsky models for text-to-image, image-to-image, inpainting, interpolation, and more.",ys,le,Kt="Before you begin, make sure you have the following libraries installed:",us,ne,Ms,X,fs,ae,hs,ie,qt="To use the Kandinsky models for any task, you always start by setting up the prior pipeline to encode the prompt and generate the image embeddings. The prior pipeline also generates <code>negative_image_embeds</code> that correspond to the negative prompt <code>&quot;&quot;</code>. For better results, you can pass an actual <code>negative_prompt</code> to the prior pipeline, but this’ll increase the effective batch size of the prior pipeline by 2x.",Js,R,bs,pe,Lt='🤗 Diffusers also provides an end-to-end API with the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky#diffusers.KandinskyCombinedPipeline">KandinskyCombinedPipeline</a> and <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22CombinedPipeline">KandinskyV22CombinedPipeline</a>, meaning you don’t have to separately load the prior and text-to-image pipeline. The combined pipeline automatically loads both the prior model and the decoder. You can still set different values for the prior pipeline with the <code>prior_guidance_scale</code> and <code>prior_num_inference_steps</code> parameters if you want.',gs,me,Dt='Use the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image">AutoPipelineForText2Image</a> to automatically call the combined pipelines under the hood:',ks,v,ws,re,Us,oe,Pt="For image-to-image, pass the initial image and text prompt to condition the image to the pipeline. Start by loading the prior pipeline:",Zs,C,Ts,ce,At="Download an image to condition on:",Ws,de,js,Y,Ot='<img class="rounded-xl" src="https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"/>',$s,ye,el="Generate the <code>image_embeds</code> and <code>negative_image_embeds</code> with the prior pipeline:",Gs,ue,Is,Me,sl="Now pass the original image, and all the prompts and embeddings to the pipeline to generate an image:",Vs,Q,_s,fe,tl='🤗 Diffusers also provides an end-to-end API with the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky#diffusers.KandinskyImg2ImgCombinedPipeline">KandinskyImg2ImgCombinedPipeline</a> and <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22Img2ImgCombinedPipeline">KandinskyV22Img2ImgCombinedPipeline</a>, meaning you don’t have to separately load the prior and image-to-image pipeline. The combined pipeline automatically loads both the prior model and the decoder. You can still set different values for the prior pipeline with the <code>prior_guidance_scale</code> and <code>prior_num_inference_steps</code> parameters if you want.',Bs,he,ll='Use the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image">AutoPipelineForImage2Image</a> to automatically call the combined pipelines under the hood:',Xs,F,Rs,Je,vs,H,Cs,be,nl="For inpainting, you’ll need the original image, a mask of the area to replace in the original image, and a text prompt of what to inpaint. Load the prior pipeline:",Ys,N,Qs,ge,al="Load an initial image and create a mask:",Fs,ke,Hs,we,il="Generate the embeddings with the prior pipeline:",Ns,Ue,Ss,Ze,pl="Now pass the initial image, mask, and prompt and embeddings to the pipeline to generate an image:",zs,S,xs,Te,ml='You can also use the end-to-end <a href="/docs/diffusers/main/en/api/pipelines/kandinsky#diffusers.KandinskyInpaintCombinedPipeline">KandinskyInpaintCombinedPipeline</a> and <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22InpaintCombinedPipeline">KandinskyV22InpaintCombinedPipeline</a> to call the prior and decoder pipelines together under the hood. Use the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting">AutoPipelineForInpainting</a> for this:',Es,z,Ks,We,qs,je,rl="Interpolation allows you to explore the latent space between the image and text embeddings which is a cool way to see some of the prior model’s intermediate outputs. Load the prior pipeline and two images you’d like to interpolate:",Ls,x,Ds,E,ol='<div><img class="rounded-xl" src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">a cat</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/starry_night.jpeg"/> <figcaption class="mt-2 text-center text-sm text-gray-500">Van Gogh&#39;s Starry Night painting</figcaption></div>',Ps,$e,cl="Specify the text or images to interpolate, and set the weights for each text or image. Experiment with the weights to see how they affect the interpolation!",As,Ge,Os,Ie,dl="Call the <code>interpolate</code> function to generate the embeddings, and then pass them to the pipeline to generate the image:",et,K,st,Ve,tt,q,lt,_e,yl="ControlNet enables conditioning large pretrained diffusion models with additional inputs such as a depth map or edge detection. For example, you can condition Kandinsky 2.2 with a depth map so the model understands and preserves the structure of the depth image.",nt,Be,ul="Let’s load an image and extract it’s depth map:",at,Xe,it,L,Ml='<img class="rounded-xl" src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinskyv22/cat.png"/>',pt,Re,fl='Then you can use the <code>depth-estimation</code> <a href="https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline" rel="nofollow">Pipeline</a> from 🤗 Transformers to process the image and retrieve the depth map:',mt,ve,rt,Ce,ot,Ye,hl='Load the prior pipeline and the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22ControlnetPipeline">KandinskyV22ControlnetPipeline</a>:',ct,Qe,dt,Fe,Jl="Generate the image embeddings from a prompt and negative prompt:",yt,He,ut,Ne,bl='Finally, pass the image embeddings and the depth image to the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22ControlnetPipeline">KandinskyV22ControlnetPipeline</a> to generate an image:',Mt,Se,ft,D,gl='<img class="rounded-xl" src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinskyv22/robot_cat_text2img.png"/>',ht,ze,Jt,xe,kl="For image-to-image with ControlNet, you’ll need to use the:",bt,Ee,wl='<li><a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22PriorEmb2EmbPipeline">KandinskyV22PriorEmb2EmbPipeline</a> to generate the image embeddings from a text prompt and an image</li> <li><a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22ControlnetImg2ImgPipeline">KandinskyV22ControlnetImg2ImgPipeline</a> to generate an image from the initial image and the image embeddings</li>',gt,Ke,Ul='Process and extract a depth map of an initial image of a cat with the <code>depth-estimation</code> <a href="https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline" rel="nofollow">Pipeline</a> from 🤗 Transformers:',kt,qe,wt,Le,Zl='Load the prior pipeline and the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22ControlnetImg2ImgPipeline">KandinskyV22ControlnetImg2ImgPipeline</a>:',Ut,De,Zt,Pe,Tl="Pass a text prompt and the initial image to the prior pipeline to generate the image embeddings:",Tt,Ae,Wt,Oe,Wl='Now you can run the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22ControlnetImg2ImgPipeline">KandinskyV22ControlnetImg2ImgPipeline</a> to generate an image from the initial image and the image embeddings:',jt,es,$t,P,jl='<img class="rounded-xl" src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinskyv22/robot_cat.png"/>',Gt,ss,It,ts,$l="Kandinsky is unique because it requires a prior pipeline to generate the mappings, and a second pipeline to decode the latents into an image. Optimization efforts should be focused on the second pipeline because that is where the bulk of the computation is done. Here are some tips to improve Kandinsky during inference.",Vt,ls,Gl='<li>Enable <a href="../optimization/xformers">xFormers</a> if you’re using PyTorch &lt; 2.0:</li>',_t,ns,Bt,A,Il="<li>Enable <code>torch.compile</code> if you’re using PyTorch &gt;= 2.0 to automatically use scaled dot-product attention (SDPA):</li>",Xt,as,Rt,is,Vl='This is the same as explicitly setting the attention processor to use <a href="/docs/diffusers/main/en/api/attnprocessor#diffusers.models.attention_processor.AttnAddedKVProcessor2_0">AttnAddedKVProcessor2_0</a>:',vt,ps,Ct,O,_l='<li>Offload the model to the CPU with <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/gligen#diffusers.StableDiffusionGLIGENTextImagePipeline.enable_model_cpu_offload">enable_model_cpu_offload()</a> to avoid out-of-memory errors:</li>',Yt,ms,Qt,ee,Bl='<li>By default, the text-to-image pipeline uses the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> but you can replace it with another scheduler like <a href="/docs/diffusers/main/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a> to see how that affects the tradeoff between inference speed and image quality:</li>',Ft,rs,Ht,os,Nt;return l=new B({props:{title:"Kandinsky",local:"kandinsky",headingTag:"h1"}}),J=new en({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/kandinsky.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/kandinsky.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/kandinsky.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/kandinsky.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/kandinsky.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/kandinsky.ipynb"}]}}),ne=new T({props:{code:"JTIzJTIwdW5jb21tZW50JTIwdG8lMjBpbnN0YWxsJTIwdGhlJTIwbmVjZXNzYXJ5JTIwbGlicmFyaWVzJTIwaW4lMjBDb2xhYiUwQSUyMyFwaXAlMjBpbnN0YWxsJTIwLXElMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBhY2NlbGVyYXRl",highlighted:`<span class="hljs-comment"># uncomment to install the necessary libraries in Colab</span>
<span class="hljs-comment">#!pip install -q diffusers transformers accelerate</span>`,wrap:!1}}),X=new St({props:{warning:!0,$$slots:{default:[sn]},$$scope:{ctx:b}}}),ae=new B({props:{title:"Text-to-image",local:"text-to-image",headingTag:"h2"}}),R=new _({props:{id:"text-to-image",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[nn]},$$scope:{ctx:b}}}),v=new _({props:{id:"text-to-image",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[mn]},$$scope:{ctx:b}}}),re=new B({props:{title:"Image-to-image",local:"image-to-image",headingTag:"h2"}}),C=new _({props:{id:"image-to-image",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[cn]},$$scope:{ctx:b}}}),de=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEElMjMlMjBkb3dubG9hZCUyMGltYWdlJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGQ29tcFZpcyUyRnN0YWJsZS1kaWZmdXNpb24lMkZtYWluJTJGYXNzZXRzJTJGc3RhYmxlLXNhbXBsZXMlMkZpbWcyaW1nJTJGc2tldGNoLW1vdW50YWlucy1pbnB1dC5qcGclMjIlMEFvcmlnaW5hbF9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UodXJsKSUwQW9yaWdpbmFsX2ltYWdlJTIwJTNEJTIwb3JpZ2luYWxfaW1hZ2UucmVzaXplKCg3NjglMkMlMjA1MTIpKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

<span class="hljs-comment"># download image</span>
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
original_image = load_image(url)
original_image = original_image.resize((<span class="hljs-number">768</span>, <span class="hljs-number">512</span>))`,wrap:!1}}),ue=new T({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyQSUyMGZhbnRhc3klMjBsYW5kc2NhcGUlMkMlMjBDaW5lbWF0aWMlMjBsaWdodGluZyUyMiUwQW5lZ2F0aXZlX3Byb21wdCUyMCUzRCUyMCUyMmxvdyUyMHF1YWxpdHklMkMlMjBiYWQlMjBxdWFsaXR5JTIyJTBBJTBBaW1hZ2VfZW1iZWRzJTJDJTIwbmVnYXRpdmVfaW1hZ2VfZW1iZWRzJTIwJTNEJTIwcHJpb3JfcGlwZWxpbmUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0KS50b190dXBsZSgp",highlighted:`prompt = <span class="hljs-string">&quot;A fantasy landscape, Cinematic lighting&quot;</span>
negative_prompt = <span class="hljs-string">&quot;low quality, bad quality&quot;</span>

image_embeds, negative_image_embeds = prior_pipeline(prompt, negative_prompt).to_tuple()`,wrap:!1}}),Q=new _({props:{id:"image-to-image",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[un]},$$scope:{ctx:b}}}),F=new _({props:{id:"image-to-image",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[hn]},$$scope:{ctx:b}}}),Je=new B({props:{title:"Inpainting",local:"inpainting",headingTag:"h2"}}),H=new St({props:{warning:!0,$$slots:{default:[Jn]},$$scope:{ctx:b}}}),N=new _({props:{id:"inpaint",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[kn]},$$scope:{ctx:b}}}),ke=new T({props:{code:"aW5pdF9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmthbmRpbnNreSUyRmNhdC5wbmclMjIpJTBBbWFzayUyMCUzRCUyMG5wLnplcm9zKCg3NjglMkMlMjA3NjgpJTJDJTIwZHR5cGUlM0RucC5mbG9hdDMyKSUwQSUyMyUyMG1hc2slMjBhcmVhJTIwYWJvdmUlMjBjYXQncyUyMGhlYWQlMEFtYXNrJTVCJTNBMjUwJTJDJTIwMjUwJTNBLTI1MCU1RCUyMCUzRCUyMDE=",highlighted:`init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinsky/cat.png&quot;</span>)
mask = np.zeros((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>), dtype=np.float32)
<span class="hljs-comment"># mask area above cat&#x27;s head</span>
mask[:<span class="hljs-number">250</span>, <span class="hljs-number">250</span>:-<span class="hljs-number">250</span>] = <span class="hljs-number">1</span>`,wrap:!1}}),Ue=new T({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyYSUyMGhhdCUyMiUwQXByaW9yX291dHB1dCUyMCUzRCUyMHByaW9yX3BpcGVsaW5lKHByb21wdCk=",highlighted:`prompt = <span class="hljs-string">&quot;a hat&quot;</span>
prior_output = prior_pipeline(prompt)`,wrap:!1}}),S=new _({props:{id:"inpaint",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[Zn]},$$scope:{ctx:b}}}),z=new _({props:{id:"inpaint",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[jn]},$$scope:{ctx:b}}}),We=new B({props:{title:"Interpolation",local:"interpolation",headingTag:"h2"}}),x=new _({props:{id:"interpolate",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[In]},$$scope:{ctx:b}}}),Ge=new T({props:{code:"aW1hZ2VzX3RleHRzJTIwJTNEJTIwJTVCJTIyYSUyMGNhdCUyMiUyQyUyMGltZ18xJTJDJTIwaW1nXzIlNUQlMEF3ZWlnaHRzJTIwJTNEJTIwJTVCMC4zJTJDJTIwMC4zJTJDJTIwMC40JTVE",highlighted:`images_texts = [<span class="hljs-string">&quot;a cat&quot;</span>, img_1, img_2]
weights = [<span class="hljs-number">0.3</span>, <span class="hljs-number">0.3</span>, <span class="hljs-number">0.4</span>]`,wrap:!1}}),K=new _({props:{id:"interpolate",options:["Kandinsky 2.1","Kandinsky 2.2"],$$slots:{default:[Bn]},$$scope:{ctx:b}}}),Ve=new B({props:{title:"ControlNet",local:"controlnet",headingTag:"h2"}}),q=new St({props:{warning:!0,$$slots:{default:[Xn]},$$scope:{ctx:b}}}),Xe=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFpbWclMjAlM0QlMjBsb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZrYW5kaW5za3l2MjIlMkZjYXQucG5nJTIyJTBBKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkpJTBBaW1n",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

img = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinskyv22/cat.png&quot;</span>
).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))
img`,wrap:!1}}),ve=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEElMEFkZWYlMjBtYWtlX2hpbnQoaW1hZ2UlMkMlMjBkZXB0aF9lc3RpbWF0b3IpJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBkZXB0aF9lc3RpbWF0b3IoaW1hZ2UpJTVCJTIyZGVwdGglMjIlNUQlMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMG5wLmFycmF5KGltYWdlKSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwaW1hZ2UlNUIlM0ElMkMlMjAlM0ElMkMlMjBOb25lJTVEJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBucC5jb25jYXRlbmF0ZSglNUJpbWFnZSUyQyUyMGltYWdlJTJDJTIwaW1hZ2UlNUQlMkMlMjBheGlzJTNEMiklMEElMjAlMjAlMjAlMjBkZXRlY3RlZF9tYXAlMjAlM0QlMjB0b3JjaC5mcm9tX251bXB5KGltYWdlKS5mbG9hdCgpJTIwJTJGJTIwMjU1LjAlMEElMjAlMjAlMjAlMjBoaW50JTIwJTNEJTIwZGV0ZWN0ZWRfbWFwLnBlcm11dGUoMiUyQyUyMDAlMkMlMjAxKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGhpbnQlMEElMEFkZXB0aF9lc3RpbWF0b3IlMjAlM0QlMjBwaXBlbGluZSglMjJkZXB0aC1lc3RpbWF0aW9uJTIyKSUwQWhpbnQlMjAlM0QlMjBtYWtlX2hpbnQoaW1nJTJDJTIwZGVwdGhfZXN0aW1hdG9yKS51bnNxdWVlemUoMCkuaGFsZigpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-keyword">def</span> <span class="hljs-title function_">make_hint</span>(<span class="hljs-params">image, depth_estimator</span>):
    image = depth_estimator(image)[<span class="hljs-string">&quot;depth&quot;</span>]
    image = np.array(image)
    image = image[:, :, <span class="hljs-literal">None</span>]
    image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>)
    detected_map = torch.from_numpy(image).<span class="hljs-built_in">float</span>() / <span class="hljs-number">255.0</span>
    hint = detected_map.permute(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>)
    <span class="hljs-keyword">return</span> hint

depth_estimator = pipeline(<span class="hljs-string">&quot;depth-estimation&quot;</span>)
hint = make_hint(img, depth_estimator).unsqueeze(<span class="hljs-number">0</span>).half().to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),Ce=new B({props:{title:"Text-to-image",local:"controlnet-text-to-image",headingTag:"h3"}}),Qe=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lWMjJDb250cm9sbmV0UGlwZWxpbmUlMEElMEFwcmlvcl9waXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVYyMlByaW9yUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0yLXByaW9yJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlbGluZSUyMCUzRCUyMEthbmRpbnNreVYyMkNvbnRyb2xuZXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTItY29udHJvbG5ldC1kZXB0aCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22PriorPipeline, KandinskyV22ControlnetPipeline

prior_pipeline = KandinskyV22PriorPipeline.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline = KandinskyV22ControlnetPipeline.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-controlnet-depth&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),He=new T({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyQSUyMHJvYm90JTJDJTIwNGslMjBwaG90byUyMiUwQW5lZ2F0aXZlX3ByaW9yX3Byb21wdCUyMCUzRCUyMCUyMmxvd3JlcyUyQyUyMHRleHQlMkMlMjBlcnJvciUyQyUyMGNyb3BwZWQlMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBsb3clMjBxdWFsaXR5JTJDJTIwanBlZyUyMGFydGlmYWN0cyUyQyUyMHVnbHklMkMlMjBkdXBsaWNhdGUlMkMlMjBtb3JiaWQlMkMlMjBtdXRpbGF0ZWQlMkMlMjBvdXQlMjBvZiUyMGZyYW1lJTJDJTIwZXh0cmElMjBmaW5nZXJzJTJDJTIwbXV0YXRlZCUyMGhhbmRzJTJDJTIwcG9vcmx5JTIwZHJhd24lMjBoYW5kcyUyQyUyMHBvb3JseSUyMGRyYXduJTIwZmFjZSUyQyUyMG11dGF0aW9uJTJDJTIwZGVmb3JtZWQlMkMlMjBibHVycnklMkMlMjBkZWh5ZHJhdGVkJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMGJhZCUyMHByb3BvcnRpb25zJTJDJTIwZXh0cmElMjBsaW1icyUyQyUyMGNsb25lZCUyMGZhY2UlMkMlMjBkaXNmaWd1cmVkJTJDJTIwZ3Jvc3MlMjBwcm9wb3J0aW9ucyUyQyUyMG1hbGZvcm1lZCUyMGxpbWJzJTJDJTIwbWlzc2luZyUyMGFybXMlMkMlMjBtaXNzaW5nJTIwbGVncyUyQyUyMGV4dHJhJTIwYXJtcyUyQyUyMGV4dHJhJTIwbGVncyUyQyUyMGZ1c2VkJTIwZmluZ2VycyUyQyUyMHRvbyUyMG1hbnklMjBmaW5nZXJzJTJDJTIwbG9uZyUyMG5lY2slMkMlMjB1c2VybmFtZSUyQyUyMHdhdGVybWFyayUyQyUyMHNpZ25hdHVyZSUyMiUwQSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjdWRhJTIyKS5tYW51YWxfc2VlZCg0MyklMEElMEFpbWFnZV9lbWIlMkMlMjB6ZXJvX2ltYWdlX2VtYiUyMCUzRCUyMHByaW9yX3BpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3ByaW9yX3Byb21wdCUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUwQSkudG9fdHVwbGUoKQ==",highlighted:`prompt = <span class="hljs-string">&quot;A robot, 4k photo&quot;</span>
negative_prior_prompt = <span class="hljs-string">&quot;lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature&quot;</span>

generator = torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">43</span>)

image_emb, zero_image_emb = prior_pipeline(
    prompt=prompt, negative_prompt=negative_prior_prompt, generator=generator
).to_tuple()`,wrap:!1}}),Se=new T({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShpbWFnZV9lbWJlZHMlM0RpbWFnZV9lbWIlMkMlMjBuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlM0R6ZXJvX2ltYWdlX2VtYiUyQyUyMGhpbnQlM0RoaW50JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwaGVpZ2h0JTNENzY4JTJDJTIwd2lkdGglM0Q3NjgpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`image = pipeline(image_embeds=image_emb, negative_image_embeds=zero_image_emb, hint=hint, num_inference_steps=<span class="hljs-number">50</span>, generator=generator, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),ze=new B({props:{title:"Image-to-image",local:"controlnet-image-to-image",headingTag:"h3"}}),qe=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwS2FuZGluc2t5VjIyUHJpb3JFbWIyRW1iUGlwZWxpbmUlMkMlMjBLYW5kaW5za3lWMjJDb250cm9sbmV0SW1nMkltZ1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEElMEFpbWclMjAlM0QlMjBsb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZrYW5kaW5za3l2MjIlMkZjYXQucG5nJTIyJTBBKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkpJTBBJTBBZGVmJTIwbWFrZV9oaW50KGltYWdlJTJDJTIwZGVwdGhfZXN0aW1hdG9yKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwZGVwdGhfZXN0aW1hdG9yKGltYWdlKSU1QiUyMmRlcHRoJTIyJTVEJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBucC5hcnJheShpbWFnZSklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMGltYWdlJTVCJTNBJTJDJTIwJTNBJTJDJTIwTm9uZSU1RCUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwbnAuY29uY2F0ZW5hdGUoJTVCaW1hZ2UlMkMlMjBpbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwYXhpcyUzRDIpJTBBJTIwJTIwJTIwJTIwZGV0ZWN0ZWRfbWFwJTIwJTNEJTIwdG9yY2guZnJvbV9udW1weShpbWFnZSkuZmxvYXQoKSUyMCUyRiUyMDI1NS4wJTBBJTIwJTIwJTIwJTIwaGludCUyMCUzRCUyMGRldGVjdGVkX21hcC5wZXJtdXRlKDIlMkMlMjAwJTJDJTIwMSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBoaW50JTBBJTBBZGVwdGhfZXN0aW1hdG9yJTIwJTNEJTIwcGlwZWxpbmUoJTIyZGVwdGgtZXN0aW1hdGlvbiUyMiklMEFoaW50JTIwJTNEJTIwbWFrZV9oaW50KGltZyUyQyUyMGRlcHRoX2VzdGltYXRvcikudW5zcXVlZXplKDApLmhhbGYoKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> KandinskyV22PriorEmb2EmbPipeline, KandinskyV22ControlnetImg2ImgPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

img = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/kandinskyv22/cat.png&quot;</span>
).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

<span class="hljs-keyword">def</span> <span class="hljs-title function_">make_hint</span>(<span class="hljs-params">image, depth_estimator</span>):
    image = depth_estimator(image)[<span class="hljs-string">&quot;depth&quot;</span>]
    image = np.array(image)
    image = image[:, :, <span class="hljs-literal">None</span>]
    image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>)
    detected_map = torch.from_numpy(image).<span class="hljs-built_in">float</span>() / <span class="hljs-number">255.0</span>
    hint = detected_map.permute(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>)
    <span class="hljs-keyword">return</span> hint

depth_estimator = pipeline(<span class="hljs-string">&quot;depth-estimation&quot;</span>)
hint = make_hint(img, depth_estimator).unsqueeze(<span class="hljs-number">0</span>).half().to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),De=new T({props:{code:"cHJpb3JfcGlwZWxpbmUlMjAlM0QlMjBLYW5kaW5za3lWMjJQcmlvckVtYjJFbWJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTItcHJpb3IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwS2FuZGluc2t5VjIyQ29udHJvbG5ldEltZzJJbWdQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTItY29udHJvbG5ldC1kZXB0aCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMik=",highlighted:`prior_pipeline = KandinskyV22PriorEmb2EmbPipeline.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-prior&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline = KandinskyV22ControlnetImg2ImgPipeline.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-controlnet-depth&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),Ae=new T({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyQSUyMHJvYm90JTJDJTIwNGslMjBwaG90byUyMiUwQW5lZ2F0aXZlX3ByaW9yX3Byb21wdCUyMCUzRCUyMCUyMmxvd3JlcyUyQyUyMHRleHQlMkMlMjBlcnJvciUyQyUyMGNyb3BwZWQlMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBsb3clMjBxdWFsaXR5JTJDJTIwanBlZyUyMGFydGlmYWN0cyUyQyUyMHVnbHklMkMlMjBkdXBsaWNhdGUlMkMlMjBtb3JiaWQlMkMlMjBtdXRpbGF0ZWQlMkMlMjBvdXQlMjBvZiUyMGZyYW1lJTJDJTIwZXh0cmElMjBmaW5nZXJzJTJDJTIwbXV0YXRlZCUyMGhhbmRzJTJDJTIwcG9vcmx5JTIwZHJhd24lMjBoYW5kcyUyQyUyMHBvb3JseSUyMGRyYXduJTIwZmFjZSUyQyUyMG11dGF0aW9uJTJDJTIwZGVmb3JtZWQlMkMlMjBibHVycnklMkMlMjBkZWh5ZHJhdGVkJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMGJhZCUyMHByb3BvcnRpb25zJTJDJTIwZXh0cmElMjBsaW1icyUyQyUyMGNsb25lZCUyMGZhY2UlMkMlMjBkaXNmaWd1cmVkJTJDJTIwZ3Jvc3MlMjBwcm9wb3J0aW9ucyUyQyUyMG1hbGZvcm1lZCUyMGxpbWJzJTJDJTIwbWlzc2luZyUyMGFybXMlMkMlMjBtaXNzaW5nJTIwbGVncyUyQyUyMGV4dHJhJTIwYXJtcyUyQyUyMGV4dHJhJTIwbGVncyUyQyUyMGZ1c2VkJTIwZmluZ2VycyUyQyUyMHRvbyUyMG1hbnklMjBmaW5nZXJzJTJDJTIwbG9uZyUyMG5lY2slMkMlMjB1c2VybmFtZSUyQyUyMHdhdGVybWFyayUyQyUyMHNpZ25hdHVyZSUyMiUwQSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjdWRhJTIyKS5tYW51YWxfc2VlZCg0MyklMEElMEFpbWdfZW1iJTIwJTNEJTIwcHJpb3JfcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0RpbWclMkMlMjBzdHJlbmd0aCUzRDAuODUlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpJTBBbmVnYXRpdmVfZW1iJTIwJTNEJTIwcHJpb3JfcGlwZWxpbmUocHJvbXB0JTNEbmVnYXRpdmVfcHJpb3JfcHJvbXB0JTJDJTIwaW1hZ2UlM0RpbWclMkMlMjBzdHJlbmd0aCUzRDElMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3Ip",highlighted:`prompt = <span class="hljs-string">&quot;A robot, 4k photo&quot;</span>
negative_prior_prompt = <span class="hljs-string">&quot;lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature&quot;</span>

generator = torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">43</span>)

img_emb = prior_pipeline(prompt=prompt, image=img, strength=<span class="hljs-number">0.85</span>, generator=generator)
negative_emb = prior_pipeline(prompt=negative_prior_prompt, image=img, strength=<span class="hljs-number">1</span>, generator=generator)`,wrap:!1}}),es=new T({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShpbWFnZSUzRGltZyUyQyUyMHN0cmVuZ3RoJTNEMC41JTJDJTIwaW1hZ2VfZW1iZWRzJTNEaW1nX2VtYi5pbWFnZV9lbWJlZHMlMkMlMjBuZWdhdGl2ZV9pbWFnZV9lbWJlZHMlM0RuZWdhdGl2ZV9lbWIuaW1hZ2VfZW1iZWRzJTJDJTIwaGludCUzRGhpbnQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMjBoZWlnaHQlM0Q3NjglMkMlMjB3aWR0aCUzRDc2OCkuaW1hZ2VzJTVCMCU1RCUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbWcucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUyQyUyMGltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`image = pipeline(image=img, strength=<span class="hljs-number">0.5</span>, image_embeds=img_emb.image_embeds, negative_image_embeds=negative_emb.image_embeds, hint=hint, num_inference_steps=<span class="hljs-number">50</span>, generator=generator, height=<span class="hljs-number">768</span>, width=<span class="hljs-number">768</span>).images[<span class="hljs-number">0</span>]
make_image_grid([img.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)), image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),ss=new B({props:{title:"Optimizations",local:"optimizations",headingTag:"h2"}}),ns=new T({props:{code:"JTIwJTIwZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMEElMjAlMjBwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQSUyQiUyMHBpcGUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCk=",highlighted:`  from diffusers import DiffusionPipeline
  import torch

  pipe = DiffusionPipeline.from_pretrained(&quot;kandinsky-community/kandinsky-2-1&quot;, torch_dtype=torch.float16)
<span class="hljs-addition">+ pipe.enable_xformers_memory_efficient_attention()</span>`,wrap:!1}}),as=new T({props:{code:"JTIwJTIwcGlwZS51bmV0LnRvKG1lbW9yeV9mb3JtYXQlM0R0b3JjaC5jaGFubmVsc19sYXN0KSUwQSUyQiUyMHBpcGUudW5ldCUyMCUzRCUyMHRvcmNoLmNvbXBpbGUocGlwZS51bmV0JTJDJTIwbW9kZSUzRCUyMnJlZHVjZS1vdmVyaGVhZCUyMiUyQyUyMGZ1bGxncmFwaCUzRFRydWUp",highlighted:`  pipe.unet.to(memory_format=torch.channels_last)
<span class="hljs-addition">+ pipe.unet = torch.compile(pipe.unet, mode=&quot;reduce-overhead&quot;, fullgraph=True)</span>`,wrap:!1}}),ps=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy5tb2RlbHMuYXR0ZW50aW9uX3Byb2Nlc3NvciUyMGltcG9ydCUyMEF0dG5BZGRlZEtWUHJvY2Vzc29yMl8wJTBBJTBBcGlwZS51bmV0LnNldF9hdHRuX3Byb2Nlc3NvcihBdHRuQWRkZWRLVlByb2Nlc3NvcjJfMCgpKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers.models.attention_processor <span class="hljs-keyword">import</span> AttnAddedKVProcessor2_0

pipe.unet.set_attn_processor(AttnAddedKVProcessor2_0())`,wrap:!1}}),ms=new T({props:{code:"JTIwJTIwZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMEElMjAlMjBwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmthbmRpbnNreS1jb21tdW5pdHklMkZrYW5kaW5za3ktMi0xJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQSUyQiUyMHBpcGUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCk=",highlighted:`  from diffusers import DiffusionPipeline
  import torch

  pipe = DiffusionPipeline.from_pretrained(&quot;kandinsky-community/kandinsky-2-1&quot;, torch_dtype=torch.float16)
<span class="hljs-addition">+ pipe.enable_model_cpu_offload()</span>`,wrap:!1}}),rs=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEREUE1TY2hlZHVsZXIlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFzY2hlZHVsZXIlMjAlM0QlMjBERFBNU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMmRkcG1fc2NoZWR1bGVyJTIyKSUwQXBpcGUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIya2FuZGluc2t5LWNvbW11bml0eSUyRmthbmRpbnNreS0yLTElMjIlMkMlMjBzY2hlZHVsZXIlM0RzY2hlZHVsZXIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDPMScheduler
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

scheduler = DDPMScheduler.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, subfolder=<span class="hljs-string">&quot;ddpm_scheduler&quot;</span>)
pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;kandinsky-community/kandinsky-2-1&quot;</span>, scheduler=scheduler, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),{c(){t=g("meta"),m=o(),s=g("p"),r=o(),d(l.$$.fragment),n=o(),d(J.$$.fragment),Z=o(),I=g("p"),I.textContent=V,U=o(),W=g("p"),W.innerHTML=zt,cs=o(),se=g("p"),se.innerHTML=xt,ds=o(),te=g("p"),te.textContent=Et,ys=o(),le=g("p"),le.textContent=Kt,us=o(),d(ne.$$.fragment),Ms=o(),d(X.$$.fragment),fs=o(),d(ae.$$.fragment),hs=o(),ie=g("p"),ie.innerHTML=qt,Js=o(),d(R.$$.fragment),bs=o(),pe=g("p"),pe.innerHTML=Lt,gs=o(),me=g("p"),me.innerHTML=Dt,ks=o(),d(v.$$.fragment),ws=o(),d(re.$$.fragment),Us=o(),oe=g("p"),oe.textContent=Pt,Zs=o(),d(C.$$.fragment),Ts=o(),ce=g("p"),ce.textContent=At,Ws=o(),d(de.$$.fragment),js=o(),Y=g("div"),Y.innerHTML=Ot,$s=o(),ye=g("p"),ye.innerHTML=el,Gs=o(),d(ue.$$.fragment),Is=o(),Me=g("p"),Me.textContent=sl,Vs=o(),d(Q.$$.fragment),_s=o(),fe=g("p"),fe.innerHTML=tl,Bs=o(),he=g("p"),he.innerHTML=ll,Xs=o(),d(F.$$.fragment),Rs=o(),d(Je.$$.fragment),vs=o(),d(H.$$.fragment),Cs=o(),be=g("p"),be.textContent=nl,Ys=o(),d(N.$$.fragment),Qs=o(),ge=g("p"),ge.textContent=al,Fs=o(),d(ke.$$.fragment),Hs=o(),we=g("p"),we.textContent=il,Ns=o(),d(Ue.$$.fragment),Ss=o(),Ze=g("p"),Ze.textContent=pl,zs=o(),d(S.$$.fragment),xs=o(),Te=g("p"),Te.innerHTML=ml,Es=o(),d(z.$$.fragment),Ks=o(),d(We.$$.fragment),qs=o(),je=g("p"),je.textContent=rl,Ls=o(),d(x.$$.fragment),Ds=o(),E=g("div"),E.innerHTML=ol,Ps=o(),$e=g("p"),$e.textContent=cl,As=o(),d(Ge.$$.fragment),Os=o(),Ie=g("p"),Ie.innerHTML=dl,et=o(),d(K.$$.fragment),st=o(),d(Ve.$$.fragment),tt=o(),d(q.$$.fragment),lt=o(),_e=g("p"),_e.textContent=yl,nt=o(),Be=g("p"),Be.textContent=ul,at=o(),d(Xe.$$.fragment),it=o(),L=g("div"),L.innerHTML=Ml,pt=o(),Re=g("p"),Re.innerHTML=fl,mt=o(),d(ve.$$.fragment),rt=o(),d(Ce.$$.fragment),ot=o(),Ye=g("p"),Ye.innerHTML=hl,ct=o(),d(Qe.$$.fragment),dt=o(),Fe=g("p"),Fe.textContent=Jl,yt=o(),d(He.$$.fragment),ut=o(),Ne=g("p"),Ne.innerHTML=bl,Mt=o(),d(Se.$$.fragment),ft=o(),D=g("div"),D.innerHTML=gl,ht=o(),d(ze.$$.fragment),Jt=o(),xe=g("p"),xe.textContent=kl,bt=o(),Ee=g("ul"),Ee.innerHTML=wl,gt=o(),Ke=g("p"),Ke.innerHTML=Ul,kt=o(),d(qe.$$.fragment),wt=o(),Le=g("p"),Le.innerHTML=Zl,Ut=o(),d(De.$$.fragment),Zt=o(),Pe=g("p"),Pe.textContent=Tl,Tt=o(),d(Ae.$$.fragment),Wt=o(),Oe=g("p"),Oe.innerHTML=Wl,jt=o(),d(es.$$.fragment),$t=o(),P=g("div"),P.innerHTML=jl,Gt=o(),d(ss.$$.fragment),It=o(),ts=g("p"),ts.textContent=$l,Vt=o(),ls=g("ol"),ls.innerHTML=Gl,_t=o(),d(ns.$$.fragment),Bt=o(),A=g("ol"),A.innerHTML=Il,Xt=o(),d(as.$$.fragment),Rt=o(),is=g("p"),is.innerHTML=Vl,vt=o(),d(ps.$$.fragment),Ct=o(),O=g("ol"),O.innerHTML=_l,Yt=o(),d(ms.$$.fragment),Qt=o(),ee=g("ol"),ee.innerHTML=Bl,Ft=o(),d(rs.$$.fragment),Ht=o(),os=g("p"),this.h()},l(e){const a=Al("svelte-u9bgzb",document.head);t=k(a,"META",{name:!0,content:!0}),a.forEach(i),m=c(e),s=k(e,"P",{}),Kl(s).forEach(i),r=c(e),y(l.$$.fragment,e),n=c(e),y(J.$$.fragment,e),Z=c(e),I=k(e,"P",{"data-svelte-h":!0}),w(I)!=="svelte-nyn2ud"&&(I.textContent=V),U=c(e),W=k(e,"P",{"data-svelte-h":!0}),w(W)!=="svelte-rc0qhg"&&(W.innerHTML=zt),cs=c(e),se=k(e,"P",{"data-svelte-h":!0}),w(se)!=="svelte-1lazcye"&&(se.innerHTML=xt),ds=c(e),te=k(e,"P",{"data-svelte-h":!0}),w(te)!=="svelte-1l6ivg9"&&(te.textContent=Et),ys=c(e),le=k(e,"P",{"data-svelte-h":!0}),w(le)!=="svelte-cwruts"&&(le.textContent=Kt),us=c(e),y(ne.$$.fragment,e),Ms=c(e),y(X.$$.fragment,e),fs=c(e),y(ae.$$.fragment,e),hs=c(e),ie=k(e,"P",{"data-svelte-h":!0}),w(ie)!=="svelte-kq2poq"&&(ie.innerHTML=qt),Js=c(e),y(R.$$.fragment,e),bs=c(e),pe=k(e,"P",{"data-svelte-h":!0}),w(pe)!=="svelte-1ia5b2q"&&(pe.innerHTML=Lt),gs=c(e),me=k(e,"P",{"data-svelte-h":!0}),w(me)!=="svelte-enihv1"&&(me.innerHTML=Dt),ks=c(e),y(v.$$.fragment,e),ws=c(e),y(re.$$.fragment,e),Us=c(e),oe=k(e,"P",{"data-svelte-h":!0}),w(oe)!=="svelte-1pueb9d"&&(oe.textContent=Pt),Zs=c(e),y(C.$$.fragment,e),Ts=c(e),ce=k(e,"P",{"data-svelte-h":!0}),w(ce)!=="svelte-1sl9181"&&(ce.textContent=At),Ws=c(e),y(de.$$.fragment,e),js=c(e),Y=k(e,"DIV",{class:!0,"data-svelte-h":!0}),w(Y)!=="svelte-1w2zk95"&&(Y.innerHTML=Ot),$s=c(e),ye=k(e,"P",{"data-svelte-h":!0}),w(ye)!=="svelte-ctvdye"&&(ye.innerHTML=el),Gs=c(e),y(ue.$$.fragment,e),Is=c(e),Me=k(e,"P",{"data-svelte-h":!0}),w(Me)!=="svelte-zsncr3"&&(Me.textContent=sl),Vs=c(e),y(Q.$$.fragment,e),_s=c(e),fe=k(e,"P",{"data-svelte-h":!0}),w(fe)!=="svelte-1tkzfu"&&(fe.innerHTML=tl),Bs=c(e),he=k(e,"P",{"data-svelte-h":!0}),w(he)!=="svelte-1mrjxh5"&&(he.innerHTML=ll),Xs=c(e),y(F.$$.fragment,e),Rs=c(e),y(Je.$$.fragment,e),vs=c(e),y(H.$$.fragment,e),Cs=c(e),be=k(e,"P",{"data-svelte-h":!0}),w(be)!=="svelte-1h9m0px"&&(be.textContent=nl),Ys=c(e),y(N.$$.fragment,e),Qs=c(e),ge=k(e,"P",{"data-svelte-h":!0}),w(ge)!=="svelte-1lisfug"&&(ge.textContent=al),Fs=c(e),y(ke.$$.fragment,e),Hs=c(e),we=k(e,"P",{"data-svelte-h":!0}),w(we)!=="svelte-1seehfb"&&(we.textContent=il),Ns=c(e),y(Ue.$$.fragment,e),Ss=c(e),Ze=k(e,"P",{"data-svelte-h":!0}),w(Ze)!=="svelte-1c90mh7"&&(Ze.textContent=pl),zs=c(e),y(S.$$.fragment,e),xs=c(e),Te=k(e,"P",{"data-svelte-h":!0}),w(Te)!=="svelte-19cbvto"&&(Te.innerHTML=ml),Es=c(e),y(z.$$.fragment,e),Ks=c(e),y(We.$$.fragment,e),qs=c(e),je=k(e,"P",{"data-svelte-h":!0}),w(je)!=="svelte-iexz0f"&&(je.textContent=rl),Ls=c(e),y(x.$$.fragment,e),Ds=c(e),E=k(e,"DIV",{class:!0,"data-svelte-h":!0}),w(E)!=="svelte-1c7h32m"&&(E.innerHTML=ol),Ps=c(e),$e=k(e,"P",{"data-svelte-h":!0}),w($e)!=="svelte-1yz0908"&&($e.textContent=cl),As=c(e),y(Ge.$$.fragment,e),Os=c(e),Ie=k(e,"P",{"data-svelte-h":!0}),w(Ie)!=="svelte-lrlri1"&&(Ie.innerHTML=dl),et=c(e),y(K.$$.fragment,e),st=c(e),y(Ve.$$.fragment,e),tt=c(e),y(q.$$.fragment,e),lt=c(e),_e=k(e,"P",{"data-svelte-h":!0}),w(_e)!=="svelte-1shkert"&&(_e.textContent=yl),nt=c(e),Be=k(e,"P",{"data-svelte-h":!0}),w(Be)!=="svelte-191d2jn"&&(Be.textContent=ul),at=c(e),y(Xe.$$.fragment,e),it=c(e),L=k(e,"DIV",{class:!0,"data-svelte-h":!0}),w(L)!=="svelte-11gtyyz"&&(L.innerHTML=Ml),pt=c(e),Re=k(e,"P",{"data-svelte-h":!0}),w(Re)!=="svelte-cpjujb"&&(Re.innerHTML=fl),mt=c(e),y(ve.$$.fragment,e),rt=c(e),y(Ce.$$.fragment,e),ot=c(e),Ye=k(e,"P",{"data-svelte-h":!0}),w(Ye)!=="svelte-h6d89t"&&(Ye.innerHTML=hl),ct=c(e),y(Qe.$$.fragment,e),dt=c(e),Fe=k(e,"P",{"data-svelte-h":!0}),w(Fe)!=="svelte-ncejue"&&(Fe.textContent=Jl),yt=c(e),y(He.$$.fragment,e),ut=c(e),Ne=k(e,"P",{"data-svelte-h":!0}),w(Ne)!=="svelte-1x84eg0"&&(Ne.innerHTML=bl),Mt=c(e),y(Se.$$.fragment,e),ft=c(e),D=k(e,"DIV",{class:!0,"data-svelte-h":!0}),w(D)!=="svelte-1oo0se1"&&(D.innerHTML=gl),ht=c(e),y(ze.$$.fragment,e),Jt=c(e),xe=k(e,"P",{"data-svelte-h":!0}),w(xe)!=="svelte-1hxrtxz"&&(xe.textContent=kl),bt=c(e),Ee=k(e,"UL",{"data-svelte-h":!0}),w(Ee)!=="svelte-1wnirbi"&&(Ee.innerHTML=wl),gt=c(e),Ke=k(e,"P",{"data-svelte-h":!0}),w(Ke)!=="svelte-1eccwor"&&(Ke.innerHTML=Ul),kt=c(e),y(qe.$$.fragment,e),wt=c(e),Le=k(e,"P",{"data-svelte-h":!0}),w(Le)!=="svelte-1bme2gp"&&(Le.innerHTML=Zl),Ut=c(e),y(De.$$.fragment,e),Zt=c(e),Pe=k(e,"P",{"data-svelte-h":!0}),w(Pe)!=="svelte-1ltdt5k"&&(Pe.textContent=Tl),Tt=c(e),y(Ae.$$.fragment,e),Wt=c(e),Oe=k(e,"P",{"data-svelte-h":!0}),w(Oe)!=="svelte-gs93x4"&&(Oe.innerHTML=Wl),jt=c(e),y(es.$$.fragment,e),$t=c(e),P=k(e,"DIV",{class:!0,"data-svelte-h":!0}),w(P)!=="svelte-eey5ka"&&(P.innerHTML=jl),Gt=c(e),y(ss.$$.fragment,e),It=c(e),ts=k(e,"P",{"data-svelte-h":!0}),w(ts)!=="svelte-1x6zzpe"&&(ts.textContent=$l),Vt=c(e),ls=k(e,"OL",{"data-svelte-h":!0}),w(ls)!=="svelte-gyrsfr"&&(ls.innerHTML=Gl),_t=c(e),y(ns.$$.fragment,e),Bt=c(e),A=k(e,"OL",{start:!0,"data-svelte-h":!0}),w(A)!=="svelte-y09ur0"&&(A.innerHTML=Il),Xt=c(e),y(as.$$.fragment,e),Rt=c(e),is=k(e,"P",{"data-svelte-h":!0}),w(is)!=="svelte-1ruz9lc"&&(is.innerHTML=Vl),vt=c(e),y(ps.$$.fragment,e),Ct=c(e),O=k(e,"OL",{start:!0,"data-svelte-h":!0}),w(O)!=="svelte-1bcl59f"&&(O.innerHTML=_l),Yt=c(e),y(ms.$$.fragment,e),Qt=c(e),ee=k(e,"OL",{start:!0,"data-svelte-h":!0}),w(ee)!=="svelte-gz9ims"&&(ee.innerHTML=Bl),Ft=c(e),y(rs.$$.fragment,e),Ht=c(e),os=k(e,"P",{}),Kl(os).forEach(i),this.h()},h(){G(t,"name","hf:doc:metadata"),G(t,"content",vn),G(Y,"class","flex justify-center"),G(E,"class","flex gap-4"),G(L,"class","flex justify-center"),G(D,"class","flex justify-center"),G(P,"class","flex justify-center"),G(A,"start","2"),G(O,"start","3"),G(ee,"start","4")},m(e,a){Ol(document.head,t),p(e,m,a),p(e,s,a),p(e,r,a),u(l,e,a),p(e,n,a),u(J,e,a),p(e,Z,a),p(e,I,a),p(e,U,a),p(e,W,a),p(e,cs,a),p(e,se,a),p(e,ds,a),p(e,te,a),p(e,ys,a),p(e,le,a),p(e,us,a),u(ne,e,a),p(e,Ms,a),u(X,e,a),p(e,fs,a),u(ae,e,a),p(e,hs,a),p(e,ie,a),p(e,Js,a),u(R,e,a),p(e,bs,a),p(e,pe,a),p(e,gs,a),p(e,me,a),p(e,ks,a),u(v,e,a),p(e,ws,a),u(re,e,a),p(e,Us,a),p(e,oe,a),p(e,Zs,a),u(C,e,a),p(e,Ts,a),p(e,ce,a),p(e,Ws,a),u(de,e,a),p(e,js,a),p(e,Y,a),p(e,$s,a),p(e,ye,a),p(e,Gs,a),u(ue,e,a),p(e,Is,a),p(e,Me,a),p(e,Vs,a),u(Q,e,a),p(e,_s,a),p(e,fe,a),p(e,Bs,a),p(e,he,a),p(e,Xs,a),u(F,e,a),p(e,Rs,a),u(Je,e,a),p(e,vs,a),u(H,e,a),p(e,Cs,a),p(e,be,a),p(e,Ys,a),u(N,e,a),p(e,Qs,a),p(e,ge,a),p(e,Fs,a),u(ke,e,a),p(e,Hs,a),p(e,we,a),p(e,Ns,a),u(Ue,e,a),p(e,Ss,a),p(e,Ze,a),p(e,zs,a),u(S,e,a),p(e,xs,a),p(e,Te,a),p(e,Es,a),u(z,e,a),p(e,Ks,a),u(We,e,a),p(e,qs,a),p(e,je,a),p(e,Ls,a),u(x,e,a),p(e,Ds,a),p(e,E,a),p(e,Ps,a),p(e,$e,a),p(e,As,a),u(Ge,e,a),p(e,Os,a),p(e,Ie,a),p(e,et,a),u(K,e,a),p(e,st,a),u(Ve,e,a),p(e,tt,a),u(q,e,a),p(e,lt,a),p(e,_e,a),p(e,nt,a),p(e,Be,a),p(e,at,a),u(Xe,e,a),p(e,it,a),p(e,L,a),p(e,pt,a),p(e,Re,a),p(e,mt,a),u(ve,e,a),p(e,rt,a),u(Ce,e,a),p(e,ot,a),p(e,Ye,a),p(e,ct,a),u(Qe,e,a),p(e,dt,a),p(e,Fe,a),p(e,yt,a),u(He,e,a),p(e,ut,a),p(e,Ne,a),p(e,Mt,a),u(Se,e,a),p(e,ft,a),p(e,D,a),p(e,ht,a),u(ze,e,a),p(e,Jt,a),p(e,xe,a),p(e,bt,a),p(e,Ee,a),p(e,gt,a),p(e,Ke,a),p(e,kt,a),u(qe,e,a),p(e,wt,a),p(e,Le,a),p(e,Ut,a),u(De,e,a),p(e,Zt,a),p(e,Pe,a),p(e,Tt,a),u(Ae,e,a),p(e,Wt,a),p(e,Oe,a),p(e,jt,a),u(es,e,a),p(e,$t,a),p(e,P,a),p(e,Gt,a),u(ss,e,a),p(e,It,a),p(e,ts,a),p(e,Vt,a),p(e,ls,a),p(e,_t,a),u(ns,e,a),p(e,Bt,a),p(e,A,a),p(e,Xt,a),u(as,e,a),p(e,Rt,a),p(e,is,a),p(e,vt,a),u(ps,e,a),p(e,Ct,a),p(e,O,a),p(e,Yt,a),u(ms,e,a),p(e,Qt,a),p(e,ee,a),p(e,Ft,a),u(rs,e,a),p(e,Ht,a),p(e,os,a),Nt=!0},p(e,[a]){const Xl={};a&2&&(Xl.$$scope={dirty:a,ctx:e}),X.$set(Xl);const Rl={};a&2&&(Rl.$$scope={dirty:a,ctx:e}),R.$set(Rl);const vl={};a&2&&(vl.$$scope={dirty:a,ctx:e}),v.$set(vl);const Cl={};a&2&&(Cl.$$scope={dirty:a,ctx:e}),C.$set(Cl);const Yl={};a&2&&(Yl.$$scope={dirty:a,ctx:e}),Q.$set(Yl);const Ql={};a&2&&(Ql.$$scope={dirty:a,ctx:e}),F.$set(Ql);const Fl={};a&2&&(Fl.$$scope={dirty:a,ctx:e}),H.$set(Fl);const Hl={};a&2&&(Hl.$$scope={dirty:a,ctx:e}),N.$set(Hl);const Nl={};a&2&&(Nl.$$scope={dirty:a,ctx:e}),S.$set(Nl);const Sl={};a&2&&(Sl.$$scope={dirty:a,ctx:e}),z.$set(Sl);const zl={};a&2&&(zl.$$scope={dirty:a,ctx:e}),x.$set(zl);const xl={};a&2&&(xl.$$scope={dirty:a,ctx:e}),K.$set(xl);const El={};a&2&&(El.$$scope={dirty:a,ctx:e}),q.$set(El)},i(e){Nt||(M(l.$$.fragment,e),M(J.$$.fragment,e),M(ne.$$.fragment,e),M(X.$$.fragment,e),M(ae.$$.fragment,e),M(R.$$.fragment,e),M(v.$$.fragment,e),M(re.$$.fragment,e),M(C.$$.fragment,e),M(de.$$.fragment,e),M(ue.$$.fragment,e),M(Q.$$.fragment,e),M(F.$$.fragment,e),M(Je.$$.fragment,e),M(H.$$.fragment,e),M(N.$$.fragment,e),M(ke.$$.fragment,e),M(Ue.$$.fragment,e),M(S.$$.fragment,e),M(z.$$.fragment,e),M(We.$$.fragment,e),M(x.$$.fragment,e),M(Ge.$$.fragment,e),M(K.$$.fragment,e),M(Ve.$$.fragment,e),M(q.$$.fragment,e),M(Xe.$$.fragment,e),M(ve.$$.fragment,e),M(Ce.$$.fragment,e),M(Qe.$$.fragment,e),M(He.$$.fragment,e),M(Se.$$.fragment,e),M(ze.$$.fragment,e),M(qe.$$.fragment,e),M(De.$$.fragment,e),M(Ae.$$.fragment,e),M(es.$$.fragment,e),M(ss.$$.fragment,e),M(ns.$$.fragment,e),M(as.$$.fragment,e),M(ps.$$.fragment,e),M(ms.$$.fragment,e),M(rs.$$.fragment,e),Nt=!0)},o(e){f(l.$$.fragment,e),f(J.$$.fragment,e),f(ne.$$.fragment,e),f(X.$$.fragment,e),f(ae.$$.fragment,e),f(R.$$.fragment,e),f(v.$$.fragment,e),f(re.$$.fragment,e),f(C.$$.fragment,e),f(de.$$.fragment,e),f(ue.$$.fragment,e),f(Q.$$.fragment,e),f(F.$$.fragment,e),f(Je.$$.fragment,e),f(H.$$.fragment,e),f(N.$$.fragment,e),f(ke.$$.fragment,e),f(Ue.$$.fragment,e),f(S.$$.fragment,e),f(z.$$.fragment,e),f(We.$$.fragment,e),f(x.$$.fragment,e),f(Ge.$$.fragment,e),f(K.$$.fragment,e),f(Ve.$$.fragment,e),f(q.$$.fragment,e),f(Xe.$$.fragment,e),f(ve.$$.fragment,e),f(Ce.$$.fragment,e),f(Qe.$$.fragment,e),f(He.$$.fragment,e),f(Se.$$.fragment,e),f(ze.$$.fragment,e),f(qe.$$.fragment,e),f(De.$$.fragment,e),f(Ae.$$.fragment,e),f(es.$$.fragment,e),f(ss.$$.fragment,e),f(ns.$$.fragment,e),f(as.$$.fragment,e),f(ps.$$.fragment,e),f(ms.$$.fragment,e),f(rs.$$.fragment,e),Nt=!1},d(e){e&&(i(m),i(s),i(r),i(n),i(Z),i(I),i(U),i(W),i(cs),i(se),i(ds),i(te),i(ys),i(le),i(us),i(Ms),i(fs),i(hs),i(ie),i(Js),i(bs),i(pe),i(gs),i(me),i(ks),i(ws),i(Us),i(oe),i(Zs),i(Ts),i(ce),i(Ws),i(js),i(Y),i($s),i(ye),i(Gs),i(Is),i(Me),i(Vs),i(_s),i(fe),i(Bs),i(he),i(Xs),i(Rs),i(vs),i(Cs),i(be),i(Ys),i(Qs),i(ge),i(Fs),i(Hs),i(we),i(Ns),i(Ss),i(Ze),i(zs),i(xs),i(Te),i(Es),i(Ks),i(qs),i(je),i(Ls),i(Ds),i(E),i(Ps),i($e),i(As),i(Os),i(Ie),i(et),i(st),i(tt),i(lt),i(_e),i(nt),i(Be),i(at),i(it),i(L),i(pt),i(Re),i(mt),i(rt),i(ot),i(Ye),i(ct),i(dt),i(Fe),i(yt),i(ut),i(Ne),i(Mt),i(ft),i(D),i(ht),i(Jt),i(xe),i(bt),i(Ee),i(gt),i(Ke),i(kt),i(wt),i(Le),i(Ut),i(Zt),i(Pe),i(Tt),i(Wt),i(Oe),i(jt),i($t),i(P),i(Gt),i(It),i(ts),i(Vt),i(ls),i(_t),i(Bt),i(A),i(Xt),i(Rt),i(is),i(vt),i(Ct),i(O),i(Yt),i(Qt),i(ee),i(Ft),i(Ht),i(os)),i(t),h(l,e),h(J,e),h(ne,e),h(X,e),h(ae,e),h(R,e),h(v,e),h(re,e),h(C,e),h(de,e),h(ue,e),h(Q,e),h(F,e),h(Je,e),h(H,e),h(N,e),h(ke,e),h(Ue,e),h(S,e),h(z,e),h(We,e),h(x,e),h(Ge,e),h(K,e),h(Ve,e),h(q,e),h(Xe,e),h(ve,e),h(Ce,e),h(Qe,e),h(He,e),h(Se,e),h(ze,e),h(qe,e),h(De,e),h(Ae,e),h(es,e),h(ss,e),h(ns,e),h(as,e),h(ps,e),h(ms,e),h(rs,e)}}}const vn='{"title":"Kandinsky","local":"kandinsky","sections":[{"title":"Text-to-image","local":"text-to-image","sections":[],"depth":2},{"title":"Image-to-image","local":"image-to-image","sections":[],"depth":2},{"title":"Inpainting","local":"inpainting","sections":[],"depth":2},{"title":"Interpolation","local":"interpolation","sections":[],"depth":2},{"title":"ControlNet","local":"controlnet","sections":[{"title":"Text-to-image","local":"controlnet-text-to-image","sections":[],"depth":3},{"title":"Image-to-image","local":"controlnet-image-to-image","sections":[],"depth":3}],"depth":2},{"title":"Optimizations","local":"optimizations","sections":[],"depth":2}],"depth":1}';function Cn(b){return Ll(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xn extends Dl{constructor(t){super(),Pl(this,t,Cn,Rn,ql,{})}}export{xn as component};
