import{s as qs,o as Hs,n as Gs}from"../chunks/scheduler.5c93273d.js";import{S as zs,i as Ls,g as T,s as c,r as M,A as Ds,h as g,f as a,c as u,j as Vs,u as J,x as $,k as Cs,y as ps,a as p,v as m,d as j,t as f,w as U}from"../chunks/index.e43dd92b.js";import{C as W}from"../chunks/CodeBlock.6896320e.js";import{H as ts,E as Ss}from"../chunks/getInferenceSnippets.7a494bf3.js";import{H as Fs,a as ks}from"../chunks/HfOption.d50154c3.js";function Ks(w){let e,d;return e=new W({props:{code:"Z3VpZGVyX3NwZWMlMjAlM0QlMjB0MmlfcGlwZWxpbmUuZ2V0X2NvbXBvbmVudF9zcGVjKCUyMmd1aWRlciUyMiklMEFndWlkZXIlMjAlM0QlMjBndWlkZXJfc3BlYy5jcmVhdGUoZ3VpZGFuY2Vfc2NhbGUlM0QxMCklMEF0MmlfcGlwZWxpbmUudXBkYXRlX2NvbXBvbmVudHMoZ3VpZGVyJTNEZ3VpZGVyKQ==",highlighted:`guider_spec = t2i_pipeline.get_component_spec(<span class="hljs-string">&quot;guider&quot;</span>)
guider = guider_spec.create(guidance_scale=<span class="hljs-number">10</span>)
t2i_pipeline.update_components(guider=guider)`,wrap:!1}}),{c(){M(e.$$.fragment)},l(t){J(e.$$.fragment,t)},m(t,r){m(e,t,r),d=!0},p:Gs,i(t){d||(j(e.$$.fragment,t),d=!0)},o(t){f(e.$$.fragment,t),d=!1},d(t){U(e,t)}}}function Ps(w){let e,d;return e=new W({props:{code:"Z3VpZGVyX3NwZWMlMjAlM0QlMjB0MmlfcGlwZWxpbmUuZ2V0X2NvbXBvbmVudF9zcGVjKCUyMmd1aWRlciUyMiklMEFndWlkZXJfc3BlYy5jb25maWclNUIlMjJndWlkYW5jZV9zY2FsZSUyMiU1RCUyMCUzRCUyMDEwJTBBdDJpX3BpcGVsaW5lLnVwZGF0ZV9jb21wb25lbnRzKGd1aWRlciUzRGd1aWRlcl9zcGVjKQ==",highlighted:`guider_spec = t2i_pipeline.get_component_spec(<span class="hljs-string">&quot;guider&quot;</span>)
guider_spec.config[<span class="hljs-string">&quot;guidance_scale&quot;</span>] = <span class="hljs-number">10</span>
t2i_pipeline.update_components(guider=guider_spec)`,wrap:!1}}),{c(){M(e.$$.fragment)},l(t){J(e.$$.fragment,t)},m(t,r){m(e,t,r),d=!0},p:Gs,i(t){d||(j(e.$$.fragment,t),d=!0)},o(t){f(e.$$.fragment,t),d=!1},d(t){U(e,t)}}}function Os(w){let e,d,t,r;return e=new ks({props:{id:"switch",option:"create",$$slots:{default:[Ks]},$$scope:{ctx:w}}}),t=new ks({props:{id:"switch",option:"update_components",$$slots:{default:[Ps]},$$scope:{ctx:w}}}),{c(){M(e.$$.fragment),d=c(),M(t.$$.fragment)},l(n){J(e.$$.fragment,n),d=u(n),J(t.$$.fragment,n)},m(n,i){m(e,n,i),p(n,d,i),m(t,n,i),r=!0},p(n,i){const h={};i&2&&(h.$$scope={dirty:i,ctx:n}),e.$set(h);const Z={};i&2&&(Z.$$scope={dirty:i,ctx:n}),t.$set(Z)},i(n){r||(j(e.$$.fragment,n),j(t.$$.fragment,n),r=!0)},o(n){f(e.$$.fragment,n),f(t.$$.fragment,n),r=!1},d(n){n&&a(d),U(e,n),U(t,n)}}}function sl(w){let e,d=`编辑 <code>modular_model_index.json</code> 文件，并添加引导器的加载规范，指向包含引导器配置的文件夹
例如。`,t,r,n;return r=new W({props:{code:"JTdCJTBBJTIwJTIwJTIyZ3VpZGVyJTIyJTNBJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyUGVydHVyYmVkQXR0ZW50aW9uR3VpZGFuY2UlMjIlMkMlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJyZXBvJTIyJTNBJTIwJTIyWWlZaVh1JTJGbW9kdWxhci1sb2FkZXItdDJpLWd1aWRlciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnJldmlzaW9uJTIyJTNBJTIwbnVsbCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnN1YmZvbGRlciUyMiUzQSUyMCUyMnBhZ19ndWlkZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJ0eXBlX2hpbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkaWZmdXNlcnMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJQZXJ0dXJiZWRBdHRlbnRpb25HdWlkYW5jZSUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnZhcmlhbnQlMjIlM0ElMjBudWxsJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTVEJTJD",highlighted:`<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;guider&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-string">&quot;diffusers&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-string">&quot;PerturbedAttentionGuidance&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;repo&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-guider&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;revision&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;subfolder&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;pag_guider&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;type_hint&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
        <span class="hljs-string">&quot;diffusers&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-string">&quot;PerturbedAttentionGuidance&quot;</span>
      <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;variant&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>`,wrap:!1}}),{c(){e=T("p"),e.innerHTML=d,t=c(),M(r.$$.fragment)},l(i){e=g(i,"P",{"data-svelte-h":!0}),$(e)!=="svelte-1593jyl"&&(e.innerHTML=d),t=u(i),J(r.$$.fragment,i)},m(i,h){p(i,e,h),p(i,t,h),m(r,i,h),n=!0},p:Gs,i(i){n||(j(r.$$.fragment,i),n=!0)},o(i){f(r.$$.fragment,i),n=!1},d(i){i&&(a(e),a(t)),U(r,i)}}}function ll(w){let e,d="将 <code>default_creation_method()</code> 更改为 <code>from_pretrained</code> 并使用 <code>update_components()</code> 来更新引导器和组件规范以及管道配置。",t,r,n,i="更改创建方法将返回文本，告知您正在将创建类型更改为 <code>from_pretrained</code>。",h,Z,k,b,R,V,C="要使其成为管道的默认引导器，请调用 <code>push_to_hub()</code>。这是一个可选步骤，如果您仅在本地进行实验，则不需要。",G,_,B;return Z=new W({props:{code:"TW9kdWxhclBpcGVsaW5lLnVwZGF0ZV9jb21wb25lbnRzJTNBJTIwJUU1JUIwJTg2JUU1JUJDJTk1JUU1JUFGJUJDJUU1JTk5JUE4JUU3JTlBJTg0JTIwZGVmYXVsdF9jcmVhdGlvbl9tZXRob2QlMjAlRTQlQkIlOEUlMjBmcm9tX2NvbmZpZyUyMCVFNiU5QiVCNCVFNiU5NCVCOSVFNCVCOCVCQSUyMGZyb21fcHJldHJhaW5lZCVFMyU4MCU4Mg==",highlighted:"ModularPipeline.update_components: 将引导器的 default_creation_method 从 from_config 更改为 from_pretrained。",wrap:!1}}),b=new W({props:{code:"Z3VpZGVyX3NwZWMlMjAlM0QlMjB0MmlfcGlwZWxpbmUuZ2V0X2NvbXBvbmVudF9zcGVjKCUyMmd1aWRlciUyMiklMEFndWlkZXJfc3BlYy5kZWZhdWx0X2NyZWF0aW9uX21ldGhvZCUzRCUyMmZyb21fcHJldHJhaW5lZCUyMiUwQWd1aWRlcl9zcGVjLnJlcG8lM0QlMjJZaVlpWHUlMkZtb2R1bGFyLWxvYWRlci10MmktZ3VpZGVyJTIyJTBBZ3VpZGVyX3NwZWMuc3ViZm9sZGVyJTNEJTIycGFnX2d1aWRlciUyMiUwQXBhZ19ndWlkZXIlMjAlM0QlMjBndWlkZXJfc3BlYy5sb2FkKCklMEF0MmlfcGlwZWxpbmUudXBkYXRlX2NvbXBvbmVudHMoZ3VpZGVyJTNEcGFnX2d1aWRlcik=",highlighted:`guider_spec = t2i_pipeline.get_component_spec(<span class="hljs-string">&quot;guider&quot;</span>)
guider_spec.default_creation_method=<span class="hljs-string">&quot;from_pretrained&quot;</span>
guider_spec.repo=<span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-guider&quot;</span>
guider_spec.subfolder=<span class="hljs-string">&quot;pag_guider&quot;</span>
pag_guider = guider_spec.load()
t2i_pipeline.update_components(guider=pag_guider)`,wrap:!1}}),_=new W({props:{code:"dDJpX3BpcGVsaW5lLnB1c2hfdG9faHViKCUyMllpWWlYdSUyRm1vZHVsYXItZG9jLWd1aWRlciUyMik=",highlighted:'t2i_pipeline.push_to_hub(<span class="hljs-string">&quot;YiYiXu/modular-doc-guider&quot;</span>)',wrap:!1}}),{c(){e=T("p"),e.innerHTML=d,t=c(),r=T("blockquote"),n=T("p"),n.innerHTML=i,h=c(),M(Z.$$.fragment),k=c(),M(b.$$.fragment),R=c(),V=T("p"),V.innerHTML=C,G=c(),M(_.$$.fragment),this.h()},l(o){e=g(o,"P",{"data-svelte-h":!0}),$(e)!=="svelte-8z78f8"&&(e.innerHTML=d),t=u(o),r=g(o,"BLOCKQUOTE",{class:!0});var y=Vs(r);n=g(y,"P",{"data-svelte-h":!0}),$(n)!=="svelte-ok1hap"&&(n.innerHTML=i),h=u(y),J(Z.$$.fragment,y),y.forEach(a),k=u(o),J(b.$$.fragment,o),R=u(o),V=g(o,"P",{"data-svelte-h":!0}),$(V)!=="svelte-17sy0mx"&&(V.innerHTML=C),G=u(o),J(_.$$.fragment,o),this.h()},h(){Cs(r,"class","tip")},m(o,y){p(o,e,y),p(o,t,y),p(o,r,y),ps(r,n),ps(r,h),m(Z,r,null),p(o,k,y),m(b,o,y),p(o,R,y),p(o,V,y),p(o,G,y),m(_,o,y),B=!0},p:Gs,i(o){B||(j(Z.$$.fragment,o),j(b.$$.fragment,o),j(_.$$.fragment,o),B=!0)},o(o){f(Z.$$.fragment,o),f(b.$$.fragment,o),f(_.$$.fragment,o),B=!1},d(o){o&&(a(e),a(t),a(r),a(k),a(R),a(V),a(G)),U(Z),U(b,o),U(_,o)}}}function nl(w){let e,d,t,r;return e=new ks({props:{id:"upload",option:"modular_model_index.json",$$slots:{default:[sl]},$$scope:{ctx:w}}}),t=new ks({props:{id:"upload",option:"update_components",$$slots:{default:[ll]},$$scope:{ctx:w}}}),{c(){M(e.$$.fragment),d=c(),M(t.$$.fragment)},l(n){J(e.$$.fragment,n),d=u(n),J(t.$$.fragment,n)},m(n,i){m(e,n,i),p(n,d,i),m(t,n,i),r=!0},p(n,i){const h={};i&2&&(h.$$scope={dirty:i,ctx:n}),e.$set(h);const Z={};i&2&&(Z.$$scope={dirty:i,ctx:n}),t.$set(Z)},i(n){r||(j(e.$$.fragment,n),j(t.$$.fragment,n),r=!0)},o(n){f(e.$$.fragment,n),f(t.$$.fragment,n),r=!1},d(n){n&&a(d),U(e,n),U(t,n)}}}function el(w){let e,d,t,r,n,i,h,Z='<a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-free guidance</a> 引导模型生成更好地匹配提示，通常用于提高生成质量、控制和提示的遵循度。有不同类型的引导方法，在 Diffusers 中，它们被称为<em>引导器</em>。与块类似，可以轻松切换和使用不同的引导器以适应不同的用例，而无需重写管道。',k,b,R="本指南将向您展示如何切换引导器、调整引导器参数，以及将它们加载并共享到 Hub。",V,C,G,_,B="<code>ClassifierFreeGuidance</code> 是默认引导器，在使用 <code>init_pipeline()</code> 初始化管道时创建。它通过 <code>from_config</code> 创建，这意味着它不需要从模块化存储库加载规范。引导器不会列在 <code>modular_model_index.json</code> 中。",o,y,xs="使用 <code>get_component_spec()</code> 来检查引导器。",is,N,cs,Q,Is="通过将新引导器传递给 <code>update_components()</code> 来切换到不同的引导器。",us,X,es,Rs="更改引导器将返回文本，让您知道您正在更改引导器类型。",Xs,A,rs,Y,os,v,Bs="再次使用 <code>get_component_spec()</code> 来验证引导器类型是否不同。",ds,E,Ms,F,Js,q,Ns="已经在 Hub 上保存并带有 <code>modular_model_index.json</code> 文件的引导器现在被视为 <code>from_pretrained</code> 组件，而不是 <code>from_config</code> 组件。",ms,H,js,z,Qs="引导器只有在调用 <code>load_components()</code> 之后才会创建，基于 <code>modular_model_index.json</code> 中的加载规范。",fs,L,Us,D,ys,S,As="引导器参数可以通过 <code>create()</code> 方法或 <code>update_components()</code> 方法进行调整。下面的示例更改了 <code>guidance_scale</code> 值。",hs,x,Ts,K,gs,P,Ys="在自定义引导器上调用 <code>push_to_hub()</code> 方法，将其分享到 Hub。",Zs,O,$s,ss,vs="要使此引导器可用于管道，可以修改 <code>modular_model_index.json</code> 文件或使用 <code>update_components()</code> 方法。",bs,I,_s,ls,ws,as,Ws;return n=new ts({props:{title:"引导器",local:"引导器",headingTag:"h1"}}),C=new ts({props:{title:"切换引导器",local:"切换引导器",headingTag:"h2"}}),N=new W({props:{code:"dDJpX3BpcGVsaW5lLmdldF9jb21wb25lbnRfc3BlYyglMjJndWlkZXIlMjIpJTBBQ29tcG9uZW50U3BlYyhuYW1lJTNEJ2d1aWRlciclMkMlMjB0eXBlX2hpbnQlM0QlM0NjbGFzcyUyMCdkaWZmdXNlcnMuZ3VpZGVycy5jbGFzc2lmaWVyX2ZyZWVfZ3VpZGFuY2UuQ2xhc3NpZmllckZyZWVHdWlkYW5jZSclM0UlMkMlMjBkZXNjcmlwdGlvbiUzRE5vbmUlMkMlMjBjb25maWclM0RGcm96ZW5EaWN0KCU1QignZ3VpZGFuY2Vfc2NhbGUnJTJDJTIwNy41KSUyQyUyMCgnZ3VpZGFuY2VfcmVzY2FsZSclMkMlMjAwLjApJTJDJTIwKCd1c2Vfb3JpZ2luYWxfZm9ybXVsYXRpb24nJTJDJTIwRmFsc2UpJTJDJTIwKCdzdGFydCclMkMlMjAwLjApJTJDJTIwKCdzdG9wJyUyQyUyMDEuMCklMkMlMjAoJ191c2VfZGVmYXVsdF92YWx1ZXMnJTJDJTIwJTVCJ3N0YXJ0JyUyQyUyMCdndWlkYW5jZV9yZXNjYWxlJyUyQyUyMCdzdG9wJyUyQyUyMCd1c2Vfb3JpZ2luYWxfZm9ybXVsYXRpb24nJTVEKSU1RCklMkMlMjByZXBvJTNETm9uZSUyQyUyMHN1YmZvbGRlciUzRE5vbmUlMkMlMjB2YXJpYW50JTNETm9uZSUyQyUyMHJldmlzaW9uJTNETm9uZSUyQyUyMGRlZmF1bHRfY3JlYXRpb25fbWV0aG9kJTNEJ2Zyb21fY29uZmlnJyk=",highlighted:`t2i_pipeline.get_component_spec(<span class="hljs-string">&quot;guider&quot;</span>)
ComponentSpec(name=<span class="hljs-string">&#x27;guider&#x27;</span>, type_hint=&lt;<span class="hljs-keyword">class</span> <span class="hljs-string">&#x27;diffusers.guiders.classifier_free_guidance.ClassifierFreeGuidance&#x27;</span>&gt;, description=<span class="hljs-literal">None</span>, config=FrozenDict([(<span class="hljs-string">&#x27;guidance_scale&#x27;</span>, <span class="hljs-number">7.5</span>), (<span class="hljs-string">&#x27;guidance_rescale&#x27;</span>, <span class="hljs-number">0.0</span>), (<span class="hljs-string">&#x27;use_original_formulation&#x27;</span>, <span class="hljs-literal">False</span>), (<span class="hljs-string">&#x27;start&#x27;</span>, <span class="hljs-number">0.0</span>), (<span class="hljs-string">&#x27;stop&#x27;</span>, <span class="hljs-number">1.0</span>), (<span class="hljs-string">&#x27;_use_default_values&#x27;</span>, [<span class="hljs-string">&#x27;start&#x27;</span>, <span class="hljs-string">&#x27;guidance_rescale&#x27;</span>, <span class="hljs-string">&#x27;stop&#x27;</span>, <span class="hljs-string">&#x27;use_original_formulation&#x27;</span>])]), repo=<span class="hljs-literal">None</span>, subfolder=<span class="hljs-literal">None</span>, variant=<span class="hljs-literal">None</span>, revision=<span class="hljs-literal">None</span>, default_creation_method=<span class="hljs-string">&#x27;from_config&#x27;</span>)`,wrap:!1}}),A=new W({props:{code:"TW9kdWxhclBpcGVsaW5lLnVwZGF0ZV9jb21wb25lbnRzJTNBJTIwJUU2JUI3JUJCJUU1JThBJUEwJUU1JTg1JUI3JUU2JTlDJTg5JUU2JTk2JUIwJUU3JUIxJUJCJUU1JTlFJThCJUU3JTlBJTg0JUU1JUJDJTk1JUU1JUFGJUJDJUU1JTk5JUE4JTNBJTIwUGVydHVyYmVkQXR0ZW50aW9uR3VpZGFuY2UlMkMlMjAlRTUlODUlODglRTUlODklOEQlRTclQjElQkIlRTUlOUUlOEIlM0ElMjBDbGFzc2lmaWVyRnJlZUd1aWRhbmNl",highlighted:"ModularPipeline.update_components: 添加具有新类型的引导器: PerturbedAttentionGuidance, 先前类型: ClassifierFreeGuidance",wrap:!1}}),Y=new W({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExheWVyU2tpcENvbmZpZyUyQyUyMFBlcnR1cmJlZEF0dGVudGlvbkd1aWRhbmNlJTBBJTBBY29uZmlnJTIwJTNEJTIwTGF5ZXJTa2lwQ29uZmlnKGluZGljZXMlM0QlNUIyJTJDJTIwOSU1RCUyQyUyMGZxbiUzRCUyMm1pZF9ibG9jay5hdHRlbnRpb25zLjAudHJhbnNmb3JtZXJfYmxvY2tzJTIyJTJDJTIwc2tpcF9hdHRlbnRpb24lM0RGYWxzZSUyQyUyMHNraXBfYXR0ZW50aW9uX3Njb3JlcyUzRFRydWUlMkMlMjBza2lwX2ZmJTNERmFsc2UpJTBBZ3VpZGVyJTIwJTNEJTIwUGVydHVyYmVkQXR0ZW50aW9uR3VpZGFuY2UoJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q1LjAlMkMlMjBwZXJ0dXJiZWRfZ3VpZGFuY2Vfc2NhbGUlM0QyLjUlMkMlMjBwZXJ0dXJiZWRfZ3VpZGFuY2VfY29uZmlnJTNEY29uZmlnJTBBKSUwQXQyaV9waXBlbGluZS51cGRhdGVfY29tcG9uZW50cyhndWlkZXIlM0RndWlkZXIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LayerSkipConfig, PerturbedAttentionGuidance

config = LayerSkipConfig(indices=[<span class="hljs-number">2</span>, <span class="hljs-number">9</span>], fqn=<span class="hljs-string">&quot;mid_block.attentions.0.transformer_blocks&quot;</span>, skip_attention=<span class="hljs-literal">False</span>, skip_attention_scores=<span class="hljs-literal">True</span>, skip_ff=<span class="hljs-literal">False</span>)
guider = PerturbedAttentionGuidance(
    guidance_scale=<span class="hljs-number">5.0</span>, perturbed_guidance_scale=<span class="hljs-number">2.5</span>, perturbed_guidance_config=config
)
t2i_pipeline.update_components(guider=guider)`,wrap:!1}}),E=new W({props:{code:"dDJpX3BpcGVsaW5lLmdldF9jb21wb25lbnRfc3BlYyglMjJndWlkZXIlMjIpJTBBQ29tcG9uZW50U3BlYyhuYW1lJTNEJ2d1aWRlciclMkMlMjB0eXBlX2hpbnQlM0QlM0NjbGFzcyUyMCdkaWZmdXNlcnMuZ3VpZGVycy5wZXJ0dXJiZWRfYXR0ZW50aW9uX2d1aWRhbmNlLlBlcnR1cmJlZEF0dGVudGlvbkd1aWRhbmNlJyUzRSUyQyUyMGRlc2NyaXB0aW9uJTNETm9uZSUyQyUyMGNvbmZpZyUzREZyb3plbkRpY3QoJTVCKCdndWlkYW5jZV9zY2FsZSclMkMlMjA1LjApJTJDJTIwKCdwZXJ0dXJiZWRfZ3VpZGFuY2Vfc2NhbGUnJTJDJTIwMi41KSUyQyUyMCgncGVydHVyYmVkX2d1aWRhbmNlX3N0YXJ0JyUyQyUyMDAuMDEpJTJDJTIwKCdwZXJ0dXJiZWRfZ3VpZGFuY2Vfc3RvcCclMkMlMjAwLjIpJTJDJTIwKCdwZXJ0dXJiZWRfZ3VpZGFuY2VfbGF5ZXJzJyUyQyUyME5vbmUpJTJDJTIwKCdwZXJ0dXJiZWRfZ3VpZGFuY2VfY29uZmlnJyUyQyUyMExheWVyU2tpcENvbmZpZyhpbmRpY2VzJTNEJTVCMiUyQyUyMDklNUQlMkMlMjBmcW4lM0QnbWlkX2Jsb2NrLmF0dGVudGlvbnMuMC50cmFuc2Zvcm1lcl9ibG9ja3MnJTJDJTIwc2tpcF9hdHRlbnRpb24lM0RGYWxzZSUyQyUyMHNraXBfYXR0ZW50aW9uX3Njb3JlcyUzRFRydWUlMkMlMjBza2lwX2ZmJTNERmFsc2UlMkMlMjBkcm9wb3V0JTNEMS4wKSklMkMlMjAoJ2d1aWRhbmNlX3Jlc2NhbGUnJTJDJTIwMC4wKSUyQyUyMCgndXNlX29yaWdpbmFsX2Zvcm11bGF0aW9uJyUyQyUyMEZhbHNlKSUyQyUyMCgnc3RhcnQnJTJDJTIwMC4wKSUyQyUyMCgnc3RvcCclMkMlMjAxLjApJTJDJTIwKCdfdXNlX2RlZmF1bHRfdmFsdWVzJyUyQyUyMCU1QidwZXJ0dXJiZWRfZ3VpZGFuY2Vfc3RhcnQnJTJDJTIwJ3VzZV9vcmlnaW5hbF9mb3JtdWxhdGlvbiclMkMlMjAncGVydHVyYmVkX2d1aWRhbmNlX2xheWVycyclMkMlMjAnc3RvcCclMkMlMjAnc3RhcnQnJTJDJTIwJ2d1aWRhbmNlX3Jlc2NhbGUnJTJDJTIwJ3BlcnR1cmJlZF9ndWlkYW5jZV9zdG9wJyU1RCklMkMlMjAoJ19jbGFzc19uYW1lJyUyQyUyMCdQZXJ0dXJiZWRBdHRlbnRpb25HdWlkYW5jZScpJTJDJTIwKCdfZGlmZnVzZXJzX3ZlcnNpb24nJTJDJTIwJzAuMzUuMC5kZXYwJyklNUQpJTJDJTIwcmVwbyUzRE5vbmUlMkMlMjBzdWJmb2xkZXIlM0ROb25lJTJDJTIwdmFyaWFudCUzRE5vbmUlMkMlMjByZXZpc2lvbiUzRE5vbmUlMkMlMjBkZWZhdWx0X2NyZWF0aW9uX21ldGhvZCUzRCdmcm9tX2NvbmZpZycp",highlighted:`t2i_pipeline.get_component_spec(<span class="hljs-string">&quot;guider&quot;</span>)
ComponentSpec(name=<span class="hljs-string">&#x27;guider&#x27;</span>, type_hint=&lt;<span class="hljs-keyword">class</span> <span class="hljs-string">&#x27;diffusers.guiders.perturbed_attention_guidance.PerturbedAttentionGuidance&#x27;</span>&gt;, description=<span class="hljs-literal">None</span>, config=FrozenDict([(<span class="hljs-string">&#x27;guidance_scale&#x27;</span>, <span class="hljs-number">5.0</span>), (<span class="hljs-string">&#x27;perturbed_guidance_scale&#x27;</span>, <span class="hljs-number">2.5</span>), (<span class="hljs-string">&#x27;perturbed_guidance_start&#x27;</span>, <span class="hljs-number">0.01</span>), (<span class="hljs-string">&#x27;perturbed_guidance_stop&#x27;</span>, <span class="hljs-number">0.2</span>), (<span class="hljs-string">&#x27;perturbed_guidance_layers&#x27;</span>, <span class="hljs-literal">None</span>), (<span class="hljs-string">&#x27;perturbed_guidance_config&#x27;</span>, LayerSkipConfig(indices=[<span class="hljs-number">2</span>, <span class="hljs-number">9</span>], fqn=<span class="hljs-string">&#x27;mid_block.attentions.0.transformer_blocks&#x27;</span>, skip_attention=<span class="hljs-literal">False</span>, skip_attention_scores=<span class="hljs-literal">True</span>, skip_ff=<span class="hljs-literal">False</span>, dropout=<span class="hljs-number">1.0</span>)), (<span class="hljs-string">&#x27;guidance_rescale&#x27;</span>, <span class="hljs-number">0.0</span>), (<span class="hljs-string">&#x27;use_original_formulation&#x27;</span>, <span class="hljs-literal">False</span>), (<span class="hljs-string">&#x27;start&#x27;</span>, <span class="hljs-number">0.0</span>), (<span class="hljs-string">&#x27;stop&#x27;</span>, <span class="hljs-number">1.0</span>), (<span class="hljs-string">&#x27;_use_default_values&#x27;</span>, [<span class="hljs-string">&#x27;perturbed_guidance_start&#x27;</span>, <span class="hljs-string">&#x27;use_original_formulation&#x27;</span>, <span class="hljs-string">&#x27;perturbed_guidance_layers&#x27;</span>, <span class="hljs-string">&#x27;stop&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>, <span class="hljs-string">&#x27;guidance_rescale&#x27;</span>, <span class="hljs-string">&#x27;perturbed_guidance_stop&#x27;</span>]), (<span class="hljs-string">&#x27;_class_name&#x27;</span>, <span class="hljs-string">&#x27;PerturbedAttentionGuidance&#x27;</span>), (<span class="hljs-string">&#x27;_diffusers_version&#x27;</span>, <span class="hljs-string">&#x27;0.35.0.dev0&#x27;</span>)]), repo=<span class="hljs-literal">None</span>, subfolder=<span class="hljs-literal">None</span>, variant=<span class="hljs-literal">None</span>, revision=<span class="hljs-literal">None</span>, default_creation_method=<span class="hljs-string">&#x27;from_config&#x27;</span>)`,wrap:!1}}),F=new ts({props:{title:"加载自定义引导器",local:"加载自定义引导器",headingTag:"h2"}}),H=new W({props:{code:"JTdCJTBBJTIwJTIwJTIyZ3VpZGVyJTIyJTNBJTIwJTVCJTBBJTIwJTIwJTIwJTIwbnVsbCUyQyUwQSUyMCUyMCUyMCUyMG51bGwlMkMlMEElMjAlMjAlMjAlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJyZXBvJTIyJTNBJTIwJTIyWWlZaVh1JTJGbW9kdWxhci1sb2FkZXItdDJpLWd1aWRlciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnJldmlzaW9uJTIyJTNBJTIwbnVsbCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnN1YmZvbGRlciUyMiUzQSUyMCUyMnBhZ19ndWlkZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJ0eXBlX2hpbnQlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJkaWZmdXNlcnMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJQZXJ0dXJiZWRBdHRlbnRpb25HdWlkYW5jZSUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMnZhcmlhbnQlMjIlM0ElMjBudWxsJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTVEJTBBJTdE",highlighted:`<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;guider&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;repo&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-guider&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;revision&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;subfolder&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;pag_guider&quot;</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;type_hint&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
        <span class="hljs-string">&quot;diffusers&quot;</span><span class="hljs-punctuation">,</span>
        <span class="hljs-string">&quot;PerturbedAttentionGuidance&quot;</span>
      <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">&quot;variant&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),L=new W({props:{code:"dDJpX3BpcGVsaW5lJTIwJTNEJTIwdDJpX2Jsb2Nrcy5pbml0X3BpcGVsaW5lKCUyMllpWWlYdSUyRm1vZHVsYXItZG9jLWd1aWRlciUyMiklMEElMjMlMjAlRTUlOUMlQTglRTUlODglOUQlRTUlQTclOEIlRTUlOEMlOTYlRTYlOTclQjYlRTYlOUMlQUElRTUlODglOUIlRTUlQkIlQkElMEFhc3NlcnQlMjB0MmlfcGlwZWxpbmUuZ3VpZGVyJTIwaXMlMjBOb25lJTBBdDJpX3BpcGVsaW5lLmxvYWRfY29tcG9uZW50cygpJTBBJTIzJTIwJUU1JThBJUEwJUU4JUJEJUJEJUU0JUI4JUJBJTIwUEFHJTIwJUU1JUJDJTk1JUU1JUFGJUJDJUU1JTk5JUE4JTBBdDJpX3BpcGVsaW5lLmd1aWRlcg==",highlighted:`t2i_pipeline = t2i_blocks.init_pipeline(<span class="hljs-string">&quot;YiYiXu/modular-doc-guider&quot;</span>)
<span class="hljs-comment"># 在初始化时未创建</span>
<span class="hljs-keyword">assert</span> t2i_pipeline.guider <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>
t2i_pipeline.load_components()
<span class="hljs-comment"># 加载为 PAG 引导器</span>
t2i_pipeline.guider`,wrap:!1}}),D=new ts({props:{title:"更改引导器参数",local:"更改引导器参数",headingTag:"h2"}}),x=new Fs({props:{id:"switch",options:["create","update_components"],$$slots:{default:[Os]},$$scope:{ctx:w}}}),K=new ts({props:{title:"上传自定义引导器",local:"上传自定义引导器",headingTag:"h2"}}),O=new W({props:{code:"Z3VpZGVyLnB1c2hfdG9faHViKCUyMllpWWlYdSUyRm1vZHVsYXItbG9hZGVyLXQyaS1ndWlkZXIlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJwYWdfZ3VpZGVyJTIyKQ==",highlighted:'guider.push_to_hub(<span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-guider&quot;</span>, subfolder=<span class="hljs-string">&quot;pag_guider&quot;</span>)',wrap:!1}}),I=new Fs({props:{id:"upload",options:["modular_model_index.json","update_components"],$$slots:{default:[nl]},$$scope:{ctx:w}}}),ls=new Ss({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/modular_diffusers/guiders.md"}}),{c(){e=T("meta"),d=c(),t=T("p"),r=c(),M(n.$$.fragment),i=c(),h=T("p"),h.innerHTML=Z,k=c(),b=T("p"),b.textContent=R,V=c(),M(C.$$.fragment),G=c(),_=T("p"),_.innerHTML=B,o=c(),y=T("p"),y.innerHTML=xs,is=c(),M(N.$$.fragment),cs=c(),Q=T("p"),Q.innerHTML=Is,us=c(),X=T("blockquote"),es=T("p"),es.textContent=Rs,Xs=c(),M(A.$$.fragment),rs=c(),M(Y.$$.fragment),os=c(),v=T("p"),v.innerHTML=Bs,ds=c(),M(E.$$.fragment),Ms=c(),M(F.$$.fragment),Js=c(),q=T("p"),q.innerHTML=Ns,ms=c(),M(H.$$.fragment),js=c(),z=T("p"),z.innerHTML=Qs,fs=c(),M(L.$$.fragment),Us=c(),M(D.$$.fragment),ys=c(),S=T("p"),S.innerHTML=As,hs=c(),M(x.$$.fragment),Ts=c(),M(K.$$.fragment),gs=c(),P=T("p"),P.innerHTML=Ys,Zs=c(),M(O.$$.fragment),$s=c(),ss=T("p"),ss.innerHTML=vs,bs=c(),M(I.$$.fragment),_s=c(),M(ls.$$.fragment),ws=c(),as=T("p"),this.h()},l(s){const l=Ds("svelte-u9bgzb",document.head);e=g(l,"META",{name:!0,content:!0}),l.forEach(a),d=u(s),t=g(s,"P",{}),Vs(t).forEach(a),r=u(s),J(n.$$.fragment,s),i=u(s),h=g(s,"P",{"data-svelte-h":!0}),$(h)!=="svelte-1iwhoj0"&&(h.innerHTML=Z),k=u(s),b=g(s,"P",{"data-svelte-h":!0}),$(b)!=="svelte-3z0omg"&&(b.textContent=R),V=u(s),J(C.$$.fragment,s),G=u(s),_=g(s,"P",{"data-svelte-h":!0}),$(_)!=="svelte-1ku6bpr"&&(_.innerHTML=B),o=u(s),y=g(s,"P",{"data-svelte-h":!0}),$(y)!=="svelte-19hxoke"&&(y.innerHTML=xs),is=u(s),J(N.$$.fragment,s),cs=u(s),Q=g(s,"P",{"data-svelte-h":!0}),$(Q)!=="svelte-10xevcx"&&(Q.innerHTML=Is),us=u(s),X=g(s,"BLOCKQUOTE",{class:!0});var ns=Vs(X);es=g(ns,"P",{"data-svelte-h":!0}),$(es)!=="svelte-131vc75"&&(es.textContent=Rs),Xs=u(ns),J(A.$$.fragment,ns),ns.forEach(a),rs=u(s),J(Y.$$.fragment,s),os=u(s),v=g(s,"P",{"data-svelte-h":!0}),$(v)!=="svelte-1mmyg0a"&&(v.innerHTML=Bs),ds=u(s),J(E.$$.fragment,s),Ms=u(s),J(F.$$.fragment,s),Js=u(s),q=g(s,"P",{"data-svelte-h":!0}),$(q)!=="svelte-egn8rj"&&(q.innerHTML=Ns),ms=u(s),J(H.$$.fragment,s),js=u(s),z=g(s,"P",{"data-svelte-h":!0}),$(z)!=="svelte-s65gxe"&&(z.innerHTML=Qs),fs=u(s),J(L.$$.fragment,s),Us=u(s),J(D.$$.fragment,s),ys=u(s),S=g(s,"P",{"data-svelte-h":!0}),$(S)!=="svelte-zwnbgd"&&(S.innerHTML=As),hs=u(s),J(x.$$.fragment,s),Ts=u(s),J(K.$$.fragment,s),gs=u(s),P=g(s,"P",{"data-svelte-h":!0}),$(P)!=="svelte-1o7fr7l"&&(P.innerHTML=Ys),Zs=u(s),J(O.$$.fragment,s),$s=u(s),ss=g(s,"P",{"data-svelte-h":!0}),$(ss)!=="svelte-wbgo9d"&&(ss.innerHTML=vs),bs=u(s),J(I.$$.fragment,s),_s=u(s),J(ls.$$.fragment,s),ws=u(s),as=g(s,"P",{}),Vs(as).forEach(a),this.h()},h(){Cs(e,"name","hf:doc:metadata"),Cs(e,"content",al),Cs(X,"class","tip")},m(s,l){ps(document.head,e),p(s,d,l),p(s,t,l),p(s,r,l),m(n,s,l),p(s,i,l),p(s,h,l),p(s,k,l),p(s,b,l),p(s,V,l),m(C,s,l),p(s,G,l),p(s,_,l),p(s,o,l),p(s,y,l),p(s,is,l),m(N,s,l),p(s,cs,l),p(s,Q,l),p(s,us,l),p(s,X,l),ps(X,es),ps(X,Xs),m(A,X,null),p(s,rs,l),m(Y,s,l),p(s,os,l),p(s,v,l),p(s,ds,l),m(E,s,l),p(s,Ms,l),m(F,s,l),p(s,Js,l),p(s,q,l),p(s,ms,l),m(H,s,l),p(s,js,l),p(s,z,l),p(s,fs,l),m(L,s,l),p(s,Us,l),m(D,s,l),p(s,ys,l),p(s,S,l),p(s,hs,l),m(x,s,l),p(s,Ts,l),m(K,s,l),p(s,gs,l),p(s,P,l),p(s,Zs,l),m(O,s,l),p(s,$s,l),p(s,ss,l),p(s,bs,l),m(I,s,l),p(s,_s,l),m(ls,s,l),p(s,ws,l),p(s,as,l),Ws=!0},p(s,[l]){const ns={};l&2&&(ns.$$scope={dirty:l,ctx:s}),x.$set(ns);const Es={};l&2&&(Es.$$scope={dirty:l,ctx:s}),I.$set(Es)},i(s){Ws||(j(n.$$.fragment,s),j(C.$$.fragment,s),j(N.$$.fragment,s),j(A.$$.fragment,s),j(Y.$$.fragment,s),j(E.$$.fragment,s),j(F.$$.fragment,s),j(H.$$.fragment,s),j(L.$$.fragment,s),j(D.$$.fragment,s),j(x.$$.fragment,s),j(K.$$.fragment,s),j(O.$$.fragment,s),j(I.$$.fragment,s),j(ls.$$.fragment,s),Ws=!0)},o(s){f(n.$$.fragment,s),f(C.$$.fragment,s),f(N.$$.fragment,s),f(A.$$.fragment,s),f(Y.$$.fragment,s),f(E.$$.fragment,s),f(F.$$.fragment,s),f(H.$$.fragment,s),f(L.$$.fragment,s),f(D.$$.fragment,s),f(x.$$.fragment,s),f(K.$$.fragment,s),f(O.$$.fragment,s),f(I.$$.fragment,s),f(ls.$$.fragment,s),Ws=!1},d(s){s&&(a(d),a(t),a(r),a(i),a(h),a(k),a(b),a(V),a(G),a(_),a(o),a(y),a(is),a(cs),a(Q),a(us),a(X),a(rs),a(os),a(v),a(ds),a(Ms),a(Js),a(q),a(ms),a(js),a(z),a(fs),a(Us),a(ys),a(S),a(hs),a(Ts),a(gs),a(P),a(Zs),a($s),a(ss),a(bs),a(_s),a(ws),a(as)),a(e),U(n,s),U(C,s),U(N,s),U(A),U(Y,s),U(E,s),U(F,s),U(H,s),U(L,s),U(D,s),U(x,s),U(K,s),U(O,s),U(I,s),U(ls,s)}}}const al='{"title":"引导器","local":"引导器","sections":[{"title":"切换引导器","local":"切换引导器","sections":[],"depth":2},{"title":"加载自定义引导器","local":"加载自定义引导器","sections":[],"depth":2},{"title":"更改引导器参数","local":"更改引导器参数","sections":[],"depth":2},{"title":"上传自定义引导器","local":"上传自定义引导器","sections":[],"depth":2}],"depth":1}';function tl(w){return Hs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ol extends zs{constructor(e){super(),Ls(this,e,tl,el,qs,{})}}export{ol as component};
