import{S as ea,i as ta,s as la,e as s,k as m,w as Z,t as i,M as ia,c as n,d as l,m as u,a as p,x as _,h as a,b as f,N as ni,G as t,g as r,y as I,q as U,o as v,B as k,v as aa}from"../../chunks/vendor-hf-doc-builder.js";import{T as sa}from"../../chunks/Tip-hf-doc-builder.js";import{I as oi}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as H}from"../../chunks/CodeBlock-hf-doc-builder.js";function na(et){let c,R,d,g,E;return{c(){c=s("p"),R=i("Take a look at the "),d=s("a"),g=i("AutoPipeline"),E=i(" reference to see which tasks are supported. Currently, it supports text-to-image, image-to-image, and inpainting."),this.h()},l(y){c=n(y,"P",{});var T=p(c);R=a(T,"Take a look at the "),d=n(T,"A",{href:!0});var A=p(d);g=a(A,"AutoPipeline"),A.forEach(l),E=a(T," reference to see which tasks are supported. Currently, it supports text-to-image, image-to-image, and inpainting."),T.forEach(l),this.h()},h(){f(d,"href","./pipelines/auto_pipeline")},m(y,T){r(y,c,T),t(c,R),t(c,d),t(d,g),t(c,E)},d(y){y&&l(c)}}}function oa(et){let c,R,d,g,E,y,T,A,Rt,tt,w,At,L,St,$t,de,xt,Pt,he,Qt,Yt,lt,b,Nt,Ve,Ct,Dt,Re,zt,qt,Ae,Ht,Lt,it,S,at,$,Kt,Se,Ot,el,st,B,x,$e,K,tl,xe,ll,nt,j,il,O,al,sl,ye,nl,ol,ot,ee,pt,te,ge,pi,rt,P,pl,we,rl,fl,ft,Q,X,ml,Pe,ul,cl,le,Qe,dl,hl,yl,F,gl,Ye,wl,bl,Ne,Ml,Jl,mt,h,Zl,be,_l,Il,Ce,Ul,vl,De,kl,Tl,Me,jl,Wl,ze,Gl,El,ut,ie,ct,ae,Je,ri,dt,W,Bl,Ze,Xl,Fl,_e,Vl,Rl,ht,se,yt,ne,Ie,fi,gt,Ue,Al,wt,oe,bt,V,Y,qe,pe,Sl,He,$l,Mt,N,xl,ve,Pl,Ql,Jt,G,Yl,ke,Nl,Cl,Le,Dl,zl,Zt,re,_t,M,ql,Te,Hl,Ll,Ke,Kl,Ol,je,ei,ti,It,fe,Ut,We,li,vt,me,kt,C,ii,Oe,ai,si,Tt,ue,jt;return y=new oi({}),S=new sa({props:{$$slots:{default:[na]},$$scope:{ctx:et}}}),K=new oi({}),ee=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMnBlYXNhbnQlMjBhbmQlMjBkcmFnb24lMjBjb21iYXQlMkMlMjB3b29kJTIwY3V0dGluZyUyMHN0eWxlJTJDJTIwdmlraW5nJTIwZXJhJTJDJTIwYmV2ZWwlMjB3aXRoJTIwcnVuZSUyMiUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI1KS5pbWFnZXMlNUIwJTVE",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;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;peasant and dragon combat, wood cutting style, viking era, bevel with rune&quot;</span>

image = pipeline(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>]`}}),ie=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTJDJTBBKS50byglMjJjdWRhJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMmElMjBwb3J0cmFpdCUyMG9mJTIwYSUyMGRvZyUyMHdlYXJpbmclMjBhJTIwcGVhcmwlMjBlYXJyaW5nJTIyJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZ1cGxvYWQud2lraW1lZGlhLm9yZyUyRndpa2lwZWRpYSUyRmNvbW1vbnMlMkZ0aHVtYiUyRjAlMkYwZiUyRjE2NjVfR2lybF93aXRoX2FfUGVhcmxfRWFycmluZy5qcGclMkY4MDBweC0xNjY1X0dpcmxfd2l0aF9hX1BlYXJsX0VhcnJpbmcuanBnJTIyJTBBJTBBcmVzcG9uc2UlMjAlM0QlMjByZXF1ZXN0cy5nZXQodXJsKSUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihCeXRlc0lPKHJlc3BvbnNlLmNvbnRlbnQpKS5jb252ZXJ0KCUyMlJHQiUyMiklMEFpbWFnZS50aHVtYm5haWwoKDc2OCUyQyUyMDc2OCkpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBpbWFnZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMDAlMkMlMjBzdHJlbmd0aCUzRDAuNzUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDEwLjUpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image

pipeline = AutoPipelineForImage2Image.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>,
    torch_dtype=torch.float16,
    use_safetensors=<span class="hljs-literal">True</span>,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;a portrait of a dog wearing a pearl earring&quot;</span>

url = <span class="hljs-string">&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/1665_Girl_with_a_Pearl_Earring.jpg/800px-1665_Girl_with_a_Pearl_Earring.jpg&quot;</span>

response = requests.get(url)
image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
image.thumbnail((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

image = pipeline(prompt, image, num_inference_steps=<span class="hljs-number">200</span>, strength=<span class="hljs-number">0.75</span>, guidance_scale=<span class="hljs-number">10.5</span>).images[<span class="hljs-number">0</span>]`}}),se=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvcklucGFpbnRpbmclMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZy5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGQ29tcFZpcyUyRmxhdGVudC1kaWZmdXNpb24lMkZtYWluJTJGZGF0YSUyRmlucGFpbnRpbmdfZXhhbXBsZXMlMkZvdmVydHVyZS1jcmVhdGlvbnMtNXNJNmZRZ1lJdW8ucG5nJTIyJTBBbWFza191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZDb21wVmlzJTJGbGF0ZW50LWRpZmZ1c2lvbiUyRm1haW4lMkZkYXRhJTJGaW5wYWludGluZ19leGFtcGxlcyUyRm92ZXJ0dXJlLWNyZWF0aW9ucy01c0k2ZlFnWUl1b19tYXNrLnBuZyUyMiUwQSUwQWluaXRfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKGltZ191cmwpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQW1hc2tfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKG1hc2tfdXJsKS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwbWFqZXN0aWMlMjB0aWdlciUyMHNpdHRpbmclMjBvbiUyMGElMjBiZW5jaCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMjBzdHJlbmd0aCUzRDAuODApLmltYWdlcyU1QjAlNUQ=",highlighted:`<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

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png&quot;</span>

init_image = load_image(img_url).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
mask_image = load_image(mask_url).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

prompt = <span class="hljs-string">&quot;A majestic tiger sitting on a bench&quot;</span>
image = pipeline(prompt, image=init_image, mask_image=mask_image, num_inference_steps=<span class="hljs-number">50</span>, strength=<span class="hljs-number">0.80</span>).images[<span class="hljs-number">0</span>]`}}),oe=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJvcGVuYWklMkZzaGFwLWUtaW1nMmltZyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpJTBBJTIyVmFsdWVFcnJvciUzQSUyMEF1dG9QaXBlbGluZSUyMGNhbid0JTIwZmluZCUyMGElMjBwaXBlbGluZSUyMGxpbmtlZCUyMHRvJTIwU2hhcEVJbWcySW1nUGlwZWxpbmUlMjBmb3IlMjBOb25lJTIy",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForImage2Image.from_pretrained(
    <span class="hljs-string">&quot;openai/shap-e-img2img&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
)
<span class="hljs-string">&quot;ValueError: AutoPipeline can&#x27;t find a pipeline linked to ShapEImg2ImgPipeline for None&quot;</span>`}}),pe=new oi({}),re=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMkMlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZSUwQSUwQXBpcGVsaW5lX3RleHQyaW1nJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKSUwQXByaW50KHR5cGUocGlwZWxpbmVfdGV4dDJpbWcpKSUwQSUyMiUzQ2NsYXNzJTIwJ2RpZmZ1c2Vycy5waXBlbGluZXMuc3RhYmxlX2RpZmZ1c2lvbi5waXBlbGluZV9zdGFibGVfZGlmZnVzaW9uLlN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJyUzRSUyMg==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image, AutoPipelineForImage2Image

pipeline_text2img = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
)
<span class="hljs-built_in">print</span>(<span class="hljs-built_in">type</span>(pipeline_text2img))
<span class="hljs-string">&quot;&lt;class &#x27;diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline&#x27;&gt;&quot;</span>`}}),fe=new H({props:{code:"cGlwZWxpbmVfaW1nMmltZyUyMCUzRCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlLmZyb21fcGlwZShwaXBlbGluZV90ZXh0MmltZyklMEFwcmludCh0eXBlKHBpcGVsaW5lX2ltZzJpbWcpKSUwQSUyMiUzQ2NsYXNzJTIwJ2RpZmZ1c2Vycy5waXBlbGluZXMuc3RhYmxlX2RpZmZ1c2lvbi5waXBlbGluZV9zdGFibGVfZGlmZnVzaW9uX2ltZzJpbWcuU3RhYmxlRGlmZnVzaW9uSW1nMkltZ1BpcGVsaW5lJyUzRSUyMg==",highlighted:`pipeline_img2img = AutoPipelineForImage2Image.from_pipe(pipeline_text2img)
<span class="hljs-built_in">print</span>(<span class="hljs-built_in">type</span>(pipeline_img2img))
<span class="hljs-string">&quot;&lt;class &#x27;diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusionImg2ImgPipeline&#x27;&gt;&quot;</span>`}}),me=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMkMlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZSUwQSUwQXBpcGVsaW5lX3RleHQyaW1nJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmVxdWlyZXNfc2FmZXR5X2NoZWNrZXIlM0RGYWxzZSUyQyUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlbGluZV9pbWcyaW1nJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9waXBlKHBpcGVsaW5lX3RleHQyaW1nKSUwQXByaW50KHBpcGUuY29uZmlnLnJlcXVpcmVzX3NhZmV0eV9jaGVja2VyKSUwQSUyMkZhbHNlJTIy",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image, AutoPipelineForImage2Image

pipeline_text2img = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>,
    torch_dtype=torch.float16,
    use_safetensors=<span class="hljs-literal">True</span>,
    requires_safety_checker=<span class="hljs-literal">False</span>,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline_img2img = AutoPipelineForImage2Image.from_pipe(pipeline_text2img)
<span class="hljs-built_in">print</span>(pipe.config.requires_safety_checker)
<span class="hljs-string">&quot;False&quot;</span>`}}),ue=new H({props:{code:"cGlwZWxpbmVfaW1nMmltZyUyMCUzRCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlLmZyb21fcGlwZShwaXBlbGluZV90ZXh0MmltZyUyQyUyMHJlcXVpcmVzX3NhZmV0eV9jaGVja2VyJTNEVHJ1ZSUyQyUyMHN0cmVuZ3RoJTNEMC4zKQ==",highlighted:'pipeline_img2img = AutoPipelineForImage2Image.from_pipe(pipeline_text2img, requires_safety_checker=<span class="hljs-literal">True</span>, strength=<span class="hljs-number">0.3</span>)'}}),{c(){c=s("meta"),R=m(),d=s("h1"),g=s("a"),E=s("span"),Z(y.$$.fragment),T=m(),A=s("span"),Rt=i("AutoPipeline"),tt=m(),w=s("p"),At=i("\u{1F917} Diffusers is able to complete many different tasks, and you can often reuse the same pretrained weights for multiple tasks such as text-to-image, image-to-image, and inpainting. If you\u2019re new to the library and diffusion models though, it may be difficult to know which pipeline to use for a task. For example, if you\u2019re using the "),L=s("a"),St=i("runwayml/stable-diffusion-v1-5"),$t=i(" checkpoint for text-to-image, you might not know that you could also use it for image-to-image and inpainting by loading the checkpoint with the "),de=s("a"),xt=i("StableDiffusionImg2ImgPipeline"),Pt=i(" and "),he=s("a"),Qt=i("StableDiffusionInpaintPipeline"),Yt=i(" classes respectively."),lt=m(),b=s("p"),Nt=i("The "),Ve=s("code"),Ct=i("AutoPipeline"),Dt=i(" class is designed to simplify the variety of pipelines in \u{1F917} Diffusers. It is a generic, "),Re=s("em"),zt=i("task-first"),qt=i(" pipeline that lets you focus on the task. The "),Ae=s("code"),Ht=i("AutoPipeline"),Lt=i(" automatically detects the correct pipeline class to use, which makes it easier to load a checkpoint for a task without knowing the specific pipeline class name."),it=m(),Z(S.$$.fragment),at=m(),$=s("p"),Kt=i("This tutorial shows you how to use an "),Se=s("code"),Ot=i("AutoPipeline"),el=i(" to automatically infer the pipeline class to load for a specific task, given the pretrained weights."),st=m(),B=s("h2"),x=s("a"),$e=s("span"),Z(K.$$.fragment),tl=m(),xe=s("span"),ll=i("Choose an AutoPipeline for your task"),nt=m(),j=s("p"),il=i("Start by picking a checkpoint. For example, if you\u2019re interested in text-to-image with the "),O=s("a"),al=i("runwayml/stable-diffusion-v1-5"),sl=i(" checkpoint, use "),ye=s("a"),nl=i("AutoPipelineForText2Image"),ol=i(":"),ot=m(),Z(ee.$$.fragment),pt=m(),te=s("div"),ge=s("img"),rt=m(),P=s("p"),pl=i("Under the hood, "),we=s("a"),rl=i("AutoPipelineForText2Image"),fl=i(":"),ft=m(),Q=s("ol"),X=s("li"),ml=i("automatically detects a "),Pe=s("code"),ul=i('"stable-diffusion"'),cl=i(" class from the "),le=s("a"),Qe=s("code"),dl=i("model_index.json"),hl=i(" file"),yl=m(),F=s("li"),gl=i("loads the corresponding text-to-image "),Ye=s("code"),wl=i("StableDiffusionPipline"),bl=i(" based on the "),Ne=s("code"),Ml=i('"stable-diffusion"'),Jl=i(" class name"),mt=m(),h=s("p"),Zl=i("Likewise, for image-to-image, "),be=s("a"),_l=i("AutoPipelineForImage2Image"),Il=i(" detects a "),Ce=s("code"),Ul=i('"stable-diffusion"'),vl=i(" checkpoint from the "),De=s("code"),kl=i("model_index.json"),Tl=i(" file and it\u2019ll load the corresponding "),Me=s("a"),jl=i("StableDiffusionImg2ImgPipeline"),Wl=i(" behind the scenes. You can also pass any additional arguments specific to the pipeline class such as "),ze=s("code"),Gl=i("strength"),El=i(", which determines the amount of noise or variation added to an input image:"),ut=m(),Z(ie.$$.fragment),ct=m(),ae=s("div"),Je=s("img"),dt=m(),W=s("p"),Bl=i("And if you want to do inpainting, then "),Ze=s("a"),Xl=i("AutoPipelineForInpainting"),Fl=i(" loads the underlying "),_e=s("a"),Vl=i("StableDiffusionInpaintPipeline"),Rl=i(" class in the same way:"),ht=m(),Z(se.$$.fragment),yt=m(),ne=s("div"),Ie=s("img"),gt=m(),Ue=s("p"),Al=i("If you try to load an unsupported checkpoint, it\u2019ll throw an error:"),wt=m(),Z(oe.$$.fragment),bt=m(),V=s("h2"),Y=s("a"),qe=s("span"),Z(pe.$$.fragment),Sl=m(),He=s("span"),$l=i("Use multiple pipelines"),Mt=m(),N=s("p"),xl=i("For some workflows or if you\u2019re loading many pipelines, it is more memory-efficient to reuse the same components from a checkpoint instead of reloading them which would unnecessarily consume additional memory. For example, if you\u2019re using a checkpoint for text-to-image and you want to use it again for image-to-image, use the "),ve=s("a"),Pl=i("from_pipe()"),Ql=i(" method. This method creates a new pipeline from the components of a previously loaded pipeline at no additional memory cost."),Jt=m(),G=s("p"),Yl=i("The "),ke=s("a"),Nl=i("from_pipe()"),Cl=i(" method detects the original pipeline class and maps it to the new pipeline class corresponding to the task you want to do. For example, if you load a "),Le=s("code"),Dl=i('"stable-diffusion"'),zl=i(" class pipeline for text-to-image:"),Zt=m(),Z(re.$$.fragment),_t=m(),M=s("p"),ql=i("Then "),Te=s("a"),Hl=i("from_pipe()"),Ll=i(" maps the original "),Ke=s("code"),Kl=i('"stable-diffusion"'),Ol=i(" pipeline class to "),je=s("a"),ei=i("StableDiffusionImg2ImgPipeline"),ti=i(":"),It=m(),Z(fe.$$.fragment),Ut=m(),We=s("p"),li=i("If you passed an optional argument - like disabling the safety checker - to the original pipeline, this argument is also passed on to the new pipeline:"),vt=m(),Z(me.$$.fragment),kt=m(),C=s("p"),ii=i("You can overwrite any of the arguments and even configuration from the original pipeline if you want to change the behavior of the new pipeline. For example, to turn the safety checker back on and add the "),Oe=s("code"),ai=i("strength"),si=i(" argument:"),Tt=m(),Z(ue.$$.fragment),this.h()},l(e){const o=ia('[data-svelte="svelte-1phssyn"]',document.head);c=n(o,"META",{name:!0,content:!0}),o.forEach(l),R=u(e),d=n(e,"H1",{class:!0});var ce=p(d);g=n(ce,"A",{id:!0,class:!0,href:!0});var mi=p(g);E=n(mi,"SPAN",{});var ui=p(E);_(y.$$.fragment,ui),ui.forEach(l),mi.forEach(l),T=u(ce),A=n(ce,"SPAN",{});var ci=p(A);Rt=a(ci,"AutoPipeline"),ci.forEach(l),ce.forEach(l),tt=u(e),w=n(e,"P",{});var D=p(w);At=a(D,"\u{1F917} Diffusers is able to complete many different tasks, and you can often reuse the same pretrained weights for multiple tasks such as text-to-image, image-to-image, and inpainting. If you\u2019re new to the library and diffusion models though, it may be difficult to know which pipeline to use for a task. For example, if you\u2019re using the "),L=n(D,"A",{href:!0,rel:!0});var di=p(L);St=a(di,"runwayml/stable-diffusion-v1-5"),di.forEach(l),$t=a(D," checkpoint for text-to-image, you might not know that you could also use it for image-to-image and inpainting by loading the checkpoint with the "),de=n(D,"A",{href:!0});var hi=p(de);xt=a(hi,"StableDiffusionImg2ImgPipeline"),hi.forEach(l),Pt=a(D," and "),he=n(D,"A",{href:!0});var yi=p(he);Qt=a(yi,"StableDiffusionInpaintPipeline"),yi.forEach(l),Yt=a(D," classes respectively."),D.forEach(l),lt=u(e),b=n(e,"P",{});var z=p(b);Nt=a(z,"The "),Ve=n(z,"CODE",{});var gi=p(Ve);Ct=a(gi,"AutoPipeline"),gi.forEach(l),Dt=a(z," class is designed to simplify the variety of pipelines in \u{1F917} Diffusers. It is a generic, "),Re=n(z,"EM",{});var wi=p(Re);zt=a(wi,"task-first"),wi.forEach(l),qt=a(z," pipeline that lets you focus on the task. The "),Ae=n(z,"CODE",{});var bi=p(Ae);Ht=a(bi,"AutoPipeline"),bi.forEach(l),Lt=a(z," automatically detects the correct pipeline class to use, which makes it easier to load a checkpoint for a task without knowing the specific pipeline class name."),z.forEach(l),it=u(e),_(S.$$.fragment,e),at=u(e),$=n(e,"P",{});var Wt=p($);Kt=a(Wt,"This tutorial shows you how to use an "),Se=n(Wt,"CODE",{});var Mi=p(Se);Ot=a(Mi,"AutoPipeline"),Mi.forEach(l),el=a(Wt," to automatically infer the pipeline class to load for a specific task, given the pretrained weights."),Wt.forEach(l),st=u(e),B=n(e,"H2",{class:!0});var Gt=p(B);x=n(Gt,"A",{id:!0,class:!0,href:!0});var Ji=p(x);$e=n(Ji,"SPAN",{});var Zi=p($e);_(K.$$.fragment,Zi),Zi.forEach(l),Ji.forEach(l),tl=u(Gt),xe=n(Gt,"SPAN",{});var _i=p(xe);ll=a(_i,"Choose an AutoPipeline for your task"),_i.forEach(l),Gt.forEach(l),nt=u(e),j=n(e,"P",{});var Ge=p(j);il=a(Ge,"Start by picking a checkpoint. For example, if you\u2019re interested in text-to-image with the "),O=n(Ge,"A",{href:!0,rel:!0});var Ii=p(O);al=a(Ii,"runwayml/stable-diffusion-v1-5"),Ii.forEach(l),sl=a(Ge," checkpoint, use "),ye=n(Ge,"A",{href:!0});var Ui=p(ye);nl=a(Ui,"AutoPipelineForText2Image"),Ui.forEach(l),ol=a(Ge,":"),Ge.forEach(l),ot=u(e),_(ee.$$.fragment,e),pt=u(e),te=n(e,"DIV",{class:!0});var vi=p(te);ge=n(vi,"IMG",{src:!0,alt:!0}),vi.forEach(l),rt=u(e),P=n(e,"P",{});var Et=p(P);pl=a(Et,"Under the hood, "),we=n(Et,"A",{href:!0});var ki=p(we);rl=a(ki,"AutoPipelineForText2Image"),ki.forEach(l),fl=a(Et,":"),Et.forEach(l),ft=u(e),Q=n(e,"OL",{});var Bt=p(Q);X=n(Bt,"LI",{});var Ee=p(X);ml=a(Ee,"automatically detects a "),Pe=n(Ee,"CODE",{});var Ti=p(Pe);ul=a(Ti,'"stable-diffusion"'),Ti.forEach(l),cl=a(Ee," class from the "),le=n(Ee,"A",{href:!0,rel:!0});var ji=p(le);Qe=n(ji,"CODE",{});var Wi=p(Qe);dl=a(Wi,"model_index.json"),Wi.forEach(l),ji.forEach(l),hl=a(Ee," file"),Ee.forEach(l),yl=u(Bt),F=n(Bt,"LI",{});var Be=p(F);gl=a(Be,"loads the corresponding text-to-image "),Ye=n(Be,"CODE",{});var Gi=p(Ye);wl=a(Gi,"StableDiffusionPipline"),Gi.forEach(l),bl=a(Be," based on the "),Ne=n(Be,"CODE",{});var Ei=p(Ne);Ml=a(Ei,'"stable-diffusion"'),Ei.forEach(l),Jl=a(Be," class name"),Be.forEach(l),Bt.forEach(l),mt=u(e),h=n(e,"P",{});var J=p(h);Zl=a(J,"Likewise, for image-to-image, "),be=n(J,"A",{href:!0});var Bi=p(be);_l=a(Bi,"AutoPipelineForImage2Image"),Bi.forEach(l),Il=a(J," detects a "),Ce=n(J,"CODE",{});var Xi=p(Ce);Ul=a(Xi,'"stable-diffusion"'),Xi.forEach(l),vl=a(J," checkpoint from the "),De=n(J,"CODE",{});var Fi=p(De);kl=a(Fi,"model_index.json"),Fi.forEach(l),Tl=a(J," file and it\u2019ll load the corresponding "),Me=n(J,"A",{href:!0});var Vi=p(Me);jl=a(Vi,"StableDiffusionImg2ImgPipeline"),Vi.forEach(l),Wl=a(J," behind the scenes. You can also pass any additional arguments specific to the pipeline class such as "),ze=n(J,"CODE",{});var Ri=p(ze);Gl=a(Ri,"strength"),Ri.forEach(l),El=a(J,", which determines the amount of noise or variation added to an input image:"),J.forEach(l),ut=u(e),_(ie.$$.fragment,e),ct=u(e),ae=n(e,"DIV",{class:!0});var Ai=p(ae);Je=n(Ai,"IMG",{src:!0,alt:!0}),Ai.forEach(l),dt=u(e),W=n(e,"P",{});var Xe=p(W);Bl=a(Xe,"And if you want to do inpainting, then "),Ze=n(Xe,"A",{href:!0});var Si=p(Ze);Xl=a(Si,"AutoPipelineForInpainting"),Si.forEach(l),Fl=a(Xe," loads the underlying "),_e=n(Xe,"A",{href:!0});var $i=p(_e);Vl=a($i,"StableDiffusionInpaintPipeline"),$i.forEach(l),Rl=a(Xe," class in the same way:"),Xe.forEach(l),ht=u(e),_(se.$$.fragment,e),yt=u(e),ne=n(e,"DIV",{class:!0});var xi=p(ne);Ie=n(xi,"IMG",{src:!0,alt:!0}),xi.forEach(l),gt=u(e),Ue=n(e,"P",{});var Pi=p(Ue);Al=a(Pi,"If you try to load an unsupported checkpoint, it\u2019ll throw an error:"),Pi.forEach(l),wt=u(e),_(oe.$$.fragment,e),bt=u(e),V=n(e,"H2",{class:!0});var Xt=p(V);Y=n(Xt,"A",{id:!0,class:!0,href:!0});var Qi=p(Y);qe=n(Qi,"SPAN",{});var Yi=p(qe);_(pe.$$.fragment,Yi),Yi.forEach(l),Qi.forEach(l),Sl=u(Xt),He=n(Xt,"SPAN",{});var Ni=p(He);$l=a(Ni,"Use multiple pipelines"),Ni.forEach(l),Xt.forEach(l),Mt=u(e),N=n(e,"P",{});var Ft=p(N);xl=a(Ft,"For some workflows or if you\u2019re loading many pipelines, it is more memory-efficient to reuse the same components from a checkpoint instead of reloading them which would unnecessarily consume additional memory. For example, if you\u2019re using a checkpoint for text-to-image and you want to use it again for image-to-image, use the "),ve=n(Ft,"A",{href:!0});var Ci=p(ve);Pl=a(Ci,"from_pipe()"),Ci.forEach(l),Ql=a(Ft," method. This method creates a new pipeline from the components of a previously loaded pipeline at no additional memory cost."),Ft.forEach(l),Jt=u(e),G=n(e,"P",{});var Fe=p(G);Yl=a(Fe,"The "),ke=n(Fe,"A",{href:!0});var Di=p(ke);Nl=a(Di,"from_pipe()"),Di.forEach(l),Cl=a(Fe," method detects the original pipeline class and maps it to the new pipeline class corresponding to the task you want to do. For example, if you load a "),Le=n(Fe,"CODE",{});var zi=p(Le);Dl=a(zi,'"stable-diffusion"'),zi.forEach(l),zl=a(Fe," class pipeline for text-to-image:"),Fe.forEach(l),Zt=u(e),_(re.$$.fragment,e),_t=u(e),M=n(e,"P",{});var q=p(M);ql=a(q,"Then "),Te=n(q,"A",{href:!0});var qi=p(Te);Hl=a(qi,"from_pipe()"),qi.forEach(l),Ll=a(q," maps the original "),Ke=n(q,"CODE",{});var Hi=p(Ke);Kl=a(Hi,'"stable-diffusion"'),Hi.forEach(l),Ol=a(q," pipeline class to "),je=n(q,"A",{href:!0});var Li=p(je);ei=a(Li,"StableDiffusionImg2ImgPipeline"),Li.forEach(l),ti=a(q,":"),q.forEach(l),It=u(e),_(fe.$$.fragment,e),Ut=u(e),We=n(e,"P",{});var Ki=p(We);li=a(Ki,"If you passed an optional argument - like disabling the safety checker - to the original pipeline, this argument is also passed on to the new pipeline:"),Ki.forEach(l),vt=u(e),_(me.$$.fragment,e),kt=u(e),C=n(e,"P",{});var Vt=p(C);ii=a(Vt,"You can overwrite any of the arguments and even configuration from the original pipeline if you want to change the behavior of the new pipeline. For example, to turn the safety checker back on and add the "),Oe=n(Vt,"CODE",{});var Oi=p(Oe);ai=a(Oi,"strength"),Oi.forEach(l),si=a(Vt," argument:"),Vt.forEach(l),Tt=u(e),_(ue.$$.fragment,e),this.h()},h(){f(c,"name","hf:doc:metadata"),f(c,"content",JSON.stringify(pa)),f(g,"id","autopipeline"),f(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(g,"href","#autopipeline"),f(d,"class","relative group"),f(L,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),f(L,"rel","nofollow"),f(de,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline"),f(he,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline"),f(x,"id","choose-an-autopipeline-for-your-task"),f(x,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(x,"href","#choose-an-autopipeline-for-your-task"),f(B,"class","relative group"),f(O,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),f(O,"rel","nofollow"),f(ye,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image"),ni(ge.src,pi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/autopipeline-text2img.png")||f(ge,"src",pi),f(ge,"alt","generated image of peasant fighting dragon in wood cutting style"),f(te,"class","flex justify-center"),f(we,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image"),f(le,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/model_index.json"),f(le,"rel","nofollow"),f(be,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image"),f(Me,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline"),ni(Je.src,ri="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/autopipeline-img2img.png")||f(Je,"src",ri),f(Je,"alt","generated image of a vermeer portrait of a dog wearing a pearl earring"),f(ae,"class","flex justify-center"),f(Ze,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting"),f(_e,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline"),ni(Ie.src,fi="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/autopipeline-inpaint.png")||f(Ie,"src",fi),f(Ie,"alt","generated image of a tiger sitting on a bench"),f(ne,"class","flex justify-center"),f(Y,"id","use-multiple-pipelines"),f(Y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(Y,"href","#use-multiple-pipelines"),f(V,"class","relative group"),f(ve,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pipe"),f(ke,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pipe"),f(Te,"href","/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pipe"),f(je,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline")},m(e,o){t(document.head,c),r(e,R,o),r(e,d,o),t(d,g),t(g,E),I(y,E,null),t(d,T),t(d,A),t(A,Rt),r(e,tt,o),r(e,w,o),t(w,At),t(w,L),t(L,St),t(w,$t),t(w,de),t(de,xt),t(w,Pt),t(w,he),t(he,Qt),t(w,Yt),r(e,lt,o),r(e,b,o),t(b,Nt),t(b,Ve),t(Ve,Ct),t(b,Dt),t(b,Re),t(Re,zt),t(b,qt),t(b,Ae),t(Ae,Ht),t(b,Lt),r(e,it,o),I(S,e,o),r(e,at,o),r(e,$,o),t($,Kt),t($,Se),t(Se,Ot),t($,el),r(e,st,o),r(e,B,o),t(B,x),t(x,$e),I(K,$e,null),t(B,tl),t(B,xe),t(xe,ll),r(e,nt,o),r(e,j,o),t(j,il),t(j,O),t(O,al),t(j,sl),t(j,ye),t(ye,nl),t(j,ol),r(e,ot,o),I(ee,e,o),r(e,pt,o),r(e,te,o),t(te,ge),r(e,rt,o),r(e,P,o),t(P,pl),t(P,we),t(we,rl),t(P,fl),r(e,ft,o),r(e,Q,o),t(Q,X),t(X,ml),t(X,Pe),t(Pe,ul),t(X,cl),t(X,le),t(le,Qe),t(Qe,dl),t(X,hl),t(Q,yl),t(Q,F),t(F,gl),t(F,Ye),t(Ye,wl),t(F,bl),t(F,Ne),t(Ne,Ml),t(F,Jl),r(e,mt,o),r(e,h,o),t(h,Zl),t(h,be),t(be,_l),t(h,Il),t(h,Ce),t(Ce,Ul),t(h,vl),t(h,De),t(De,kl),t(h,Tl),t(h,Me),t(Me,jl),t(h,Wl),t(h,ze),t(ze,Gl),t(h,El),r(e,ut,o),I(ie,e,o),r(e,ct,o),r(e,ae,o),t(ae,Je),r(e,dt,o),r(e,W,o),t(W,Bl),t(W,Ze),t(Ze,Xl),t(W,Fl),t(W,_e),t(_e,Vl),t(W,Rl),r(e,ht,o),I(se,e,o),r(e,yt,o),r(e,ne,o),t(ne,Ie),r(e,gt,o),r(e,Ue,o),t(Ue,Al),r(e,wt,o),I(oe,e,o),r(e,bt,o),r(e,V,o),t(V,Y),t(Y,qe),I(pe,qe,null),t(V,Sl),t(V,He),t(He,$l),r(e,Mt,o),r(e,N,o),t(N,xl),t(N,ve),t(ve,Pl),t(N,Ql),r(e,Jt,o),r(e,G,o),t(G,Yl),t(G,ke),t(ke,Nl),t(G,Cl),t(G,Le),t(Le,Dl),t(G,zl),r(e,Zt,o),I(re,e,o),r(e,_t,o),r(e,M,o),t(M,ql),t(M,Te),t(Te,Hl),t(M,Ll),t(M,Ke),t(Ke,Kl),t(M,Ol),t(M,je),t(je,ei),t(M,ti),r(e,It,o),I(fe,e,o),r(e,Ut,o),r(e,We,o),t(We,li),r(e,vt,o),I(me,e,o),r(e,kt,o),r(e,C,o),t(C,ii),t(C,Oe),t(Oe,ai),t(C,si),r(e,Tt,o),I(ue,e,o),jt=!0},p(e,[o]){const ce={};o&2&&(ce.$$scope={dirty:o,ctx:e}),S.$set(ce)},i(e){jt||(U(y.$$.fragment,e),U(S.$$.fragment,e),U(K.$$.fragment,e),U(ee.$$.fragment,e),U(ie.$$.fragment,e),U(se.$$.fragment,e),U(oe.$$.fragment,e),U(pe.$$.fragment,e),U(re.$$.fragment,e),U(fe.$$.fragment,e),U(me.$$.fragment,e),U(ue.$$.fragment,e),jt=!0)},o(e){v(y.$$.fragment,e),v(S.$$.fragment,e),v(K.$$.fragment,e),v(ee.$$.fragment,e),v(ie.$$.fragment,e),v(se.$$.fragment,e),v(oe.$$.fragment,e),v(pe.$$.fragment,e),v(re.$$.fragment,e),v(fe.$$.fragment,e),v(me.$$.fragment,e),v(ue.$$.fragment,e),jt=!1},d(e){l(c),e&&l(R),e&&l(d),k(y),e&&l(tt),e&&l(w),e&&l(lt),e&&l(b),e&&l(it),k(S,e),e&&l(at),e&&l($),e&&l(st),e&&l(B),k(K),e&&l(nt),e&&l(j),e&&l(ot),k(ee,e),e&&l(pt),e&&l(te),e&&l(rt),e&&l(P),e&&l(ft),e&&l(Q),e&&l(mt),e&&l(h),e&&l(ut),k(ie,e),e&&l(ct),e&&l(ae),e&&l(dt),e&&l(W),e&&l(ht),k(se,e),e&&l(yt),e&&l(ne),e&&l(gt),e&&l(Ue),e&&l(wt),k(oe,e),e&&l(bt),e&&l(V),k(pe),e&&l(Mt),e&&l(N),e&&l(Jt),e&&l(G),e&&l(Zt),k(re,e),e&&l(_t),e&&l(M),e&&l(It),k(fe,e),e&&l(Ut),e&&l(We),e&&l(vt),k(me,e),e&&l(kt),e&&l(C),e&&l(Tt),k(ue,e)}}}const pa={local:"autopipeline",sections:[{local:"choose-an-autopipeline-for-your-task",title:"Choose an AutoPipeline for your task"},{local:"use-multiple-pipelines",title:"Use multiple pipelines"}],title:"AutoPipeline"};function ra(et){return aa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class da extends ea{constructor(c){super();ta(this,c,ra,oa,la,{})}}export{da as default,pa as metadata};
