import{s as xt,o as vt,n as at}from"../chunks/scheduler.5c93273d.js";import{S as Qt,i as Gt,g as c,s,r as d,A as Ft,h as m,f as l,c as p,j as Bt,u as M,x as f,k as Wt,y as Xt,a as n,v as U,d as u,t as r,w as y}from"../chunks/index.e43dd92b.js";import{T as It}from"../chunks/Tip.1cbfe904.js";import{C}from"../chunks/CodeBlock.6896320e.js";import{H as _,E as Yt}from"../chunks/getInferenceSnippets.bd93e167.js";import{H as St,a as kt}from"../chunks/HfOption.d50154c3.js";function qt($){let o,J="<code>collection</code> 参数是可选的，但可以更轻松地组织和管理组件。";return{c(){o=c("p"),o.innerHTML=J},l(a){o=m(a,"P",{"data-svelte-h":!0}),f(o)!=="svelte-n7baf9"&&(o.innerHTML=J)},m(a,b){n(a,o,b)},p:at,d(a){a&&l(o)}}}function Et($){let o,J;return o=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyME1vZHVsYXJQaXBlbGluZSUyQyUyMENvbXBvbmVudHNNYW5hZ2VyJTBBJTBBY29tcCUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEFwaXBlJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJZaVlpWHUlMkZtb2R1bGFyLWRlbW8tYXV0byUyMiUyQyUyMGNvbXBvbmVudHNfbWFuYWdlciUzRGNvbXAlMkMlMjBjb2xsZWN0aW9uJTNEJTIydGVzdDElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline, ComponentsManager

comp = ComponentsManager()
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;YiYiXu/modular-demo-auto&quot;</span>, components_manager=comp, collection=<span class="hljs-string">&quot;test1&quot;</span>)`,wrap:!1}}),{c(){d(o.$$.fragment)},l(a){M(o.$$.fragment,a)},m(a,b){U(o,a,b),J=!0},p:at,i(a){J||(u(o.$$.fragment,a),J=!0)},o(a){r(o.$$.fragment,a),J=!1},d(a){y(o,a)}}}function Ht($){let o,J;return o=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudHNNYW5hZ2VyJTBBZnJvbSUyMGRpZmZ1c2Vycy5tb2R1bGFyX3BpcGVsaW5lcyUyMGltcG9ydCUyMFNlcXVlbnRpYWxQaXBlbGluZUJsb2NrcyUwQWZyb20lMjBkaWZmdXNlcnMubW9kdWxhcl9waXBlbGluZXMuc3RhYmxlX2RpZmZ1c2lvbl94bCUyMGltcG9ydCUyMFRFWFQySU1BR0VfQkxPQ0tTJTBBJTBBdDJpX2Jsb2NrcyUyMCUzRCUyMFNlcXVlbnRpYWxQaXBlbGluZUJsb2Nrcy5mcm9tX2Jsb2Nrc19kaWN0KFRFWFQySU1BR0VfQkxPQ0tTKSUwQSUwQW1vZHVsYXJfcmVwb19pZCUyMCUzRCUyMCUyMllpWWlYdSUyRm1vZHVsYXItbG9hZGVyLXQyaS0wNzA0JTIyJTBBY29tcG9uZW50cyUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEF0MmlfcGlwZWxpbmUlMjAlM0QlMjB0MmlfYmxvY2tzLmluaXRfcGlwZWxpbmUobW9kdWxhcl9yZXBvX2lkJTJDJTIwY29tcG9uZW50c19tYW5hZ2VyJTNEY29tcG9uZW50cyk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentsManager
<span class="hljs-keyword">from</span> diffusers.modular_pipelines <span class="hljs-keyword">import</span> SequentialPipelineBlocks
<span class="hljs-keyword">from</span> diffusers.modular_pipelines.stable_diffusion_xl <span class="hljs-keyword">import</span> TEXT2IMAGE_BLOCKS

t2i_blocks = SequentialPipelineBlocks.from_blocks_dict(TEXT2IMAGE_BLOCKS)

modular_repo_id = <span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-0704&quot;</span>
components = ComponentsManager()
t2i_pipeline = t2i_blocks.init_pipeline(modular_repo_id, components_manager=components)`,wrap:!1}}),{c(){d(o.$$.fragment)},l(a){M(o.$$.fragment,a)},m(a,b){U(o,a,b),J=!0},p:at,i(a){J||(u(o.$$.fragment,a),J=!0)},o(a){r(o.$$.fragment,a),J=!1},d(a){y(o,a)}}}function zt($){let o,J,a,b;return o=new kt({props:{id:"create",option:"from_pretrained",$$slots:{default:[Et]},$$scope:{ctx:$}}}),a=new kt({props:{id:"create",option:"init_pipeline",$$slots:{default:[Ht]},$$scope:{ctx:$}}}),{c(){d(o.$$.fragment),J=s(),d(a.$$.fragment)},l(i){M(o.$$.fragment,i),J=p(i),M(a.$$.fragment,i)},m(i,T){U(o,i,T),n(i,J,T),U(a,i,T),b=!0},p(i,T){const V={};T&2&&(V.$$scope={dirty:T,ctx:i}),o.$set(V);const ue={};T&2&&(ue.$$scope={dirty:T,ctx:i}),a.$set(ue)},i(i){b||(u(o.$$.fragment,i),u(a.$$.fragment,i),b=!0)},o(i){r(o.$$.fragment,i),r(a.$$.fragment,i),b=!1},d(i){i&&l(J),y(o,i),y(a,i)}}}function Lt($){let o,J,a,b,i,T,V,ue="<code>ComponentsManager</code> 是 Modular Diffusers 的模型注册和管理系统。它添加和跟踪模型，存储有用的元数据（模型大小、设备放置、适配器），防止重复模型实例，并支持卸载。",ye,N,it="本指南将展示如何使用 <code>ComponentsManager</code> 来管理组件和设备内存。",fe,Z,Je,w,ct="<code>ComponentsManager</code> 应与 <code>ModularPipeline</code> 一起创建，在 <code>from_pretrained()</code> 或 <code>init_pipeline()</code> 中。",be,j,Te,g,Ce,h,mt="组件仅在调用 <code>load_components()</code> 或 <code>load_components()</code> 时加载和注册。以下示例使用 <code>load_components()</code> 创建第二个管道，重用第一个管道的所有组件，并将其分配到不同的集合。",$e,R,Ve,B,dt="使用 <code>null_component_names</code> 属性来识别需要加载的任何组件，使用 <code>get_components_by_names()</code> 检索它们，然后调用 <code>update_components()</code> 来添加缺失的组件。",je,W,ge,k,Mt="要添加单个组件，请使用 <code>add()</code> 方法。这会使用唯一 id 注册一个组件。",_e,x,Ne,v,Ut="使用 <code>remove()</code> 通过其 id 移除一个组件。",Ze,Q,we,G,he,F,ut="<code>ComponentsManager</code> 提供了几种方法来检索已注册的组件。",Re,X,Be,I,rt="<code>get_one()</code> 方法返回单个组件，并支持对 <code>name</code> 参数进行模式匹配。如果多个组件匹配，<code>get_one()</code> 会返回错误。",We,Y,yt="<thead><tr><th>模式</th> <th>示例</th> <th>描述</th></tr></thead> <tbody><tr><td>exact</td> <td><code>comp.get_one(name=&quot;unet&quot;)</code></td> <td>精确名称匹配</td></tr> <tr><td>wildcard</td> <td><code>comp.get_one(name=&quot;unet*&quot;)</code></td> <td>名称以 “unet” 开头</td></tr> <tr><td>exclusion</td> <td><code>comp.get_one(name=&quot;!unet&quot;)</code></td> <td>排除名为 “unet” 的组件</td></tr> <tr><td>or</td> <td><code>comp.get_one(name=&quot;unet|vae&quot;)</code></td> <td>名称为 “unet” 或 “vae”</td></tr></tbody>",ke,S,ft="<code>get_one()</code> 还通过 <code>collection</code> 参数或 <code>load_id</code> 参数过滤组件。",xe,q,ve,E,Qe,H,Jt="<code>get_components_by_names()</code> 方法接受一个名称列表，并返回一个将名称映射到组件的字典。这在 <code>ModularPipeline</code> 中特别有用，因为它们提供了所需组件名称的列表，并且返回的字典可以直接传递给 <code>update_components()</code>。",Ge,z,Fe,L,Xe,O,bt="建议使用 <code>ComponentSpec</code> 加载模型组件，以分配具有唯一 id 的组件，该 id 编码了它们的加载参数。这允许 <code>ComponentsManager</code> 自动检测并防止重复的模型实例，即使不同的对象代表相同的底层检查点。",Ie,D,Ye,A,Tt="这会返回一个警告，附带移除重复项的说明。",Se,P,qe,K,Ct="您也可以不使用 <code>ComponentSpec</code> 添加组件，并且在大多数情况下，即使您以不同名称添加相同组件，重复检测仍然有效。",Ee,ee,$t="然而，当您将相同组件加载到不同对象时，<code>ComponentManager</code> 无法检测重复项。在这种情况下，您应该使用 <code>ComponentSpec</code> 加载模型。",He,te,ze,le,Le,ne,Vt="集合是为组件分配的标签，用于更好的组织和管理。使用 <code>add()</code> 中的 <code>collection</code> 参数将组件添加到集合中。",Oe,se,jt="每个集合中只允许每个名称有一个组件。添加第二个同名组件会自动移除第一个组件。",De,pe,Ae,oe,gt="这使得在基于节点的系统中工作变得方便，因为您可以：",Pe,ae,_t="<li>使用 <code>collection</code> 标签标记所有从一个节点加载的模型。</li> <li>当新检查点以相同名称加载时自动替换模型。</li> <li>当节点被移除时批量删除集合中的所有模型。</li>",Ke,ie,et,ce,Nt="<code>enable_auto_cpu_offload()</code> 方法是一种全局卸载策略，适用于所有模型，无论哪个管道在使用它们。一旦启用，您无需担心设备放置，如果您添加或移除组件。",tt,me,lt,de,Zt="所有模型开始时都在 CPU 上，<code>ComponentsManager</code> 在需要它们之前将它们移动到适当的设备，并在 GPU 内存不足时将其他模型移回 CPU。",nt,Me,wt="您可以设置自己的规则来决定哪些模型要卸载。",st,Ue,pt,re,ot;return i=new _({props:{title:"组件管理器",local:"组件管理器",headingTag:"h1"}}),Z=new _({props:{title:"添加组件",local:"添加组件",headingTag:"h2"}}),j=new It({props:{warning:!1,$$slots:{default:[qt]},$$scope:{ctx:$}}}),g=new St({props:{id:"create",options:["from_pretrained","init_pipeline"],$$slots:{default:[zt]},$$scope:{ctx:$}}}),R=new C({props:{code:"cGlwZS5sb2FkX2NvbXBvbmVudHMoKSUwQXBpcGUyJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJZaVlpWHUlMkZtb2R1bGFyLWRlbW8tYXV0byUyMiUyQyUyMGNvbXBvbmVudHNfbWFuYWdlciUzRGNvbXAlMkMlMjBjb2xsZWN0aW9uJTNEJTIydGVzdDIlMjIp",highlighted:`pipe.load_components()
pipe2 = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;YiYiXu/modular-demo-auto&quot;</span>, components_manager=comp, collection=<span class="hljs-string">&quot;test2&quot;</span>)`,wrap:!1}}),W=new C({props:{code:"cGlwZTIubnVsbF9jb21wb25lbnRfbmFtZXMlMjAlMEElNUIndGV4dF9lbmNvZGVyJyUyQyUyMCd0ZXh0X2VuY29kZXJfMiclMkMlMjAndG9rZW5pemVyJyUyQyUyMCd0b2tlbml6ZXJfMiclMkMlMjAnaW1hZ2VfZW5jb2RlciclMkMlMjAndW5ldCclMkMlMjAndmFlJyUyQyUyMCdzY2hlZHVsZXInJTJDJTIwJ2NvbnRyb2xuZXQnJTVEJTBBJTBBY29tcF9kaWN0JTIwJTNEJTIwY29tcC5nZXRfY29tcG9uZW50c19ieV9uYW1lcyhuYW1lcyUzRHBpcGUyLm51bGxfY29tcG9uZW50X25hbWVzKSUwQXBpcGUyLnVwZGF0ZV9jb21wb25lbnRzKCoqY29tcF9kaWN0KQ==",highlighted:`pipe2.null_component_names 
[<span class="hljs-string">&#x27;text_encoder&#x27;</span>, <span class="hljs-string">&#x27;text_encoder_2&#x27;</span>, <span class="hljs-string">&#x27;tokenizer&#x27;</span>, <span class="hljs-string">&#x27;tokenizer_2&#x27;</span>, <span class="hljs-string">&#x27;image_encoder&#x27;</span>, <span class="hljs-string">&#x27;unet&#x27;</span>, <span class="hljs-string">&#x27;vae&#x27;</span>, <span class="hljs-string">&#x27;scheduler&#x27;</span>, <span class="hljs-string">&#x27;controlnet&#x27;</span>]

comp_dict = comp.get_components_by_names(names=pipe2.null_component_names)
pipe2.update_components(**comp_dict)`,wrap:!1}}),x=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQXRleHRfZW5jb2RlciUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyKSUwQWNvbXBvbmVudF9pZCUyMCUzRCUyMGNvbXAuYWRkKCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHRleHRfZW5jb2RlciklMEFjb21w",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel

text_encoder = AutoModel.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>)
component_id = comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, text_encoder)
comp`,wrap:!1}}),Q=new C({props:{code:"Y29tcC5yZW1vdmUoJTIydGV4dF9lbmNvZGVyXzEzOTkxNzczMzA0Mjg2NCUyMik=",highlighted:'comp.remove(<span class="hljs-string">&quot;text_encoder_139917733042864&quot;</span>)',wrap:!1}}),G=new _({props:{title:"检索组件",local:"检索组件",headingTag:"h2"}}),X=new _({props:{title:"get_one",local:"getone",headingTag:"h3"}}),q=new C({props:{code:"Y29tcC5nZXRfb25lKG5hbWUlM0QlMjJ1bmV0JTIyJTJDJTIwY29sbGVjdGlvbiUzRCUyMnNkeGwlMjIp",highlighted:'comp.get_one(name=<span class="hljs-string">&quot;unet&quot;</span>, collection=<span class="hljs-string">&quot;sdxl&quot;</span>)',wrap:!1}}),E=new _({props:{title:"get_components_by_names",local:"getcomponentsbynames",headingTag:"h3"}}),z=new C({props:{code:"Y29tcG9uZW50X2RpY3QlMjAlM0QlMjBjb21wLmdldF9jb21wb25lbnRzX2J5X25hbWVzKG5hbWVzJTNEJTVCJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwJTIydW5ldCUyMiUyQyUyMCUyMnZhZSUyMiU1RCklMEElN0IlMjJ0ZXh0X2VuY29kZXIlMjIlM0ElMjBjb21wb25lbnQxJTJDJTIwJTIydW5ldCUyMiUzQSUyMGNvbXBvbmVudDIlMkMlMjAlMjJ2YWUlMjIlM0ElMjBjb21wb25lbnQzJTdE",highlighted:`component_dict = comp.get_components_by_names(names=[<span class="hljs-string">&quot;text_encoder&quot;</span>, <span class="hljs-string">&quot;unet&quot;</span>, <span class="hljs-string">&quot;vae&quot;</span>])
{<span class="hljs-string">&quot;text_encoder&quot;</span>: component1, <span class="hljs-string">&quot;unet&quot;</span>: component2, <span class="hljs-string">&quot;vae&quot;</span>: component3}`,wrap:!1}}),L=new _({props:{title:"重复检测",local:"重复检测",headingTag:"h2"}}),D=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudFNwZWMlMkMlMjBDb21wb25lbnRzTWFuYWdlciUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBDTElQVGV4dE1vZGVsJTBBJTBBY29tcCUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEElMEElMjMlMjAlRTQlQjglQkElRTclQUMlQUMlRTQlQjglODAlRTQlQjglQUElRTYlOTYlODclRTYlOUMlQUMlRTclQkMlOTYlRTclQTAlODElRTUlOTklQTglRTUlODglOUIlRTUlQkIlQkElMjBDb21wb25lbnRTcGVjJTBBc3BlYyUyMCUzRCUyMENvbXBvbmVudFNwZWMobmFtZSUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHJlcG8lM0QlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0ZXh0X2VuY29kZXIlMjIlMkMlMjB0eXBlX2hpbnQlM0RBdXRvTW9kZWwpJTBBJTIzJTIwJUU0JUI4JUJBJUU5JTg3JThEJUU1JUE0JThEJUU3JTlBJTg0JUU2JTk2JTg3JUU2JTlDJUFDJUU3JUJDJTk2JUU3JUEwJTgxJUU1JTk5JUE4JUU1JTg4JTlCJUU1JUJCJUJBJTIwQ29tcG9uZW50U3BlYyVFRiVCQyU4OCVFNSVBRSU4MyVFNiU5OCVBRiVFNyU5QiVCOCVFNSU5MCU4QyVFNyU5QSU4NCVFNiVBMyU4MCVFNiU5RiVBNSVFNyU4MiVCOSVFRiVCQyU4QyVFNiU5RCVBNSVFOCU4NyVBQSVFNyU5QiVCOCVFNSU5MCU4QyVFNyU5QSU4NCVFNCVCQiU5MyVFNSVCQSU5MyUyRiVFNSVBRCU5MCVFNiU5NiU4NyVFNCVCQiVCNiVFNSVBNCVCOSVFRiVCQyU4OSUwQXNwZWNfZHVwbGljYXRlZCUyMCUzRCUyMENvbXBvbmVudFNwZWMobmFtZSUzRCUyMnRleHRfZW5jb2Rlcl9kdXBsaWNhdGVkJTIyJTJDJTIwcmVwbyUzRCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHR5JTBBcGVfaGludCUzRENMSVBUZXh0TW9kZWwpJTBBJTBBJTIzJTIwJUU1JThBJUEwJUU4JUJEJUJEJUU1JUI5JUI2JUU2JUI3JUJCJUU1JThBJUEwJUU0JUI4JUE0JUU0JUI4JUFBJUU3JUJCJTg0JUU0JUJCJUI2JTIwLSUyMCVFNyVBRSVBMSVFNyU5MCU4NiVFNSU5OSVBOCVFNCVCQyU5QSVFNiVBMyU4MCVFNiVCNSU4QiVFNSU4OCVCMCVFNSVBRSU4MyVFNCVCQiVBQyVFNiU5OCVBRiVFNSU5MCU4QyVFNCVCOCU4MCVFNCVCOCVBQSVFNiVBOCVBMSVFNSU5RSU4QiUwQWNvbXAuYWRkKCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHNwZWMubG9hZCgpKSUwQWNvbXAuYWRkKCUyMnRleHRfZW5jb2Rlcl9kdXBsaWNhdGVkJTIyJTJDJTIwc3BlY19kdXBsaWNhdGVkLmxvYWQoKSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentSpec, ComponentsManager
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPTextModel

comp = ComponentsManager()

<span class="hljs-comment"># 为第一个文本编码器创建 ComponentSpec</span>
spec = ComponentSpec(name=<span class="hljs-string">&quot;text_encoder&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, type_hint=AutoModel)
<span class="hljs-comment"># 为重复的文本编码器创建 ComponentSpec（它是相同的检查点，来自相同的仓库/子文件夹）</span>
spec_duplicated = ComponentSpec(name=<span class="hljs-string">&quot;text_encoder_duplicated&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, ty
pe_hint=CLIPTextModel)

<span class="hljs-comment"># 加载并添加两个组件 - 管理器会检测到它们是同一个模型</span>
comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, spec.load())
comp.add(<span class="hljs-string">&quot;text_encoder_duplicated&quot;</span>, spec_duplicated.load())`,wrap:!1}}),P=new C({props:{code:"Q29tcG9uZW50c01hbmFnZXIlM0ElMjBhZGRpbmclMjBjb21wb25lbnQlMjAndGV4dF9lbmNvZGVyX2R1cGxpY2F0ZWRfMTM5OTE3NTgwNjgyNjcyJyUyQyUyMGJ1dCUyMGl0JTIwaGFzJTIwZHVwbGljYXRlJTIwbG9hZF9pZCUyMCdzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlN0N0ZXh0X2VuY29kZXIlN0NudWxsJTdDbnVsbCclMjB3aXRoJTIwZXhpc3RpbmclMjBjb21wb25lbnRzJTNBJTIwdGV4dF9lbmNvZGVyXzEzOTkxODUwNjI0NjgzMi4lMjBUbyUyMHJlbW92ZSUyMGElMjBkdXBsaWNhdGUlMkMlMjBjYWxsJTIwJTYwY29tcG9uZW50c19tYW5hZ2VyLnJlbW92ZSgnJTNDY29tcG9uZW50X2lkJTNFJyklNjAuJTBBJ3RleHRfZW5jb2Rlcl9kdXBsaWNhdGVkXzEzOTkxNzU4MDY4MjY3Mic=",highlighted:'ComponentsManager: adding component <span class="hljs-string">&#x27;text_encoder_duplicated_139917580682672&#x27;</span>, but it has duplicate load_id <span class="hljs-string">&#x27;stabilityai/stable-diffusion-xl-base-1.0|text_encoder|null|null&#x27;</span> <span class="hljs-keyword">with</span> existing components: text_encoder_139918506246832. To remove a duplicate, call `components_manager.remove(<span class="hljs-string">&#x27;&lt;component_id&gt;&#x27;</span>)`.\n<span class="hljs-string">&#x27;text_encoder_duplicated_139917580682672&#x27;</span>',wrap:!1}}),te=new C({props:{code:"dGV4dF9lbmNvZGVyXzIlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiklMEFjb21wLmFkZCglMjJ0ZXh0X2VuY29kZXIlMjIlMkMlMjB0ZXh0X2VuY29kZXJfMiklMEEndGV4dF9lbmNvZGVyXzEzOTkxNzczMjk4MzY2NCc=",highlighted:`text_encoder_2 = AutoModel.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>)
comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, text_encoder_2)
<span class="hljs-string">&#x27;text_encoder_139917732983664&#x27;</span>`,wrap:!1}}),le=new _({props:{title:"集合",local:"集合",headingTag:"h2"}}),pe=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudFNwZWMlMkMlMjBDb21wb25lbnRzTWFuYWdlciUwQSUwQWNvbXAlMjAlM0QlMjBDb21wb25lbnRzTWFuYWdlcigpJTBBJTIzJTIwJUU0JUI4JUJBJUU3JUFDJUFDJUU0JUI4JTgwJUU0JUI4JUFBJTIwVU5ldCUyMCVFNSU4OCU5QiVFNSVCQiVCQSUyMENvbXBvbmVudFNwZWMlMEFzcGVjJTIwJTNEJTIwQ29tcG9uZW50U3BlYyhuYW1lJTNEJTIydW5ldCUyMiUyQyUyMHJlcG8lM0QlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwdHlwZV9oaW50JTNEQXV0b01vZGVsKSUwQSUyMyUyMCVFNCVCOCVCQSVFNSU4RiVBNiVFNCVCOCU4MCVFNCVCOCVBQSUyMFVOZXQlMjAlRTUlODglOUIlRTUlQkIlQkElMjBDb21wb25lbnRTcGVjJTBBc3BlYzIlMjAlM0QlMjBDb21wb25lbnRTcGVjKG5hbWUlM0QlMjJ1bmV0JTIyJTJDJTIwcmVwbyUzRCUyMlJ1bkRpZmZ1c2lvbiUyRkp1Z2dlcm5hdXQtWEwtdjklMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwdHlwZV9oaW50JTNEQXV0b01vZGVsJTJDJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIpJTBBJTBBJTIzJTIwJUU1JUIwJTg2JUU0JUI4JUE0JUU0JUI4JUFBJTIwVU5ldCUyMCVFNiVCNyVCQiVFNSU4QSVBMCVFNSU4OCVCMCVFNSU5MCU4QyVFNCVCOCU4MCVFNCVCOCVBQSVFOSU5QiU4NiVFNSU5MCU4OCUyMC0lMjAlRTclQUMlQUMlRTQlQkElOEMlRTQlQjglQUElRTUlQjAlODYlRTYlOUIlQkYlRTYlOEQlQTIlRTclQUMlQUMlRTQlQjglODAlRTQlQjglQUElMEFjb21wLmFkZCglMjJ1bmV0JTIyJTJDJTIwc3BlYy5sb2FkKCklMkMlMjBjb2xsZWN0aW9uJTNEJTIyc2R4bCUyMiklMEFjb21wLmFkZCglMjJ1bmV0JTIyJTJDJTIwc3BlYzIubG9hZCgpJTJDJTIwY29sbGVjdGlvbiUzRCUyMnNkeGwlMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentSpec, ComponentsManager

comp = ComponentsManager()
<span class="hljs-comment"># 为第一个 UNet 创建 ComponentSpec</span>
spec = ComponentSpec(name=<span class="hljs-string">&quot;unet&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, type_hint=AutoModel)
<span class="hljs-comment"># 为另一个 UNet 创建 ComponentSpec</span>
spec2 = ComponentSpec(name=<span class="hljs-string">&quot;unet&quot;</span>, repo=<span class="hljs-string">&quot;RunDiffusion/Juggernaut-XL-v9&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, type_hint=AutoModel, variant=<span class="hljs-string">&quot;fp16&quot;</span>)

<span class="hljs-comment"># 将两个 UNet 添加到同一个集合 - 第二个将替换第一个</span>
comp.add(<span class="hljs-string">&quot;unet&quot;</span>, spec.load(), collection=<span class="hljs-string">&quot;sdxl&quot;</span>)
comp.add(<span class="hljs-string">&quot;unet&quot;</span>, spec2.load(), collection=<span class="hljs-string">&quot;sdxl&quot;</span>)`,wrap:!1}}),ie=new _({props:{title:"卸载",local:"卸载",headingTag:"h2"}}),me=new C({props:{code:"Y29tcC5lbmFibGVfYXV0b19jcHVfb2ZmbG9hZChkZXZpY2UlM0QlMjJjdWRhJTIyKQ==",highlighted:'comp.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),Ue=new Yt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/modular_diffusers/components_manager.md"}}),{c(){o=c("meta"),J=s(),a=c("p"),b=s(),d(i.$$.fragment),T=s(),V=c("p"),V.innerHTML=ue,ye=s(),N=c("p"),N.innerHTML=it,fe=s(),d(Z.$$.fragment),Je=s(),w=c("p"),w.innerHTML=ct,be=s(),d(j.$$.fragment),Te=s(),d(g.$$.fragment),Ce=s(),h=c("p"),h.innerHTML=mt,$e=s(),d(R.$$.fragment),Ve=s(),B=c("p"),B.innerHTML=dt,je=s(),d(W.$$.fragment),ge=s(),k=c("p"),k.innerHTML=Mt,_e=s(),d(x.$$.fragment),Ne=s(),v=c("p"),v.innerHTML=Ut,Ze=s(),d(Q.$$.fragment),we=s(),d(G.$$.fragment),he=s(),F=c("p"),F.innerHTML=ut,Re=s(),d(X.$$.fragment),Be=s(),I=c("p"),I.innerHTML=rt,We=s(),Y=c("table"),Y.innerHTML=yt,ke=s(),S=c("p"),S.innerHTML=ft,xe=s(),d(q.$$.fragment),ve=s(),d(E.$$.fragment),Qe=s(),H=c("p"),H.innerHTML=Jt,Ge=s(),d(z.$$.fragment),Fe=s(),d(L.$$.fragment),Xe=s(),O=c("p"),O.innerHTML=bt,Ie=s(),d(D.$$.fragment),Ye=s(),A=c("p"),A.textContent=Tt,Se=s(),d(P.$$.fragment),qe=s(),K=c("p"),K.innerHTML=Ct,Ee=s(),ee=c("p"),ee.innerHTML=$t,He=s(),d(te.$$.fragment),ze=s(),d(le.$$.fragment),Le=s(),ne=c("p"),ne.innerHTML=Vt,Oe=s(),se=c("p"),se.textContent=jt,De=s(),d(pe.$$.fragment),Ae=s(),oe=c("p"),oe.textContent=gt,Pe=s(),ae=c("ul"),ae.innerHTML=_t,Ke=s(),d(ie.$$.fragment),et=s(),ce=c("p"),ce.innerHTML=Nt,tt=s(),d(me.$$.fragment),lt=s(),de=c("p"),de.innerHTML=Zt,nt=s(),Me=c("p"),Me.textContent=wt,st=s(),d(Ue.$$.fragment),pt=s(),re=c("p"),this.h()},l(e){const t=Ft("svelte-u9bgzb",document.head);o=m(t,"META",{name:!0,content:!0}),t.forEach(l),J=p(e),a=m(e,"P",{}),Bt(a).forEach(l),b=p(e),M(i.$$.fragment,e),T=p(e),V=m(e,"P",{"data-svelte-h":!0}),f(V)!=="svelte-1vkk8wr"&&(V.innerHTML=ue),ye=p(e),N=m(e,"P",{"data-svelte-h":!0}),f(N)!=="svelte-btfbdf"&&(N.innerHTML=it),fe=p(e),M(Z.$$.fragment,e),Je=p(e),w=m(e,"P",{"data-svelte-h":!0}),f(w)!=="svelte-357gdc"&&(w.innerHTML=ct),be=p(e),M(j.$$.fragment,e),Te=p(e),M(g.$$.fragment,e),Ce=p(e),h=m(e,"P",{"data-svelte-h":!0}),f(h)!=="svelte-5zx8o7"&&(h.innerHTML=mt),$e=p(e),M(R.$$.fragment,e),Ve=p(e),B=m(e,"P",{"data-svelte-h":!0}),f(B)!=="svelte-10ue6nx"&&(B.innerHTML=dt),je=p(e),M(W.$$.fragment,e),ge=p(e),k=m(e,"P",{"data-svelte-h":!0}),f(k)!=="svelte-1avjawg"&&(k.innerHTML=Mt),_e=p(e),M(x.$$.fragment,e),Ne=p(e),v=m(e,"P",{"data-svelte-h":!0}),f(v)!=="svelte-1xo6ira"&&(v.innerHTML=Ut),Ze=p(e),M(Q.$$.fragment,e),we=p(e),M(G.$$.fragment,e),he=p(e),F=m(e,"P",{"data-svelte-h":!0}),f(F)!=="svelte-1i33j7x"&&(F.innerHTML=ut),Re=p(e),M(X.$$.fragment,e),Be=p(e),I=m(e,"P",{"data-svelte-h":!0}),f(I)!=="svelte-1675jc5"&&(I.innerHTML=rt),We=p(e),Y=m(e,"TABLE",{"data-svelte-h":!0}),f(Y)!=="svelte-154liov"&&(Y.innerHTML=yt),ke=p(e),S=m(e,"P",{"data-svelte-h":!0}),f(S)!=="svelte-124kykz"&&(S.innerHTML=ft),xe=p(e),M(q.$$.fragment,e),ve=p(e),M(E.$$.fragment,e),Qe=p(e),H=m(e,"P",{"data-svelte-h":!0}),f(H)!=="svelte-1jgc3kd"&&(H.innerHTML=Jt),Ge=p(e),M(z.$$.fragment,e),Fe=p(e),M(L.$$.fragment,e),Xe=p(e),O=m(e,"P",{"data-svelte-h":!0}),f(O)!=="svelte-1fl2c4h"&&(O.innerHTML=bt),Ie=p(e),M(D.$$.fragment,e),Ye=p(e),A=m(e,"P",{"data-svelte-h":!0}),f(A)!=="svelte-1lmaszj"&&(A.textContent=Tt),Se=p(e),M(P.$$.fragment,e),qe=p(e),K=m(e,"P",{"data-svelte-h":!0}),f(K)!=="svelte-t3wjvs"&&(K.innerHTML=Ct),Ee=p(e),ee=m(e,"P",{"data-svelte-h":!0}),f(ee)!=="svelte-13lybv6"&&(ee.innerHTML=$t),He=p(e),M(te.$$.fragment,e),ze=p(e),M(le.$$.fragment,e),Le=p(e),ne=m(e,"P",{"data-svelte-h":!0}),f(ne)!=="svelte-kru0jg"&&(ne.innerHTML=Vt),Oe=p(e),se=m(e,"P",{"data-svelte-h":!0}),f(se)!=="svelte-o60soj"&&(se.textContent=jt),De=p(e),M(pe.$$.fragment,e),Ae=p(e),oe=m(e,"P",{"data-svelte-h":!0}),f(oe)!=="svelte-1kgji9x"&&(oe.textContent=gt),Pe=p(e),ae=m(e,"UL",{"data-svelte-h":!0}),f(ae)!=="svelte-8piqdl"&&(ae.innerHTML=_t),Ke=p(e),M(ie.$$.fragment,e),et=p(e),ce=m(e,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-gu4wm9"&&(ce.innerHTML=Nt),tt=p(e),M(me.$$.fragment,e),lt=p(e),de=m(e,"P",{"data-svelte-h":!0}),f(de)!=="svelte-1njhi8b"&&(de.innerHTML=Zt),nt=p(e),Me=m(e,"P",{"data-svelte-h":!0}),f(Me)!=="svelte-1hqy2kb"&&(Me.textContent=wt),st=p(e),M(Ue.$$.fragment,e),pt=p(e),re=m(e,"P",{}),Bt(re).forEach(l),this.h()},h(){Wt(o,"name","hf:doc:metadata"),Wt(o,"content",Ot)},m(e,t){Xt(document.head,o),n(e,J,t),n(e,a,t),n(e,b,t),U(i,e,t),n(e,T,t),n(e,V,t),n(e,ye,t),n(e,N,t),n(e,fe,t),U(Z,e,t),n(e,Je,t),n(e,w,t),n(e,be,t),U(j,e,t),n(e,Te,t),U(g,e,t),n(e,Ce,t),n(e,h,t),n(e,$e,t),U(R,e,t),n(e,Ve,t),n(e,B,t),n(e,je,t),U(W,e,t),n(e,ge,t),n(e,k,t),n(e,_e,t),U(x,e,t),n(e,Ne,t),n(e,v,t),n(e,Ze,t),U(Q,e,t),n(e,we,t),U(G,e,t),n(e,he,t),n(e,F,t),n(e,Re,t),U(X,e,t),n(e,Be,t),n(e,I,t),n(e,We,t),n(e,Y,t),n(e,ke,t),n(e,S,t),n(e,xe,t),U(q,e,t),n(e,ve,t),U(E,e,t),n(e,Qe,t),n(e,H,t),n(e,Ge,t),U(z,e,t),n(e,Fe,t),U(L,e,t),n(e,Xe,t),n(e,O,t),n(e,Ie,t),U(D,e,t),n(e,Ye,t),n(e,A,t),n(e,Se,t),U(P,e,t),n(e,qe,t),n(e,K,t),n(e,Ee,t),n(e,ee,t),n(e,He,t),U(te,e,t),n(e,ze,t),U(le,e,t),n(e,Le,t),n(e,ne,t),n(e,Oe,t),n(e,se,t),n(e,De,t),U(pe,e,t),n(e,Ae,t),n(e,oe,t),n(e,Pe,t),n(e,ae,t),n(e,Ke,t),U(ie,e,t),n(e,et,t),n(e,ce,t),n(e,tt,t),U(me,e,t),n(e,lt,t),n(e,de,t),n(e,nt,t),n(e,Me,t),n(e,st,t),U(Ue,e,t),n(e,pt,t),n(e,re,t),ot=!0},p(e,[t]){const ht={};t&2&&(ht.$$scope={dirty:t,ctx:e}),j.$set(ht);const Rt={};t&2&&(Rt.$$scope={dirty:t,ctx:e}),g.$set(Rt)},i(e){ot||(u(i.$$.fragment,e),u(Z.$$.fragment,e),u(j.$$.fragment,e),u(g.$$.fragment,e),u(R.$$.fragment,e),u(W.$$.fragment,e),u(x.$$.fragment,e),u(Q.$$.fragment,e),u(G.$$.fragment,e),u(X.$$.fragment,e),u(q.$$.fragment,e),u(E.$$.fragment,e),u(z.$$.fragment,e),u(L.$$.fragment,e),u(D.$$.fragment,e),u(P.$$.fragment,e),u(te.$$.fragment,e),u(le.$$.fragment,e),u(pe.$$.fragment,e),u(ie.$$.fragment,e),u(me.$$.fragment,e),u(Ue.$$.fragment,e),ot=!0)},o(e){r(i.$$.fragment,e),r(Z.$$.fragment,e),r(j.$$.fragment,e),r(g.$$.fragment,e),r(R.$$.fragment,e),r(W.$$.fragment,e),r(x.$$.fragment,e),r(Q.$$.fragment,e),r(G.$$.fragment,e),r(X.$$.fragment,e),r(q.$$.fragment,e),r(E.$$.fragment,e),r(z.$$.fragment,e),r(L.$$.fragment,e),r(D.$$.fragment,e),r(P.$$.fragment,e),r(te.$$.fragment,e),r(le.$$.fragment,e),r(pe.$$.fragment,e),r(ie.$$.fragment,e),r(me.$$.fragment,e),r(Ue.$$.fragment,e),ot=!1},d(e){e&&(l(J),l(a),l(b),l(T),l(V),l(ye),l(N),l(fe),l(Je),l(w),l(be),l(Te),l(Ce),l(h),l($e),l(Ve),l(B),l(je),l(ge),l(k),l(_e),l(Ne),l(v),l(Ze),l(we),l(he),l(F),l(Re),l(Be),l(I),l(We),l(Y),l(ke),l(S),l(xe),l(ve),l(Qe),l(H),l(Ge),l(Fe),l(Xe),l(O),l(Ie),l(Ye),l(A),l(Se),l(qe),l(K),l(Ee),l(ee),l(He),l(ze),l(Le),l(ne),l(Oe),l(se),l(De),l(Ae),l(oe),l(Pe),l(ae),l(Ke),l(et),l(ce),l(tt),l(lt),l(de),l(nt),l(Me),l(st),l(pt),l(re)),l(o),y(i,e),y(Z,e),y(j,e),y(g,e),y(R,e),y(W,e),y(x,e),y(Q,e),y(G,e),y(X,e),y(q,e),y(E,e),y(z,e),y(L,e),y(D,e),y(P,e),y(te,e),y(le,e),y(pe,e),y(ie,e),y(me,e),y(Ue,e)}}}const Ot='{"title":"组件管理器","local":"组件管理器","sections":[{"title":"添加组件","local":"添加组件","sections":[],"depth":2},{"title":"检索组件","local":"检索组件","sections":[{"title":"get_one","local":"getone","sections":[],"depth":3},{"title":"get_components_by_names","local":"getcomponentsbynames","sections":[],"depth":3}],"depth":2},{"title":"重复检测","local":"重复检测","sections":[],"depth":2},{"title":"集合","local":"集合","sections":[],"depth":2},{"title":"卸载","local":"卸载","sections":[],"depth":2}],"depth":1}';function Dt($){return vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nl extends Qt{constructor(o){super(),Gt(this,o,Dt,Lt,xt,{})}}export{nl as component};
