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