import{s as ue,n as me,o as ce}from"../chunks/scheduler.182ea377.js";import{S as de,i as he,g as n,s as a,r as v,A as ge,h as o,f as i,c as l,j as pe,u as T,x as p,k as K,y as be,a as s,v as J,d as V,t as D,w as G}from"../chunks/index.abf12888.js";import{C as re}from"../chunks/CodeBlock.57fe6e13.js";import{H as Y}from"../chunks/Heading.16916d63.js";function ye(O){let f,W,C,F,u,j,m,ee='Stable Diffusion is a text-to-image latent diffusion model created by the researchers and engineers from <a href="https://github.com/CompVis" rel="nofollow">CompVis</a>, <a href="https://stability.ai/" rel="nofollow">Stability AI</a> and <a href="https://laion.ai/" rel="nofollow">LAION</a>. Latent diffusion applies the diffusion process over a lower dimensional latent space to reduce memory and compute complexity. This specific type of diffusion model was proposed in <a href="https://huggingface.co/papers/2112.10752" rel="nofollow">High-Resolution Image Synthesis with Latent Diffusion Models</a> by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer.',_,c,te="Stable Diffusion is trained on 512x512 images from a subset of the LAION-5B dataset. This model uses a frozen CLIP ViT-L/14 text encoder to condition the model on text prompts. With its 860M UNet and 123M text encoder, the model is relatively lightweight and can run on consumer GPUs.",R,d,ie='For more details about how Stable Diffusion works and how it differs from the base latent diffusion model, take a look at the Stability AI <a href="https://stability.ai/blog/stable-diffusion-announcement" rel="nofollow">announcement</a> and our own <a href="https://huggingface.co/blog/stable_diffusion#how-does-stable-diffusion-work" rel="nofollow">blog post</a> for more technical details.',k,h,se='You can find the original codebase for Stable Diffusion v1.0 at <a href="https://github.com/CompVis/stable-diffusion" rel="nofollow">CompVis/stable-diffusion</a> and Stable Diffusion v2.0 at <a href="https://github.com/Stability-AI/stablediffusion" rel="nofollow">Stability-AI/stablediffusion</a> as well as their original scripts for various tasks. Additional official checkpoints for the different Stable Diffusion versions and tasks can be found on the <a href="https://huggingface.co/CompVis" rel="nofollow">CompVis</a>, <a href="https://huggingface.co/runwayml" rel="nofollow">Runway</a>, and <a href="https://huggingface.co/stabilityai" rel="nofollow">Stability AI</a> Hub organizations. Explore these organizations to find the best checkpoint for your use-case!',H,g,ae="The table below summarizes the available Stable Diffusion pipelines, their supported tasks, and an interactive demo:",I,r,le=`<div class="rounded-xl border border-gray-200"><table class="min-w-full divide-y-2 divide-gray-200 bg-white text-sm"><thead><tr><th class="px-4 py-2 font-medium text-gray-900 text-left">Pipeline</th> <th class="px-4 py-2 font-medium text-gray-900 text-left">Supported tasks</th> <th class="px-4 py-2 font-medium text-gray-900 text-left">Space</th></tr></thead> <tbody class="divide-y divide-gray-200"><tr><td class="px-4 py-2 text-gray-700"><a href="./text2img">StableDiffusion</a></td> <td class="px-4 py-2 text-gray-700">text-to-image</td> <td class="px-4 py-2"><a href="https://huggingface.co/spaces/stabilityai/stable-diffusion"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a></td></tr> <a href="./img2img">StableDiffusionImg2Img</a>
            
            image-to-image
            <a href="https://huggingface.co/spaces/huggingface/diffuse-the-rest"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./inpaint">StableDiffusionInpaint</a>
            
            inpainting
            <a href="https://huggingface.co/spaces/runwayml/stable-diffusion-inpainting"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./depth2img">StableDiffusionDepth2Img</a>
            
            depth-to-image
            <a href="https://huggingface.co/spaces/radames/stable-diffusion-depth2img"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./image_variation">StableDiffusionImageVariation</a>
            
            image variation
            <a href="https://huggingface.co/spaces/lambdalabs/stable-diffusion-image-variations"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./stable_diffusion_safe">StableDiffusionPipelineSafe</a>
            
            filtered text-to-image
            <a href="https://huggingface.co/spaces/AIML-TUDA/unsafe-vs-safe-stable-diffusion"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./stable_diffusion_2">StableDiffusion2</a>
            
            text-to-image, inpainting, depth-to-image, super-resolution
            <a href="https://huggingface.co/spaces/stabilityai/stable-diffusion"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./stable_diffusion_xl">StableDiffusionXL</a>
            
            text-to-image, image-to-image
            <a href="https://huggingface.co/spaces/RamAnanth1/stable-diffusion-xl"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./latent_upscale">StableDiffusionLatentUpscale</a>
            
            super-resolution
            <a href="https://huggingface.co/spaces/huggingface-projects/stable-diffusion-latent-upscaler"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a> <a href="./upscale">StableDiffusionUpscale</a>
            
            super-resolution
        <tr><td class="px-4 py-2 text-gray-700"><a href="./ldm3d_diffusion">StableDiffusionLDM3D</a></td> <td class="px-4 py-2 text-gray-700">text-to-rgb, text-to-depth</td> <td class="px-4 py-2"><a href="https://huggingface.co/spaces/r23/ldm3d-space"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a></td></tr></tbody></table></div>`,N,b,X,y,ne="To help you get the most out of the Stable Diffusion pipelines, here are a few tips for improving performance and usability. These tips are applicable to all Stable Diffusion pipelines.",L,S,P,M,oe='<a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> uses the <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a> by default, but 🤗 Diffusers provides many other schedulers (some of which are faster or output better quality) that are compatible. For example, if you want to use the <a href="/docs/diffusers/main/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a> instead of the default:',A,w,B,Z,E,x,fe="To save memory and use the same components across multiple pipelines, use the <code>.components</code> method to avoid loading weights into RAM more than once.",Q,U,z,$,q;return u=new Y({props:{title:"Stable Diffusion pipelines",local:"stable-diffusion-pipelines",headingTag:"h1"}}),b=new Y({props:{title:"Tips",local:"tips",headingTag:"h2"}}),S=new Y({props:{title:"Explore tradeoff between speed and quality",local:"explore-tradeoff-between-speed-and-quality",headingTag:"h3"}}),w=new re({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTJDJTIwRXVsZXJEaXNjcmV0ZVNjaGVkdWxlciUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIpJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwRXVsZXJEaXNjcmV0ZVNjaGVkdWxlci5mcm9tX2NvbmZpZyhwaXBlbGluZS5zY2hlZHVsZXIuY29uZmlnKSUwQSUwQSUyMyUyMG9yJTBBZXVsZXJfc2NoZWR1bGVyJTIwJTNEJTIwRXVsZXJEaXNjcmV0ZVNjaGVkdWxlci5mcm9tX3ByZXRyYWluZWQoJTIyQ29tcFZpcyUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJDb21wVmlzJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS00JTIyJTJDJTIwc2NoZWR1bGVyJTNEZXVsZXJfc2NoZWR1bGVyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, EulerDiscreteScheduler

pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>)
pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)

<span class="hljs-comment"># or</span>
euler_scheduler = EulerDiscreteScheduler.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, scheduler=euler_scheduler)`,wrap:!1}}),Z=new Y({props:{title:"Reuse pipeline components to save memory",local:"reuse-pipeline-components-to-save-memory",headingTag:"h3"}}),U=new re({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZSUyQyUwQSUyMCUyMCUyMCUyMFN0YWJsZURpZmZ1c2lvbkltZzJJbWdQaXBlbGluZSUyQyUwQSUyMCUyMCUyMCUyMFN0YWJsZURpZmZ1c2lvbklucGFpbnRQaXBlbGluZSUyQyUwQSklMEElMEF0ZXh0MmltZyUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJDb21wVmlzJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS00JTIyKSUwQWltZzJpbWclMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbWcySW1nUGlwZWxpbmUoKip0ZXh0MmltZy5jb21wb25lbnRzKSUwQWlucGFpbnQlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnBhaW50UGlwZWxpbmUoKip0ZXh0MmltZy5jb21wb25lbnRzKSUwQSUwQSUyMyUyMG5vdyUyMHlvdSUyMGNhbiUyMHVzZSUyMHRleHQyaW1nKC4uLiklMkMlMjBpbWcyaW1nKC4uLiklMkMlMjBpbnBhaW50KC4uLiklMjBqdXN0JTIwbGlrZSUyMHRoZSUyMGNhbGwlMjBtZXRob2RzJTIwb2YlMjBlYWNoJTIwcmVzcGVjdGl2ZSUyMHBpcGVsaW5l",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> (
    StableDiffusionPipeline,
    StableDiffusionImg2ImgPipeline,
    StableDiffusionInpaintPipeline,
)

text2img = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>)
img2img = StableDiffusionImg2ImgPipeline(**text2img.components)
inpaint = StableDiffusionInpaintPipeline(**text2img.components)

<span class="hljs-comment"># now you can use text2img(...), img2img(...), inpaint(...) just like the call methods of each respective pipeline</span>`,wrap:!1}}),{c(){f=n("meta"),W=a(),C=n("p"),F=a(),v(u.$$.fragment),j=a(),m=n("p"),m.innerHTML=ee,_=a(),c=n("p"),c.textContent=te,R=a(),d=n("p"),d.innerHTML=ie,k=a(),h=n("p"),h.innerHTML=se,H=a(),g=n("p"),g.textContent=ae,I=a(),r=n("div"),r.innerHTML=le,N=a(),v(b.$$.fragment),X=a(),y=n("p"),y.textContent=ne,L=a(),v(S.$$.fragment),P=a(),M=n("p"),M.innerHTML=oe,A=a(),v(w.$$.fragment),B=a(),v(Z.$$.fragment),E=a(),x=n("p"),x.innerHTML=fe,Q=a(),v(U.$$.fragment),z=a(),$=n("p"),this.h()},l(e){const t=ge("svelte-u9bgzb",document.head);f=o(t,"META",{name:!0,content:!0}),t.forEach(i),W=l(e),C=o(e,"P",{}),pe(C).forEach(i),F=l(e),T(u.$$.fragment,e),j=l(e),m=o(e,"P",{"data-svelte-h":!0}),p(m)!=="svelte-s9e3v0"&&(m.innerHTML=ee),_=l(e),c=o(e,"P",{"data-svelte-h":!0}),p(c)!=="svelte-1uvrn1d"&&(c.textContent=te),R=l(e),d=o(e,"P",{"data-svelte-h":!0}),p(d)!=="svelte-xod3ql"&&(d.innerHTML=ie),k=l(e),h=o(e,"P",{"data-svelte-h":!0}),p(h)!=="svelte-1nl1je7"&&(h.innerHTML=se),H=l(e),g=o(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-1j9k8x2"&&(g.textContent=ae),I=l(e),r=o(e,"DIV",{class:!0,"data-svelte-h":!0}),p(r)!=="svelte-13fdadd"&&(r.innerHTML=le),N=l(e),T(b.$$.fragment,e),X=l(e),y=o(e,"P",{"data-svelte-h":!0}),p(y)!=="svelte-1u5hutj"&&(y.textContent=ne),L=l(e),T(S.$$.fragment,e),P=l(e),M=o(e,"P",{"data-svelte-h":!0}),p(M)!=="svelte-14c0gel"&&(M.innerHTML=oe),A=l(e),T(w.$$.fragment,e),B=l(e),T(Z.$$.fragment,e),E=l(e),x=o(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-l7kf3o"&&(x.innerHTML=fe),Q=l(e),T(U.$$.fragment,e),z=l(e),$=o(e,"P",{}),pe($).forEach(i),this.h()},h(){K(f,"name","hf:doc:metadata"),K(f,"content",Se),K(r,"class","flex justify-center")},m(e,t){be(document.head,f),s(e,W,t),s(e,C,t),s(e,F,t),J(u,e,t),s(e,j,t),s(e,m,t),s(e,_,t),s(e,c,t),s(e,R,t),s(e,d,t),s(e,k,t),s(e,h,t),s(e,H,t),s(e,g,t),s(e,I,t),s(e,r,t),s(e,N,t),J(b,e,t),s(e,X,t),s(e,y,t),s(e,L,t),J(S,e,t),s(e,P,t),s(e,M,t),s(e,A,t),J(w,e,t),s(e,B,t),J(Z,e,t),s(e,E,t),s(e,x,t),s(e,Q,t),J(U,e,t),s(e,z,t),s(e,$,t),q=!0},p:me,i(e){q||(V(u.$$.fragment,e),V(b.$$.fragment,e),V(S.$$.fragment,e),V(w.$$.fragment,e),V(Z.$$.fragment,e),V(U.$$.fragment,e),q=!0)},o(e){D(u.$$.fragment,e),D(b.$$.fragment,e),D(S.$$.fragment,e),D(w.$$.fragment,e),D(Z.$$.fragment,e),D(U.$$.fragment,e),q=!1},d(e){e&&(i(W),i(C),i(F),i(j),i(m),i(_),i(c),i(R),i(d),i(k),i(h),i(H),i(g),i(I),i(r),i(N),i(X),i(y),i(L),i(P),i(M),i(A),i(B),i(E),i(x),i(Q),i(z),i($)),i(f),G(u,e),G(b,e),G(S,e),G(w,e),G(Z,e),G(U,e)}}}const Se='{"title":"Stable Diffusion pipelines","local":"stable-diffusion-pipelines","sections":[{"title":"Tips","local":"tips","sections":[{"title":"Explore tradeoff between speed and quality","local":"explore-tradeoff-between-speed-and-quality","sections":[],"depth":3},{"title":"Reuse pipeline components to save memory","local":"reuse-pipeline-components-to-save-memory","sections":[],"depth":3}],"depth":2}],"depth":1}';function Me(O){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ve extends de{constructor(f){super(),he(this,f,Me,ye,ue,{})}}export{ve as component};
