import{S as Lo,i as Qo,s as Do,e as r,k as d,w as b,t as l,M as Po,c as s,d as a,m as w,a as n,x as T,h as o,b as c,G as t,g as h,y as J,q as U,o as v,B as $,v as Ho,L as Da}from"../../chunks/vendor-hf-doc-builder.js";import{T as Vo}from"../../chunks/Tip-hf-doc-builder.js";import{I as et}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as ve}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Yo,M as Pa}from"../../chunks/Markdown-hf-doc-builder.js";function zo(X){let p,_;return{c(){p=r("p"),_=l("The text-to-image fine-tuning script is experimental. It\u2019s easy to overfit and run into issues like catastrophic forgetting. We recommend you explore different hyperparameters to get the best results on your dataset.")},l(i){p=s(i,"P",{});var g=n(p);_=o(g,"The text-to-image fine-tuning script is experimental. It\u2019s easy to overfit and run into issues like catastrophic forgetting. We recommend you explore different hyperparameters to get the best results on your dataset."),g.forEach(a)},m(i,g){h(i,p,g),t(p,_)},d(i){i&&a(p)}}}function qo(X){let p,_,i,g,W,Z,ue,ge,ye,R,D,N,V,Me,F,re,se,be,O,ne,Te,j,me,C,$e,ie,P,B,Ee,E,Re,pe,Je,I,K,ee,Ie,te,A,ae,de,x,he,le,H,z,k,S,we,u,y,Ue,Y,oe,je,Ce,_e,fe,Ae,L,Ne,q,xe,G,Xe;return ne=new ve({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBkYXRhc2V0X25hbWUlM0QlMjJsYW1iZGFsYWJzJTJGcG9rZW1vbi1ibGlwLWNhcHRpb25zJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCUyMHRyYWluX3RleHRfdG9faW1hZ2UucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTI0ZGF0YXNldF9uYW1lJTIwJTVDJTBBJTIwJTIwLS11c2VfZW1hJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwLS1jZW50ZXJfY3JvcCUyMC0tcmFuZG9tX2ZsaXAlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0JTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9jaGVja3BvaW50aW5nJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QxNTAwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTA1JTIwJTVDJTBBJTIwJTIwLS1tYXhfZ3JhZF9ub3JtJTNEMSUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjJzZC1wb2tlbW9uLW1vZGVsJTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> dataset_name=<span class="hljs-string">&quot;lambdalabs/pokemon-blip-captions&quot;</span>

accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>  train_text_to_image.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$dataset_name</span> \\
  --use_ema \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --gradient_checkpointing \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-string">&quot;sd-pokemon-model&quot;</span> \\
  --push_to_hub`}}),he=new ve({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBUUkFJTl9ESVIlM0QlMjJwYXRoX3RvX3lvdXJfZGF0YXNldCUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJwYXRoX3RvX3NhdmVfbW9kZWwlMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fdGV4dF90b19pbWFnZS5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9kYXRhX2RpciUzRCUyNFRSQUlOX0RJUiUyMCU1QyUwQSUyMCUyMC0tdXNlX2VtYSUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMC0tY2VudGVyX2Nyb3AlMjAtLXJhbmRvbV9mbGlwJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfY2hlY2twb2ludGluZyUyMCU1QyUwQSUyMCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMTUwMDAlMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS0wNSUyMCU1QyUwQSUyMCUyMC0tbWF4X2dyYWRfbm9ybSUzRDElMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvbnN0YW50JTIyJTIwJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0JTdCT1VUUFVUX0RJUiU3RCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> TRAIN_DIR=<span class="hljs-string">&quot;path_to_your_dataset&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_save_model&quot;</span>

accelerate launch train_text_to_image.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --train_data_dir=<span class="hljs-variable">$TRAIN_DIR</span> \\
  --use_ema \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --gradient_checkpointing \\
  --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> 
  --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-variable">\${OUTPUT_DIR}</span> \\
  --push_to_hub`}}),S=new et({}),G=new ve({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBkYXRhc2V0X25hbWUlM0QlMjJsYW1iZGFsYWJzJTJGcG9rZW1vbi1ibGlwLWNhcHRpb25zJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMC0tbXVsdGlfZ3B1JTIwJTIwdHJhaW5fdGV4dF90b19pbWFnZS5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS1kYXRhc2V0X25hbWUlM0QlMjRkYXRhc2V0X25hbWUlMjAlNUMlMEElMjAlMjAtLXVzZV9lbWElMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAtLWNlbnRlcl9jcm9wJTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDQlMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTIwJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMWUtMDUlMjAlNUMlMEElMjAlMjAtLW1heF9ncmFkX25vcm0lM0QxJTIwJTVDJTBBJTIwJTIwLS1scl9zY2hlZHVsZXIlM0QlMjJjb25zdGFudCUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyMnNkLXBva2Vtb24tbW9kZWwlMjIlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> dataset_name=<span class="hljs-string">&quot;lambdalabs/pokemon-blip-captions&quot;</span>

accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> --multi_gpu  train_text_to_image.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$dataset_name</span> \\
  --use_ema \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --gradient_checkpointing \\
  --max_train_steps=15000 \\ 
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-string">&quot;sd-pokemon-model&quot;</span> \\
  --push_to_hub`}}),{c(){p=r("p"),_=l("Launch the "),i=r("a"),g=l("PyTorch training script"),W=l(" for a fine-tuning run on the "),Z=r("a"),ue=l("Pok\xE9mon BLIP captions"),ge=l(" dataset like this."),ye=d(),R=r("p"),D=l("Specify the "),N=r("code"),V=l("MODEL_NAME"),Me=l(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),F=r("a"),re=r("code"),se=l("pretrained_model_name_or_path"),be=l(" argument."),O=d(),b(ne.$$.fragment),Te=d(),j=r("p"),me=l("To finetune on your own dataset, prepare the dataset according to the format required by \u{1F917} "),C=r("a"),$e=l("Datasets"),ie=l(". You can "),P=r("a"),B=l("upload your dataset to the Hub"),Ee=l(", or you can "),E=r("a"),Re=l("prepare a local folder with your files"),pe=l("."),Je=d(),I=r("p"),K=l("Modify the script if you want to use custom loading logic. We left pointers in the code in the appropriate places to help you. \u{1F917} The example script below shows how to finetune on a local dataset in "),ee=r("code"),Ie=l("TRAIN_DIR"),te=l(" and where to save the model to in "),A=r("code"),ae=l("OUTPUT_DIR"),de=l(":"),x=d(),b(he.$$.fragment),le=d(),H=r("h4"),z=r("a"),k=r("span"),b(S.$$.fragment),we=d(),u=r("span"),y=l("Training with multiple GPUs"),Ue=d(),Y=r("p"),oe=r("code"),je=l("accelerate"),Ce=l(" allows for seamless multi-GPU training. Follow the instructions "),_e=r("a"),fe=l("here"),Ae=l(`
for running distributed training with `),L=r("code"),Ne=l("accelerate"),q=l(". Here is an example command:"),xe=d(),b(G.$$.fragment),this.h()},l(m){p=s(m,"P",{});var M=n(p);_=o(M,"Launch the "),i=s(M,"A",{href:!0,rel:!0});var kt=n(i);g=o(kt,"PyTorch training script"),kt.forEach(a),W=o(M," for a fine-tuning run on the "),Z=s(M,"A",{href:!0,rel:!0});var Rt=n(Z);ue=o(Rt,"Pok\xE9mon BLIP captions"),Rt.forEach(a),ge=o(M," dataset like this."),M.forEach(a),ye=w(m),R=s(m,"P",{});var Ze=n(R);D=o(Ze,"Specify the "),N=s(Ze,"CODE",{});var De=n(N);V=o(De,"MODEL_NAME"),De.forEach(a),Me=o(Ze," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),F=s(Ze,"A",{href:!0,rel:!0});var It=n(F);re=s(It,"CODE",{});var dt=n(re);se=o(dt,"pretrained_model_name_or_path"),dt.forEach(a),It.forEach(a),be=o(Ze," argument."),Ze.forEach(a),O=w(m),T(ne.$$.fragment,m),Te=w(m),j=s(m,"P",{});var Q=n(j);me=o(Q,"To finetune on your own dataset, prepare the dataset according to the format required by \u{1F917} "),C=s(Q,"A",{href:!0,rel:!0});var Be=n(C);$e=o(Be,"Datasets"),Be.forEach(a),ie=o(Q,". You can "),P=s(Q,"A",{href:!0,rel:!0});var tt=n(P);B=o(tt,"upload your dataset to the Hub"),tt.forEach(a),Ee=o(Q,", or you can "),E=s(Q,"A",{href:!0,rel:!0});var Se=n(E);Re=o(Se,"prepare a local folder with your files"),Se.forEach(a),pe=o(Q,"."),Q.forEach(a),Je=w(m),I=s(m,"P",{});var Ge=n(I);K=o(Ge,"Modify the script if you want to use custom loading logic. We left pointers in the code in the appropriate places to help you. \u{1F917} The example script below shows how to finetune on a local dataset in "),ee=s(Ge,"CODE",{});var at=n(ee);Ie=o(at,"TRAIN_DIR"),at.forEach(a),te=o(Ge," and where to save the model to in "),A=s(Ge,"CODE",{});var Nt=n(A);ae=o(Nt,"OUTPUT_DIR"),Nt.forEach(a),de=o(Ge,":"),Ge.forEach(a),x=w(m),T(he.$$.fragment,m),le=w(m),H=s(m,"H4",{class:!0});var Pe=n(H);z=s(Pe,"A",{id:!0,class:!0,href:!0});var He=n(z);k=s(He,"SPAN",{});var xt=n(k);T(S.$$.fragment,xt),xt.forEach(a),He.forEach(a),we=w(Pe),u=s(Pe,"SPAN",{});var wt=n(u);y=o(wt,"Training with multiple GPUs"),wt.forEach(a),Pe.forEach(a),Ue=w(m),Y=s(m,"P",{});var ce=n(Y);oe=s(ce,"CODE",{});var _t=n(oe);je=o(_t,"accelerate"),_t.forEach(a),Ce=o(ce," allows for seamless multi-GPU training. Follow the instructions "),_e=s(ce,"A",{href:!0,rel:!0});var We=n(_e);fe=o(We,"here"),We.forEach(a),Ae=o(ce,`
for running distributed training with `),L=s(ce,"CODE",{});var Fe=n(L);Ne=o(Fe,"accelerate"),Fe.forEach(a),q=o(ce,". Here is an example command:"),ce.forEach(a),xe=w(m),T(G.$$.fragment,m),this.h()},h(){c(i,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py"),c(i,"rel","nofollow"),c(Z,"href","https://huggingface.co/datasets/lambdalabs/pokemon-blip-captions"),c(Z,"rel","nofollow"),c(F,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),c(F,"rel","nofollow"),c(C,"href","https://huggingface.co/docs/datasets/index"),c(C,"rel","nofollow"),c(P,"href","https://huggingface.co/docs/datasets/image_dataset#upload-dataset-to-the-hub"),c(P,"rel","nofollow"),c(E,"href","https://huggingface.co/docs/datasets/image_dataset#imagefolder"),c(E,"rel","nofollow"),c(z,"id","training-with-multiple-gpus"),c(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(z,"href","#training-with-multiple-gpus"),c(H,"class","relative group"),c(_e,"href","https://huggingface.co/docs/accelerate/basic_tutorials/launch"),c(_e,"rel","nofollow")},m(m,M){h(m,p,M),t(p,_),t(p,i),t(i,g),t(p,W),t(p,Z),t(Z,ue),t(p,ge),h(m,ye,M),h(m,R,M),t(R,D),t(R,N),t(N,V),t(R,Me),t(R,F),t(F,re),t(re,se),t(R,be),h(m,O,M),J(ne,m,M),h(m,Te,M),h(m,j,M),t(j,me),t(j,C),t(C,$e),t(j,ie),t(j,P),t(P,B),t(j,Ee),t(j,E),t(E,Re),t(j,pe),h(m,Je,M),h(m,I,M),t(I,K),t(I,ee),t(ee,Ie),t(I,te),t(I,A),t(A,ae),t(I,de),h(m,x,M),J(he,m,M),h(m,le,M),h(m,H,M),t(H,z),t(z,k),J(S,k,null),t(H,we),t(H,u),t(u,y),h(m,Ue,M),h(m,Y,M),t(Y,oe),t(oe,je),t(Y,Ce),t(Y,_e),t(_e,fe),t(Y,Ae),t(Y,L),t(L,Ne),t(Y,q),h(m,xe,M),J(G,m,M),Xe=!0},p:Da,i(m){Xe||(U(ne.$$.fragment,m),U(he.$$.fragment,m),U(S.$$.fragment,m),U(G.$$.fragment,m),Xe=!0)},o(m){v(ne.$$.fragment,m),v(he.$$.fragment,m),v(S.$$.fragment,m),v(G.$$.fragment,m),Xe=!1},d(m){m&&a(p),m&&a(ye),m&&a(R),m&&a(O),$(ne,m),m&&a(Te),m&&a(j),m&&a(Je),m&&a(I),m&&a(x),$(he,m),m&&a(le),m&&a(H),$(S),m&&a(Ue),m&&a(Y),m&&a(xe),$(G,m)}}}function Oo(X){let p,_;return p=new Pa({props:{$$slots:{default:[qo]},$$scope:{ctx:X}}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p(i,g){const W={};g&2&&(W.$$scope={dirty:g,ctx:i}),p.$set(W)},i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function Ko(X){let p,_,i,g,W,Z,ue,ge,ye,R,D,N,V,Me,F,re,se,be,O,ne,Te,j,me,C,$e,ie,P,B,Ee,E,Re,pe,Je,I,K,ee,Ie,te,A,ae,de,x,he,le,H,z,k,S,we;return R=new ve({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:"pip install -U -r requirements_flax.txt"}}),B=new ve({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwZGF0YXNldF9uYW1lJTNEJTIybGFtYmRhbGFicyUyRnBva2Vtb24tYmxpcC1jYXB0aW9ucyUyMiUwQSUwQXB5dGhvbiUyMHRyYWluX3RleHRfdG9faW1hZ2VfZmxheC5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS1kYXRhc2V0X25hbWUlM0QlMjRkYXRhc2V0X25hbWUlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAtLWNlbnRlcl9jcm9wJTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMWUtMDUlMjAlNUMlMEElMjAlMjAtLW1heF9ncmFkX25vcm0lM0QxJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIyc2QtcG9rZW1vbi1tb2RlbCUyMiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> dataset_name=<span class="hljs-string">&quot;lambdalabs/pokemon-blip-captions&quot;</span>

python train_text_to_image_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$dataset_name</span> \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --output_dir=<span class="hljs-string">&quot;sd-pokemon-model&quot;</span> \\
  --push_to_hub`}}),S=new ve({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMFRSQUlOX0RJUiUzRCUyMnBhdGhfdG9feW91cl9kYXRhc2V0JTIyJTBBJTBBcHl0aG9uJTIwdHJhaW5fdGV4dF90b19pbWFnZV9mbGF4LnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAtLXRyYWluX2RhdGFfZGlyJTNEJTI0VFJBSU5fRElSJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwLS1jZW50ZXJfY3JvcCUyMC0tcmFuZG9tX2ZsaXAlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1taXhlZF9wcmVjaXNpb24lM0QlMjJmcDE2JTIyJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QxNTAwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTA1JTIwJTVDJTBBJTIwJTIwLS1tYXhfZ3JhZF9ub3JtJTNEMSUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyMnNkLXBva2Vtb24tbW9kZWwlMjIlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",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> TRAIN_DIR=<span class="hljs-string">&quot;path_to_your_dataset&quot;</span>

python train_text_to_image_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --train_data_dir=<span class="hljs-variable">$TRAIN_DIR</span> \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --output_dir=<span class="hljs-string">&quot;sd-pokemon-model&quot;</span> \\
  --push_to_hub`}}),{c(){p=r("p"),_=l("With Flax, it\u2019s possible to train a Stable Diffusion model faster on TPUs and GPUs thanks to "),i=r("a"),g=l("@duongna211"),W=l(". This is very efficient on TPU hardware but works great on GPUs too. The Flax training script doesn\u2019t support features like gradient checkpointing or gradient accumulation yet, so you\u2019ll need a GPU with at least 30GB of memory or a TPU v3."),Z=d(),ue=r("p"),ge=l("Before running the script, make sure you have the requirements installed:"),ye=d(),b(R.$$.fragment),D=d(),N=r("p"),V=l("Specify the "),Me=r("code"),F=l("MODEL_NAME"),re=l(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),se=r("a"),be=r("code"),O=l("pretrained_model_name_or_path"),ne=l(" argument."),Te=d(),j=r("p"),me=l("Now you can launch the "),C=r("a"),$e=l("Flax training script"),ie=l(" like this:"),P=d(),b(B.$$.fragment),Ee=d(),E=r("p"),Re=l("To finetune on your own dataset, prepare the dataset according to the format required by \u{1F917} "),pe=r("a"),Je=l("Datasets"),I=l(". You can "),K=r("a"),ee=l("upload your dataset to the Hub"),Ie=l(", or you can "),te=r("a"),A=l("prepare a local folder with your files"),ae=l("."),de=d(),x=r("p"),he=l("Modify the script if you want to use custom loading logic. We left pointers in the code in the appropriate places to help you. \u{1F917} The example script below shows how to finetune on a local dataset in "),le=r("code"),H=l("TRAIN_DIR"),z=l(":"),k=d(),b(S.$$.fragment),this.h()},l(u){p=s(u,"P",{});var y=n(p);_=o(y,"With Flax, it\u2019s possible to train a Stable Diffusion model faster on TPUs and GPUs thanks to "),i=s(y,"A",{href:!0,rel:!0});var Ue=n(i);g=o(Ue,"@duongna211"),Ue.forEach(a),W=o(y,". This is very efficient on TPU hardware but works great on GPUs too. The Flax training script doesn\u2019t support features like gradient checkpointing or gradient accumulation yet, so you\u2019ll need a GPU with at least 30GB of memory or a TPU v3."),y.forEach(a),Z=w(u),ue=s(u,"P",{});var Y=n(ue);ge=o(Y,"Before running the script, make sure you have the requirements installed:"),Y.forEach(a),ye=w(u),T(R.$$.fragment,u),D=w(u),N=s(u,"P",{});var oe=n(N);V=o(oe,"Specify the "),Me=s(oe,"CODE",{});var je=n(Me);F=o(je,"MODEL_NAME"),je.forEach(a),re=o(oe," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),se=s(oe,"A",{href:!0,rel:!0});var Ce=n(se);be=s(Ce,"CODE",{});var _e=n(be);O=o(_e,"pretrained_model_name_or_path"),_e.forEach(a),Ce.forEach(a),ne=o(oe," argument."),oe.forEach(a),Te=w(u),j=s(u,"P",{});var fe=n(j);me=o(fe,"Now you can launch the "),C=s(fe,"A",{href:!0,rel:!0});var Ae=n(C);$e=o(Ae,"Flax training script"),Ae.forEach(a),ie=o(fe," like this:"),fe.forEach(a),P=w(u),T(B.$$.fragment,u),Ee=w(u),E=s(u,"P",{});var L=n(E);Re=o(L,"To finetune on your own dataset, prepare the dataset according to the format required by \u{1F917} "),pe=s(L,"A",{href:!0,rel:!0});var Ne=n(pe);Je=o(Ne,"Datasets"),Ne.forEach(a),I=o(L,". You can "),K=s(L,"A",{href:!0,rel:!0});var q=n(K);ee=o(q,"upload your dataset to the Hub"),q.forEach(a),Ie=o(L,", or you can "),te=s(L,"A",{href:!0,rel:!0});var xe=n(te);A=o(xe,"prepare a local folder with your files"),xe.forEach(a),ae=o(L,"."),L.forEach(a),de=w(u),x=s(u,"P",{});var G=n(x);he=o(G,"Modify the script if you want to use custom loading logic. We left pointers in the code in the appropriate places to help you. \u{1F917} The example script below shows how to finetune on a local dataset in "),le=s(G,"CODE",{});var Xe=n(le);H=o(Xe,"TRAIN_DIR"),Xe.forEach(a),z=o(G,":"),G.forEach(a),k=w(u),T(S.$$.fragment,u),this.h()},h(){c(i,"href","https://github.com/duongna21"),c(i,"rel","nofollow"),c(se,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),c(se,"rel","nofollow"),c(C,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_flax.py"),c(C,"rel","nofollow"),c(pe,"href","https://huggingface.co/docs/datasets/index"),c(pe,"rel","nofollow"),c(K,"href","https://huggingface.co/docs/datasets/image_dataset#upload-dataset-to-the-hub"),c(K,"rel","nofollow"),c(te,"href","https://huggingface.co/docs/datasets/image_dataset#imagefolder"),c(te,"rel","nofollow")},m(u,y){h(u,p,y),t(p,_),t(p,i),t(i,g),t(p,W),h(u,Z,y),h(u,ue,y),t(ue,ge),h(u,ye,y),J(R,u,y),h(u,D,y),h(u,N,y),t(N,V),t(N,Me),t(Me,F),t(N,re),t(N,se),t(se,be),t(be,O),t(N,ne),h(u,Te,y),h(u,j,y),t(j,me),t(j,C),t(C,$e),t(j,ie),h(u,P,y),J(B,u,y),h(u,Ee,y),h(u,E,y),t(E,Re),t(E,pe),t(pe,Je),t(E,I),t(E,K),t(K,ee),t(E,Ie),t(E,te),t(te,A),t(E,ae),h(u,de,y),h(u,x,y),t(x,he),t(x,le),t(le,H),t(x,z),h(u,k,y),J(S,u,y),we=!0},p:Da,i(u){we||(U(R.$$.fragment,u),U(B.$$.fragment,u),U(S.$$.fragment,u),we=!0)},o(u){v(R.$$.fragment,u),v(B.$$.fragment,u),v(S.$$.fragment,u),we=!1},d(u){u&&a(p),u&&a(Z),u&&a(ue),u&&a(ye),$(R,u),u&&a(D),u&&a(N),u&&a(Te),u&&a(j),u&&a(P),$(B,u),u&&a(Ee),u&&a(E),u&&a(de),u&&a(x),u&&a(k),$(S,u)}}}function er(X){let p,_;return p=new Pa({props:{$$slots:{default:[Ko]},$$scope:{ctx:X}}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p(i,g){const W={};g&2&&(W.$$scope={dirty:g,ctx:i}),p.$set(W)},i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function tr(X){let p,_;return{c(){p=r("p"),_=l("Training with Min-SNR weighting strategy is only supported in PyTorch.")},l(i){p=s(i,"P",{});var g=n(p);_=o(g,"Training with Min-SNR weighting strategy is only supported in PyTorch."),g.forEach(a)},m(i,g){h(i,p,g),t(p,_)},d(i){i&&a(p)}}}function ar(X){let p,_;return p=new ve({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnBhdGhfdG9fc2F2ZWRfbW9kZWwlMjIlMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX3BhdGglMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0QlMjJ5b2RhJTIyKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJ5b2RhLXBva2Vtb24ucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

model_path = <span class="hljs-string">&quot;path_to_saved_model&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe(prompt=<span class="hljs-string">&quot;yoda&quot;</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;yoda-pokemon.png&quot;</span>)`}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p:Da,i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function lr(X){let p,_;return p=new Pa({props:{$$slots:{default:[ar]},$$scope:{ctx:X}}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p(i,g){const W={};g&2&&(W.$$scope={dirty:g,ctx:i}),p.$set(W)},i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function or(X){let p,_;return p=new ve({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnBhdGhfdG9fc2F2ZWRfbW9kZWwlMjIlMEFwaXBlJTJDJTIwcGFyYW1zJTIwJTNEJTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9wYXRoJTJDJTIwZHR5cGUlM0RqYXgubnVtcHkuYmZsb2F0MTYpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyeW9kYSUyMHBva2Vtb24lMjIlMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLlBSTkdLZXkoMCklMEFudW1faW5mZXJlbmNlX3N0ZXBzJTIwJTNEJTIwNTAlMEElMEFudW1fc2FtcGxlcyUyMCUzRCUyMGpheC5kZXZpY2VfY291bnQoKSUwQXByb21wdCUyMCUzRCUyMG51bV9zYW1wbGVzJTIwKiUyMCU1QnByb21wdCU1RCUwQXByb21wdF9pZHMlMjAlM0QlMjBwaXBlbGluZS5wcmVwYXJlX2lucHV0cyhwcm9tcHQpJTBBJTBBJTIzJTIwc2hhcmQlMjBpbnB1dHMlMjBhbmQlMjBybmclMEFwYXJhbXMlMjAlM0QlMjByZXBsaWNhdGUocGFyYW1zKSUwQXBybmdfc2VlZCUyMCUzRCUyMGpheC5yYW5kb20uc3BsaXQocHJuZ19zZWVkJTJDJTIwamF4LmRldmljZV9jb3VudCgpKSUwQXByb21wdF9pZHMlMjAlM0QlMjBzaGFyZChwcm9tcHRfaWRzKSUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKHByb21wdF9pZHMlMkMlMjBwYXJhbXMlMkMlMjBwcm5nX3NlZWQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTJDJTIwaml0JTNEVHJ1ZSkuaW1hZ2VzJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUubnVtcHlfdG9fcGlsKG5wLmFzYXJyYXkoaW1hZ2VzLnJlc2hhcGUoKG51bV9zYW1wbGVzJTJDKSUyMCUyQiUyMGltYWdlcy5zaGFwZSU1Qi0zJTNBJTVEKSkpJTBBaW1hZ2Uuc2F2ZSglMjJ5b2RhLXBva2Vtb24ucG5nJTIyKQ==",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

model_path = <span class="hljs-string">&quot;path_to_saved_model&quot;</span>
pipe, params = FlaxStableDiffusionPipeline.from_pretrained(model_path, dtype=jax.numpy.bfloat16)

prompt = <span class="hljs-string">&quot;yoda pokemon&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"># shard inputs and rng</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;yoda-pokemon.png&quot;</span>)`}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p:Da,i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function rr(X){let p,_;return p=new Pa({props:{$$slots:{default:[or]},$$scope:{ctx:X}}}),{c(){b(p.$$.fragment)},l(i){T(p.$$.fragment,i)},m(i,g){J(p,i,g),_=!0},p(i,g){const W={};g&2&&(W.$$scope={dirty:g,ctx:i}),p.$set(W)},i(i){_||(U(p.$$.fragment,i),_=!0)},o(i){v(p.$$.fragment,i),_=!1},d(i){$(p,i)}}}function sr(X){let p,_,i,g,W,Z,ue,ge,ye,R,D,N,V,Me,F,re,se,be,O,ne,Te,j,me,C,$e,ie,P,B,Ee,E,Re,pe,Je,I,K,ee,Ie,te,A,ae,de,x,he,le,H,z,k,S,we,u,y,Ue,Y,oe,je,Ce,_e,fe,Ae,L,Ne,q,xe,G,Xe,m,M,kt,Rt,Ze,De,It,dt,Q,Be,tt,Se,Ge,at,Nt,Pe,He,xt,wt,ce,_t,We,Fe,Yt,gt,Ha,Lt,za,ua,Xt,qa,ma,yt,da,ke,Oa,Qt,Ka,el,Dt,tl,al,Pt,ll,ol,wa,lt,rl,Ht,sl,nl,_a,Mt,ga,ze,ot,zt,bt,il,qt,pl,ya,rt,Ma,qe,st,Ot,Tt,hl,Kt,fl,ba,Ve,cl,Jt,ul,ml,ea,dl,wl,Ta,nt,_l,Ut,gl,yl,Ja,Ye,ta,Ml,bl,vt,Tl,aa,Jl,Ul,vl,$t,$l,la,El,jl,Ua,Zt,Wl,va,Le,kl,oa,Rl,Il,ra,Nl,xl,$a,it,Ea,Oe,pt,sa,Et,Xl,na,Zl,ja,ht,Bl,Bt,Fl,Cl,Wa,Ke,ft,ia,jt,Al,pa,Sl,ka,ct,Gl,Ft,Vl,Yl,Ra,ut,Ia;return Z=new et({}),D=new Vo({props:{warning:!0,$$slots:{default:[zo]},$$scope:{ctx:X}}}),ie=new ve({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGZGlmZnVzZXJzLmdpdCUwQXBpcCUyMGluc3RhbGwlMjAtVSUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dA==",highlighted:`pip install git+https://github.com/huggingface/diffusers.git
pip install -U -r requirements.txt`}}),I=new ve({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),x=new et({}),Se=new et({}),ce=new ve({props:{code:"JTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:"  --push_to_hub"}}),gt=new et({}),yt=new ve({props:{code:"JTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAw",highlighted:"  --checkpointing_steps=500"}}),Mt=new ve({props:{code:"JTIwJTIwLS1yZXN1bWVfZnJvbV9jaGVja3BvaW50JTNEJTIyY2hlY2twb2ludC0xNTAwJTIy",highlighted:'  --resume_from_checkpoint=<span class="hljs-string">&quot;checkpoint-1500&quot;</span>'}}),bt=new et({}),rt=new Yo({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[er],pytorch:[Oo]},$$scope:{ctx:X}}}),Tt=new et({}),it=new Vo({props:{warning:!0,$$slots:{default:[tr]},$$scope:{ctx:X}}}),Et=new et({}),jt=new et({}),ut=new Yo({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[rr],pytorch:[lr]},$$scope:{ctx:X}}}),{c(){p=r("meta"),_=d(),i=r("h1"),g=r("a"),W=r("span"),b(Z.$$.fragment),ue=d(),ge=r("span"),ye=l("Text-to-image"),R=d(),b(D.$$.fragment),N=d(),V=r("p"),Me=l("Text-to-image models like Stable Diffusion generate an image from a text prompt. This guide will show you how to finetune the "),F=r("a"),re=r("code"),se=l("CompVis/stable-diffusion-v1-4"),be=l(" model on your own dataset with PyTorch and Flax. All the training scripts for text-to-image finetuning used in this guide can be found in this "),O=r("a"),ne=l("repository"),Te=l(" if you\u2019re interested in taking a closer look."),j=d(),me=r("p"),C=l("Before running the scripts, make sure to install the library\u2019s training dependencies:"),$e=d(),b(ie.$$.fragment),P=d(),B=r("p"),Ee=l("And initialize an "),E=r("a"),Re=l("\u{1F917} Accelerate"),pe=l(" environment with:"),Je=d(),b(I.$$.fragment),K=d(),ee=r("p"),Ie=l("If you have already cloned the repo, then you won\u2019t need to go through these steps. Instead, you can pass the path to your local checkout to the training script and it will be loaded from there."),te=d(),A=r("h2"),ae=r("a"),de=r("span"),b(x.$$.fragment),he=d(),le=r("span"),H=l("Hardware requirements"),z=d(),k=r("p"),S=l("Using "),we=r("code"),u=l("gradient_checkpointing"),y=l(" and "),Ue=r("code"),Y=l("mixed_precision"),oe=l(", it should be possible to finetune the model on a single 24GB GPU. For higher "),je=r("code"),Ce=l("batch_size"),_e=l("\u2019s and faster training, it\u2019s better to use GPUs with more than 30GB of GPU memory. You can also use JAX/Flax for fine-tuning on TPUs or GPUs, which will be covered "),fe=r("a"),Ae=l("below"),L=l("."),Ne=d(),q=r("p"),xe=l("You can reduce your memory footprint even more by enabling memory efficient attention with xFormers. Make sure you have "),G=r("a"),Xe=l("xFormers installed"),m=l(" and pass the "),M=r("code"),kt=l("--enable_xformers_memory_efficient_attention"),Rt=l(" flag to the training script."),Ze=d(),De=r("p"),It=l("xFormers is not available for Flax."),dt=d(),Q=r("h2"),Be=r("a"),tt=r("span"),b(Se.$$.fragment),Ge=d(),at=r("span"),Nt=l("Upload model to Hub"),Pe=d(),He=r("p"),xt=l("Store your model on the Hub by adding the following argument to the training script:"),wt=d(),b(ce.$$.fragment),_t=d(),We=r("h2"),Fe=r("a"),Yt=r("span"),b(gt.$$.fragment),Ha=d(),Lt=r("span"),za=l("Save and load checkpoints"),ua=d(),Xt=r("p"),qa=l("It is a good idea to regularly save checkpoints in case anything happens during training. To save a checkpoint, pass the following argument to the training script:"),ma=d(),b(yt.$$.fragment),da=d(),ke=r("p"),Oa=l("Every 500 steps, the full training state is saved in a subfolder in the "),Qt=r("code"),Ka=l("output_dir"),el=l(". The checkpoint has the format "),Dt=r("code"),tl=l("checkpoint-"),al=l(" followed by the number of steps trained so far. For example, "),Pt=r("code"),ll=l("checkpoint-1500"),ol=l(" is a checkpoint saved after 1500 training steps."),wa=d(),lt=r("p"),rl=l("To load a checkpoint to resume training, pass the argument "),Ht=r("code"),sl=l("--resume_from_checkpoint"),nl=l(" to the training script and specify the checkpoint you want to resume from. For example, the following argument resumes training from the checkpoint saved after 1500 training steps:"),_a=d(),b(Mt.$$.fragment),ga=d(),ze=r("h2"),ot=r("a"),zt=r("span"),b(bt.$$.fragment),il=d(),qt=r("span"),pl=l("Fine-tuning"),ya=d(),b(rt.$$.fragment),Ma=d(),qe=r("h2"),st=r("a"),Ot=r("span"),b(Tt.$$.fragment),hl=d(),Kt=r("span"),fl=l("Training with Min-SNR weighting"),ba=d(),Ve=r("p"),cl=l("We support training with the Min-SNR weighting strategy proposed in "),Jt=r("a"),ul=l("Efficient Diffusion Training via Min-SNR Weighting Strategy"),ml=l(` which helps to achieve faster convergence
by rebalancing the loss. In order to use it, one needs to set the `),ea=r("code"),dl=l("--snr_gamma"),wl=l(` argument. The recommended
value when using it is 5.0.`),Ta=d(),nt=r("p"),_l=l("You can find "),Ut=r("a"),gl=l("this project on Weights and Biases"),yl=l(" that compares the loss surfaces of the following setups:"),Ja=d(),Ye=r("ul"),ta=r("li"),Ml=l("Training without the Min-SNR weighting strategy"),bl=d(),vt=r("li"),Tl=l("Training with the Min-SNR weighting strategy ("),aa=r("code"),Jl=l("snr_gamma"),Ul=l(" set to 5.0)"),vl=d(),$t=r("li"),$l=l("Training with the Min-SNR weighting strategy ("),la=r("code"),El=l("snr_gamma"),jl=l(" set to 1.0)"),Ua=d(),Zt=r("p"),Wl=l("For our small Pokemons dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced."),va=d(),Le=r("p"),kl=l("Also, note that in this example, we either predict "),oa=r("code"),Rl=l("epsilon"),Il=l(" (i.e., the noise) or the "),ra=r("code"),Nl=l("v_prediction"),xl=l(". For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds."),$a=d(),b(it.$$.fragment),Ea=d(),Oe=r("h2"),pt=r("a"),sa=r("span"),b(Et.$$.fragment),Xl=d(),na=r("span"),Zl=l("LoRA"),ja=d(),ht=r("p"),Bl=l("You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, for fine-tuning text-to-image models. For more details, take a look at the "),Bt=r("a"),Fl=l("LoRA training"),Cl=l(" guide."),Wa=d(),Ke=r("h2"),ft=r("a"),ia=r("span"),b(jt.$$.fragment),Al=d(),pa=r("span"),Sl=l("Inference"),ka=d(),ct=r("p"),Gl=l("Now you can load the fine-tuned model for inference by passing the model path or model name on the Hub to the "),Ft=r("a"),Vl=l("StableDiffusionPipeline"),Yl=l(":"),Ra=d(),b(ut.$$.fragment),this.h()},l(e){const f=Po('[data-svelte="svelte-1phssyn"]',document.head);p=s(f,"META",{name:!0,content:!0}),f.forEach(a),_=w(e),i=s(e,"H1",{class:!0});var Wt=n(i);g=s(Wt,"A",{id:!0,class:!0,href:!0});var ha=n(g);W=s(ha,"SPAN",{});var fa=n(W);T(Z.$$.fragment,fa),fa.forEach(a),ha.forEach(a),ue=w(Wt),ge=s(Wt,"SPAN",{});var ca=n(ge);ye=o(ca,"Text-to-image"),ca.forEach(a),Wt.forEach(a),R=w(e),T(D.$$.fragment,e),N=w(e),V=s(e,"P",{});var Ct=n(V);Me=o(Ct,"Text-to-image models like Stable Diffusion generate an image from a text prompt. This guide will show you how to finetune the "),F=s(Ct,"A",{href:!0,rel:!0});var Ll=n(F);re=s(Ll,"CODE",{});var Ql=n(re);se=o(Ql,"CompVis/stable-diffusion-v1-4"),Ql.forEach(a),Ll.forEach(a),be=o(Ct," model on your own dataset with PyTorch and Flax. All the training scripts for text-to-image finetuning used in this guide can be found in this "),O=s(Ct,"A",{href:!0,rel:!0});var Dl=n(O);ne=o(Dl,"repository"),Dl.forEach(a),Te=o(Ct," if you\u2019re interested in taking a closer look."),Ct.forEach(a),j=w(e),me=s(e,"P",{});var Pl=n(me);C=o(Pl,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),Pl.forEach(a),$e=w(e),T(ie.$$.fragment,e),P=w(e),B=s(e,"P",{});var Na=n(B);Ee=o(Na,"And initialize an "),E=s(Na,"A",{href:!0,rel:!0});var Hl=n(E);Re=o(Hl,"\u{1F917} Accelerate"),Hl.forEach(a),pe=o(Na," environment with:"),Na.forEach(a),Je=w(e),T(I.$$.fragment,e),K=w(e),ee=s(e,"P",{});var zl=n(ee);Ie=o(zl,"If you have already cloned the repo, then you won\u2019t need to go through these steps. Instead, you can pass the path to your local checkout to the training script and it will be loaded from there."),zl.forEach(a),te=w(e),A=s(e,"H2",{class:!0});var xa=n(A);ae=s(xa,"A",{id:!0,class:!0,href:!0});var ql=n(ae);de=s(ql,"SPAN",{});var Ol=n(de);T(x.$$.fragment,Ol),Ol.forEach(a),ql.forEach(a),he=w(xa),le=s(xa,"SPAN",{});var Kl=n(le);H=o(Kl,"Hardware requirements"),Kl.forEach(a),xa.forEach(a),z=w(e),k=s(e,"P",{});var Qe=n(k);S=o(Qe,"Using "),we=s(Qe,"CODE",{});var eo=n(we);u=o(eo,"gradient_checkpointing"),eo.forEach(a),y=o(Qe," and "),Ue=s(Qe,"CODE",{});var to=n(Ue);Y=o(to,"mixed_precision"),to.forEach(a),oe=o(Qe,", it should be possible to finetune the model on a single 24GB GPU. For higher "),je=s(Qe,"CODE",{});var ao=n(je);Ce=o(ao,"batch_size"),ao.forEach(a),_e=o(Qe,"\u2019s and faster training, it\u2019s better to use GPUs with more than 30GB of GPU memory. You can also use JAX/Flax for fine-tuning on TPUs or GPUs, which will be covered "),fe=s(Qe,"A",{href:!0});var lo=n(fe);Ae=o(lo,"below"),lo.forEach(a),L=o(Qe,"."),Qe.forEach(a),Ne=w(e),q=s(e,"P",{});var At=n(q);xe=o(At,"You can reduce your memory footprint even more by enabling memory efficient attention with xFormers. Make sure you have "),G=s(At,"A",{href:!0});var oo=n(G);Xe=o(oo,"xFormers installed"),oo.forEach(a),m=o(At," and pass the "),M=s(At,"CODE",{});var ro=n(M);kt=o(ro,"--enable_xformers_memory_efficient_attention"),ro.forEach(a),Rt=o(At," flag to the training script."),At.forEach(a),Ze=w(e),De=s(e,"P",{});var so=n(De);It=o(so,"xFormers is not available for Flax."),so.forEach(a),dt=w(e),Q=s(e,"H2",{class:!0});var Xa=n(Q);Be=s(Xa,"A",{id:!0,class:!0,href:!0});var no=n(Be);tt=s(no,"SPAN",{});var io=n(tt);T(Se.$$.fragment,io),io.forEach(a),no.forEach(a),Ge=w(Xa),at=s(Xa,"SPAN",{});var po=n(at);Nt=o(po,"Upload model to Hub"),po.forEach(a),Xa.forEach(a),Pe=w(e),He=s(e,"P",{});var ho=n(He);xt=o(ho,"Store your model on the Hub by adding the following argument to the training script:"),ho.forEach(a),wt=w(e),T(ce.$$.fragment,e),_t=w(e),We=s(e,"H2",{class:!0});var Za=n(We);Fe=s(Za,"A",{id:!0,class:!0,href:!0});var fo=n(Fe);Yt=s(fo,"SPAN",{});var co=n(Yt);T(gt.$$.fragment,co),co.forEach(a),fo.forEach(a),Ha=w(Za),Lt=s(Za,"SPAN",{});var uo=n(Lt);za=o(uo,"Save and load checkpoints"),uo.forEach(a),Za.forEach(a),ua=w(e),Xt=s(e,"P",{});var mo=n(Xt);qa=o(mo,"It is a good idea to regularly save checkpoints in case anything happens during training. To save a checkpoint, pass the following argument to the training script:"),mo.forEach(a),ma=w(e),T(yt.$$.fragment,e),da=w(e),ke=s(e,"P",{});var mt=n(ke);Oa=o(mt,"Every 500 steps, the full training state is saved in a subfolder in the "),Qt=s(mt,"CODE",{});var wo=n(Qt);Ka=o(wo,"output_dir"),wo.forEach(a),el=o(mt,". The checkpoint has the format "),Dt=s(mt,"CODE",{});var _o=n(Dt);tl=o(_o,"checkpoint-"),_o.forEach(a),al=o(mt," followed by the number of steps trained so far. For example, "),Pt=s(mt,"CODE",{});var go=n(Pt);ll=o(go,"checkpoint-1500"),go.forEach(a),ol=o(mt," is a checkpoint saved after 1500 training steps."),mt.forEach(a),wa=w(e),lt=s(e,"P",{});var Ba=n(lt);rl=o(Ba,"To load a checkpoint to resume training, pass the argument "),Ht=s(Ba,"CODE",{});var yo=n(Ht);sl=o(yo,"--resume_from_checkpoint"),yo.forEach(a),nl=o(Ba," to the training script and specify the checkpoint you want to resume from. For example, the following argument resumes training from the checkpoint saved after 1500 training steps:"),Ba.forEach(a),_a=w(e),T(Mt.$$.fragment,e),ga=w(e),ze=s(e,"H2",{class:!0});var Fa=n(ze);ot=s(Fa,"A",{id:!0,class:!0,href:!0});var Mo=n(ot);zt=s(Mo,"SPAN",{});var bo=n(zt);T(bt.$$.fragment,bo),bo.forEach(a),Mo.forEach(a),il=w(Fa),qt=s(Fa,"SPAN",{});var To=n(qt);pl=o(To,"Fine-tuning"),To.forEach(a),Fa.forEach(a),ya=w(e),T(rt.$$.fragment,e),Ma=w(e),qe=s(e,"H2",{class:!0});var Ca=n(qe);st=s(Ca,"A",{id:!0,class:!0,href:!0});var Jo=n(st);Ot=s(Jo,"SPAN",{});var Uo=n(Ot);T(Tt.$$.fragment,Uo),Uo.forEach(a),Jo.forEach(a),hl=w(Ca),Kt=s(Ca,"SPAN",{});var vo=n(Kt);fl=o(vo,"Training with Min-SNR weighting"),vo.forEach(a),Ca.forEach(a),ba=w(e),Ve=s(e,"P",{});var St=n(Ve);cl=o(St,"We support training with the Min-SNR weighting strategy proposed in "),Jt=s(St,"A",{href:!0,rel:!0});var $o=n(Jt);ul=o($o,"Efficient Diffusion Training via Min-SNR Weighting Strategy"),$o.forEach(a),ml=o(St,` which helps to achieve faster convergence
by rebalancing the loss. In order to use it, one needs to set the `),ea=s(St,"CODE",{});var Eo=n(ea);dl=o(Eo,"--snr_gamma"),Eo.forEach(a),wl=o(St,` argument. The recommended
value when using it is 5.0.`),St.forEach(a),Ta=w(e),nt=s(e,"P",{});var Aa=n(nt);_l=o(Aa,"You can find "),Ut=s(Aa,"A",{href:!0,rel:!0});var jo=n(Ut);gl=o(jo,"this project on Weights and Biases"),jo.forEach(a),yl=o(Aa," that compares the loss surfaces of the following setups:"),Aa.forEach(a),Ja=w(e),Ye=s(e,"UL",{});var Gt=n(Ye);ta=s(Gt,"LI",{});var Wo=n(ta);Ml=o(Wo,"Training without the Min-SNR weighting strategy"),Wo.forEach(a),bl=w(Gt),vt=s(Gt,"LI",{});var Sa=n(vt);Tl=o(Sa,"Training with the Min-SNR weighting strategy ("),aa=s(Sa,"CODE",{});var ko=n(aa);Jl=o(ko,"snr_gamma"),ko.forEach(a),Ul=o(Sa," set to 5.0)"),Sa.forEach(a),vl=w(Gt),$t=s(Gt,"LI",{});var Ga=n($t);$l=o(Ga,"Training with the Min-SNR weighting strategy ("),la=s(Ga,"CODE",{});var Ro=n(la);El=o(Ro,"snr_gamma"),Ro.forEach(a),jl=o(Ga," set to 1.0)"),Ga.forEach(a),Gt.forEach(a),Ua=w(e),Zt=s(e,"P",{});var Io=n(Zt);Wl=o(Io,"For our small Pokemons dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced."),Io.forEach(a),va=w(e),Le=s(e,"P",{});var Vt=n(Le);kl=o(Vt,"Also, note that in this example, we either predict "),oa=s(Vt,"CODE",{});var No=n(oa);Rl=o(No,"epsilon"),No.forEach(a),Il=o(Vt," (i.e., the noise) or the "),ra=s(Vt,"CODE",{});var xo=n(ra);Nl=o(xo,"v_prediction"),xo.forEach(a),xl=o(Vt,". For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds."),Vt.forEach(a),$a=w(e),T(it.$$.fragment,e),Ea=w(e),Oe=s(e,"H2",{class:!0});var Va=n(Oe);pt=s(Va,"A",{id:!0,class:!0,href:!0});var Xo=n(pt);sa=s(Xo,"SPAN",{});var Zo=n(sa);T(Et.$$.fragment,Zo),Zo.forEach(a),Xo.forEach(a),Xl=w(Va),na=s(Va,"SPAN",{});var Bo=n(na);Zl=o(Bo,"LoRA"),Bo.forEach(a),Va.forEach(a),ja=w(e),ht=s(e,"P",{});var Ya=n(ht);Bl=o(Ya,"You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, for fine-tuning text-to-image models. For more details, take a look at the "),Bt=s(Ya,"A",{href:!0});var Fo=n(Bt);Fl=o(Fo,"LoRA training"),Fo.forEach(a),Cl=o(Ya," guide."),Ya.forEach(a),Wa=w(e),Ke=s(e,"H2",{class:!0});var La=n(Ke);ft=s(La,"A",{id:!0,class:!0,href:!0});var Co=n(ft);ia=s(Co,"SPAN",{});var Ao=n(ia);T(jt.$$.fragment,Ao),Ao.forEach(a),Co.forEach(a),Al=w(La),pa=s(La,"SPAN",{});var So=n(pa);Sl=o(So,"Inference"),So.forEach(a),La.forEach(a),ka=w(e),ct=s(e,"P",{});var Qa=n(ct);Gl=o(Qa,"Now you can load the fine-tuned model for inference by passing the model path or model name on the Hub to the "),Ft=s(Qa,"A",{href:!0});var Go=n(Ft);Vl=o(Go,"StableDiffusionPipeline"),Go.forEach(a),Yl=o(Qa,":"),Qa.forEach(a),Ra=w(e),T(ut.$$.fragment,e),this.h()},h(){c(p,"name","hf:doc:metadata"),c(p,"content",JSON.stringify(nr)),c(g,"id","texttoimage"),c(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(g,"href","#texttoimage"),c(i,"class","relative group"),c(F,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),c(F,"rel","nofollow"),c(O,"href","https://github.com/huggingface/diffusers/tree/main/examples/text_to_image"),c(O,"rel","nofollow"),c(E,"href","https://github.com/huggingface/accelerate/"),c(E,"rel","nofollow"),c(ae,"id","hardware-requirements"),c(ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ae,"href","#hardware-requirements"),c(A,"class","relative group"),c(fe,"href","#flax-jax-finetuning"),c(G,"href","./optimization/xformers"),c(Be,"id","upload-model-to-hub"),c(Be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Be,"href","#upload-model-to-hub"),c(Q,"class","relative group"),c(Fe,"id","save-and-load-checkpoints"),c(Fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Fe,"href","#save-and-load-checkpoints"),c(We,"class","relative group"),c(ot,"id","finetuning"),c(ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ot,"href","#finetuning"),c(ze,"class","relative group"),c(st,"id","training-with-minsnr-weighting"),c(st,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(st,"href","#training-with-minsnr-weighting"),c(qe,"class","relative group"),c(Jt,"href","https://arxiv.org/abs/2303.09556"),c(Jt,"rel","nofollow"),c(Ut,"href","https://wandb.ai/sayakpaul/text2image-finetune-minsnr"),c(Ut,"rel","nofollow"),c(pt,"id","lora"),c(pt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(pt,"href","#lora"),c(Oe,"class","relative group"),c(Bt,"href","lora#text-to-image"),c(ft,"id","inference"),c(ft,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ft,"href","#inference"),c(Ke,"class","relative group"),c(Ft,"href","/docs/diffusers/v0.19.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline")},m(e,f){t(document.head,p),h(e,_,f),h(e,i,f),t(i,g),t(g,W),J(Z,W,null),t(i,ue),t(i,ge),t(ge,ye),h(e,R,f),J(D,e,f),h(e,N,f),h(e,V,f),t(V,Me),t(V,F),t(F,re),t(re,se),t(V,be),t(V,O),t(O,ne),t(V,Te),h(e,j,f),h(e,me,f),t(me,C),h(e,$e,f),J(ie,e,f),h(e,P,f),h(e,B,f),t(B,Ee),t(B,E),t(E,Re),t(B,pe),h(e,Je,f),J(I,e,f),h(e,K,f),h(e,ee,f),t(ee,Ie),h(e,te,f),h(e,A,f),t(A,ae),t(ae,de),J(x,de,null),t(A,he),t(A,le),t(le,H),h(e,z,f),h(e,k,f),t(k,S),t(k,we),t(we,u),t(k,y),t(k,Ue),t(Ue,Y),t(k,oe),t(k,je),t(je,Ce),t(k,_e),t(k,fe),t(fe,Ae),t(k,L),h(e,Ne,f),h(e,q,f),t(q,xe),t(q,G),t(G,Xe),t(q,m),t(q,M),t(M,kt),t(q,Rt),h(e,Ze,f),h(e,De,f),t(De,It),h(e,dt,f),h(e,Q,f),t(Q,Be),t(Be,tt),J(Se,tt,null),t(Q,Ge),t(Q,at),t(at,Nt),h(e,Pe,f),h(e,He,f),t(He,xt),h(e,wt,f),J(ce,e,f),h(e,_t,f),h(e,We,f),t(We,Fe),t(Fe,Yt),J(gt,Yt,null),t(We,Ha),t(We,Lt),t(Lt,za),h(e,ua,f),h(e,Xt,f),t(Xt,qa),h(e,ma,f),J(yt,e,f),h(e,da,f),h(e,ke,f),t(ke,Oa),t(ke,Qt),t(Qt,Ka),t(ke,el),t(ke,Dt),t(Dt,tl),t(ke,al),t(ke,Pt),t(Pt,ll),t(ke,ol),h(e,wa,f),h(e,lt,f),t(lt,rl),t(lt,Ht),t(Ht,sl),t(lt,nl),h(e,_a,f),J(Mt,e,f),h(e,ga,f),h(e,ze,f),t(ze,ot),t(ot,zt),J(bt,zt,null),t(ze,il),t(ze,qt),t(qt,pl),h(e,ya,f),J(rt,e,f),h(e,Ma,f),h(e,qe,f),t(qe,st),t(st,Ot),J(Tt,Ot,null),t(qe,hl),t(qe,Kt),t(Kt,fl),h(e,ba,f),h(e,Ve,f),t(Ve,cl),t(Ve,Jt),t(Jt,ul),t(Ve,ml),t(Ve,ea),t(ea,dl),t(Ve,wl),h(e,Ta,f),h(e,nt,f),t(nt,_l),t(nt,Ut),t(Ut,gl),t(nt,yl),h(e,Ja,f),h(e,Ye,f),t(Ye,ta),t(ta,Ml),t(Ye,bl),t(Ye,vt),t(vt,Tl),t(vt,aa),t(aa,Jl),t(vt,Ul),t(Ye,vl),t(Ye,$t),t($t,$l),t($t,la),t(la,El),t($t,jl),h(e,Ua,f),h(e,Zt,f),t(Zt,Wl),h(e,va,f),h(e,Le,f),t(Le,kl),t(Le,oa),t(oa,Rl),t(Le,Il),t(Le,ra),t(ra,Nl),t(Le,xl),h(e,$a,f),J(it,e,f),h(e,Ea,f),h(e,Oe,f),t(Oe,pt),t(pt,sa),J(Et,sa,null),t(Oe,Xl),t(Oe,na),t(na,Zl),h(e,ja,f),h(e,ht,f),t(ht,Bl),t(ht,Bt),t(Bt,Fl),t(ht,Cl),h(e,Wa,f),h(e,Ke,f),t(Ke,ft),t(ft,ia),J(jt,ia,null),t(Ke,Al),t(Ke,pa),t(pa,Sl),h(e,ka,f),h(e,ct,f),t(ct,Gl),t(ct,Ft),t(Ft,Vl),t(ct,Yl),h(e,Ra,f),J(ut,e,f),Ia=!0},p(e,[f]){const Wt={};f&2&&(Wt.$$scope={dirty:f,ctx:e}),D.$set(Wt);const ha={};f&2&&(ha.$$scope={dirty:f,ctx:e}),rt.$set(ha);const fa={};f&2&&(fa.$$scope={dirty:f,ctx:e}),it.$set(fa);const ca={};f&2&&(ca.$$scope={dirty:f,ctx:e}),ut.$set(ca)},i(e){Ia||(U(Z.$$.fragment,e),U(D.$$.fragment,e),U(ie.$$.fragment,e),U(I.$$.fragment,e),U(x.$$.fragment,e),U(Se.$$.fragment,e),U(ce.$$.fragment,e),U(gt.$$.fragment,e),U(yt.$$.fragment,e),U(Mt.$$.fragment,e),U(bt.$$.fragment,e),U(rt.$$.fragment,e),U(Tt.$$.fragment,e),U(it.$$.fragment,e),U(Et.$$.fragment,e),U(jt.$$.fragment,e),U(ut.$$.fragment,e),Ia=!0)},o(e){v(Z.$$.fragment,e),v(D.$$.fragment,e),v(ie.$$.fragment,e),v(I.$$.fragment,e),v(x.$$.fragment,e),v(Se.$$.fragment,e),v(ce.$$.fragment,e),v(gt.$$.fragment,e),v(yt.$$.fragment,e),v(Mt.$$.fragment,e),v(bt.$$.fragment,e),v(rt.$$.fragment,e),v(Tt.$$.fragment,e),v(it.$$.fragment,e),v(Et.$$.fragment,e),v(jt.$$.fragment,e),v(ut.$$.fragment,e),Ia=!1},d(e){a(p),e&&a(_),e&&a(i),$(Z),e&&a(R),$(D,e),e&&a(N),e&&a(V),e&&a(j),e&&a(me),e&&a($e),$(ie,e),e&&a(P),e&&a(B),e&&a(Je),$(I,e),e&&a(K),e&&a(ee),e&&a(te),e&&a(A),$(x),e&&a(z),e&&a(k),e&&a(Ne),e&&a(q),e&&a(Ze),e&&a(De),e&&a(dt),e&&a(Q),$(Se),e&&a(Pe),e&&a(He),e&&a(wt),$(ce,e),e&&a(_t),e&&a(We),$(gt),e&&a(ua),e&&a(Xt),e&&a(ma),$(yt,e),e&&a(da),e&&a(ke),e&&a(wa),e&&a(lt),e&&a(_a),$(Mt,e),e&&a(ga),e&&a(ze),$(bt),e&&a(ya),$(rt,e),e&&a(Ma),e&&a(qe),$(Tt),e&&a(ba),e&&a(Ve),e&&a(Ta),e&&a(nt),e&&a(Ja),e&&a(Ye),e&&a(Ua),e&&a(Zt),e&&a(va),e&&a(Le),e&&a($a),$(it,e),e&&a(Ea),e&&a(Oe),$(Et),e&&a(ja),e&&a(ht),e&&a(Wa),e&&a(Ke),$(jt),e&&a(ka),e&&a(ct),e&&a(Ra),$(ut,e)}}}const nr={local:"texttoimage",sections:[{local:"hardware-requirements",title:"Hardware requirements"},{local:"upload-model-to-hub",title:"Upload model to Hub"},{local:"save-and-load-checkpoints",title:"Save and load checkpoints"},{local:"finetuning",sections:[{local:"training-with-multiple-gpus",title:"Training with multiple GPUs"}],title:"Fine-tuning"},{local:"training-with-minsnr-weighting",title:"Training with Min-SNR weighting"},{local:"lora",title:"LoRA"},{local:"inference",title:"Inference"}],title:"Text-to-image"};function ir(X){return Ho(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class mr extends Lo{constructor(p){super();Qo(this,p,ir,sr,Do,{})}}export{mr as default,nr as metadata};
