import{S as ai,i as li,s as ri,e as a,k as g,w as ne,t as o,M as si,c as l,d as t,m as w,a as p,x as ae,h as n,b as s,G as i,g as m,y as le,q as re,o as se,B as pe,v as pi}from"../../chunks/vendor-hf-doc-builder.js";import{T as fi}from"../../chunks/Tip-hf-doc-builder.js";import{I as mi}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as ni}from"../../chunks/CodeBlock-hf-doc-builder.js";function ui(U){let f,b;return{c(){f=a("p"),b=o("\u{1F512} By loading a community pipeline from the Hugging Face Hub, you are trusting that the code you are loading is safe. Make sure to inspect the code online before loading and running it automatically!")},l(u){f=l(u,"P",{});var d=p(f);b=n(d,"\u{1F512} By loading a community pipeline from the Hugging Face Hub, you are trusting that the code you are loading is safe. Make sure to inspect the code online before loading and running it automatically!"),d.forEach(t)},m(u,d){m(u,f,d),i(f,b)},d(u){u&&t(f)}}}function di(U){let f,b,u,d,O,E,fe,K,me,z,c,ue,H,de,ce,M,he,ye,k,_e,ge,Q,h,we,I,be,ve,D,Pe,$e,L,Ce,xe,W,y,Ee,V,ke,Ie,A,J,De,Le,S,R,Ae,Se,X,v,Y,T,Z,P,Te,q,qe,je,ee,j,ie,_,Be,N,He,Me,F,Ne,Fe,te;return E=new mi({}),v=new fi({props:{warning:!0,$$slots:{default:[ui]},$$scope:{ctx:U}}}),T=new ni({props:{code:`from diffusers import DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    "google/ddpm-cifar10-32", custom_pipeline="hf-internal-testing/diffusers-dummy-pipeline"
)`,highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;google/ddpm-cifar10-32&quot;</span>, custom_pipeline=<span class="hljs-string">&quot;hf-internal-testing/diffusers-dummy-pipeline&quot;</span>
)`}}),j=new ni({props:{code:`from diffusers import DiffusionPipeline
from transformers import CLIPImageProcessor, CLIPModel

clip_model_id = "laion/CLIP-ViT-B-32-laion2B-s34B-b79K"

feature_extractor = CLIPImageProcessor.from_pretrained(clip_model_id)
clip_model = CLIPModel.from_pretrained(clip_model_id)

pipeline = DiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    custom_pipeline="clip_guided_stable_diffusion",
    clip_model=clip_model,
    feature_extractor=feature_extractor,
)`,highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPImageProcessor, CLIPModel

clip_model_id = <span class="hljs-string">&quot;laion/CLIP-ViT-B-32-laion2B-s34B-b79K&quot;</span>

feature_extractor = CLIPImageProcessor.from_pretrained(clip_model_id)
clip_model = CLIPModel.from_pretrained(clip_model_id)

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>,
    custom_pipeline=<span class="hljs-string">&quot;clip_guided_stable_diffusion&quot;</span>,
    clip_model=clip_model,
    feature_extractor=feature_extractor,
)`}}),{c(){f=a("meta"),b=g(),u=a("h1"),d=a("a"),O=a("span"),ne(E.$$.fragment),fe=g(),K=a("span"),me=o("Load community pipelines"),z=g(),c=a("p"),ue=o("Community pipelines are any "),H=a("a"),de=o("DiffusionPipeline"),ce=o(" class that are different from the original implementation as specified in their paper (for example, the "),M=a("a"),he=o("StableDiffusionControlNetPipeline"),ye=o(" corresponds to the "),k=a("a"),_e=o("Text-to-Image Generation with ControlNet Conditioning"),ge=o(" paper). They provide additional functionality or extend the original implementation of a pipeline."),Q=g(),h=a("p"),we=o("There are many cool community pipelines like "),I=a("a"),be=o("Speech to Image"),ve=o(" or "),D=a("a"),Pe=o("Composable Stable Diffusion"),$e=o(", and you can find all the official community pipelines "),L=a("a"),Ce=o("here"),xe=o("."),W=g(),y=a("p"),Ee=o("To load any community pipeline on the Hub, pass the repository id of the community pipeline to the "),V=a("code"),ke=o("custom_pipeline"),Ie=o(" argument and the model repository where you\u2019d like to load the pipeline weights and components from. For example, the example below loads a dummy pipeline from "),A=a("a"),J=a("code"),De=o("hf-internal-testing/diffusers-dummy-pipeline"),Le=o(" and the pipeline weights and components from "),S=a("a"),R=a("code"),Ae=o("google/ddpm-cifar10-32"),Se=o(":"),X=g(),ne(v.$$.fragment),Y=g(),ne(T.$$.fragment),Z=g(),P=a("p"),Te=o("Loading an official community pipeline is similar, but you can mix loading weights from an official repository id and pass pipeline components directly. The example below loads the community "),q=a("a"),qe=o("CLIP Guided Stable Diffusion"),je=o(" pipeline, and you can pass the CLIP model components directly to it:"),ee=g(),ne(j.$$.fragment),ie=g(),_=a("p"),Be=o("For more information about community pipelines, take a look at the "),N=a("a"),He=o("Community pipelines"),Me=o(" guide for how to use them and if you\u2019re interested in adding a community pipeline check out the "),F=a("a"),Ne=o("How to contribute a community pipeline"),Fe=o(" guide!"),this.h()},l(e){const r=si('[data-svelte="svelte-1phssyn"]',document.head);f=l(r,"META",{name:!0,content:!0}),r.forEach(t),b=w(e),u=l(e,"H1",{class:!0});var B=p(u);d=l(B,"A",{id:!0,class:!0,href:!0});var Ge=p(d);O=l(Ge,"SPAN",{});var Oe=p(O);ae(E.$$.fragment,Oe),Oe.forEach(t),Ge.forEach(t),fe=w(B),K=l(B,"SPAN",{});var Ke=p(K);me=n(Ke,"Load community pipelines"),Ke.forEach(t),B.forEach(t),z=w(e),c=l(e,"P",{});var $=p(c);ue=n($,"Community pipelines are any "),H=l($,"A",{href:!0});var Ve=p(H);de=n(Ve,"DiffusionPipeline"),Ve.forEach(t),ce=n($," class that are different from the original implementation as specified in their paper (for example, the "),M=l($,"A",{href:!0});var Je=p(M);he=n(Je,"StableDiffusionControlNetPipeline"),Je.forEach(t),ye=n($," corresponds to the "),k=l($,"A",{href:!0,rel:!0});var Re=p(k);_e=n(Re,"Text-to-Image Generation with ControlNet Conditioning"),Re.forEach(t),ge=n($," paper). They provide additional functionality or extend the original implementation of a pipeline."),$.forEach(t),Q=w(e),h=l(e,"P",{});var C=p(h);we=n(C,"There are many cool community pipelines like "),I=l(C,"A",{href:!0,rel:!0});var Ue=p(I);be=n(Ue,"Speech to Image"),Ue.forEach(t),ve=n(C," or "),D=l(C,"A",{href:!0,rel:!0});var ze=p(D);Pe=n(ze,"Composable Stable Diffusion"),ze.forEach(t),$e=n(C,", and you can find all the official community pipelines "),L=l(C,"A",{href:!0,rel:!0});var Qe=p(L);Ce=n(Qe,"here"),Qe.forEach(t),xe=n(C,"."),C.forEach(t),W=w(e),y=l(e,"P",{});var x=p(y);Ee=n(x,"To load any community pipeline on the Hub, pass the repository id of the community pipeline to the "),V=l(x,"CODE",{});var We=p(V);ke=n(We,"custom_pipeline"),We.forEach(t),Ie=n(x," argument and the model repository where you\u2019d like to load the pipeline weights and components from. For example, the example below loads a dummy pipeline from "),A=l(x,"A",{href:!0,rel:!0});var Xe=p(A);J=l(Xe,"CODE",{});var Ye=p(J);De=n(Ye,"hf-internal-testing/diffusers-dummy-pipeline"),Ye.forEach(t),Xe.forEach(t),Le=n(x," and the pipeline weights and components from "),S=l(x,"A",{href:!0,rel:!0});var Ze=p(S);R=l(Ze,"CODE",{});var ei=p(R);Ae=n(ei,"google/ddpm-cifar10-32"),ei.forEach(t),Ze.forEach(t),Se=n(x,":"),x.forEach(t),X=w(e),ae(v.$$.fragment,e),Y=w(e),ae(T.$$.fragment,e),Z=w(e),P=l(e,"P",{});var oe=p(P);Te=n(oe,"Loading an official community pipeline is similar, but you can mix loading weights from an official repository id and pass pipeline components directly. The example below loads the community "),q=l(oe,"A",{href:!0,rel:!0});var ii=p(q);qe=n(ii,"CLIP Guided Stable Diffusion"),ii.forEach(t),je=n(oe," pipeline, and you can pass the CLIP model components directly to it:"),oe.forEach(t),ee=w(e),ae(j.$$.fragment,e),ie=w(e),_=l(e,"P",{});var G=p(_);Be=n(G,"For more information about community pipelines, take a look at the "),N=l(G,"A",{href:!0});var ti=p(N);He=n(ti,"Community pipelines"),ti.forEach(t),Me=n(G," guide for how to use them and if you\u2019re interested in adding a community pipeline check out the "),F=l(G,"A",{href:!0});var oi=p(F);Ne=n(oi,"How to contribute a community pipeline"),oi.forEach(t),Fe=n(G," guide!"),G.forEach(t),this.h()},h(){s(f,"name","hf:doc:metadata"),s(f,"content",JSON.stringify(ci)),s(d,"id","load-community-pipelines"),s(d,"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"),s(d,"href","#load-community-pipelines"),s(u,"class","relative group"),s(H,"href","/docs/diffusers/v0.16.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),s(M,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/controlnet#diffusers.StableDiffusionControlNetPipeline"),s(k,"href","https://arxiv.org/abs/2302.05543"),s(k,"rel","nofollow"),s(I,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#speech-to-image"),s(I,"rel","nofollow"),s(D,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#composable-stable-diffusion"),s(D,"rel","nofollow"),s(L,"href","https://github.com/huggingface/diffusers/tree/main/examples/community"),s(L,"rel","nofollow"),s(A,"href","https://huggingface.co/hf-internal-testing/diffusers-dummy-pipeline/blob/main/pipeline.py"),s(A,"rel","nofollow"),s(S,"href","https://huggingface.co/google/ddpm-cifar10-32"),s(S,"rel","nofollow"),s(q,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#clip-guided-stable-diffusion"),s(q,"rel","nofollow"),s(N,"href","custom_pipeline_examples"),s(F,"href","contribute_pipeline")},m(e,r){i(document.head,f),m(e,b,r),m(e,u,r),i(u,d),i(d,O),le(E,O,null),i(u,fe),i(u,K),i(K,me),m(e,z,r),m(e,c,r),i(c,ue),i(c,H),i(H,de),i(c,ce),i(c,M),i(M,he),i(c,ye),i(c,k),i(k,_e),i(c,ge),m(e,Q,r),m(e,h,r),i(h,we),i(h,I),i(I,be),i(h,ve),i(h,D),i(D,Pe),i(h,$e),i(h,L),i(L,Ce),i(h,xe),m(e,W,r),m(e,y,r),i(y,Ee),i(y,V),i(V,ke),i(y,Ie),i(y,A),i(A,J),i(J,De),i(y,Le),i(y,S),i(S,R),i(R,Ae),i(y,Se),m(e,X,r),le(v,e,r),m(e,Y,r),le(T,e,r),m(e,Z,r),m(e,P,r),i(P,Te),i(P,q),i(q,qe),i(P,je),m(e,ee,r),le(j,e,r),m(e,ie,r),m(e,_,r),i(_,Be),i(_,N),i(N,He),i(_,Me),i(_,F),i(F,Ne),i(_,Fe),te=!0},p(e,[r]){const B={};r&2&&(B.$$scope={dirty:r,ctx:e}),v.$set(B)},i(e){te||(re(E.$$.fragment,e),re(v.$$.fragment,e),re(T.$$.fragment,e),re(j.$$.fragment,e),te=!0)},o(e){se(E.$$.fragment,e),se(v.$$.fragment,e),se(T.$$.fragment,e),se(j.$$.fragment,e),te=!1},d(e){t(f),e&&t(b),e&&t(u),pe(E),e&&t(z),e&&t(c),e&&t(Q),e&&t(h),e&&t(W),e&&t(y),e&&t(X),pe(v,e),e&&t(Y),pe(T,e),e&&t(Z),e&&t(P),e&&t(ee),pe(j,e),e&&t(ie),e&&t(_)}}}const ci={local:"load-community-pipelines",title:"Load community pipelines"};function hi(U){return pi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class bi extends ai{constructor(f){super();li(this,f,hi,di,ri,{})}}export{bi as default,ci as metadata};
