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