Buckets:
hf-doc-build/doc / diffusers /main /en /_app /pages /using-diffusers /custom_pipeline_overview.mdx-hf-doc-builder.js
| 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 z,q,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,U,ce,F,ue,te,C,ie,d,de,S,he,ye,R,be,ge,E,we,_e,oe,h,ve,$,Me,Je,k,Te,Ze,I,Ue,Ce,le,y,Ee,L,$e,ke,G,A,Ie,Ge,x,Q,xe,We,ae,v,ne,W,se,M,Ve,V,Be,Pe,re,B,pe,w,Se,N,Re,Ne,j,je,De,me;return U=new ut({}),C=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:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZ29vZ2xlJTJGZGRwbS1jaWZhcjEwLTMyJTIyJTJDJTIwY3VzdG9tX3BpcGVsaW5lJTNEJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1kdW1teS1waXBlbGluZSUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| pipeline = DiffusionPipeline.from_pretrained( | |
| <span class="hljs-string">"google/ddpm-cifar10-32"</span>, custom_pipeline=<span class="hljs-string">"hf-internal-testing/diffusers-dummy-pipeline"</span>, use_safetensors=<span class="hljs-literal">True</span> | |
| )`}}),B=new nt({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENMSVBJbWFnZVByb2Nlc3NvciUyQyUyMENMSVBNb2RlbCUwQSUwQWNsaXBfbW9kZWxfaWQlMjAlM0QlMjAlMjJsYWlvbiUyRkNMSVAtVmlULUItMzItbGFpb24yQi1zMzRCLWI3OUslMjIlMEElMEFmZWF0dXJlX2V4dHJhY3RvciUyMCUzRCUyMENMSVBJbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoY2xpcF9tb2RlbF9pZCklMEFjbGlwX21vZGVsJTIwJTNEJTIwQ0xJUE1vZGVsLmZyb21fcHJldHJhaW5lZChjbGlwX21vZGVsX2lkKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwY3VzdG9tX3BpcGVsaW5lJTNEJTIyY2xpcF9ndWlkZWRfc3RhYmxlX2RpZmZ1c2lvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMGNsaXBfbW9kZWwlM0RjbGlwX21vZGVsJTJDJTBBJTIwJTIwJTIwJTIwZmVhdHVyZV9leHRyYWN0b3IlM0RmZWF0dXJlX2V4dHJhY3RvciUyQyUwQSUyMCUyMCUyMCUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMkMlMEEp",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">"laion/CLIP-ViT-B-32-laion2B-s34B-b79K"</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">"runwayml/stable-diffusion-v1-5"</span>, | |
| custom_pipeline=<span class="hljs-string">"clip_guided_stable_diffusion"</span>, | |
| clip_model=clip_model, | |
| feature_extractor=feature_extractor, | |
| use_safetensors=<span class="hljs-literal">True</span>, | |
| )`}}),{c(){f=n("meta"),_=b(),c=n("h1"),u=n("a"),X=n("span"),H(U.$$.fragment),ce=b(),F=n("span"),ue=o("Load community pipelines"),te=b(),H(C.$$.fragment),ie=b(),d=n("p"),de=o("Community pipelines are any "),S=n("a"),he=o("DiffusionPipeline"),ye=o(" class that are different from the original implementation as specified in their paper (for example, the "),R=n("a"),be=o("StableDiffusionControlNetPipeline"),ge=o(" corresponds to the "),E=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 "),$=n("a"),Me=o("Speech to Image"),Je=o(" or "),k=n("a"),Te=o("Composable Stable Diffusion"),Ze=o(", and you can find all the official community pipelines "),I=n("a"),Ue=o("here"),Ce=o("."),le=b(),y=n("p"),Ee=o("To load any community pipeline on the Hub, pass the repository id of the community pipeline to the "),L=n("code"),$e=o("custom_pipeline"),ke=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=n("a"),A=n("code"),Ie=o("hf-internal-testing/diffusers-dummy-pipeline"),Ge=o(" and the pipeline weights and components from "),x=n("a"),Q=n("code"),xe=o("google/ddpm-cifar10-32"),We=o(":"),ae=b(),H(v.$$.fragment),ne=b(),H(W.$$.fragment),se=b(),M=n("p"),Ve=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 "),V=n("a"),Be=o("CLIP Guided Stable Diffusion"),Pe=o(" pipeline, and you can pass the CLIP model components directly to it:"),re=b(),H(B.$$.fragment),pe=b(),w=n("p"),Se=o("For more information about community pipelines, take a look at the "),N=n("a"),Re=o("Community pipelines"),Ne=o(" guide for how to use them and if you\u2019re interested in adding a community pipeline check out the "),j=n("a"),je=o("How to contribute a community pipeline"),De=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 P=p(c);u=s(P,"A",{id:!0,class:!0,href:!0});var Xe=p(u);X=s(Xe,"SPAN",{});var Fe=p(X);Y(U.$$.fragment,Fe),Fe.forEach(i),Xe.forEach(i),ce=g(P),F=s(P,"SPAN",{});var Le=p(F);ue=l(Le,"Load community pipelines"),Le.forEach(i),P.forEach(i),te=g(e),Y(C.$$.fragment,e),ie=g(e),d=s(e,"P",{});var J=p(d);de=l(J,"Community pipelines are any "),S=s(J,"A",{href:!0});var Ae=p(S);he=l(Ae,"DiffusionPipeline"),Ae.forEach(i),ye=l(J," class that are different from the original implementation as specified in their paper (for example, the "),R=s(J,"A",{href:!0});var Qe=p(R);be=l(Qe,"StableDiffusionControlNetPipeline"),Qe.forEach(i),ge=l(J," corresponds to the "),E=s(J,"A",{href:!0,rel:!0});var He=p(E);we=l(He,"Text-to-Image Generation with ControlNet Conditioning"),He.forEach(i),_e=l(J," paper). They provide additional functionality or extend the original implementation of a pipeline."),J.forEach(i),oe=g(e),h=s(e,"P",{});var T=p(h);ve=l(T,"There are many cool community pipelines like "),$=s(T,"A",{href:!0,rel:!0});var Ye=p($);Me=l(Ye,"Speech to Image"),Ye.forEach(i),Je=l(T," or "),k=s(T,"A",{href:!0,rel:!0});var ze=p(k);Te=l(ze,"Composable Stable Diffusion"),ze.forEach(i),Ze=l(T,", and you can find all the official community pipelines "),I=s(T,"A",{href:!0,rel:!0});var qe=p(I);Ue=l(qe,"here"),qe.forEach(i),Ce=l(T,"."),T.forEach(i),le=g(e),y=s(e,"P",{});var Z=p(y);Ee=l(Z,"To load any community pipeline on the Hub, pass the repository id of the community pipeline to the "),L=s(Z,"CODE",{});var Oe=p(L);$e=l(Oe,"custom_pipeline"),Oe.forEach(i),ke=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=s(Z,"A",{href:!0,rel:!0});var Ke=p(G);A=s(Ke,"CODE",{});var et=p(A);Ie=l(et,"hf-internal-testing/diffusers-dummy-pipeline"),et.forEach(i),Ke.forEach(i),Ge=l(Z," and the pipeline weights and components from "),x=s(Z,"A",{href:!0,rel:!0});var tt=p(x);Q=s(tt,"CODE",{});var it=p(Q);xe=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),M=s(e,"P",{});var fe=p(M);Ve=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 "),V=s(fe,"A",{href:!0,rel:!0});var ot=p(V);Be=l(ot,"CLIP Guided Stable Diffusion"),ot.forEach(i),Pe=l(fe," pipeline, and you can pass the CLIP model components directly to it:"),fe.forEach(i),re=g(e),Y(B.$$.fragment,e),pe=g(e),w=s(e,"P",{});var D=p(w);Se=l(D,"For more information about community pipelines, take a look at the "),N=s(D,"A",{href:!0});var lt=p(N);Re=l(lt,"Community pipelines"),lt.forEach(i),Ne=l(D," guide for how to use them and if you\u2019re interested in adding a community pipeline check out the "),j=s(D,"A",{href:!0});var at=p(j);je=l(at,"How to contribute a community pipeline"),at.forEach(i),De=l(D," guide!"),D.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(S,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),r(R,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline"),r(E,"href","https://arxiv.org/abs/2302.05543"),r(E,"rel","nofollow"),r($,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#speech-to-image"),r($,"rel","nofollow"),r(k,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#composable-stable-diffusion"),r(k,"rel","nofollow"),r(I,"href","https://github.com/huggingface/diffusers/tree/main/examples/community"),r(I,"rel","nofollow"),r(G,"href","https://huggingface.co/hf-internal-testing/diffusers-dummy-pipeline/blob/main/pipeline.py"),r(G,"rel","nofollow"),r(x,"href","https://huggingface.co/google/ddpm-cifar10-32"),r(x,"rel","nofollow"),r(V,"href","https://github.com/huggingface/diffusers/tree/main/examples/community#clip-guided-stable-diffusion"),r(V,"rel","nofollow"),r(N,"href","custom_pipeline_examples"),r(j,"href","contribute_pipeline")},m(e,a){t(document.head,f),m(e,_,a),m(e,c,a),t(c,u),t(u,X),z(U,X,null),t(c,ce),t(c,F),t(F,ue),m(e,te,a),z(C,e,a),m(e,ie,a),m(e,d,a),t(d,de),t(d,S),t(S,he),t(d,ye),t(d,R),t(R,be),t(d,ge),t(d,E),t(E,we),t(d,_e),m(e,oe,a),m(e,h,a),t(h,ve),t(h,$),t($,Me),t(h,Je),t(h,k),t(k,Te),t(h,Ze),t(h,I),t(I,Ue),t(h,Ce),m(e,le,a),m(e,y,a),t(y,Ee),t(y,L),t(L,$e),t(y,ke),t(y,G),t(G,A),t(A,Ie),t(y,Ge),t(y,x),t(x,Q),t(Q,xe),t(y,We),m(e,ae,a),z(v,e,a),m(e,ne,a),z(W,e,a),m(e,se,a),m(e,M,a),t(M,Ve),t(M,V),t(V,Be),t(M,Pe),m(e,re,a),z(B,e,a),m(e,pe,a),m(e,w,a),t(w,Se),t(w,N),t(N,Re),t(w,Ne),t(w,j),t(j,je),t(w,De),me=!0},p(e,[a]){const P={};a&2&&(P.$$scope={dirty:a,ctx:e}),v.$set(P)},i(e){me||(q(U.$$.fragment,e),q(C.$$.fragment,e),q(v.$$.fragment,e),q(W.$$.fragment,e),q(B.$$.fragment,e),me=!0)},o(e){O(U.$$.fragment,e),O(C.$$.fragment,e),O(v.$$.fragment,e),O(W.$$.fragment,e),O(B.$$.fragment,e),me=!1},d(e){i(f),e&&i(_),e&&i(c),K(U),e&&i(te),K(C,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(M),e&&i(re),K(B,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 Tt extends st{constructor(f){super();rt(this,f,gt,yt,pt,{})}}export{Tt as default,bt as metadata}; | |
Xet Storage Details
- Size:
- 12.9 kB
- Xet hash:
- 11b624950010e1220f4a4f982df83ce3382cbc5bda8a92c31ca7eb99f1f70c9a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.