Buckets:
| import"../chunks/DsnmJJEf.js";import{i as oe,h as se,C as ie,H as n,D as o,E as le,s as ne,a as te}from"../chunks/BtE7mKSK.js";import{p as re,o as ae,s as e,f as E,a as h,b as ce,c as s,d as _,n as l,r as i}from"../chunks/jDjavuwI.js";import{E as de}from"../chunks/SrSJA0zO.js";const pe='{"title":"Pipeline blocks","local":"pipeline-blocks","sections":[{"title":"ModularPipelineBlocks","local":"diffusers.ModularPipelineBlocks","sections":[],"depth":2},{"title":"SequentialPipelineBlocks","local":"diffusers.SequentialPipelineBlocks","sections":[],"depth":2},{"title":"LoopSequentialPipelineBlocks","local":"diffusers.LoopSequentialPipelineBlocks","sections":[],"depth":2},{"title":"AutoPipelineBlocks","local":"diffusers.AutoPipelineBlocks","sections":[],"depth":2},{"title":"ConditionalPipelineBlocks","local":"diffusers.ConditionalPipelineBlocks","sections":[],"depth":2}],"depth":1}';var ue=_('<meta name="hf:doc:metadata"/>'),me=_("<p>Example:</p> <!>",1),fe=_(`<p></p> <!> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Base class for all Pipeline Blocks: ConditionalPipelineBlocks, AutoPipelineBlocks, SequentialPipelineBlocks, | |
| LoopSequentialPipelineBlocks</p> <p><a href="/docs/diffusers/pr_14212/en/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a> provides method to load and save the definition of pipeline blocks.</p> <blockquote class="warning"><p>> This is an experimental feature and is likely to change in the future.</p></blockquote> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get all inputs and intermediates in one dictionary</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the block(s) that would execute given the inputs. Must be implemented by subclasses that support | |
| conditional block selection.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the execution blocks for a specific workflow. Must be implemented by subclasses that define <code>_workflow_map</code>.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>create a ModularPipeline, optionally accept pretrained_model_name_or_path to load from hub.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A Pipeline Blocks that combines multiple pipeline block classes into one. When called, it will call each block in | |
| sequence.</p> <p>This class inherits from <a href="/docs/diffusers/pr_14212/en/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipeline blocks (such as loading or saving etc.)</p> <blockquote class="warning"><p>> This is an experimental feature and is likely to change in the future.</p></blockquote> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Creates a SequentialPipelineBlocks instance from a dictionary of blocks.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the blocks that would execute given the specified inputs.</p> <p>As the traversal walks through sequential blocks, intermediate outputs from resolved blocks are added to the | |
| active inputs. This means conditional blocks that depend on intermediates (e.g., “run img2img if image_latents | |
| is present”) will resolve correctly, as long as the condition is based on presence/absence (None or not None), | |
| not on the actual value.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A Pipeline blocks that combines multiple pipeline block classes into a For Loop. When called, it will call each | |
| block in sequence.</p> <p>This class inherits from <a href="/docs/diffusers/pr_14212/en/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipeline blocks (such as loading or saving etc.)</p> <blockquote class="warning"><p>> This is an experimental feature and is likely to change in the future.</p></blockquote> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Creates a LoopSequentialPipelineBlocks instance from a dictionary of blocks.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A Pipeline Blocks that automatically selects a block to run based on the presence of trigger inputs.</p> <p>This is a specialized version of <code>ConditionalPipelineBlocks</code> where:</p> <ul><li>Each block has one corresponding trigger input (1:1 mapping)</li> <li>Block selection is automatic: the first block whose trigger input is present gets selected</li> <li><code>block_trigger_inputs</code> must have the same length as <code>block_names</code> and <code>block_classes</code></li> <li>Use <code>None</code> in <code>block_trigger_inputs</code> to specify the default block, i.e the block that will run if no trigger | |
| inputs are present</li></ul> <!> <p>With this definition:</p> <ul><li>As long as <code>mask_image</code> is provided, “inpaint” block runs (regardless of <code>image</code> being provided or not)</li> <li>If <code>mask_image</code> is not provided but <code>image</code> is provided, “img2img” block runs</li> <li>Otherwise, “text2img” block runs (default, trigger is <code>None</code>)</li></ul> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Select block based on which trigger input is present (not None).</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A Pipeline Blocks that conditionally selects a block to run based on the inputs. Subclasses must implement the <code>select_block</code> method to define the logic for selecting the block. Currently, we only support selection logic based | |
| on the presence or absence of inputs (i.e., whether they are <code>None</code> or not)</p> <p>This class inherits from <a href="/docs/diffusers/pr_14212/en/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipeline blocks (such as loading or saving etc.)</p> <blockquote class="warning"><p>> This is an experimental feature and is likely to change in the future.</p></blockquote> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Get the block(s) that would execute given the inputs.</p> <p>Recursively resolves nested ConditionalPipelineBlocks until reaching either:</p> <ul><li>A leaf block (no sub_blocks or LoopSequentialPipelineBlocks) → returns single <code>ModularPipelineBlocks</code></li> <li>A <code>SequentialPipelineBlocks</code> → delegates to its <code>get_execution_blocks()</code> which returns | |
| a <code>SequentialPipelineBlocks</code> containing the resolved execution blocks</li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Select the block to run based on the trigger inputs. Subclasses must implement this method to define the logic | |
| for selecting the block.</p> <p>Note: When trigger inputs include intermediate outputs from earlier blocks, the selection logic should only | |
| depend on the presence or absence of the input (i.e., whether it is None or not), not on its actual value. This | |
| is because <code>get_execution_blocks()</code> resolves conditions statically by propagating intermediate output names | |
| without their runtime values.</p></div></div> <!> <p></p>`,1);function _e(W,F){re(F,!1),ae(()=>{new URLSearchParams(window.location.search).get("fw")}),oe();var v=fe();se("xd10q2",t=>{var k=ue();ne(k,"content",pe),h(t,k)});var B=e(E(v),2);ie(B,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var P=e(B,2);n(P,{title:"Pipeline blocks",local:"pipeline-blocks",headingTag:"h1"});var y=e(P,2);n(y,{title:"ModularPipelineBlocks",local:"diffusers.ModularPipelineBlocks",headingTag:"h2"});var r=e(y,2),x=s(r);o(x,{name:"class diffusers.ModularPipelineBlocks",anchor:"diffusers.ModularPipelineBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L308",parameters:[]});var a=e(x,8),Q=s(a);o(Q,{name:"get_block_state",anchor:"diffusers.ModularPipelineBlocks.get_block_state",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L496",parameters:[{name:"state",val:": PipelineState"}]}),l(2),i(a);var c=e(a,2),Z=s(c);o(Z,{name:"get_execution_blocks",anchor:"diffusers.ModularPipelineBlocks.get_execution_blocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L378",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.ModularPipelineBlocks.get_execution_blocks.*kwargs",description:"*<strong>*kwargs</strong> — Input names and values. Only trigger inputs affect block selection.",name:"*kwargs"}]}),l(2),i(c);var d=e(c,2),R=s(d);o(R,{name:"get_workflow",anchor:"diffusers.ModularPipelineBlocks.get_workflow",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L396",parameters:[{name:"workflow_name",val:": str"}],parametersDescription:[{anchor:"diffusers.ModularPipelineBlocks.get_workflow.workflow_name",description:"<strong>workflow_name</strong> — Name of the workflow to retrieve.",name:"workflow_name"}]}),l(2),i(d);var w=e(d,2),V=s(w);o(V,{name:"init_pipeline",anchor:"diffusers.ModularPipelineBlocks.init_pipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L474",parameters:[{name:"pretrained_model_name_or_path",val:": str | os.PathLike | None = None"},{name:"components_manager",val:": diffusers.modular_pipelines.components_manager.ComponentsManager | None = None"},{name:"collection",val:": str | None = None"}]}),l(2),i(w),i(r);var M=e(r,2);n(M,{title:"SequentialPipelineBlocks",local:"diffusers.SequentialPipelineBlocks",headingTag:"h2"});var p=e(M,2),q=s(p);o(q,{name:"class diffusers.SequentialPipelineBlocks",anchor:"diffusers.SequentialPipelineBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L943",parameters:[],parametersDescription:[{anchor:"diffusers.SequentialPipelineBlocks.block_classes",description:"<strong>block_classes</strong> — list of block classes to be used",name:"block_classes"},{anchor:"diffusers.SequentialPipelineBlocks.block_names",description:"<strong>block_names</strong> — list of prefixes for each block",name:"block_names"}]});var u=e(q,8),Y=s(u);o(Y,{name:"from_blocks_dict",anchor:"diffusers.SequentialPipelineBlocks.from_blocks_dict",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L1010",parameters:[{name:"blocks_dict",val:": dict"},{name:"description",val:": str | None = None"}],parametersDescription:[{anchor:"diffusers.SequentialPipelineBlocks.from_blocks_dict.blocks_dict",description:"<strong>blocks_dict</strong> — Dictionary mapping block names to block classes or instances",name:"blocks_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A new SequentialPipelineBlocks instance</p> | |
| `}),l(2),i(u);var A=e(u,2),z=s(A);o(z,{name:"get_execution_blocks",anchor:"diffusers.SequentialPipelineBlocks.get_execution_blocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L1153",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.SequentialPipelineBlocks.get_execution_blocks.*kwargs",description:"*<strong>*kwargs</strong> — Input names and values. Only trigger inputs affect block selection.",name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>SequentialPipelineBlocks containing only the blocks that would execute</p> | |
| `}),l(4),i(A),i(p);var j=e(p,2);n(j,{title:"LoopSequentialPipelineBlocks",local:"diffusers.LoopSequentialPipelineBlocks",headingTag:"h2"});var m=e(j,2),T=s(m);o(T,{name:"class diffusers.LoopSequentialPipelineBlocks",anchor:"diffusers.LoopSequentialPipelineBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L1298",parameters:[],parametersDescription:[{anchor:"diffusers.LoopSequentialPipelineBlocks.block_classes",description:"<strong>block_classes</strong> — list of block classes to be used",name:"block_classes"},{anchor:"diffusers.LoopSequentialPipelineBlocks.block_names",description:"<strong>block_names</strong> — list of prefixes for each block",name:"block_names"}]});var C=e(T,8),O=s(C);o(O,{name:"from_blocks_dict",anchor:"diffusers.LoopSequentialPipelineBlocks.from_blocks_dict",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L1461",parameters:[{name:"blocks_dict",val:": dict"}],parametersDescription:[{anchor:"diffusers.LoopSequentialPipelineBlocks.from_blocks_dict.blocks_dict",description:"<strong>blocks_dict</strong> — Dictionary mapping block names to block instances",name:"blocks_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A new LoopSequentialPipelineBlocks instance</p> | |
| `}),l(2),i(C),i(m);var S=e(m,2);n(S,{title:"AutoPipelineBlocks",local:"diffusers.AutoPipelineBlocks",headingTag:"h2"});var f=e(S,2),L=s(f);o(L,{name:"class diffusers.AutoPipelineBlocks",anchor:"diffusers.AutoPipelineBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L882",parameters:[],parametersDescription:[{anchor:"diffusers.AutoPipelineBlocks.block_classes",description:`<strong>block_classes</strong> — | |
| List of block classes to be used. Must have the same length as <code>block_names</code> and | |
| <code>block_trigger_inputs</code>.`,name:"block_classes"},{anchor:"diffusers.AutoPipelineBlocks.block_names",description:`<strong>block_names</strong> — | |
| List of names for each block. Must have the same length as <code>block_classes</code> and <code>block_trigger_inputs</code>.`,name:"block_names"},{anchor:"diffusers.AutoPipelineBlocks.block_trigger_inputs",description:`<strong>block_trigger_inputs</strong> — | |
| List of input names where each element specifies the trigger input for the corresponding block. Use | |
| <code>None</code> to mark the default block.`,name:"block_trigger_inputs"}]});var N=e(L,8);de(N,{anchor:"diffusers.AutoPipelineBlocks.example",children:(t,k)=>{var G=me(),ee=e(E(G),2);te(ee,{code:"JTIwJTIwJTIwJTIwY2xhc3MlMjBNeUF1dG9CbG9jayhBdXRvUGlwZWxpbmVCbG9ja3MpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmxvY2tfY2xhc3NlcyUyMCUzRCUyMCU1QklucGFpbnRFbmNvZGVyQmxvY2slMkMlMjBJbWFnZUVuY29kZXJCbG9jayUyQyUyMFRleHRFbmNvZGVyQmxvY2slNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBibG9ja19uYW1lcyUyMCUzRCUyMCU1QiUyMmlucGFpbnQlMjIlMkMlMjAlMjJpbWcyaW1nJTIyJTJDJTIwJTIydGV4dDJpbWclMjIlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBibG9ja190cmlnZ2VyX2lucHV0cyUyMCUzRCUyMCU1QiUyMm1hc2tfaW1hZ2UlMjIlMkMlMjAlMjJpbWFnZSUyMiUyQyUyME5vbmUlNUQlMjAlMjAlMjMlMjB0ZXh0MmltZyUyMGlzJTIwdGhlJTIwZGVmYXVsdA==",highlighted:` <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyAutoBlock</span>(<span class="hljs-title class_ inherited__">AutoPipelineBlocks</span>): | |
| block_classes = [InpaintEncoderBlock, ImageEncoderBlock, TextEncoderBlock] | |
| block_names = [<span class="hljs-string">"inpaint"</span>, <span class="hljs-string">"img2img"</span>, <span class="hljs-string">"text2img"</span>] | |
| block_trigger_inputs = [<span class="hljs-string">"mask_image"</span>, <span class="hljs-string">"image"</span>, <span class="hljs-literal">None</span>] <span class="hljs-comment"># text2img is the default</span>`,lang:"python",wrap:!1}),h(t,G)},$$slots:{default:!0}});var U=e(N,6),X=s(U);o(X,{name:"select_block",anchor:"diffusers.AutoPipelineBlocks.select_block",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L935",parameters:[{name:"**kwargs",val:""}]}),l(2),i(U),i(f);var I=e(f,2);n(I,{title:"ConditionalPipelineBlocks",local:"diffusers.ConditionalPipelineBlocks",headingTag:"h2"});var b=e(I,2),J=s(b);o(J,{name:"class diffusers.ConditionalPipelineBlocks",anchor:"diffusers.ConditionalPipelineBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L581",parameters:[],parametersDescription:[{anchor:"diffusers.ConditionalPipelineBlocks.block_classes",description:"<strong>block_classes</strong> — List of block classes to be used. Must have the same length as <code>block_names</code>.",name:"block_classes"},{anchor:"diffusers.ConditionalPipelineBlocks.block_names",description:"<strong>block_names</strong> — List of names for each block. Must have the same length as <code>block_classes</code>.",name:"block_names"},{anchor:"diffusers.ConditionalPipelineBlocks.block_trigger_inputs",description:`<strong>block_trigger_inputs</strong> — List of input names that <code>select_block()</code> uses to determine which block to run. | |
| For <code>ConditionalPipelineBlocks</code>, this does not need to correspond to <code>block_names</code> and <code>block_classes</code>. For | |
| <code>AutoPipelineBlocks</code>, this must have the same length as <code>block_names</code> and <code>block_classes</code>, where each | |
| element specifies the trigger input for the corresponding block.`,name:"block_trigger_inputs"},{anchor:"diffusers.ConditionalPipelineBlocks.default_block_name",description:`<strong>default_block_name</strong> — Name of the default block to run when no trigger inputs match. | |
| If None, this block can be skipped entirely when no trigger inputs are provided.`,name:"default_block_name"}]});var g=e(J,8),H=s(g);o(H,{name:"get_execution_blocks",anchor:"diffusers.ConditionalPipelineBlocks.get_execution_blocks",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L773",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.ConditionalPipelineBlocks.get_execution_blocks.*kwargs",description:"*<strong>*kwargs</strong> — Input names and values. Only trigger inputs affect block selection.",name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A leaf block or resolved <code>SequentialPipelineBlocks</code></p> | |
| <ul> | |
| <li><code>None</code>: If this block would be skipped (no trigger matched and no default)</li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <ul> | |
| <li><code>ModularPipelineBlocks</code></li> | |
| </ul> | |
| `}),l(6),i(g);var D=e(g,2),$=s(D);o($,{name:"select_block",anchor:"diffusers.ConditionalPipelineBlocks.select_block",source:"https://github.com/huggingface/diffusers/blob/vr_14212/src/diffusers/modular_pipelines/modular_pipeline.py#L729",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.ConditionalPipelineBlocks.select_block.*kwargs",description:"*<strong>*kwargs</strong> — Trigger input names and their values from the state.",name:"*kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The name of the block to run, or None to use default/skip.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>str | None</p> | |
| `}),l(4),i(D),i(b);var K=e(b,2);le(K,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/modular_diffusers/pipeline_blocks.md"}),l(2),h(W,v),ce()}export{_e as component}; | |
Xet Storage Details
- Size:
- 20.6 kB
- Xet hash:
- 609b07ab9fdd39bd3b4dd78afe97fc78035957795e1ff34fad59a15c4332556a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.