import{s as Bs,o as Ns,n as E}from"../chunks/scheduler.e4ff9b64.js";import{S as Ws,i as vs,e as d,s as i,c as u,h as Fs,a as U,d as t,b as o,f as Fl,g as y,j as J,k as ct,l as El,m as s,n as T,t as b,o as h,p as w}from"../chunks/index.09f1bca0.js";import{C as Es,H as x,E as xs}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.b71282d6.js";import{C as G}from"../chunks/CodeBlock.c52051fd.js";import{H as dt,a as F}from"../chunks/HfOption.44827c7f.js";function ks(g){let a,f;return a=new G({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements.txt`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function Ys(g){let a,f;return a=new G({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements_flax.txt`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function Ss(g){let a,f,n,m;return a=new F({props:{id:"installation",option:"PyTorch",$$slots:{default:[ks]},$$scope:{ctx:g}}}),n=new F({props:{id:"installation",option:"Flax",$$slots:{default:[Ys]},$$scope:{ctx:g}}}),{c(){u(a.$$.fragment),f=i(),u(n.$$.fragment)},l(p){y(a.$$.fragment,p),f=o(p),y(n.$$.fragment,p)},m(p,M){T(a,p,M),s(p,f,M),T(n,p,M),m=!0},p(p,M){const c={};M&2&&(c.$$scope={dirty:M,ctx:p}),a.$set(c);const _={};M&2&&(_.$$scope={dirty:M,ctx:p}),n.$set(_)},i(p){m||(b(a.$$.fragment,p),b(n.$$.fragment,p),m=!0)},o(p){h(a.$$.fragment,p),h(n.$$.fragment,p),m=!1},d(p){p&&t(f),w(a,p),w(n,p)}}}function As(g){let a,f="在 16GB GPU 上，您可以使用 bitsandbytes 8 位优化器和梯度检查点来帮助训练 DreamBooth 模型。安装 bitsandbytes：",n,m,p,M,c="然后，将以下参数添加到您的训练命令中：",_,r,$;return m=new G({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes",wrap:!1}}),r=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUM=",highlighted:`accelerate launch train_dreambooth.py \\
  --gradient_checkpointing \\
  --use_8bit_adam \\`,wrap:!1}}),{c(){a=d("p"),a.textContent=f,n=i(),u(m.$$.fragment),p=i(),M=d("p"),M.textContent=c,_=i(),u(r.$$.fragment)},l(Z){a=U(Z,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1tref92"&&(a.textContent=f),n=o(Z),y(m.$$.fragment,Z),p=o(Z),M=U(Z,"P",{"data-svelte-h":!0}),J(M)!=="svelte-13tkjff"&&(M.textContent=c),_=o(Z),y(r.$$.fragment,Z)},m(Z,R){s(Z,a,R),s(Z,n,R),T(m,Z,R),s(Z,p,R),s(Z,M,R),s(Z,_,R),T(r,Z,R),$=!0},p:E,i(Z){$||(b(m.$$.fragment,Z),b(r.$$.fragment,Z),$=!0)},o(Z){h(m.$$.fragment,Z),h(r.$$.fragment,Z),$=!1},d(Z){Z&&(t(a),t(n),t(p),t(M),t(_)),w(m,Z),w(r,Z)}}}function Ls(g){let a,f="在 12GB GPU 上，您需要 bitsandbytes 8 位优化器、梯度检查点、xFormers，并将梯度设置为 <code>None</code> 而不是零以减少内存使用。",n,m,p;return m=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLWVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbiUyMCU1QyUwQSUyMCUyMC0tc2V0X2dyYWRzX3RvX25vbmUlMjAlNUM=",highlighted:`accelerate launch train_dreambooth.py \\
  --use_8bit_adam \\
  --gradient_checkpointing \\
  --enable_xformers_memory_efficient_attention \\
  --set_grads_to_none \\`,wrap:!1}}),{c(){a=d("p"),a.innerHTML=f,n=i(),u(m.$$.fragment)},l(M){a=U(M,"P",{"data-svelte-h":!0}),J(a)!=="svelte-iq1zeg"&&(a.innerHTML=f),n=o(M),y(m.$$.fragment,M)},m(M,c){s(M,a,c),s(M,n,c),T(m,M,c),p=!0},p:E,i(M){p||(b(m.$$.fragment,M),p=!0)},o(M){h(m.$$.fragment,M),p=!1},d(M){M&&(t(a),t(n)),w(m,M)}}}function zs(g){let a,f='在 8GB GPU 上，您需要 <a href="https://www.deepspeed.ai/" rel="nofollow">DeepSpeed</a> 将一些张量从 vRAM 卸载到 CPU 或 NVME，以便在更少的 GPU 内存下进行训练。',n,m,p="运行以下命令来配置您的 🤗 Accelerate 环境：",M,c,_,r,$='在配置过程中，确认您想使用 DeepSpeed。现在，通过结合 DeepSpeed 阶段 2、fp16 混合精度以及将模型参数和优化器状态卸载到 CPU，应该可以在低于 8GB vRAM 的情况下进行训练。缺点是这需要更多的系统 RAM（约 25 GB）。有关更多配置选项，请参阅 <a href="https://huggingface.co/docs/accelerate/usage_guides/deepspeed" rel="nofollow">DeepSpeed 文档</a>。',Z,R,B='您还应将默认的 Adam 优化器更改为 DeepSpeed 的优化版本 <a href="https://deepspeed.readthedocs.io/en/latest/optimizers.html#adam-cpu" rel="nofollow"><code>deepspeed.ops.adam.DeepSpeedCPUAdam</code></a> 以获得显著的速度提升。启用 <code>DeepSpeedCPUAdam</code> 要求您的系统 CUDA 工具链版本与 PyTorch 安装的版本相同。',N,I,v="目前，bitsandbytes 8 位优化器似乎与 DeepSpeed 不兼容。",W,j,X="就是这样！您不需要向训练命令添加任何额外参数。",k;return c=new G({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),{c(){a=d("p"),a.innerHTML=f,n=i(),m=d("p"),m.textContent=p,M=i(),u(c.$$.fragment),_=i(),r=d("p"),r.innerHTML=$,Z=i(),R=d("p"),R.innerHTML=B,N=i(),I=d("p"),I.textContent=v,W=i(),j=d("p"),j.textContent=X},l(C){a=U(C,"P",{"data-svelte-h":!0}),J(a)!=="svelte-jkd0g3"&&(a.innerHTML=f),n=o(C),m=U(C,"P",{"data-svelte-h":!0}),J(m)!=="svelte-axex8f"&&(m.textContent=p),M=o(C),y(c.$$.fragment,C),_=o(C),r=U(C,"P",{"data-svelte-h":!0}),J(r)!=="svelte-yd1wd8"&&(r.innerHTML=$),Z=o(C),R=U(C,"P",{"data-svelte-h":!0}),J(R)!=="svelte-1fv4fvf"&&(R.innerHTML=B),N=o(C),I=U(C,"P",{"data-svelte-h":!0}),J(I)!=="svelte-eh5hb5"&&(I.textContent=v),W=o(C),j=U(C,"P",{"data-svelte-h":!0}),J(j)!=="svelte-15aa0ut"&&(j.textContent=X)},m(C,V){s(C,a,V),s(C,n,V),s(C,m,V),s(C,M,V),T(c,C,V),s(C,_,V),s(C,r,V),s(C,Z,V),s(C,R,V),s(C,N,V),s(C,I,V),s(C,W,V),s(C,j,V),k=!0},p:E,i(C){k||(b(c.$$.fragment,C),k=!0)},o(C){h(c.$$.fragment,C),k=!1},d(C){C&&(t(a),t(n),t(m),t(M),t(_),t(r),t(Z),t(R),t(N),t(I),t(W),t(j)),w(c,C)}}}function Qs(g){let a,f,n,m,p,M;return a=new F({props:{id:"gpu-select",option:"16GB",$$slots:{default:[As]},$$scope:{ctx:g}}}),n=new F({props:{id:"gpu-select",option:"12GB",$$slots:{default:[Ls]},$$scope:{ctx:g}}}),p=new F({props:{id:"gpu-select",option:"8GB",$$slots:{default:[zs]},$$scope:{ctx:g}}}),{c(){u(a.$$.fragment),f=i(),u(n.$$.fragment),m=i(),u(p.$$.fragment)},l(c){y(a.$$.fragment,c),f=o(c),y(n.$$.fragment,c),m=o(c),y(p.$$.fragment,c)},m(c,_){T(a,c,_),s(c,f,_),T(n,c,_),s(c,m,_),T(p,c,_),M=!0},p(c,_){const r={};_&2&&(r.$$scope={dirty:_,ctx:c}),a.$set(r);const $={};_&2&&($.$$scope={dirty:_,ctx:c}),n.$set($);const Z={};_&2&&(Z.$$scope={dirty:_,ctx:c}),p.$set(Z)},i(c){M||(b(a.$$.fragment,c),b(n.$$.fragment,c),b(p.$$.fragment,c),M=!0)},o(c){h(a.$$.fragment,c),h(n.$$.fragment,c),h(p.$$.fragment,c),M=!1},d(c){c&&(t(f),t(m)),w(a,c),w(n,c),w(p,c)}}}function Ds(g){let a,f;return a=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b18lMEFzYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3RoLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDQwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_
saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --max_train_steps=400 \\
  --push_to_hub`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function Hs(g){let a,f;return a=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBJTBBcHl0aG9uJTIwdHJhaW5fZHJlYW1ib290aF9mbGF4LnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENDAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;duongna/stable-diffusion-v1-4-flax&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

python train_dreambooth_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --learning_rate=5e-6 \\
  --max_train_steps=400 \\
  --push_to_hub`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function qs(g){let a,f,n,m;return a=new F({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[Ds]},$$scope:{ctx:g}}}),n=new F({props:{id:"training-inference",option:"Flax",$$slots:{default:[Hs]},$$scope:{ctx:g}}}),{c(){u(a.$$.fragment),f=i(),u(n.$$.fragment)},l(p){y(a.$$.fragment,p),f=o(p),y(n.$$.fragment,p)},m(p,M){T(a,p,M),s(p,f,M),T(n,p,M),m=!0},p(p,M){const c={};M&2&&(c.$$scope={dirty:M,ctx:p}),a.$set(c);const _={};M&2&&(_.$$scope={dirty:M,ctx:p}),n.$set(_)},i(p){m||(b(a.$$.fragment,p),b(n.$$.fragment,p),m=!0)},o(p){h(a.$$.fragment,p),h(n.$$.fragment,p),m=!1},d(p){p&&t(f),w(a,p),w(n,p)}}}function Ps(g){let a,f;return a=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoX3RvX3NhdmVkX21vZGVsJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMiklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKCUyMkElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIwaW4lMjBhJTIwYnVja2V0JTIyJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmRvZy1idWNrZXQucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch

pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;path_to_saved_model&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipeline(<span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function Os(g){let a,f;return a=new G({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGgtdG8teW91ci10cmFpbmVkLW1vZGVsJTIyJTJDJTIwZHR5cGUlM0RqYXgubnVtcHkuYmZsb2F0MTYpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLlBSTkdLZXkoMCklMEFudW1faW5mZXJlbmNlX3N0ZXBzJTIwJTNEJTIwNTAlMEElMEFudW1fc2FtcGxlcyUyMCUzRCUyMGpheC5kZXZpY2VfY291bnQoKSUwQXByb21wdCUyMCUzRCUyMG51bV9zYW1wbGVzJTIwKiUyMCU1QnByb21wdCU1RCUwQXByb21wdF9pZHMlMjAlM0QlMjBwaXBlbGluZS5wcmVwYXJlX2lucHV0cyhwcm9tcHQpJTBBJTBBJTIzJTIwJUU1JTg4JTg2JUU3JTg5JTg3JUU4JUJFJTkzJUU1JTg1JUE1JUU1JTkyJThDJUU5JTlBJThGJUU2JTlDJUJBJUU2JTk1JUIwJUU3JTk0JTlGJUU2JTg4JTkwJUU1JTk5JUE4JTBBcGFyYW1zJTIwJTNEJTIwcmVwbGljYXRlKHBhcmFtcyklMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLnNwbGl0KHBybmdfc2VlZCUyQyUyMGpheC5kZXZpY2VfY291bnQoKSklMEFwcm9tcHRfaWRzJTIwJTNEJTIwc2hhcmQocHJvbXB0X2lkcyklMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShwcm9tcHRfaWRzJTJDJTIwcGFyYW1zJTJDJTIwcHJuZ19zZWVkJTJDJTIwbnVtX2luZmVyZW5jZV8lMEFzdGVwcyUyQyUyMGppdCUzRFRydWUpLmltYWdlcyUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lLm51bXB5X3RvX3BpbChucC5hc2FycmF5KGltYWdlcy5yZXNoYXBlKChudW1fc2FtcGxlcyUyQyklMjAlMkIlMjBpbWFnZXMuc2hhcGUlNUItMyUzQSU1RCkpKSUwQWltYWdlLnNhdmUoJTIyZG9nLWJ1Y2tldC5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> jax
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> flax.jax_utils <span class="hljs-keyword">import</span> replicate
<span class="hljs-keyword">from</span> flax.training.common_utils <span class="hljs-keyword">import</span> shard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlaxStableDiffusionPipeline

pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;path-to-your-trained-model&quot;</span>, dtype=jax.numpy.bfloat16)

prompt = <span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>
prng_seed = jax.random.PRNGKey(<span class="hljs-number">0</span>)
num_inference_steps = <span class="hljs-number">50</span>

num_samples = jax.device_count()
prompt = num_samples * [prompt]
prompt_ids = pipeline.prepare_inputs(prompt)

<span class="hljs-comment"># 分片输入和随机数生成器</span>
params = replicate(params)
prng_seed = jax.random.split(prng_seed, jax.device_count())
prompt_ids = shard(prompt_ids)

images = pipeline(prompt_ids, params, prng_seed, num_inference_
steps, jit=<span class="hljs-literal">True</span>).images
images = pipeline.numpy_to_pil(np.asarray(images.reshape((num_samples,) + images.shape[-<span class="hljs-number">3</span>:])))
image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`,wrap:!1}}),{c(){u(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,m){T(a,n,m),f=!0},p:E,i(n){f||(b(a.$$.fragment,n),f=!0)},o(n){h(a.$$.fragment,n),f=!1},d(n){w(a,n)}}}function Ks(g){let a,f,n,m;return a=new F({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[Ps]},$$scope:{ctx:g}}}),n=new F({props:{id:"training-inference",option:"Flax",$$slots:{default:[Os]},$$scope:{ctx:g}}}),{c(){u(a.$$.fragment),f=i(),u(n.$$.fragment)},l(p){y(a.$$.fragment,p),f=o(p),y(n.$$.fragment,p)},m(p,M){T(a,p,M),s(p,f,M),T(n,p,M),m=!0},p(p,M){const c={};M&2&&(c.$$scope={dirty:M,ctx:p}),a.$set(c);const _={};M&2&&(_.$$scope={dirty:M,ctx:p}),n.$set(_)},i(p){m||(b(a.$$.fragment,p),b(n.$$.fragment,p),m=!0)},o(p){h(a.$$.fragment,p),h(n.$$.fragment,p),m=!1},d(p){p&&t(f),w(a,p),w(n,p)}}}function ea(g){let a,f="使用 LoRA 和 DreamBooth 训练 DeepFloyd IF 的第 1 阶段需要约 28GB 内存。",n,m,p;return m=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ19sb3JhJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGhfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTIwd2FuZGIlMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwc2tzJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENjQlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0Q0JTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tc2NhbGVfbHIlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDEyMDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9lcG9jaHMlM0QyNSUyMCU1QyUwQSUyMCUyMC0tY2hlY2twb2ludGluZ19zdGVwcyUzRDEwMCUyMCU1QyUwQSUyMCUyMC0tcHJlX2NvbXB1dGVfdGV4dF9lbWJlZGRpbmdzJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUzRDc3JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNr",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_lora&quot;</span>

accelerate launch train_dreambooth_lora.py \\
  --report_to wandb \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --resolution=64 \\
  --train_batch_size=4 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=5e-6 \\
  --scale_lr \\
  --max_train_steps=1200 \\
  --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --validation_epochs=25 \\
  --checkpointing_steps=100 \\
  --pre_compute_text_embeddings \\
  --tokenizer_max_length=77 \\
  --text_encoder_use_attention_mask`,wrap:!1}}),{c(){a=d("p"),a.textContent=f,n=i(),u(m.$$.fragment)},l(M){a=U(M,"P",{"data-svelte-h":!0}),J(a)!=="svelte-c5ggda"&&(a.textContent=f),n=o(M),y(m.$$.fragment,M)},m(M,c){s(M,a,c),s(M,n,c),T(m,M,c),p=!0},p:E,i(M){p||(b(m.$$.fragment,M),p=!0)},o(M){h(m.$$.fragment,M),p=!1},d(M){M&&(t(a),t(n)),w(m,M)}}}function ta(g){let a,f="对于使用 LoRA 和 DreamBooth 的 DeepFloyd IF 第 2 阶段，请注意这些参数：",n,m,p="<li><code>--validation_images</code>，验证期间用于上采样的图像</li> <li><code>--class_labels_conditioning=timesteps</code>，根据需要额外条件化 UNet，如第 2 阶段中所需</li> <li><code>--learning_rate=1e-6</code>，与第 1 阶段相比使用较低的学习率</li> <li><code>--resolution=256</code>，上采样器的预期分辨率</li>",M,c,_;return c=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2xvcmEucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlcG9ydF90byUyMHdhbmRiJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcmVzb2x1dGlvbiUzRDI1NiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAlMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS02JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QyMDAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMmElMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25fZXBvY2hzJTNEMTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRva2VuaXplcl9tYXhfbGVuZ3RoJTNENzclMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRleHRfZW5jb2Rlcl91c2VfYXR0ZW50aW9uX21hc2slMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25faW1hZ2VzJTIwJTI0VkFMSURBVElPTl9JTUFHRVMlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWNsYXNzX2xhYmVsc19jb25kaXRpb25pbmclM0R0aW1lc3RlcHM=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-II-L-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_upscale&quot;</span>
<span class="hljs-built_in">export</span> VALIDATION_IMAGES=<span class="hljs-string">&quot;dog_downsized/image_1.png dog_downsized/image_2.png dog_downsized/image_3.png dog_downsized/image_4.png&quot;</span>

python train_dreambooth_lora.py \\
    --report_to wandb \\
    --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
    --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
    --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
    --instance_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
    --resolution=256 \\
    --train_batch_size=4 \\
    --gradient_accumulation_steps=1 \\
    --learning_rate=1e-6 \\
    --max_train_steps=2000 \\
    --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
    --validation_epochs=100 \\
    --checkpointing_steps=500 \\
    --pre_compute_text_embeddings \\
    --tokenizer_max_length=77 \\
    --text_encoder_use_attention_mask \\
    --validation_images <span class="hljs-variable">$VALIDATION_IMAGES</span> \\
    --class_labels_conditioning=timesteps`,wrap:!1}}),{c(){a=d("p"),a.textContent=f,n=i(),m=d("ul"),m.innerHTML=p,M=i(),u(c.$$.fragment)},l(r){a=U(r,"P",{"data-svelte-h":!0}),J(a)!=="svelte-11ldul9"&&(a.textContent=f),n=o(r),m=U(r,"UL",{"data-svelte-h":!0}),J(m)!=="svelte-1ktyq6"&&(m.innerHTML=p),M=o(r),y(c.$$.fragment,r)},m(r,$){s(r,a,$),s(r,n,$),s(r,m,$),s(r,M,$),T(c,r,$),_=!0},p:E,i(r){_||(b(c.$$.fragment,r),_=!0)},o(r){h(c.$$.fragment,r),_=!1},d(r){r&&(t(a),t(n),t(m),t(M)),w(c,r)}}}function la(g){let a,f="对于使用 DreamBooth 的 DeepFloyd IF 第 1 阶段，请注意这些参数：",n,m,p="<li><code>--skip_save_text_encoder</code>，跳过保存完整 T5 文本编码器与微调模型</li> <li><code>--use_8bit_adam</code>，使用 8 位 Adam 优化器以节省内存，因为</li>",M,c,_="优化器状态的大小在训练完整模型时",r,$,Z="<li><code>--learning_rate=1e-7</code>，对于完整模型训练应使用非常低的学习率，否则模型质量会下降（您可以使用更高的学习率和更大的批次大小）</li>",R,B,N="使用8位Adam和批次大小为4进行训练，完整模型可以在约48GB内存下训练。",I,v,W;return v=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2lmJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDY0JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTclMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9wcm9tcHQlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUyMDI1JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUyMDc3JTIwJTVDJTBBJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLXNldF9ncmFkc190b19ub25lJTIwJTVDJTBBJTIwJTIwLS1za2lwX3NhdmVfdGV4dF9lbmNvZGVyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_if&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=64 \\
  --train_batch_size=4 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=1e-7 \\
  --max_train_steps=150 \\
  --validation_prompt <span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --validation_steps 25 \\
  --text_encoder_use_attention_mask \\
  --tokenizer_max_length 77 \\
  --pre_compute_text_embeddings \\
  --use_8bit_adam \\
  --set_grads_to_none \\
  --skip_save_text_encoder \\
  --push_to_hub`,wrap:!1}}),{c(){a=d("p"),a.textContent=f,n=i(),m=d("ul"),m.innerHTML=p,M=i(),c=d("p"),c.textContent=_,r=i(),$=d("ul"),$.innerHTML=Z,R=i(),B=d("p"),B.textContent=N,I=i(),u(v.$$.fragment)},l(j){a=U(j,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1lq2f7s"&&(a.textContent=f),n=o(j),m=U(j,"UL",{"data-svelte-h":!0}),J(m)!=="svelte-1ozc2pw"&&(m.innerHTML=p),M=o(j),c=U(j,"P",{"data-svelte-h":!0}),J(c)!=="svelte-8hl20r"&&(c.textContent=_),r=o(j),$=U(j,"UL",{"data-svelte-h":!0}),J($)!=="svelte-12mqcsr"&&($.innerHTML=Z),R=o(j),B=U(j,"P",{"data-svelte-h":!0}),J(B)!=="svelte-aqv281"&&(B.textContent=N),I=o(j),y(v.$$.fragment,j)},m(j,X){s(j,a,X),s(j,n,X),s(j,m,X),s(j,M,X),s(j,c,X),s(j,r,X),s(j,$,X),s(j,R,X),s(j,B,X),s(j,I,X),T(v,j,X),W=!0},p:E,i(j){W||(b(v.$$.fragment,j),W=!0)},o(j){h(v.$$.fragment,j),W=!1},d(j){j&&(t(a),t(n),t(m),t(M),t(c),t(r),t($),t(R),t(B),t(I)),w(v,j)}}}function sa(g){let a,f="对于DeepFloyd IF的第二阶段DreamBooth，请注意这些参数：",n,m,p="<li><code>--learning_rate=5e-6</code>，使用较低的学习率和较小的有效批次大小</li> <li><code>--resolution=256</code>，上采样器的预期分辨率</li> <li><code>--train_batch_size=2</code> 和 <code>--gradient_accumulation_steps=6</code>，为了有效训练包含面部的图像，需要更大的批次大小</li>",M,c,_;return c=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fZHJlYW1ib290aC5weSUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTIwd2FuZGIlMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwc2tzJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNEMjU2JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMiUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENiUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDVlLTYlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDIwMDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tY2hlY2twb2ludGluZ19zdGVwcyUzRDUwMCUyMCU1QyUwQSUyMCUyMC0tcHJlX2NvbXB1dGVfdGV4dF9lbWJlZGRpbmdzJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUzRDc3JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX2ltYWdlcyUyMCUyNFZBTElEQVRJT05fSU1BR0VTJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19sYWJlbHNfY29uZGl0aW9uaW5nJTIwdGltZXN0ZXBzJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-II-L-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_upscale&quot;</span>
<span class="hljs-built_in">export</span> VALIDATION_IMAGES=<span class="hljs-string">&quot;dog_downsized/image_1.png dog_downsized/image_2.png dog_downsized/image_3.png dog_downsized/image_4.png&quot;</span>

accelerate launch train_dreambooth.py \\
  --report_to wandb \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --resolution=256 \\
  --train_batch_size=2 \\
  --gradient_accumulation_steps=6 \\
  --learning_rate=5e-6 \\
  --max_train_steps=2000 \\
  --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --validation_steps=150 \\
  --checkpointing_steps=500 \\
  --pre_compute_text_embeddings \\
  --tokenizer_max_length=77 \\
  --text_encoder_use_attention_mask \\
  --validation_images <span class="hljs-variable">$VALIDATION_IMAGES</span> \\
  --class_labels_conditioning timesteps \\
  --push_to_hub`,wrap:!1}}),{c(){a=d("p"),a.textContent=f,n=i(),m=d("ul"),m.innerHTML=p,M=i(),u(c.$$.fragment)},l(r){a=U(r,"P",{"data-svelte-h":!0}),J(a)!=="svelte-19neukg"&&(a.textContent=f),n=o(r),m=U(r,"UL",{"data-svelte-h":!0}),J(m)!=="svelte-11mh8rd"&&(m.innerHTML=p),M=o(r),y(c.$$.fragment,r)},m(r,$){s(r,a,$),s(r,n,$),s(r,m,$),s(r,M,$),T(c,r,$),_=!0},p:E,i(r){_||(b(c.$$.fragment,r),_=!0)},o(r){h(c.$$.fragment,r),_=!1},d(r){r&&(t(a),t(n),t(m),t(M)),w(c,r)}}}function aa(g){let a,f,n,m,p,M,c,_;return a=new F({props:{id:"IF-DreamBooth",option:"Stage 1 LoRA DreamBooth",$$slots:{default:[ea]},$$scope:{ctx:g}}}),n=new F({props:{id:"IF-DreamBooth",option:"Stage 2 LoRA DreamBooth",$$slots:{default:[ta]},$$scope:{ctx:g}}}),p=new F({props:{id:"IF-DreamBooth",option:"Stage 1 DreamBooth",$$slots:{default:[la]},$$scope:{ctx:g}}}),c=new F({props:{id:"IF-DreamBooth",option:"Stage 2 DreamBooth",$$slots:{default:[sa]},$$scope:{ctx:g}}}),{c(){u(a.$$.fragment),f=i(),u(n.$$.fragment),m=i(),u(p.$$.fragment),M=i(),u(c.$$.fragment)},l(r){y(a.$$.fragment,r),f=o(r),y(n.$$.fragment,r),m=o(r),y(p.$$.fragment,r),M=o(r),y(c.$$.fragment,r)},m(r,$){T(a,r,$),s(r,f,$),T(n,r,$),s(r,m,$),T(p,r,$),s(r,M,$),T(c,r,$),_=!0},p(r,$){const Z={};$&2&&(Z.$$scope={dirty:$,ctx:r}),a.$set(Z);const R={};$&2&&(R.$$scope={dirty:$,ctx:r}),n.$set(R);const B={};$&2&&(B.$$scope={dirty:$,ctx:r}),p.$set(B);const N={};$&2&&(N.$$scope={dirty:$,ctx:r}),c.$set(N)},i(r){_||(b(a.$$.fragment,r),b(n.$$.fragment,r),b(p.$$.fragment,r),b(c.$$.fragment,r),_=!0)},o(r){h(a.$$.fragment,r),h(n.$$.fragment,r),h(p.$$.fragment,r),h(c.$$.fragment,r),_=!1},d(r){r&&(t(f),t(m),t(M)),w(a,r),w(n,r),w(p,r),w(c,r)}}}function na(g){let a,f,n,m,p,M,c,_,r,$='<a href="https://huggingface.co/papers/2208.12242" rel="nofollow">DreamBooth</a> 是一种训练技术，通过仅训练少数主题或风格的图像来更新整个扩散模型。它通过在提示中关联一个特殊词与示例图像来工作。',Z,R,B='如果您在 vRAM 有限的 GPU 上训练，应尝试在训练命令中启用 <code>gradient_checkpointing</code> 和 <code>mixed_precision</code> 参数。您还可以通过使用 <a href="../optimization/xformers">xFormers</a> 的内存高效注意力来减少内存占用。JAX/Flax 训练也支持在 TPU 和 GPU 上进行高效训练，但不支持梯度检查点或 xFormers。如果您想使用 Flax 更快地训练，应拥有内存 &gt;30GB 的 GPU。',N,I,v='本指南将探索 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">train_dreambooth.py</a> 脚本，帮助您更熟悉它，以及如何根据您的用例进行适配。',W,j,X="在运行脚本之前，请确保从源代码安装库：",k,C,V,P,xl="导航到包含训练脚本的示例文件夹，并安装脚本所需的依赖项：",Ut,S,Jt,A,kl='<p>🤗 Accelerate 是一个库，用于帮助您在多个 GPU/TPU 上或使用混合精度进行训练。它会根据您的硬件和环境自动配置训练设置。查看 🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">快速入门</a> 以了解更多信息。</p>',ut,O,Yl="初始化 🤗 Accelerate 环境：",yt,K,Tt,ee,Sl="要设置默认的 🤗 Accelerate 环境而不选择任何配置：",bt,te,ht,le,Al="或者，如果您的环境不支持交互式 shell，例如笔记本，您可以使用：",wt,se,_t,ae,Ll=`最后，如果您想在自己的数据集上训练模型，请查看 <a href="create_dataset">创建用于训练的数据集</a> 指南，了解如何创建与
训练脚本。`,$t,L,zl='<p>以下部分重点介绍了训练脚本中对于理解如何修改它很重要的部分，但并未详细涵盖脚本的每个方面。如果您有兴趣了解更多，请随时阅读<a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">脚本</a>，并告诉我们如果您有任何问题或疑虑。</p>',jt,ne,Zt,z,Ql='<p>DreamBooth 对训练超参数非常敏感，容易过拟合。阅读 <a href="https://huggingface.co/blog/dreambooth" rel="nofollow">使用 🧨 Diffusers 训练 Stable Diffusion 与 Dreambooth</a> 博客文章，了解针对不同主题的推荐设置，以帮助您选择合适的超参数。</p>',Ct,pe,Dl='训练脚本提供了许多参数来自定义您的训练运行。所有参数及其描述都可以在 <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L228" rel="nofollow"><code>parse_args()</code></a> 函数中找到。参数设置了默认值，这些默认值应该开箱即用效果不错，但如果您愿意，也可以在训练命令中设置自己的值。',gt,ie,Hl="例如，要以 bf16 格式进行训练：",Rt,oe,Gt,re,ql="一些基本且重要的参数需要了解和指定：",It,Me,Pl="<li><code>--pretrained_model_name_or_path</code>: Hub 上的模型名称或预训练模型的本地路径</li> <li><code>--instance_data_dir</code>: 包含训练数据集（示例图像）的文件夹路径</li> <li><code>--instance_prompt</code>: 包含示例图像特殊单词的文本提示</li> <li><code>--train_text_encoder</code>: 是否也训练文本编码器</li> <li><code>--output_dir</code>: 保存训练后模型的位置</li> <li><code>--push_to_hub</code>: 是否将训练后的模型推送到 Hub</li> <li><code>--checkpointing_steps</code>: 模型训练时保存检查点的频率；这在训练因某种原因中断时很有用，您可以通过在训练命令中添加 <code>--resume_from_checkpoint</code> 来从该检查点继续训练</li>",Vt,me,Xt,ce,Ol='<a href="https://huggingface.co/papers/2303.09556" rel="nofollow">Min-SNR</a> 加权策略可以通过重新平衡损失来帮助训练，以实现更快的收敛。训练脚本支持预测 <code>epsilon</code>（噪声）或 <code>v_prediction</code>，但 Min-SNR 与两种预测类型都兼容。此加权策略仅由 PyTorch 支持，在 Flax 训练脚本中不可用。',Bt,fe,Kl="添加 <code>--snr_gamma</code> 参数并将其设置为推荐值 5.0：",Nt,de,Wt,Ue,vt,Je,es=`先验保持损失是一种使用模型自身生成的样本来帮助它学习如何生成更多样化图像的方法。因为这些生成的样本图像属于您提供的图像相同的类别，它们帮助模型 r
etain 它已经学到的关于类别的知识，以及它如何利用已经了解的类别信息来创建新的组合。`,Ft,ue,ts="<li><code>--with_prior_preservation</code>: 是否使用先验保留损失</li> <li><code>--prior_loss_weight</code>: 控制先验保留损失对模型的影响程度</li> <li><code>--class_data_dir</code>: 包含生成的类别样本图像的文件夹路径</li> <li><code>--class_prompt</code>: 描述生成的样本图像类别的文本提示</li>",Et,ye,xt,Te,kt,be,ls="为了提高生成输出的质量，除了 UNet 之外，您还可以训练文本编码器。这需要额外的内存，并且您需要一个至少有 24GB 显存的 GPU。如果您拥有必要的硬件，那么训练文本编码器会产生更好的结果，尤其是在生成面部图像时。通过以下方式启用此选项：",Yt,he,St,we,At,_e,ss="DreamBooth 附带了自己的数据集类：",Lt,$e,as='<li><a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L604" rel="nofollow"><code>DreamBoothDataset</code></a>: 预处理图像和类别图像，并对提示进行分词以用于训练</li> <li><a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L738" rel="nofollow"><code>PromptDataset</code></a>: 生成提示嵌入以生成类别图像</li>',zt,je,ns='如果您启用了<a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L842" rel="nofollow">先验保留损失</a>，类别图像在此处生成：',Qt,Ze,Dt,Ce,ps='接下来是 <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L799" rel="nofollow"><code>main()</code></a> 函数，它处理设置训练数据集和训练循环本身。脚本加载 <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L898" rel="nofollow">tokenizer</a>、<a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L912C1-L912C1" rel="nofollow">scheduler 和 models</a>：',Ht,ge,qt,Re,is='然后，是时候<a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L1073" rel="nofollow">创建训练数据集</a>和从<code>DreamBoothDataset</code>创建DataLoader：',Pt,Ge,Ot,Ie,os='最后，<a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L1151" rel="nofollow">训练循环</a>处理剩余步骤，例如将图像转换为潜在空间、向输入添加噪声、预测噪声残差和计算损失。',Kt,Ve,rs='如果您想了解更多关于训练循环的工作原理，请查看<a href="../using-diffusers/write_own_pipeline">理解管道、模型和调度器</a>教程，该教程分解了去噪过程的基本模式。',el,Xe,tl,Be,Ms="您现在准备好启动训练脚本了！🚀",ll,Ne,ms='对于本指南，您将下载一些<a href="https://huggingface.co/datasets/diffusers/dog-example" rel="nofollow">狗的图片</a>的图像并将它们存储在一个目录中。但请记住，您可以根据需要创建和使用自己的数据集（请参阅<a href="create_dataset">创建用于训练的数据集</a>指南）。',sl,We,al,ve,cs="设置环境变量 <code>MODEL_NAME</code> 为 Hub 上的模型 ID 或本地模型路径，<code>INSTANCE_DIR</code> 为您刚刚下载狗图像的路径，<code>OUTPUT_DIR</code> 为您想保存模型的位置。您将使用 <code>sks</code> 作为特殊词来绑定训练。",nl,Fe,fs="如果您有兴趣跟随训练过程，可以定期保存生成的图像作为训练进度。将以下参数添加到训练命令中：",pl,Ee,il,xe,ds="在启动脚本之前，还有一件事！根据您拥有的 GPU，您可能需要启用某些优化来训练 DreamBooth。",ol,Q,rl,D,Ml,ke,Us="训练完成后，您可以使用新训练的模型进行推理！",ml,Y,mt,Js="等不及在训练完成前就尝试您的模型进行推理？🤭 请确保安装了最新版本的 🤗 Accelerate。",vl,Ye,cl,H,fl,Se,dl,Ae,us='LoRA 是一种训练技术，可显著减少可训练参数的数量。因此，训练速度更快，并且更容易存储生成的权重，因为它们小得多（约 100MB）。使用 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">train_dreambooth_lora.py</a> 脚本通过 LoRA 进行训练。',Ul,Le,ys='LoRA 训练脚本在 <a href="lora">LoRA 训练</a> 指南中有更详细的讨论。',Jl,ze,ul,Qe,Ts='Stable Diffusion XL (SDXL) 是一个强大的文本到图像模型，可生成高分辨率图像，并在其架构中添加了第二个文本编码器。使用 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora_sdxl.py" rel="nofollow">train_dreambooth_lora_sdxl.py</a> 脚本通过 LoRA 训练 SDXL 模型。',yl,De,bs='SDXL 训练脚本在 <a href="sdxl">SDXL 训练</a> 指南中有更详细的讨论。',Tl,He,bl,qe,hs='DeepFloyd IF 是一个级联像素扩散模型，包含三个阶段。第一阶段生成基础图像，第二和第三阶段逐步将基础图像放大为高分辨率 1024x1024 图像。使用 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">train_dreambooth_lora.py</a> 或 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">train_dreambooth.py</a> 脚本通过 LoRA 或完整模型训练 DeepFloyd IF 模型。',hl,Pe,ws="DeepFloyd IF 使用预测方差，但 Diffusers 训练脚本使用预测误差，因此训练的 DeepFloyd IF 模型被切换到固定方差调度。训练脚本将为您更新完全训练模型的调度器配置。但是，当您加载保存的 LoRA 权重时，还必须更新管道的调度器配置。",wl,Oe,_l,Ke,_s="第二阶段模型需要额外的验证图像进行放大。您可以下载并使用训练图像的缩小版本。",$l,et,jl,tt,$s="以下代码示例简要概述了如何结合 DreamBooth 和 LoRA 训练 DeepFloyd IF 模型。一些需要注意的重要参数包括：",Zl,lt,js=`<li><code>--resolution=64</code>，需要更小的分辨率，因为 DeepFloyd IF 是
一个像素扩散模型，用于处理未压缩的像素，输入图像必须更小</li> <li><code>--pre_compute_text_embeddings</code>，提前计算文本嵌入以节省内存，因为 <code>T5Model</code> 可能占用大量内存</li> <li><code>--tokenizer_max_length=77</code>，您可以使用更长的默认文本长度与 T5 作为文本编码器，但默认模型编码过程使用较短的文本长度</li> <li><code>--text_encoder_use_attention_mask</code>，将注意力掩码传递给文本编码器</li>`,Cl,q,gl,st,Rl,at,Zs="训练DeepFloyd IF模型可能具有挑战性，但以下是我们发现有用的技巧：",Gl,nt,Cs=`<li>LoRA对于训练第一阶段模型已足够，因为模型的低分辨率使得表示更精细的细节变得困难，无论如何。</li> <li>对于常见或简单的对象，您不一定需要微调上采样器。确保传递给上采样器的提示被调整以移除实例提示中的新令牌。例如，如果您第一阶段提示是”a sks dog”，那么您第二阶段的提示应该是”a dog”。</li> <li>对于更精细的细节，如面部，完全训练
使用阶段2上采样器比使用LoRA训练阶段2模型更好。使用更大的批次大小和较低的学习率也有帮助。</li> <li>应使用较低的学习率来训练阶段2模型。</li> <li><code>DDPMScheduler</code> 比训练脚本中使用的DPMSolver效果更好。</li>`,Il,pt,Vl,it,gs="恭喜您训练了您的DreamBooth模型！要了解更多关于如何使用您的新模型的信息，以下指南可能有所帮助：",Xl,ot,Rs='<li>如果您使用LoRA训练了您的模型，请学习如何<a href="../using-diffusers/loading_adapters">加载DreamBooth</a>模型进行推理。</li>',Bl,rt,Nl,ft,Wl;return p=new Es({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new x({props:{title:"DreamBooth",local:"dreambooth",headingTag:"h1"}}),C=new G({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install .`,wrap:!1}}),S=new dt({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[Ss]},$$scope:{ctx:g}}}),K=new G({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),te=new G({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),se=new G({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`,wrap:!1}}),ne=new x({props:{title:"脚本参数",local:"脚本参数",headingTag:"h2"}}),oe=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmJmMTYlMjI=",highlighted:`accelerate launch train_dreambooth.py \\
    --mixed_precision=<span class="hljs-string">&quot;bf16&quot;</span>`,wrap:!1}}),me=new x({props:{title:"Min-SNR 加权",local:"min-snr-加权",headingTag:"h3"}}),de=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXNucl9nYW1tYSUzRDUuMA==",highlighted:`accelerate launch train_dreambooth.py \\
  --snr_gamma=5.0`,wrap:!1}}),Ue=new x({props:{title:"先验保持损失",local:"先验保持损失",headingTag:"h3"}}),ye=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwJTVDJTBBJTIwJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfZGF0YV9kaXIlM0QlMjJwYXRoJTJGdG8lMkZjbGFzcyUyRmltYWdlcyUyMiUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIydGV4dCUyMHByb21wdCUyMGRlc2NyaWJpbmclMjBjbGFzcyUyMg==",highlighted:`accelerate launch train_dreambooth.py \\
  --with_prior_preservation \\
  --prior_loss_weight=1.0 \\
  --class_data_dir=<span class="hljs-string">&quot;path/to/class/images&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;text prompt describing class&quot;</span>`,wrap:!1}}),Te=new x({props:{title:"训练文本编码器",local:"训练文本编码器",headingTag:"h3"}}),he=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXRyYWluX3RleHRfZW5jb2Rlcg==",highlighted:`accelerate launch train_dreambooth.py \\
  --train_text_encoder`,wrap:!1}}),we=new x({props:{title:"训练脚本",local:"训练脚本",headingTag:"h2"}}),Ze=new G({props:{code:"c2FtcGxlX2RhdGFzZXQlMjAlM0QlMjBQcm9tcHREYXRhc2V0KGFyZ3MuY2xhc3NfcHJvbXB0JTJDJTIwbnVtX25ld19pbWFnZXMpJTBBc2FtcGxlX2RhdGFsb2FkZXIlMjAlM0QlMjB0b3JjaC51dGlscy5kYXRhLkRhdGFMb2FkZXIoc2FtcGxlX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEYXJncy5zYW1wbGVfYmF0Y2hfc2l6ZSklMEElMEFzYW1wbGVfZGF0YWxvYWRlciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoc2FtcGxlX2RhdGFsb2FkZXIpJTBBcGlwZWxpbmUudG8oYWNjZWxlcmF0b3IuZGV2aWNlKSUwQSUwQWZvciUyMGV4YW1wbGUlMjBpbiUyMHRxZG0oJTBBJTIwJTIwJTIwJTIwc2FtcGxlX2RhdGFsb2FkZXIlMkMlMjBkZXNjJTNEJTIyR2VuZXJhdGluZyUyMGNsYXNzJTIwaW1hZ2VzJTIyJTJDJTIwZGlzYWJsZSUzRG5vdCUyMGFjY2VsZXJhdG9yLmlzX2xvY2FsX21haW5fcHJvY2VzcyUwQSklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShleGFtcGxlJTVCJTIycHJvbXB0JTIyJTVEKS5pbWFnZXM=",highlighted:`sample_dataset = PromptDataset(args.class_prompt, num_new_images)
sample_dataloader = torch.utils.data.DataLoader(sample_dataset, batch_size=args.sample_batch_size)

sample_dataloader = accelerator.prepare(sample_dataloader)
pipeline.to(accelerator.device)

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(
    sample_dataloader, desc=<span class="hljs-string">&quot;Generating class images&quot;</span>, disable=<span class="hljs-keyword">not</span> accelerator.is_local_main_process
):
    images = pipeline(example[<span class="hljs-string">&quot;prompt&quot;</span>]).images`,wrap:!1}}),ge=new G({props:{code:"JTIzJTIwTG9hZCUyMHRoZSUyMHRva2VuaXplciUwQWlmJTIwYXJncy50b2tlbml6ZXJfbmFtZSUzQSUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGFyZ3MudG9rZW5pemVyX25hbWUlMkMlMjByZXZpc2lvbiUzRGFyZ3MucmV2aXNpb24lMkMlMjB1c2VfZmFzdCUzREZhbHNlKSUwQWVsaWYlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNBJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnRva2VuaXplciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHVzZV9mYXN0JTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjApJTBBJTBBJTIzJTIwJUU1JThBJUEwJUU4JUJEJUJEJUU4JUIwJTgzJUU1JUJBJUE2JUU1JTk5JUE4JUU1JTkyJThDJUU2JUE4JUExJUU1JTlFJThCJTBBbm9pc2Vfc2NoZWR1bGVyJTIwJTNEJTIwRERQTVNjaGVkdWxlci5mcm9tX3ByZXRyYWluZWQoYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEF0ZXh0X2VuY29kZXIlMjAlM0QlMjB0ZXh0X2VuY29kZXJfY2xzLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBKSUwQSUwQWlmJTIwbW9kZWxfaGFzX3ZhZShhcmdzKSUzQSUwQSUyMCUyMCUyMCUyMHZhZSUyMCUzRCUyMEF1dG9lbmNvZGVyS0wuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFyZ3MucHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJ2YWUlMjIlMkMlMjByZXZpc2lvbiUzRGFyZ3MucmV2aXNpb24lMEElMjAlMjAlMjAlMjApJTBBZWxzZSUzQSUwQSUyMCUyMCUyMCUyMHZhZSUyMCUzRCUyME5vbmUlMEElMEF1bmV0JTIwJTNEJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMGFyZ3MucHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBKQ==",highlighted:`<span class="hljs-comment"># Load the tokenizer</span>
<span class="hljs-keyword">if</span> args.tokenizer_name:
    tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name, revision=args.revision, use_fast=<span class="hljs-literal">False</span>)
<span class="hljs-keyword">elif</span> args.pretrained_model_name_or_path:
    tokenizer = AutoTokenizer.from_pretrained(
        args.pretrained_model_name_or_path,
        subfolder=<span class="hljs-string">&quot;tokenizer&quot;</span>,
        revision=args.revision,
        use_fast=<span class="hljs-literal">False</span>,
    )

<span class="hljs-comment"># 加载调度器和模型</span>
noise_scheduler = DDPMScheduler.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
text_encoder = text_encoder_cls.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, revision=args.revision
)

<span class="hljs-keyword">if</span> model_has_vae(args):
    vae = AutoencoderKL.from_pretrained(
        args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, revision=args.revision
    )
<span class="hljs-keyword">else</span>:
    vae = <span class="hljs-literal">None</span>

unet = UNet2DConditionModel.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, revision=args.revision
)`,wrap:!1}}),Ge=new G({props:{code:"dHJhaW5fZGF0YXNldCUyMCUzRCUyMERyZWFtQm9vdGhEYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGluc3RhbmNlX2RhdGFfcm9vdCUzRGFyZ3MuaW5zdGFuY2VfZGF0YV9kaXIlMkMlMEElMjAlMjAlMjAlMjBpbnN0YW5jZV9wcm9tcHQlM0RhcmdzLmluc3RhbmNlX3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMGNsYXNzX2RhdGFfcm9vdCUzRGFyZ3MuY2xhc3NfZGF0YV9kaXIlMjBpZiUyMGFyZ3Mud2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24lMjBlbHNlJTIwTm9uZSUyQyUwQSUyMCUyMCUyMCUyMGNsYXNzX3Byb21wdCUzRGFyZ3MuY2xhc3NfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwY2xhc3NfbnVtJTNEYXJncy5udW1fY2xhc3NfaW1hZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwc2l6ZSUzRGFyZ3MucmVzb2x1dGlvbiUyQyUwQSUyMCUyMCUyMCUyMGNlbnRlcl9jcm9wJTNEYXJncy5jZW50ZXJfY3JvcCUyQyUwQSUyMCUyMCUyMCUyMGVuY29kZXJfaGlkZGVuX3N0YXRlcyUzRHByZV9jb21wdXRlZF9lbmNvZGVyX2hpZGRlbl9zdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjBjbGFzc19wcm9tcHRfZW5jb2Rlcl9oaWRkZW5fc3RhdGVzJTNEcHJlX2NvbXB1dGVkX2NsYXNzX3Byb21wdF9lbmNvZGVyX2hpZGRlbl9zdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXJfbWF4X2xlbmd0aCUzRGFyZ3MudG9rZW5pemVyX21heF9sZW5ndGglMkMlMEEpJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMHRvcmNoLnV0aWxzLmRhdGEuRGF0YUxvYWRlciglMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGFyZ3MudHJhaW5fYmF0Y2hfc2l6ZSUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGxhbWJkYSUyMGV4YW1wbGVzJTNBJTIwY29sbGF0ZV9mbihleGFtcGxlcyUyQyUyMGFyZ3Mud2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24pJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dvcmtlcnMlM0RhcmdzLmRhdGFsb2FkZXJfbnVtX3dvcmtlcnMlMkMlMEEp",highlighted:`train_dataset = DreamBoothDataset(
    instance_data_root=args.instance_data_dir,
    instance_prompt=args.instance_prompt,
    class_data_root=args.class_data_dir <span class="hljs-keyword">if</span> args.with_prior_preservation <span class="hljs-keyword">else</span> <span class="hljs-literal">None</span>,
    class_prompt=args.class_prompt,
    class_num=args.num_class_images,
    tokenizer=tokenizer,
    size=args.resolution,
    center_crop=args.center_crop,
    encoder_hidden_states=pre_computed_encoder_hidden_states,
    class_prompt_encoder_hidden_states=pre_computed_class_prompt_encoder_hidden_states,
    tokenizer_max_length=args.tokenizer_max_length,
)

train_dataloader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size=args.train_batch_size,
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=<span class="hljs-keyword">lambda</span> examples: collate_fn(examples, args.with_prior_preservation),
    num_workers=args.dataloader_num_workers,
)`,wrap:!1}}),Xe=new x({props:{title:"启动脚本",local:"启动脚本",headingTag:"h2"}}),We=new G({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHNuYXBzaG90X2Rvd25sb2FkJTBBJTBBbG9jYWxfZGlyJTIwJTNEJTIwJTIyLiUyRmRvZyUyMiUwQXNuYXBzaG90X2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMCUyMmRpZmZ1c2VycyUyRmRvZy1leGFtcGxlJTIyJTJDJTBBJTIwJTIwJTIwJTIwbG9jYWxfZGlyJTNEbG9jYWxfZGlyJTJDJTBBJTIwJTIwJTIwJTIwcmVwb190eXBlJTNEJTIyZGF0YXNldCUyMiUyQyUwQSUyMCUyMCUyMCUyMGlnbm9yZV9wYXR0ZXJucyUzRCUyMi5naXRhdHRyaWJ1dGVzJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download

local_dir = <span class="hljs-string">&quot;./dog&quot;</span>
snapshot_download(
    <span class="hljs-string">&quot;diffusers/dog-example&quot;</span>,
    local_dir=local_dir,
    repo_type=<span class="hljs-string">&quot;dataset&quot;</span>,
    ignore_patterns=<span class="hljs-string">&quot;.gitattributes&quot;</span>,
)`,wrap:!1}}),Ee=new G({props:{code:"LS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMmElMjBwaG90byUyMG9mJTIwYSUyMHNrcyUyMGRvZyUyMiUwQS0tbnVtX3ZhbGlkYXRpb25faW1hZ2VzJTNENCUwQS0tdmFsaWRhdGlvbl9zdGVwcyUzRDEwMA==",highlighted:`--validation_prompt=<span class="hljs-string">&quot;a photo of a sks dog&quot;</span>
--num_validation_images=4
--validation_steps=100`,wrap:!1}}),Q=new dt({props:{id:"gpu-select",options:["16GB","12GB","8GB"],$$slots:{default:[Qs]},$$scope:{ctx:g}}}),D=new dt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[qs]},$$scope:{ctx:g}}}),Ye=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFRleHRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZtb2RlbCUyRmNoZWNrcG9pbnQtMTAwJTJGdW5ldCUyMiklMEElMEElMjMlMjAlRTUlQTYlODIlRTYlOUUlOUMlRTYlODIlQTglRTQlQkQlQkYlRTclOTQlQTglRTQlQkElODYlMjAlNjAtLWFyZ3MudHJhaW5fdGV4dF9lbmNvZGVyJTYwJTIwJUU4JUJGJTlCJUU4JUExJThDJUU4JUFFJUFEJUU3JUJCJTgzJUVGJUJDJThDJUU4JUFGJUI3JUU3JUExJUFFJUU0JUJGJTlEJUU0JUI5JTlGJUU1JThBJUEwJUU4JUJEJUJEJUU2JTk2JTg3JUU2JTlDJUFDJUU3JUJDJTk2JUU3JUEwJTgxJUU1JTk5JUE4JTBBdGV4dF9lbmNvZGVyJTIwJTNEJTIwQ0xJUFRleHRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIycGF0aCUyRnRvJTJGbW9kZWwlMkZjaGVja3BvaW50LTEwMCUyRmNoZWNrcG9pbnQtMTAwJTJGdGV4dF9lbmNvZGVyJTIyKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHVuZXQlM0R1bmV0JTJDJTIwdGV4dF9lbmNvZGVyJTNEdGV4dF9lbmNvZGVyJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTIyQSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyZG9nLWJ1Y2tldC5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, UNet2DConditionModel
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPTextModel
<span class="hljs-keyword">import</span> torch

unet = UNet2DConditionModel.from_pretrained(<span class="hljs-string">&quot;path/to/model/checkpoint-100/unet&quot;</span>)

<span class="hljs-comment"># 如果您使用了 \`--args.train_text_encoder\` 进行训练，请确保也加载文本编码器</span>
text_encoder = CLIPTextModel.from_pretrained(<span class="hljs-string">&quot;path/to/model/checkpoint-100/checkpoint-100/text_encoder&quot;</span>)

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, unet=unet, text_encoder=text_encoder, dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipeline(<span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`,wrap:!1}}),H=new dt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Ks]},$$scope:{ctx:g}}}),Se=new x({props:{title:"LoRA",local:"lora",headingTag:"h2"}}),ze=new x({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),He=new x({props:{title:"DeepFloyd IF",local:"deepfloyd-if",headingTag:"h2"}}),Oe=new G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJEZWVwRmxveWQlMkZJRi1JLVhMLXYxLjAlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQSUwQXBpcGUubG9hZF9sb3JhX3dlaWdodHMoJTIyJTNDbG9yYSUyMHdlaWdodHMlMjBwYXRoJTNFJTIyKSUwQSUwQSUyMyUyMCVFNiU5QiVCNCVFNiU5NiVCMCVFOCVCMCU4MyVFNSVCQSVBNiVFNSU5OSVBOCVFOSU4NSU4RCVFNyVCRCVBRSVFNCVCOCVCQSVFNSU5QiVCQSVFNSVBRSU5QSVFNiU5NiVCOSVFNSVCNyVBRSVFOCVCMCU4MyVFNSVCQSVBNiUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwcGlwZS5zY2hlZHVsZXIuX19jbGFzc19fLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHZhcmlhbmNlX3R5cGUlM0QlMjJmaXhlZF9zbWFsbCUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)

pipe.load_lora_weights(<span class="hljs-string">&quot;&lt;lora weights path&gt;&quot;</span>)

<span class="hljs-comment"># 更新调度器配置为固定方差调度</span>
pipe.scheduler = pipe.scheduler.__class__.from_config(pipe.scheduler.config, variance_type=<span class="hljs-string">&quot;fixed_small&quot;</span>)`,wrap:!1}}),et=new G({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHNuYXBzaG90X2Rvd25sb2FkJTBBJTBBbG9jYWxfZGlyJTIwJTNEJTIwJTIyLiUyRmRvZ19kb3duc2l6ZWQlMjIlMEFzbmFwc2hvdF9kb3dubG9hZCglMEElMjAlMjAlMjAlMjAlMjJkaWZmdXNlcnMlMkZkb2ctZXhhbXBsZS1kb3duc2l6ZWQlMjIlMkMlMEElMjAlMjAlMjAlMjBsb2NhbF9kaXIlM0Rsb2NhbF9kaXIlMkMlMEElMjAlMjAlMjAlMjByZXBvX3R5cGUlM0QlMjJkYXRhc2V0JTIyJTJDJTBBJTIwJTIwJTIwJTIwaWdub3JlX3BhdHRlcm5zJTNEJTIyLmdpdGF0dHJpYnV0ZXMlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download

local_dir = <span class="hljs-string">&quot;./dog_downsized&quot;</span>
snapshot_download(
    <span class="hljs-string">&quot;diffusers/dog-example-downsized&quot;</span>,
    local_dir=local_dir,
    repo_type=<span class="hljs-string">&quot;dataset&quot;</span>,
    ignore_patterns=<span class="hljs-string">&quot;.gitattributes&quot;</span>,
)`,wrap:!1}}),q=new dt({props:{id:"IF-DreamBooth",options:["Stage 1 LoRA DreamBooth","Stage 2 LoRA DreamBooth","Stage 1 DreamBooth","Stage 2 DreamBooth"],$$slots:{default:[aa]},$$scope:{ctx:g}}}),st=new x({props:{title:"训练技巧",local:"训练技巧",headingTag:"h3"}}),pt=new x({props:{title:"下一步",local:"下一步",headingTag:"h2"}}),rt=new xs({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/dreambooth.md"}}),{c(){a=d("meta"),f=i(),n=d("p"),m=i(),u(p.$$.fragment),M=i(),u(c.$$.fragment),_=i(),r=d("p"),r.innerHTML=$,Z=i(),R=d("p"),R.innerHTML=B,N=i(),I=d("p"),I.innerHTML=v,W=i(),j=d("p"),j.textContent=X,k=i(),u(C.$$.fragment),V=i(),P=d("p"),P.textContent=xl,Ut=i(),u(S.$$.fragment),Jt=i(),A=d("blockquote"),A.innerHTML=kl,ut=i(),O=d("p"),O.textContent=Yl,yt=i(),u(K.$$.fragment),Tt=i(),ee=d("p"),ee.textContent=Sl,bt=i(),u(te.$$.fragment),ht=i(),le=d("p"),le.textContent=Al,wt=i(),u(se.$$.fragment),_t=i(),ae=d("p"),ae.innerHTML=Ll,$t=i(),L=d("blockquote"),L.innerHTML=zl,jt=i(),u(ne.$$.fragment),Zt=i(),z=d("blockquote"),z.innerHTML=Ql,Ct=i(),pe=d("p"),pe.innerHTML=Dl,gt=i(),ie=d("p"),ie.textContent=Hl,Rt=i(),u(oe.$$.fragment),Gt=i(),re=d("p"),re.textContent=ql,It=i(),Me=d("ul"),Me.innerHTML=Pl,Vt=i(),u(me.$$.fragment),Xt=i(),ce=d("p"),ce.innerHTML=Ol,Bt=i(),fe=d("p"),fe.innerHTML=Kl,Nt=i(),u(de.$$.fragment),Wt=i(),u(Ue.$$.fragment),vt=i(),Je=d("p"),Je.textContent=es,Ft=i(),ue=d("ul"),ue.innerHTML=ts,Et=i(),u(ye.$$.fragment),xt=i(),u(Te.$$.fragment),kt=i(),be=d("p"),be.textContent=ls,Yt=i(),u(he.$$.fragment),St=i(),u(we.$$.fragment),At=i(),_e=d("p"),_e.textContent=ss,Lt=i(),$e=d("ul"),$e.innerHTML=as,zt=i(),je=d("p"),je.innerHTML=ns,Qt=i(),u(Ze.$$.fragment),Dt=i(),Ce=d("p"),Ce.innerHTML=ps,Ht=i(),u(ge.$$.fragment),qt=i(),Re=d("p"),Re.innerHTML=is,Pt=i(),u(Ge.$$.fragment),Ot=i(),Ie=d("p"),Ie.innerHTML=os,Kt=i(),Ve=d("p"),Ve.innerHTML=rs,el=i(),u(Xe.$$.fragment),tl=i(),Be=d("p"),Be.textContent=Ms,ll=i(),Ne=d("p"),Ne.innerHTML=ms,sl=i(),u(We.$$.fragment),al=i(),ve=d("p"),ve.innerHTML=cs,nl=i(),Fe=d("p"),Fe.textContent=fs,pl=i(),u(Ee.$$.fragment),il=i(),xe=d("p"),xe.textContent=ds,ol=i(),u(Q.$$.fragment),rl=i(),u(D.$$.fragment),Ml=i(),ke=d("p"),ke.textContent=Us,ml=i(),Y=d("blockquote"),mt=d("p"),mt.textContent=Js,vl=i(),u(Ye.$$.fragment),cl=i(),u(H.$$.fragment),fl=i(),u(Se.$$.fragment),dl=i(),Ae=d("p"),Ae.innerHTML=us,Ul=i(),Le=d("p"),Le.innerHTML=ys,Jl=i(),u(ze.$$.fragment),ul=i(),Qe=d("p"),Qe.innerHTML=Ts,yl=i(),De=d("p"),De.innerHTML=bs,Tl=i(),u(He.$$.fragment),bl=i(),qe=d("p"),qe.innerHTML=hs,hl=i(),Pe=d("p"),Pe.textContent=ws,wl=i(),u(Oe.$$.fragment),_l=i(),Ke=d("p"),Ke.textContent=_s,$l=i(),u(et.$$.fragment),jl=i(),tt=d("p"),tt.textContent=$s,Zl=i(),lt=d("ul"),lt.innerHTML=js,Cl=i(),u(q.$$.fragment),gl=i(),u(st.$$.fragment),Rl=i(),at=d("p"),at.textContent=Zs,Gl=i(),nt=d("ul"),nt.innerHTML=Cs,Il=i(),u(pt.$$.fragment),Vl=i(),it=d("p"),it.textContent=gs,Xl=i(),ot=d("ul"),ot.innerHTML=Rs,Bl=i(),u(rt.$$.fragment),Nl=i(),ft=d("p"),this.h()},l(e){const l=Fs("svelte-u9bgzb",document.head);a=U(l,"META",{name:!0,content:!0}),l.forEach(t),f=o(e),n=U(e,"P",{}),Fl(n).forEach(t),m=o(e),y(p.$$.fragment,e),M=o(e),y(c.$$.fragment,e),_=o(e),r=U(e,"P",{"data-svelte-h":!0}),J(r)!=="svelte-1e9t3g6"&&(r.innerHTML=$),Z=o(e),R=U(e,"P",{"data-svelte-h":!0}),J(R)!=="svelte-1ngr86v"&&(R.innerHTML=B),N=o(e),I=U(e,"P",{"data-svelte-h":!0}),J(I)!=="svelte-rplwfa"&&(I.innerHTML=v),W=o(e),j=U(e,"P",{"data-svelte-h":!0}),J(j)!=="svelte-sgtnc7"&&(j.textContent=X),k=o(e),y(C.$$.fragment,e),V=o(e),P=U(e,"P",{"data-svelte-h":!0}),J(P)!=="svelte-p2mznn"&&(P.textContent=xl),Ut=o(e),y(S.$$.fragment,e),Jt=o(e),A=U(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),J(A)!=="svelte-1smgt4p"&&(A.innerHTML=kl),ut=o(e),O=U(e,"P",{"data-svelte-h":!0}),J(O)!=="svelte-2mxnyi"&&(O.textContent=Yl),yt=o(e),y(K.$$.fragment,e),Tt=o(e),ee=U(e,"P",{"data-svelte-h":!0}),J(ee)!=="svelte-sl2ztp"&&(ee.textContent=Sl),bt=o(e),y(te.$$.fragment,e),ht=o(e),le=U(e,"P",{"data-svelte-h":!0}),J(le)!=="svelte-1dtw1zl"&&(le.textContent=Al),wt=o(e),y(se.$$.fragment,e),_t=o(e),ae=U(e,"P",{"data-svelte-h":!0}),J(ae)!=="svelte-1m05pet"&&(ae.innerHTML=Ll),$t=o(e),L=U(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),J(L)!=="svelte-18upzl9"&&(L.innerHTML=zl),jt=o(e),y(ne.$$.fragment,e),Zt=o(e),z=U(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),J(z)!=="svelte-xncjvf"&&(z.innerHTML=Ql),Ct=o(e),pe=U(e,"P",{"data-svelte-h":!0}),J(pe)!=="svelte-jyetfn"&&(pe.innerHTML=Dl),gt=o(e),ie=U(e,"P",{"data-svelte-h":!0}),J(ie)!=="svelte-uzrh94"&&(ie.textContent=Hl),Rt=o(e),y(oe.$$.fragment,e),Gt=o(e),re=U(e,"P",{"data-svelte-h":!0}),J(re)!=="svelte-ks8wy6"&&(re.textContent=ql),It=o(e),Me=U(e,"UL",{"data-svelte-h":!0}),J(Me)!=="svelte-55at4u"&&(Me.innerHTML=Pl),Vt=o(e),y(me.$$.fragment,e),Xt=o(e),ce=U(e,"P",{"data-svelte-h":!0}),J(ce)!=="svelte-mcww0e"&&(ce.innerHTML=Ol),Bt=o(e),fe=U(e,"P",{"data-svelte-h":!0}),J(fe)!=="svelte-1dvfh3c"&&(fe.innerHTML=Kl),Nt=o(e),y(de.$$.fragment,e),Wt=o(e),y(Ue.$$.fragment,e),vt=o(e),Je=U(e,"P",{"data-svelte-h":!0}),J(Je)!=="svelte-18s4z57"&&(Je.textContent=es),Ft=o(e),ue=U(e,"UL",{"data-svelte-h":!0}),J(ue)!=="svelte-1audnhp"&&(ue.innerHTML=ts),Et=o(e),y(ye.$$.fragment,e),xt=o(e),y(Te.$$.fragment,e),kt=o(e),be=U(e,"P",{"data-svelte-h":!0}),J(be)!=="svelte-1qwsx6b"&&(be.textContent=ls),Yt=o(e),y(he.$$.fragment,e),St=o(e),y(we.$$.fragment,e),At=o(e),_e=U(e,"P",{"data-svelte-h":!0}),J(_e)!=="svelte-85252j"&&(_e.textContent=ss),Lt=o(e),$e=U(e,"UL",{"data-svelte-h":!0}),J($e)!=="svelte-16ksb00"&&($e.innerHTML=as),zt=o(e),je=U(e,"P",{"data-svelte-h":!0}),J(je)!=="svelte-16cegbe"&&(je.innerHTML=ns),Qt=o(e),y(Ze.$$.fragment,e),Dt=o(e),Ce=U(e,"P",{"data-svelte-h":!0}),J(Ce)!=="svelte-1a2q73b"&&(Ce.innerHTML=ps),Ht=o(e),y(ge.$$.fragment,e),qt=o(e),Re=U(e,"P",{"data-svelte-h":!0}),J(Re)!=="svelte-1jv11vt"&&(Re.innerHTML=is),Pt=o(e),y(Ge.$$.fragment,e),Ot=o(e),Ie=U(e,"P",{"data-svelte-h":!0}),J(Ie)!=="svelte-1u5xr53"&&(Ie.innerHTML=os),Kt=o(e),Ve=U(e,"P",{"data-svelte-h":!0}),J(Ve)!=="svelte-1kc06wj"&&(Ve.innerHTML=rs),el=o(e),y(Xe.$$.fragment,e),tl=o(e),Be=U(e,"P",{"data-svelte-h":!0}),J(Be)!=="svelte-5ajv6x"&&(Be.textContent=Ms),ll=o(e),Ne=U(e,"P",{"data-svelte-h":!0}),J(Ne)!=="svelte-70dorz"&&(Ne.innerHTML=ms),sl=o(e),y(We.$$.fragment,e),al=o(e),ve=U(e,"P",{"data-svelte-h":!0}),J(ve)!=="svelte-cqu8zz"&&(ve.innerHTML=cs),nl=o(e),Fe=U(e,"P",{"data-svelte-h":!0}),J(Fe)!=="svelte-1nc6qo"&&(Fe.textContent=fs),pl=o(e),y(Ee.$$.fragment,e),il=o(e),xe=U(e,"P",{"data-svelte-h":!0}),J(xe)!=="svelte-1c286rs"&&(xe.textContent=ds),ol=o(e),y(Q.$$.fragment,e),rl=o(e),y(D.$$.fragment,e),Ml=o(e),ke=U(e,"P",{"data-svelte-h":!0}),J(ke)!=="svelte-2s2vlp"&&(ke.textContent=Us),ml=o(e),Y=U(e,"BLOCKQUOTE",{class:!0});var Mt=Fl(Y);mt=U(Mt,"P",{"data-svelte-h":!0}),J(mt)!=="svelte-hc92np"&&(mt.textContent=Js),vl=o(Mt),y(Ye.$$.fragment,Mt),Mt.forEach(t),cl=o(e),y(H.$$.fragment,e),fl=o(e),y(Se.$$.fragment,e),dl=o(e),Ae=U(e,"P",{"data-svelte-h":!0}),J(Ae)!=="svelte-99pbmn"&&(Ae.innerHTML=us),Ul=o(e),Le=U(e,"P",{"data-svelte-h":!0}),J(Le)!=="svelte-147iht9"&&(Le.innerHTML=ys),Jl=o(e),y(ze.$$.fragment,e),ul=o(e),Qe=U(e,"P",{"data-svelte-h":!0}),J(Qe)!=="svelte-kvbsu5"&&(Qe.innerHTML=Ts),yl=o(e),De=U(e,"P",{"data-svelte-h":!0}),J(De)!=="svelte-8i15cc"&&(De.innerHTML=bs),Tl=o(e),y(He.$$.fragment,e),bl=o(e),qe=U(e,"P",{"data-svelte-h":!0}),J(qe)!=="svelte-getdal"&&(qe.innerHTML=hs),hl=o(e),Pe=U(e,"P",{"data-svelte-h":!0}),J(Pe)!=="svelte-lp6rav"&&(Pe.textContent=ws),wl=o(e),y(Oe.$$.fragment,e),_l=o(e),Ke=U(e,"P",{"data-svelte-h":!0}),J(Ke)!=="svelte-1brviy5"&&(Ke.textContent=_s),$l=o(e),y(et.$$.fragment,e),jl=o(e),tt=U(e,"P",{"data-svelte-h":!0}),J(tt)!=="svelte-ysfma6"&&(tt.textContent=$s),Zl=o(e),lt=U(e,"UL",{"data-svelte-h":!0}),J(lt)!=="svelte-ijmwiq"&&(lt.innerHTML=js),Cl=o(e),y(q.$$.fragment,e),gl=o(e),y(st.$$.fragment,e),Rl=o(e),at=U(e,"P",{"data-svelte-h":!0}),J(at)!=="svelte-owgexi"&&(at.textContent=Zs),Gl=o(e),nt=U(e,"UL",{"data-svelte-h":!0}),J(nt)!=="svelte-dwv5bq"&&(nt.innerHTML=Cs),Il=o(e),y(pt.$$.fragment,e),Vl=o(e),it=U(e,"P",{"data-svelte-h":!0}),J(it)!=="svelte-1ymw29a"&&(it.textContent=gs),Xl=o(e),ot=U(e,"UL",{"data-svelte-h":!0}),J(ot)!=="svelte-1ehx6zh"&&(ot.innerHTML=Rs),Bl=o(e),y(rt.$$.fragment,e),Nl=o(e),ft=U(e,"P",{}),Fl(ft).forEach(t),this.h()},h(){ct(a,"name","hf:doc:metadata"),ct(a,"content",pa),ct(A,"class","tip"),ct(L,"class","tip"),ct(z,"class","warning"),ct(Y,"class","tip")},m(e,l){El(document.head,a),s(e,f,l),s(e,n,l),s(e,m,l),T(p,e,l),s(e,M,l),T(c,e,l),s(e,_,l),s(e,r,l),s(e,Z,l),s(e,R,l),s(e,N,l),s(e,I,l),s(e,W,l),s(e,j,l),s(e,k,l),T(C,e,l),s(e,V,l),s(e,P,l),s(e,Ut,l),T(S,e,l),s(e,Jt,l),s(e,A,l),s(e,ut,l),s(e,O,l),s(e,yt,l),T(K,e,l),s(e,Tt,l),s(e,ee,l),s(e,bt,l),T(te,e,l),s(e,ht,l),s(e,le,l),s(e,wt,l),T(se,e,l),s(e,_t,l),s(e,ae,l),s(e,$t,l),s(e,L,l),s(e,jt,l),T(ne,e,l),s(e,Zt,l),s(e,z,l),s(e,Ct,l),s(e,pe,l),s(e,gt,l),s(e,ie,l),s(e,Rt,l),T(oe,e,l),s(e,Gt,l),s(e,re,l),s(e,It,l),s(e,Me,l),s(e,Vt,l),T(me,e,l),s(e,Xt,l),s(e,ce,l),s(e,Bt,l),s(e,fe,l),s(e,Nt,l),T(de,e,l),s(e,Wt,l),T(Ue,e,l),s(e,vt,l),s(e,Je,l),s(e,Ft,l),s(e,ue,l),s(e,Et,l),T(ye,e,l),s(e,xt,l),T(Te,e,l),s(e,kt,l),s(e,be,l),s(e,Yt,l),T(he,e,l),s(e,St,l),T(we,e,l),s(e,At,l),s(e,_e,l),s(e,Lt,l),s(e,$e,l),s(e,zt,l),s(e,je,l),s(e,Qt,l),T(Ze,e,l),s(e,Dt,l),s(e,Ce,l),s(e,Ht,l),T(ge,e,l),s(e,qt,l),s(e,Re,l),s(e,Pt,l),T(Ge,e,l),s(e,Ot,l),s(e,Ie,l),s(e,Kt,l),s(e,Ve,l),s(e,el,l),T(Xe,e,l),s(e,tl,l),s(e,Be,l),s(e,ll,l),s(e,Ne,l),s(e,sl,l),T(We,e,l),s(e,al,l),s(e,ve,l),s(e,nl,l),s(e,Fe,l),s(e,pl,l),T(Ee,e,l),s(e,il,l),s(e,xe,l),s(e,ol,l),T(Q,e,l),s(e,rl,l),T(D,e,l),s(e,Ml,l),s(e,ke,l),s(e,ml,l),s(e,Y,l),El(Y,mt),El(Y,vl),T(Ye,Y,null),s(e,cl,l),T(H,e,l),s(e,fl,l),T(Se,e,l),s(e,dl,l),s(e,Ae,l),s(e,Ul,l),s(e,Le,l),s(e,Jl,l),T(ze,e,l),s(e,ul,l),s(e,Qe,l),s(e,yl,l),s(e,De,l),s(e,Tl,l),T(He,e,l),s(e,bl,l),s(e,qe,l),s(e,hl,l),s(e,Pe,l),s(e,wl,l),T(Oe,e,l),s(e,_l,l),s(e,Ke,l),s(e,$l,l),T(et,e,l),s(e,jl,l),s(e,tt,l),s(e,Zl,l),s(e,lt,l),s(e,Cl,l),T(q,e,l),s(e,gl,l),T(st,e,l),s(e,Rl,l),s(e,at,l),s(e,Gl,l),s(e,nt,l),s(e,Il,l),T(pt,e,l),s(e,Vl,l),s(e,it,l),s(e,Xl,l),s(e,ot,l),s(e,Bl,l),T(rt,e,l),s(e,Nl,l),s(e,ft,l),Wl=!0},p(e,[l]){const Mt={};l&2&&(Mt.$$scope={dirty:l,ctx:e}),S.$set(Mt);const Gs={};l&2&&(Gs.$$scope={dirty:l,ctx:e}),Q.$set(Gs);const Is={};l&2&&(Is.$$scope={dirty:l,ctx:e}),D.$set(Is);const Vs={};l&2&&(Vs.$$scope={dirty:l,ctx:e}),H.$set(Vs);const Xs={};l&2&&(Xs.$$scope={dirty:l,ctx:e}),q.$set(Xs)},i(e){Wl||(b(p.$$.fragment,e),b(c.$$.fragment,e),b(C.$$.fragment,e),b(S.$$.fragment,e),b(K.$$.fragment,e),b(te.$$.fragment,e),b(se.$$.fragment,e),b(ne.$$.fragment,e),b(oe.$$.fragment,e),b(me.$$.fragment,e),b(de.$$.fragment,e),b(Ue.$$.fragment,e),b(ye.$$.fragment,e),b(Te.$$.fragment,e),b(he.$$.fragment,e),b(we.$$.fragment,e),b(Ze.$$.fragment,e),b(ge.$$.fragment,e),b(Ge.$$.fragment,e),b(Xe.$$.fragment,e),b(We.$$.fragment,e),b(Ee.$$.fragment,e),b(Q.$$.fragment,e),b(D.$$.fragment,e),b(Ye.$$.fragment,e),b(H.$$.fragment,e),b(Se.$$.fragment,e),b(ze.$$.fragment,e),b(He.$$.fragment,e),b(Oe.$$.fragment,e),b(et.$$.fragment,e),b(q.$$.fragment,e),b(st.$$.fragment,e),b(pt.$$.fragment,e),b(rt.$$.fragment,e),Wl=!0)},o(e){h(p.$$.fragment,e),h(c.$$.fragment,e),h(C.$$.fragment,e),h(S.$$.fragment,e),h(K.$$.fragment,e),h(te.$$.fragment,e),h(se.$$.fragment,e),h(ne.$$.fragment,e),h(oe.$$.fragment,e),h(me.$$.fragment,e),h(de.$$.fragment,e),h(Ue.$$.fragment,e),h(ye.$$.fragment,e),h(Te.$$.fragment,e),h(he.$$.fragment,e),h(we.$$.fragment,e),h(Ze.$$.fragment,e),h(ge.$$.fragment,e),h(Ge.$$.fragment,e),h(Xe.$$.fragment,e),h(We.$$.fragment,e),h(Ee.$$.fragment,e),h(Q.$$.fragment,e),h(D.$$.fragment,e),h(Ye.$$.fragment,e),h(H.$$.fragment,e),h(Se.$$.fragment,e),h(ze.$$.fragment,e),h(He.$$.fragment,e),h(Oe.$$.fragment,e),h(et.$$.fragment,e),h(q.$$.fragment,e),h(st.$$.fragment,e),h(pt.$$.fragment,e),h(rt.$$.fragment,e),Wl=!1},d(e){e&&(t(f),t(n),t(m),t(M),t(_),t(r),t(Z),t(R),t(N),t(I),t(W),t(j),t(k),t(V),t(P),t(Ut),t(Jt),t(A),t(ut),t(O),t(yt),t(Tt),t(ee),t(bt),t(ht),t(le),t(wt),t(_t),t(ae),t($t),t(L),t(jt),t(Zt),t(z),t(Ct),t(pe),t(gt),t(ie),t(Rt),t(Gt),t(re),t(It),t(Me),t(Vt),t(Xt),t(ce),t(Bt),t(fe),t(Nt),t(Wt),t(vt),t(Je),t(Ft),t(ue),t(Et),t(xt),t(kt),t(be),t(Yt),t(St),t(At),t(_e),t(Lt),t($e),t(zt),t(je),t(Qt),t(Dt),t(Ce),t(Ht),t(qt),t(Re),t(Pt),t(Ot),t(Ie),t(Kt),t(Ve),t(el),t(tl),t(Be),t(ll),t(Ne),t(sl),t(al),t(ve),t(nl),t(Fe),t(pl),t(il),t(xe),t(ol),t(rl),t(Ml),t(ke),t(ml),t(Y),t(cl),t(fl),t(dl),t(Ae),t(Ul),t(Le),t(Jl),t(ul),t(Qe),t(yl),t(De),t(Tl),t(bl),t(qe),t(hl),t(Pe),t(wl),t(_l),t(Ke),t($l),t(jl),t(tt),t(Zl),t(lt),t(Cl),t(gl),t(Rl),t(at),t(Gl),t(nt),t(Il),t(Vl),t(it),t(Xl),t(ot),t(Bl),t(Nl),t(ft)),t(a),w(p,e),w(c,e),w(C,e),w(S,e),w(K,e),w(te,e),w(se,e),w(ne,e),w(oe,e),w(me,e),w(de,e),w(Ue,e),w(ye,e),w(Te,e),w(he,e),w(we,e),w(Ze,e),w(ge,e),w(Ge,e),w(Xe,e),w(We,e),w(Ee,e),w(Q,e),w(D,e),w(Ye),w(H,e),w(Se,e),w(ze,e),w(He,e),w(Oe,e),w(et,e),w(q,e),w(st,e),w(pt,e),w(rt,e)}}}const pa='{"title":"DreamBooth","local":"dreambooth","sections":[{"title":"脚本参数","local":"脚本参数","sections":[{"title":"Min-SNR 加权","local":"min-snr-加权","sections":[],"depth":3},{"title":"先验保持损失","local":"先验保持损失","sections":[],"depth":3},{"title":"训练文本编码器","local":"训练文本编码器","sections":[],"depth":3}],"depth":2},{"title":"训练脚本","local":"训练脚本","sections":[],"depth":2},{"title":"启动脚本","local":"启动脚本","sections":[],"depth":2},{"title":"LoRA","local":"lora","sections":[],"depth":2},{"title":"Stable Diffusion XL","local":"stable-diffusion-xl","sections":[],"depth":2},{"title":"DeepFloyd IF","local":"deepfloyd-if","sections":[{"title":"训练技巧","local":"训练技巧","sections":[],"depth":3}],"depth":2},{"title":"下一步","local":"下一步","sections":[],"depth":2}],"depth":1}';function ia(g){return Ns(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fa extends Ws{constructor(a){super(),vs(this,a,ia,na,Bs,{})}}export{fa as component};
