import{S as Sn,i as zn,s as xn,e as o,k as c,w as u,t as a,M as Yn,c as i,d as t,m as f,a as r,x as m,h as s,b as h,G as l,g as p,y as d,L as Qn,q as w,o as M,B as y,v as Hn}from"../../chunks/vendor-hf-doc-builder.js";import{I as N}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as U}from"../../chunks/CodeBlock-hf-doc-builder.js";function Ln(Oi){let Z,Cl,C,Q,It,me,ps,Nt,cs,Wl,W,de,fs,hs,Zt,us,ms,Xl,H,ds,we,ws,Ms,Rl,X,L,Ct,Me,ys,Wt,_s,$l,R,D,Xt,ye,bs,Rt,Us,Vl,st,Js,Gl,ot,$t,Ts,kl,q,vs,Vt,Es,gs,Al,_e,Fl,be,js,Ue,Is,Bl,Je,Sl,it,Ns,zl,Te,xl,P,Zs,ve,Cs,Ws,Yl,Ee,Ql,rt,Xs,Hl,ge,Ll,nt,Rs,Dl,je,ql,$,O,Gt,Ie,$s,kt,Vs,Pl,v,Gs,Ne,ks,As,pt,Fs,Bs,Ol,_,Ss,At,zs,xs,Ft,Ys,Qs,Bt,Hs,Ls,St,Ds,qs,zt,Ps,Os,xt,Ks,eo,Yt,to,lo,Qt,ao,so,Kl,Ze,ea,ct,Ht,Lt,V,oo,Dt,io,ro,Ce,no,po,ta,K,co,qt,fo,ho,la,We,aa,ft,G,uo,Pt,mo,wo,Xe,Mo,yo,sa,ee,_o,Ot,bo,Uo,oa,E,k,Jo,Kt,To,vo,el,Eo,go,jo,Re,Io,tl,No,Zo,Co,J,Wo,ll,Xo,Ro,al,$o,Vo,sl,Go,ko,$e,ol,il,Ao,Fo,rl,nl,Bo,ia,ht,So,ra,Ve,na,te,zo,Ge,xo,Yo,pa,g,Qo,pl,Ho,Lo,ke,Do,qo,ca,A,le,cl,Ae,Po,fl,Oo,fa,j,Ko,Fe,ei,ti,Be,li,ai,ha,ut,si,ua,Se,ma,mt,oi,da,ze,wa,ae,ii,xe,ri,ni,Ma,F,se,hl,Ye,pi,ul,ci,ya,T,fi,ml,hi,ui,dl,mi,di,wl,wi,Mi,_a,dt,yi,ba,Qe,Ua,wt,_i,Ja,He,Ta,B,oe,Ml,Le,bi,yl,Ui,va,ie,Ji,_l,Ti,vi,Ea,De,ga,Mt,Ei,ja,qe,Ia,yt,gi,Na,Pe,Za,I,ji,bl,Ii,Ni,Ul,Zi,Ci,Ca,S,re,Jl,Oe,Wi,Tl,Xi,Wa,ne,Ri,vl,$i,Vi,Xa,_t,Gi,Ra,z,pe,El,Ke,ki,gl,Ai,$a,ce,Fi,jl,Bi,Si,Va,et,zi,tt,xi,Ga,x,fe,Il,lt,Yi,Nl,Qi,ka,he,Hi,at,Li,Di,Aa;return me=new N({}),Me=new N({}),ye=new N({}),_e=new U({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC1lJTIwLg==",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install -e .`}}),Je=new U({props:{code:"Y2QlMjBleGFtcGxlcyUyRmN1c3RvbV9kaWZmdXNpb24=",highlighted:'<span class="hljs-built_in">cd</span> examples/custom_diffusion'}}),Te=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dCUwQXBpcCUyMGluc3RhbGwlMjBjbGlwLXJldHJpZXZhbCUyMA==",highlighted:`pip install -r requirements.txt
pip install clip-retrieval `}}),Ee=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),ge=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),je=new U({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`}}),Ie=new N({}),Ze=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGNsaXAtcmV0cmlldmFsJTBBcHl0aG9uJTIwcmV0cmlldmUucHklMjAtLWNsYXNzX3Byb21wdCUyMGNhdCUyMC0tY2xhc3NfZGF0YV9kaXIlMjByZWFsX3JlZyUyRnNhbXBsZXNfY2F0JTIwLS1udW1fY2xhc3NfaW1hZ2VzJTIwMjAw",highlighted:`pip install clip-retrieval
python retrieve.py --class_prompt <span class="hljs-built_in">cat</span> --class_data_dir real_reg/samples_cat --num_class_images 200`}}),We=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBZXhwb3J0JTIwSU5TVEFOQ0VfRElSJTNEJTIyLiUyRmRhdGElMkZjYXQlMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fY3VzdG9tX2RpZmZ1c2lvbi5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9kYXRhX2RpciUzRCUyNElOU1RBTkNFX0RJUiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX2RhdGFfZGlyJTNELiUyRnJlYWxfcmVnJTJGc2FtcGxlc19jYXQlMkYlMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwLS1yZWFsX3ByaW9yJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIyY2F0JTIyJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJwaG90byUyMG9mJTIwYSUyMCUzQ25ldzElM0UlMjBjYXQlMjIlMjAlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QyJTIwJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMWUtNSUyMCUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMjUwJTIwJTVDJTBBJTIwJTIwLS1zY2FsZV9sciUyMC0taGZsaXAlMjAlMjAlNUMlMEElMjAlMjAtLW1vZGlmaWVyX3Rva2VuJTIwJTIyJTNDbmV3MSUzRSUyMiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",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> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./data/cat&quot;</span>

accelerate launch train_custom_diffusion.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> \\
  --class_data_dir=./real_reg/samples_cat/ \\
  --with_prior_preservation --real_prior --prior_loss_weight=1.0 \\
  --class_prompt=<span class="hljs-string">&quot;cat&quot;</span> --num_class_images=200 \\
  --instance_prompt=<span class="hljs-string">&quot;photo of a &lt;new1&gt; cat&quot;</span>  \\
  --resolution=512  \\
  --train_batch_size=2  \\
  --learning_rate=1e-5  \\
  --lr_warmup_steps=0 \\
  --max_train_steps=250 \\
  --scale_lr --hflip  \\
  --modifier_token <span class="hljs-string">&quot;&lt;new1&gt;&quot;</span> \\
  --push_to_hub`}}),Ve=new U({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2N1c3RvbV9kaWZmdXNpb24ucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19kYXRhX2RpciUzRC4lMkZyZWFsX3JlZyUyRnNhbXBsZXNfY2F0JTJGJTIwJTVDJTBBJTIwJTIwLS13aXRoX3ByaW9yX3ByZXNlcnZhdGlvbiUyMC0tcmVhbF9wcmlvciUyMC0tcHJpb3JfbG9zc193ZWlnaHQlM0QxLjAlMjAlNUMlMEElMjAlMjAtLWNsYXNzX3Byb21wdCUzRCUyMmNhdCUyMiUyMC0tbnVtX2NsYXNzX2ltYWdlcyUzRDIwMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIycGhvdG8lMjBvZiUyMGElMjAlM0NuZXcxJTNFJTIwY2F0JTIyJTIwJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMiUyMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTUlMjAlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDI1MCUyMCU1QyUwQSUyMCUyMC0tc2NhbGVfbHIlMjAtLWhmbGlwJTIwJTIwJTVDJTBBJTIwJTIwLS1tb2RpZmllcl90b2tlbiUyMCUyMiUzQ25ldzElM0UlMjIlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyJTNDbmV3MSUzRSUyMGNhdCUyMHNpdHRpbmclMjBpbiUyMGElMjBidWNrZXQlMjIlMjAlNUMlMEElMjAlMjAtLXJlcG9ydF90byUzRCUyMndhbmRiJTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch train_custom_diffusion.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> \\
  --class_data_dir=./real_reg/samples_cat/ \\
  --with_prior_preservation --real_prior --prior_loss_weight=1.0 \\
  --class_prompt=<span class="hljs-string">&quot;cat&quot;</span> --num_class_images=200 \\
  --instance_prompt=<span class="hljs-string">&quot;photo of a &lt;new1&gt; cat&quot;</span>  \\
  --resolution=512  \\
  --train_batch_size=2  \\
  --learning_rate=1e-5  \\
  --lr_warmup_steps=0 \\
  --max_train_steps=250 \\
  --scale_lr --hflip  \\
  --modifier_token <span class="hljs-string">&quot;&lt;new1&gt;&quot;</span> \\
  --validation_prompt=<span class="hljs-string">&quot;&lt;new1&gt; cat sitting in a bucket&quot;</span> \\
  --report_to=<span class="hljs-string">&quot;wandb&quot;</span> \\
  --push_to_hub`}}),Ae=new N({}),Se=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGNsaXAtcmV0cmlldmFsJTBBcHl0aG9uJTIwcmV0cmlldmUucHklMjAtLWNsYXNzX3Byb21wdCUyMCU3QiU3RCUyMC0tY2xhc3NfZGF0YV9kaXIlMjAlN0IlN0QlMjAtLW51bV9jbGFzc19pbWFnZXMlMjAyMDA=",highlighted:`pip install clip-retrieval
python retrieve.py --class_prompt {} --class_data_dir {} --num_class_images 200`}}),ze=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2N1c3RvbV9kaWZmdXNpb24ucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLWNvbmNlcHRzX2xpc3QlM0QuJTJGY29uY2VwdF9saXN0Lmpzb24lMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwLS1yZWFsX3ByaW9yJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDIlMjAlMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS01JTIwJTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q1MDAlMjAlNUMlMEElMjAlMjAtLW51bV9jbGFzc19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLXNjYWxlX2xyJTIwLS1oZmxpcCUyMCUyMCU1QyUwQSUyMCUyMC0tbW9kaWZpZXJfdG9rZW4lMjAlMjIlM0NuZXcxJTNFJTJCJTNDbmV3MiUzRSUyMiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",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> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

accelerate launch train_custom_diffusion.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --concepts_list=./concept_list.json \\
  --with_prior_preservation --real_prior --prior_loss_weight=1.0 \\
  --resolution=512  \\
  --train_batch_size=2  \\
  --learning_rate=1e-5  \\
  --lr_warmup_steps=0 \\
  --max_train_steps=500 \\
  --num_class_images=200 \\
  --scale_lr --hflip  \\
  --modifier_token <span class="hljs-string">&quot;&lt;new1&gt;+&lt;new2&gt;&quot;</span> \\
  --push_to_hub`}}),Ye=new N({}),Qe=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGNsaXAtcmV0cmlldmFsJTBBcHl0aG9uJTIwcmV0cmlldmUucHklMjAtLWNsYXNzX3Byb21wdCUyMHBlcnNvbiUyMC0tY2xhc3NfZGF0YV9kaXIlMjByZWFsX3JlZyUyRnNhbXBsZXNfcGVyc29uJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTIwMjAw",highlighted:`pip install clip-retrieval
python retrieve.py --class_prompt person --class_data_dir real_reg/samples_person --num_class_images 200`}}),He=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBZXhwb3J0JTIwSU5TVEFOQ0VfRElSJTNEJTIycGF0aC10by1pbWFnZXMlMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fY3VzdG9tX2RpZmZ1c2lvbi5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9kYXRhX2RpciUzRCUyNElOU1RBTkNFX0RJUiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX2RhdGFfZGlyJTNELiUyRnJlYWxfcmVnJTJGc2FtcGxlc19wZXJzb24lMkYlMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwLS1yZWFsX3ByaW9yJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIycGVyc29uJTIyJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJwaG90byUyMG9mJTIwYSUyMCUzQ25ldzElM0UlMjBwZXJzb24lMjIlMjAlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QyJTIwJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMTAwMCUyMCU1QyUwQSUyMCUyMC0tc2NhbGVfbHIlMjAtLWhmbGlwJTIwLS1ub2F1ZyUyMCU1QyUwQSUyMCUyMC0tZnJlZXplX21vZGVsJTIwY3Jvc3NhdHRuJTIwJTVDJTBBJTIwJTIwLS1tb2RpZmllcl90b2tlbiUyMCUyMiUzQ25ldzElM0UlMjIlMjAlNUMlMEElMjAlMjAtLWVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",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> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;path-to-images&quot;</span>

accelerate launch train_custom_diffusion.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> \\
  --class_data_dir=./real_reg/samples_person/ \\
  --with_prior_preservation --real_prior --prior_loss_weight=1.0 \\
  --class_prompt=<span class="hljs-string">&quot;person&quot;</span> --num_class_images=200 \\
  --instance_prompt=<span class="hljs-string">&quot;photo of a &lt;new1&gt; person&quot;</span>  \\
  --resolution=512  \\
  --train_batch_size=2  \\
  --learning_rate=5e-6  \\
  --lr_warmup_steps=0 \\
  --max_train_steps=1000 \\
  --scale_lr --hflip --noaug \\
  --freeze_model crossattn \\
  --modifier_token <span class="hljs-string">&quot;&lt;new1&gt;&quot;</span> \\
  --enable_xformers_memory_efficient_attention \\
  --push_to_hub`}}),Le=new N({}),De=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZS51bmV0LmxvYWRfYXR0bl9wcm9jcyglMjJwYXRoLXRvLXNhdmUtbW9kZWwlMjIlMkMlMjB3ZWlnaHRfbmFtZSUzRCUyMnB5dG9yY2hfY3VzdG9tX2RpZmZ1c2lvbl93ZWlnaHRzLmJpbiUyMiklMEFwaXBlLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjIlM0NuZXcxJTNFLmJpbiUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwJTIyJTNDbmV3MSUzRSUyMGNhdCUyMHNpdHRpbmclMjBpbiUyMGElMjBidWNrZXQlMjIlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q2LjAlMkMlMEElMjAlMjAlMjAlMjBldGElM0QxLjAlMkMlMEEpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmNhdC5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.load_attn_procs(<span class="hljs-string">&quot;path-to-save-model&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_custom_diffusion_weights.bin&quot;</span>)
pipe.load_textual_inversion(<span class="hljs-string">&quot;path-to-save-model&quot;</span>, weight_name=<span class="hljs-string">&quot;&lt;new1&gt;.bin&quot;</span>)

image = pipe(
    <span class="hljs-string">&quot;&lt;new1&gt; cat sitting in a bucket&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
    guidance_scale=<span class="hljs-number">6.0</span>,
    eta=<span class="hljs-number">1.0</span>,
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat.png&quot;</span>)`}}),qe=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViLnJlcG9jYXJkJTIwaW1wb3J0JTIwUmVwb0NhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRmN1c3RvbS1kaWZmdXNpb24tY2F0JTIyJTBBY2FyZCUyMCUzRCUyMFJlcG9DYXJkLmxvYWQobW9kZWxfaWQpJTBBYmFzZV9tb2RlbF9pZCUyMCUzRCUyMGNhcmQuZGF0YS50b19kaWN0KCklNUIlMjJiYXNlX21vZGVsJTIyJTVEJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMjJjdWRhJTIyKSUwQXBpcGUudW5ldC5sb2FkX2F0dG5fcHJvY3MobW9kZWxfaWQlMkMlMjB3ZWlnaHRfbmFtZSUzRCUyMnB5dG9yY2hfY3VzdG9tX2RpZmZ1c2lvbl93ZWlnaHRzLmJpbiUyMiklMEFwaXBlLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24obW9kZWxfaWQlMkMlMjB3ZWlnaHRfbmFtZSUzRCUyMiUzQ25ldzElM0UuYmluJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjIlM0NuZXcxJTNFJTIwY2F0JTIwc2l0dGluZyUyMGluJTIwYSUyMGJ1Y2tldCUyMiUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDYuMCUyQyUwQSUyMCUyMCUyMCUyMGV0YSUzRDEuMCUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyY2F0LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

model_id = <span class="hljs-string">&quot;sayakpaul/custom-diffusion-cat&quot;</span>
card = RepoCard.load(model_id)
base_model_id = card.data.to_dict()[<span class="hljs-string">&quot;base_model&quot;</span>]

pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.load_attn_procs(model_id, weight_name=<span class="hljs-string">&quot;pytorch_custom_diffusion_weights.bin&quot;</span>)
pipe.load_textual_inversion(model_id, weight_name=<span class="hljs-string">&quot;&lt;new1&gt;.bin&quot;</span>)

image = pipe(
    <span class="hljs-string">&quot;&lt;new1&gt; cat sitting in a bucket&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
    guidance_scale=<span class="hljs-number">6.0</span>,
    eta=<span class="hljs-number">1.0</span>,
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat.png&quot;</span>)`}}),Pe=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViLnJlcG9jYXJkJTIwaW1wb3J0JTIwUmVwb0NhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRmN1c3RvbS1kaWZmdXNpb24tY2F0LXdvb2Rlbi1wb3QlMjIlMEFjYXJkJTIwJTNEJTIwUmVwb0NhcmQubG9hZChtb2RlbF9pZCklMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwY2FyZC5kYXRhLnRvX2RpY3QoKSU1QiUyMmJhc2VfbW9kZWwlMjIlNUQlMEElMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZS51bmV0LmxvYWRfYXR0bl9wcm9jcyhtb2RlbF9pZCUyQyUyMHdlaWdodF9uYW1lJTNEJTIycHl0b3JjaF9jdXN0b21fZGlmZnVzaW9uX3dlaWdodHMuYmluJTIyKSUwQXBpcGUubG9hZF90ZXh0dWFsX2ludmVyc2lvbihtb2RlbF9pZCUyQyUyMHdlaWdodF9uYW1lJTNEJTIyJTNDbmV3MSUzRS5iaW4lMjIpJTBBcGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKG1vZGVsX2lkJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjIlM0NuZXcyJTNFLmJpbiUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwJTIydGhlJTIwJTNDbmV3MSUzRSUyMGNhdCUyMHNjdWxwdHVyZSUyMGluJTIwdGhlJTIwc3R5bGUlMjBvZiUyMGElMjAlM0NuZXcyJTNFJTIwd29vZGVuJTIwcG90JTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNENi4wJTJDJTBBJTIwJTIwJTIwJTIwZXRhJTNEMS4wJTJDJTBBKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJtdWx0aS1zdWJqZWN0LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

model_id = <span class="hljs-string">&quot;sayakpaul/custom-diffusion-cat-wooden-pot&quot;</span>
card = RepoCard.load(model_id)
base_model_id = card.data.to_dict()[<span class="hljs-string">&quot;base_model&quot;</span>]

pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.unet.load_attn_procs(model_id, weight_name=<span class="hljs-string">&quot;pytorch_custom_diffusion_weights.bin&quot;</span>)
pipe.load_textual_inversion(model_id, weight_name=<span class="hljs-string">&quot;&lt;new1&gt;.bin&quot;</span>)
pipe.load_textual_inversion(model_id, weight_name=<span class="hljs-string">&quot;&lt;new2&gt;.bin&quot;</span>)

image = pipe(
    <span class="hljs-string">&quot;the &lt;new1&gt; cat sculpture in the style of a &lt;new2&gt; wooden pot&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
    guidance_scale=<span class="hljs-number">6.0</span>,
    eta=<span class="hljs-number">1.0</span>,
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;multi-subject.png&quot;</span>)`}}),Oe=new N({}),Ke=new N({}),lt=new N({}),{c(){Z=o("meta"),Cl=c(),C=o("h1"),Q=o("a"),It=o("span"),u(me.$$.fragment),ps=c(),Nt=o("span"),cs=a("Custom Diffusion training example"),Wl=c(),W=o("p"),de=o("a"),fs=a("Custom Diffusion"),hs=a(` is a method to customize text-to-image models like Stable Diffusion given just a few (4~5) images of a subject.
The `),Zt=o("code"),us=a("train_custom_diffusion.py"),ms=a(" script shows how to implement the training procedure and adapt it for stable diffusion."),Xl=c(),H=o("p"),ds=a("This training example was contributed by "),we=o("a"),ws=a("Nupur Kumari"),Ms=a(" (one of the authors of Custom Diffusion)."),Rl=c(),X=o("h2"),L=o("a"),Ct=o("span"),u(Me.$$.fragment),ys=c(),Wt=o("span"),_s=a("Running locally with PyTorch"),$l=c(),R=o("h3"),D=o("a"),Xt=o("span"),u(ye.$$.fragment),bs=c(),Rt=o("span"),Us=a("Installing the dependencies"),Vl=c(),st=o("p"),Js=a("Before running the scripts, make sure to install the library\u2019s training dependencies:"),Gl=c(),ot=o("p"),$t=o("strong"),Ts=a("Important"),kl=c(),q=o("p"),vs=a("To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),Vt=o("strong"),Es=a("installing from source"),gs=a(" and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),Al=c(),u(_e.$$.fragment),Fl=c(),be=o("p"),js=a("Then cd into the "),Ue=o("a"),Is=a("example folder"),Bl=c(),u(Je.$$.fragment),Sl=c(),it=o("p"),Ns=a("Now run"),zl=c(),u(Te.$$.fragment),xl=c(),P=o("p"),Zs=a("And initialize an "),ve=o("a"),Cs=a("\u{1F917}Accelerate"),Ws=a(" environment with:"),Yl=c(),u(Ee.$$.fragment),Ql=c(),rt=o("p"),Xs=a("Or for a default accelerate configuration without answering questions about your environment"),Hl=c(),u(ge.$$.fragment),Ll=c(),nt=o("p"),Rs=a("Or if your environment doesn\u2019t support an interactive shell e.g. a notebook"),Dl=c(),u(je.$$.fragment),ql=c(),$=o("h3"),O=o("a"),Gt=o("span"),u(Ie.$$.fragment),$s=c(),kt=o("span"),Vs=a("Cat example \u{1F63A}"),Pl=c(),v=o("p"),Gs=a("Now let\u2019s get our dataset. Download dataset from "),Ne=o("a"),ks=a("here"),As=a(" and unzip it. To use your own dataset, take a look at the "),pt=o("a"),Fs=a("Create a dataset for training"),Bs=a(" guide."),Ol=c(),_=o("p"),Ss=a("We also collect 200 real images using "),At=o("code"),zs=a("clip-retrieval"),xs=a(" which are combined with the target images in the training dataset as a regularization. This prevents overfitting to the the given target image. The following flags enable the regularization "),Ft=o("code"),Ys=a("with_prior_preservation"),Qs=a(", "),Bt=o("code"),Hs=a("real_prior"),Ls=a(" with "),St=o("code"),Ds=a("prior_loss_weight=1."),qs=a(`.
The `),zt=o("code"),Ps=a("class_prompt"),Os=a(" should be the category name same as target image. The collected real images are with text captions similar to the "),xt=o("code"),Ks=a("class_prompt"),eo=a(". The retrieved image are saved in "),Yt=o("code"),to=a("class_data_dir"),lo=a(". You can disable "),Qt=o("code"),ao=a("real_prior"),so=a(" to use generated images as regularization. To collect the real images use this command first before training."),Kl=c(),u(Ze.$$.fragment),ea=c(),ct=o("p"),Ht=o("strong"),Lt=o("strong"),V=o("em"),oo=a("Note: Change the "),Dt=o("code"),io=a("resolution"),ro=a(" to 768 if you are using the "),Ce=o("a"),no=a("stable-diffusion-2"),po=a(" 768x768 model."),ta=c(),K=o("p"),co=a("The script creates and saves model checkpoints and a "),qt=o("code"),fo=a("pytorch_custom_diffusion_weights.bin"),ho=a(" file in your repository."),la=c(),u(We.$$.fragment),aa=c(),ft=o("p"),G=o("strong"),uo=a("Use "),Pt=o("code"),mo=a("--enable_xformers_memory_efficient_attention"),wo=a(" for faster training with lower VRAM requirement (16GB per GPU). Follow "),Xe=o("a"),Mo=a("this guide"),yo=a(" for installation instructions."),sa=c(),ee=o("p"),_o=a("To track your experiments using Weights and Biases ("),Ot=o("code"),bo=a("wandb"),Uo=a(") and to save intermediate results (whcih we HIGHLY recommend), follow these steps:"),oa=c(),E=o("ul"),k=o("li"),Jo=a("Install "),Kt=o("code"),To=a("wandb"),vo=a(": "),el=o("code"),Eo=a("pip install wandb"),go=a("."),jo=c(),Re=o("li"),Io=a("Authorize: "),tl=o("code"),No=a("wandb login"),Zo=a("."),Co=c(),J=o("li"),Wo=a("Then specify a "),ll=o("code"),Xo=a("validation_prompt"),Ro=a(" and set "),al=o("code"),$o=a("report_to"),Vo=a(" to "),sl=o("code"),Go=a("wandb"),ko=a(" while launching training. You can also configure the following related arguments:"),$e=o("ul"),ol=o("li"),il=o("code"),Ao=a("num_validation_images"),Fo=c(),rl=o("li"),nl=o("code"),Bo=a("validation_steps"),ia=c(),ht=o("p"),So=a("Here is an example command:"),ra=c(),u(Ve.$$.fragment),na=c(),te=o("p"),zo=a("Here is an example "),Ge=o("a"),xo=a("Weights and Biases page"),Yo=a(" where you can check out the intermediate results along with other training details."),pa=c(),g=o("p"),Qo=a("If you specify "),pl=o("code"),Ho=a("--push_to_hub"),Lo=a(", the learned parameters will be pushed to a repository on the Hugging Face Hub. Here is an "),ke=o("a"),Do=a("example repository"),qo=a("."),ca=c(),A=o("h3"),le=o("a"),cl=o("span"),u(Ae.$$.fragment),Po=c(),fl=o("span"),Oo=a("Training on multiple concepts \u{1F431}\u{1FAB5}"),fa=c(),j=o("p"),Ko=a("Provide a "),Fe=o("a"),ei=a("json"),ti=a(" file with the info about each concept, similar to "),Be=o("a"),li=a("this"),ai=a("."),ha=c(),ut=o("p"),si=a("To collect the real images run this command for each concept in the json file."),ua=c(),u(Se.$$.fragment),ma=c(),mt=o("p"),oi=a("And then we\u2019re ready to start training!"),da=c(),u(ze.$$.fragment),wa=c(),ae=o("p"),ii=a("Here is an example "),xe=o("a"),ri=a("Weights and Biases page"),ni=a(" where you can check out the intermediate results along with other training details."),Ma=c(),F=o("h3"),se=o("a"),hl=o("span"),u(Ye.$$.fragment),pi=c(),ul=o("span"),ci=a("Training on human faces"),ya=c(),T=o("p"),fi=a("For fine-tuning on human faces we found the following configuration to work better: "),ml=o("code"),hi=a("learning_rate=5e-6"),ui=a(", "),dl=o("code"),mi=a("max_train_steps=1000 to 2000"),di=a(", and "),wl=o("code"),wi=a("freeze_model=crossattn"),Mi=a(" with at least 15-20 images."),_a=c(),dt=o("p"),yi=a("To collect the real images use this command first before training."),ba=c(),u(Qe.$$.fragment),Ua=c(),wt=o("p"),_i=a("Then start training!"),Ja=c(),u(He.$$.fragment),Ta=c(),B=o("h2"),oe=o("a"),Ml=o("span"),u(Le.$$.fragment),bi=c(),yl=o("span"),Ui=a("Inference"),va=c(),ie=o("p"),Ji=a("Once you have trained a model using the above command, you can run inference using the below command. Make sure to include the "),_l=o("code"),Ti=a("modifier token"),vi=a(" (e.g. \\<new1> in above example) in your prompt."),Ea=c(),u(De.$$.fragment),ga=c(),Mt=o("p"),Ei=a("It\u2019s possible to directly load these parameters from a Hub repository:"),ja=c(),u(qe.$$.fragment),Ia=c(),yt=o("p"),gi=a("Here is an example of performing inference with multiple concepts:"),Na=c(),u(Pe.$$.fragment),Za=c(),I=o("p"),ji=a("Here, "),bl=o("code"),Ii=a("cat"),Ni=a(" and "),Ul=o("code"),Zi=a("wooden pot"),Ci=a(" refer to the multiple concepts."),Ca=c(),S=o("h3"),re=o("a"),Jl=o("span"),u(Oe.$$.fragment),Wi=c(),Tl=o("span"),Xi=a("Inference from a training checkpoint"),Wa=c(),ne=o("p"),Ri=a("You can also perform inference from one of the complete checkpoint saved during the training process, if you used the "),vl=o("code"),$i=a("--checkpointing_steps"),Vi=a(" argument."),Xa=c(),_t=o("p"),Gi=a("TODO."),Ra=c(),z=o("h2"),pe=o("a"),El=o("span"),u(Ke.$$.fragment),ki=c(),gl=o("span"),Ai=a("Set grads to none"),$a=c(),ce=o("p"),Fi=a("To save even more memory, pass the "),jl=o("code"),Bi=a("--set_grads_to_none"),Si=a(" argument to the script. This will set grads to None instead of zero. However, be aware that it changes certain behaviors, so if you start experiencing any problems, remove this argument."),Va=c(),et=o("p"),zi=a("More info: "),tt=o("a"),xi=a("https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html"),Ga=c(),x=o("h2"),fe=o("a"),Il=o("span"),u(lt.$$.fragment),Yi=c(),Nl=o("span"),Qi=a("Experimental results"),ka=c(),he=o("p"),Hi=a("You can refer to "),at=o("a"),Li=a("our webpage"),Di=a(" that discusses our experiments in detail."),this.h()},l(e){const n=Yn('[data-svelte="svelte-1phssyn"]',document.head);Z=i(n,"META",{name:!0,content:!0}),n.forEach(t),Cl=f(e),C=i(e,"H1",{class:!0});var Fa=r(C);Q=i(Fa,"A",{id:!0,class:!0,href:!0});var Ki=r(Q);It=i(Ki,"SPAN",{});var er=r(It);m(me.$$.fragment,er),er.forEach(t),Ki.forEach(t),ps=f(Fa),Nt=i(Fa,"SPAN",{});var tr=r(Nt);cs=s(tr,"Custom Diffusion training example"),tr.forEach(t),Fa.forEach(t),Wl=f(e),W=i(e,"P",{});var Zl=r(W);de=i(Zl,"A",{href:!0,rel:!0});var lr=r(de);fs=s(lr,"Custom Diffusion"),lr.forEach(t),hs=s(Zl,` is a method to customize text-to-image models like Stable Diffusion given just a few (4~5) images of a subject.
The `),Zt=i(Zl,"CODE",{});var ar=r(Zt);us=s(ar,"train_custom_diffusion.py"),ar.forEach(t),ms=s(Zl," script shows how to implement the training procedure and adapt it for stable diffusion."),Zl.forEach(t),Xl=f(e),H=i(e,"P",{});var Ba=r(H);ds=s(Ba,"This training example was contributed by "),we=i(Ba,"A",{href:!0,rel:!0});var sr=r(we);ws=s(sr,"Nupur Kumari"),sr.forEach(t),Ms=s(Ba," (one of the authors of Custom Diffusion)."),Ba.forEach(t),Rl=f(e),X=i(e,"H2",{class:!0});var Sa=r(X);L=i(Sa,"A",{id:!0,class:!0,href:!0});var or=r(L);Ct=i(or,"SPAN",{});var ir=r(Ct);m(Me.$$.fragment,ir),ir.forEach(t),or.forEach(t),ys=f(Sa),Wt=i(Sa,"SPAN",{});var rr=r(Wt);_s=s(rr,"Running locally with PyTorch"),rr.forEach(t),Sa.forEach(t),$l=f(e),R=i(e,"H3",{class:!0});var za=r(R);D=i(za,"A",{id:!0,class:!0,href:!0});var nr=r(D);Xt=i(nr,"SPAN",{});var pr=r(Xt);m(ye.$$.fragment,pr),pr.forEach(t),nr.forEach(t),bs=f(za),Rt=i(za,"SPAN",{});var cr=r(Rt);Us=s(cr,"Installing the dependencies"),cr.forEach(t),za.forEach(t),Vl=f(e),st=i(e,"P",{});var fr=r(st);Js=s(fr,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),fr.forEach(t),Gl=f(e),ot=i(e,"P",{});var hr=r(ot);$t=i(hr,"STRONG",{});var ur=r($t);Ts=s(ur,"Important"),ur.forEach(t),hr.forEach(t),kl=f(e),q=i(e,"P",{});var xa=r(q);vs=s(xa,"To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),Vt=i(xa,"STRONG",{});var mr=r(Vt);Es=s(mr,"installing from source"),mr.forEach(t),gs=s(xa," and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),xa.forEach(t),Al=f(e),m(_e.$$.fragment,e),Fl=f(e),be=i(e,"P",{});var qi=r(be);js=s(qi,"Then cd into the "),Ue=i(qi,"A",{href:!0,rel:!0});var dr=r(Ue);Is=s(dr,"example folder"),dr.forEach(t),qi.forEach(t),Bl=f(e),m(Je.$$.fragment,e),Sl=f(e),it=i(e,"P",{});var wr=r(it);Ns=s(wr,"Now run"),wr.forEach(t),zl=f(e),m(Te.$$.fragment,e),xl=f(e),P=i(e,"P",{});var Ya=r(P);Zs=s(Ya,"And initialize an "),ve=i(Ya,"A",{href:!0,rel:!0});var Mr=r(ve);Cs=s(Mr,"\u{1F917}Accelerate"),Mr.forEach(t),Ws=s(Ya," environment with:"),Ya.forEach(t),Yl=f(e),m(Ee.$$.fragment,e),Ql=f(e),rt=i(e,"P",{});var yr=r(rt);Xs=s(yr,"Or for a default accelerate configuration without answering questions about your environment"),yr.forEach(t),Hl=f(e),m(ge.$$.fragment,e),Ll=f(e),nt=i(e,"P",{});var _r=r(nt);Rs=s(_r,"Or if your environment doesn\u2019t support an interactive shell e.g. a notebook"),_r.forEach(t),Dl=f(e),m(je.$$.fragment,e),ql=f(e),$=i(e,"H3",{class:!0});var Qa=r($);O=i(Qa,"A",{id:!0,class:!0,href:!0});var br=r(O);Gt=i(br,"SPAN",{});var Ur=r(Gt);m(Ie.$$.fragment,Ur),Ur.forEach(t),br.forEach(t),$s=f(Qa),kt=i(Qa,"SPAN",{});var Jr=r(kt);Vs=s(Jr,"Cat example \u{1F63A}"),Jr.forEach(t),Qa.forEach(t),Pl=f(e),v=i(e,"P",{});var bt=r(v);Gs=s(bt,"Now let\u2019s get our dataset. Download dataset from "),Ne=i(bt,"A",{href:!0,rel:!0});var Tr=r(Ne);ks=s(Tr,"here"),Tr.forEach(t),As=s(bt," and unzip it. To use your own dataset, take a look at the "),pt=i(bt,"A",{href:!0});var vr=r(pt);Fs=s(vr,"Create a dataset for training"),vr.forEach(t),Bs=s(bt," guide."),bt.forEach(t),Ol=f(e),_=i(e,"P",{});var b=r(_);Ss=s(b,"We also collect 200 real images using "),At=i(b,"CODE",{});var Er=r(At);zs=s(Er,"clip-retrieval"),Er.forEach(t),xs=s(b," which are combined with the target images in the training dataset as a regularization. This prevents overfitting to the the given target image. The following flags enable the regularization "),Ft=i(b,"CODE",{});var gr=r(Ft);Ys=s(gr,"with_prior_preservation"),gr.forEach(t),Qs=s(b,", "),Bt=i(b,"CODE",{});var jr=r(Bt);Hs=s(jr,"real_prior"),jr.forEach(t),Ls=s(b," with "),St=i(b,"CODE",{});var Ir=r(St);Ds=s(Ir,"prior_loss_weight=1."),Ir.forEach(t),qs=s(b,`.
The `),zt=i(b,"CODE",{});var Nr=r(zt);Ps=s(Nr,"class_prompt"),Nr.forEach(t),Os=s(b," should be the category name same as target image. The collected real images are with text captions similar to the "),xt=i(b,"CODE",{});var Zr=r(xt);Ks=s(Zr,"class_prompt"),Zr.forEach(t),eo=s(b,". The retrieved image are saved in "),Yt=i(b,"CODE",{});var Cr=r(Yt);to=s(Cr,"class_data_dir"),Cr.forEach(t),lo=s(b,". You can disable "),Qt=i(b,"CODE",{});var Wr=r(Qt);ao=s(Wr,"real_prior"),Wr.forEach(t),so=s(b," to use generated images as regularization. To collect the real images use this command first before training."),b.forEach(t),Kl=f(e),m(Ze.$$.fragment,e),ea=f(e),ct=i(e,"P",{});var Xr=r(ct);Ht=i(Xr,"STRONG",{});var Rr=r(Ht);Lt=i(Rr,"STRONG",{});var $r=r(Lt);V=i($r,"EM",{});var Ut=r(V);oo=s(Ut,"Note: Change the "),Dt=i(Ut,"CODE",{});var Vr=r(Dt);io=s(Vr,"resolution"),Vr.forEach(t),ro=s(Ut," to 768 if you are using the "),Ce=i(Ut,"A",{href:!0,rel:!0});var Gr=r(Ce);no=s(Gr,"stable-diffusion-2"),Gr.forEach(t),po=s(Ut," 768x768 model."),Ut.forEach(t),$r.forEach(t),Rr.forEach(t),Xr.forEach(t),ta=f(e),K=i(e,"P",{});var Ha=r(K);co=s(Ha,"The script creates and saves model checkpoints and a "),qt=i(Ha,"CODE",{});var kr=r(qt);fo=s(kr,"pytorch_custom_diffusion_weights.bin"),kr.forEach(t),ho=s(Ha," file in your repository."),Ha.forEach(t),la=f(e),m(We.$$.fragment,e),aa=f(e),ft=i(e,"P",{});var Ar=r(ft);G=i(Ar,"STRONG",{});var Jt=r(G);uo=s(Jt,"Use "),Pt=i(Jt,"CODE",{});var Fr=r(Pt);mo=s(Fr,"--enable_xformers_memory_efficient_attention"),Fr.forEach(t),wo=s(Jt," for faster training with lower VRAM requirement (16GB per GPU). Follow "),Xe=i(Jt,"A",{href:!0,rel:!0});var Br=r(Xe);Mo=s(Br,"this guide"),Br.forEach(t),yo=s(Jt," for installation instructions."),Jt.forEach(t),Ar.forEach(t),sa=f(e),ee=i(e,"P",{});var La=r(ee);_o=s(La,"To track your experiments using Weights and Biases ("),Ot=i(La,"CODE",{});var Sr=r(Ot);bo=s(Sr,"wandb"),Sr.forEach(t),Uo=s(La,") and to save intermediate results (whcih we HIGHLY recommend), follow these steps:"),La.forEach(t),oa=f(e),E=i(e,"UL",{});var Tt=r(E);k=i(Tt,"LI",{});var vt=r(k);Jo=s(vt,"Install "),Kt=i(vt,"CODE",{});var zr=r(Kt);To=s(zr,"wandb"),zr.forEach(t),vo=s(vt,": "),el=i(vt,"CODE",{});var xr=r(el);Eo=s(xr,"pip install wandb"),xr.forEach(t),go=s(vt,"."),vt.forEach(t),jo=f(Tt),Re=i(Tt,"LI",{});var Da=r(Re);Io=s(Da,"Authorize: "),tl=i(Da,"CODE",{});var Yr=r(tl);No=s(Yr,"wandb login"),Yr.forEach(t),Zo=s(Da,"."),Da.forEach(t),Co=f(Tt),J=i(Tt,"LI",{});var Y=r(J);Wo=s(Y,"Then specify a "),ll=i(Y,"CODE",{});var Qr=r(ll);Xo=s(Qr,"validation_prompt"),Qr.forEach(t),Ro=s(Y," and set "),al=i(Y,"CODE",{});var Hr=r(al);$o=s(Hr,"report_to"),Hr.forEach(t),Vo=s(Y," to "),sl=i(Y,"CODE",{});var Lr=r(sl);Go=s(Lr,"wandb"),Lr.forEach(t),ko=s(Y," while launching training. You can also configure the following related arguments:"),$e=i(Y,"UL",{});var qa=r($e);ol=i(qa,"LI",{});var Dr=r(ol);il=i(Dr,"CODE",{});var qr=r(il);Ao=s(qr,"num_validation_images"),qr.forEach(t),Dr.forEach(t),Fo=f(qa),rl=i(qa,"LI",{});var Pr=r(rl);nl=i(Pr,"CODE",{});var Or=r(nl);Bo=s(Or,"validation_steps"),Or.forEach(t),Pr.forEach(t),qa.forEach(t),Y.forEach(t),Tt.forEach(t),ia=f(e),ht=i(e,"P",{});var Kr=r(ht);So=s(Kr,"Here is an example command:"),Kr.forEach(t),ra=f(e),m(Ve.$$.fragment,e),na=f(e),te=i(e,"P",{});var Pa=r(te);zo=s(Pa,"Here is an example "),Ge=i(Pa,"A",{href:!0,rel:!0});var en=r(Ge);xo=s(en,"Weights and Biases page"),en.forEach(t),Yo=s(Pa," where you can check out the intermediate results along with other training details."),Pa.forEach(t),pa=f(e),g=i(e,"P",{});var Et=r(g);Qo=s(Et,"If you specify "),pl=i(Et,"CODE",{});var tn=r(pl);Ho=s(tn,"--push_to_hub"),tn.forEach(t),Lo=s(Et,", the learned parameters will be pushed to a repository on the Hugging Face Hub. Here is an "),ke=i(Et,"A",{href:!0,rel:!0});var ln=r(ke);Do=s(ln,"example repository"),ln.forEach(t),qo=s(Et,"."),Et.forEach(t),ca=f(e),A=i(e,"H3",{class:!0});var Oa=r(A);le=i(Oa,"A",{id:!0,class:!0,href:!0});var an=r(le);cl=i(an,"SPAN",{});var sn=r(cl);m(Ae.$$.fragment,sn),sn.forEach(t),an.forEach(t),Po=f(Oa),fl=i(Oa,"SPAN",{});var on=r(fl);Oo=s(on,"Training on multiple concepts \u{1F431}\u{1FAB5}"),on.forEach(t),Oa.forEach(t),fa=f(e),j=i(e,"P",{});var gt=r(j);Ko=s(gt,"Provide a "),Fe=i(gt,"A",{href:!0,rel:!0});var rn=r(Fe);ei=s(rn,"json"),rn.forEach(t),ti=s(gt," file with the info about each concept, similar to "),Be=i(gt,"A",{href:!0,rel:!0});var nn=r(Be);li=s(nn,"this"),nn.forEach(t),ai=s(gt,"."),gt.forEach(t),ha=f(e),ut=i(e,"P",{});var pn=r(ut);si=s(pn,"To collect the real images run this command for each concept in the json file."),pn.forEach(t),ua=f(e),m(Se.$$.fragment,e),ma=f(e),mt=i(e,"P",{});var cn=r(mt);oi=s(cn,"And then we\u2019re ready to start training!"),cn.forEach(t),da=f(e),m(ze.$$.fragment,e),wa=f(e),ae=i(e,"P",{});var Ka=r(ae);ii=s(Ka,"Here is an example "),xe=i(Ka,"A",{href:!0,rel:!0});var fn=r(xe);ri=s(fn,"Weights and Biases page"),fn.forEach(t),ni=s(Ka," where you can check out the intermediate results along with other training details."),Ka.forEach(t),Ma=f(e),F=i(e,"H3",{class:!0});var es=r(F);se=i(es,"A",{id:!0,class:!0,href:!0});var hn=r(se);hl=i(hn,"SPAN",{});var un=r(hl);m(Ye.$$.fragment,un),un.forEach(t),hn.forEach(t),pi=f(es),ul=i(es,"SPAN",{});var mn=r(ul);ci=s(mn,"Training on human faces"),mn.forEach(t),es.forEach(t),ya=f(e),T=i(e,"P",{});var ue=r(T);fi=s(ue,"For fine-tuning on human faces we found the following configuration to work better: "),ml=i(ue,"CODE",{});var dn=r(ml);hi=s(dn,"learning_rate=5e-6"),dn.forEach(t),ui=s(ue,", "),dl=i(ue,"CODE",{});var wn=r(dl);mi=s(wn,"max_train_steps=1000 to 2000"),wn.forEach(t),di=s(ue,", and "),wl=i(ue,"CODE",{});var Mn=r(wl);wi=s(Mn,"freeze_model=crossattn"),Mn.forEach(t),Mi=s(ue," with at least 15-20 images."),ue.forEach(t),_a=f(e),dt=i(e,"P",{});var yn=r(dt);yi=s(yn,"To collect the real images use this command first before training."),yn.forEach(t),ba=f(e),m(Qe.$$.fragment,e),Ua=f(e),wt=i(e,"P",{});var _n=r(wt);_i=s(_n,"Then start training!"),_n.forEach(t),Ja=f(e),m(He.$$.fragment,e),Ta=f(e),B=i(e,"H2",{class:!0});var ts=r(B);oe=i(ts,"A",{id:!0,class:!0,href:!0});var bn=r(oe);Ml=i(bn,"SPAN",{});var Un=r(Ml);m(Le.$$.fragment,Un),Un.forEach(t),bn.forEach(t),bi=f(ts),yl=i(ts,"SPAN",{});var Jn=r(yl);Ui=s(Jn,"Inference"),Jn.forEach(t),ts.forEach(t),va=f(e),ie=i(e,"P",{});var ls=r(ie);Ji=s(ls,"Once you have trained a model using the above command, you can run inference using the below command. Make sure to include the "),_l=i(ls,"CODE",{});var Tn=r(_l);Ti=s(Tn,"modifier token"),Tn.forEach(t),vi=s(ls," (e.g. \\<new1> in above example) in your prompt."),ls.forEach(t),Ea=f(e),m(De.$$.fragment,e),ga=f(e),Mt=i(e,"P",{});var vn=r(Mt);Ei=s(vn,"It\u2019s possible to directly load these parameters from a Hub repository:"),vn.forEach(t),ja=f(e),m(qe.$$.fragment,e),Ia=f(e),yt=i(e,"P",{});var En=r(yt);gi=s(En,"Here is an example of performing inference with multiple concepts:"),En.forEach(t),Na=f(e),m(Pe.$$.fragment,e),Za=f(e),I=i(e,"P",{});var jt=r(I);ji=s(jt,"Here, "),bl=i(jt,"CODE",{});var gn=r(bl);Ii=s(gn,"cat"),gn.forEach(t),Ni=s(jt," and "),Ul=i(jt,"CODE",{});var jn=r(Ul);Zi=s(jn,"wooden pot"),jn.forEach(t),Ci=s(jt," refer to the multiple concepts."),jt.forEach(t),Ca=f(e),S=i(e,"H3",{class:!0});var as=r(S);re=i(as,"A",{id:!0,class:!0,href:!0});var In=r(re);Jl=i(In,"SPAN",{});var Nn=r(Jl);m(Oe.$$.fragment,Nn),Nn.forEach(t),In.forEach(t),Wi=f(as),Tl=i(as,"SPAN",{});var Zn=r(Tl);Xi=s(Zn,"Inference from a training checkpoint"),Zn.forEach(t),as.forEach(t),Wa=f(e),ne=i(e,"P",{});var ss=r(ne);Ri=s(ss,"You can also perform inference from one of the complete checkpoint saved during the training process, if you used the "),vl=i(ss,"CODE",{});var Cn=r(vl);$i=s(Cn,"--checkpointing_steps"),Cn.forEach(t),Vi=s(ss," argument."),ss.forEach(t),Xa=f(e),_t=i(e,"P",{});var Wn=r(_t);Gi=s(Wn,"TODO."),Wn.forEach(t),Ra=f(e),z=i(e,"H2",{class:!0});var os=r(z);pe=i(os,"A",{id:!0,class:!0,href:!0});var Xn=r(pe);El=i(Xn,"SPAN",{});var Rn=r(El);m(Ke.$$.fragment,Rn),Rn.forEach(t),Xn.forEach(t),ki=f(os),gl=i(os,"SPAN",{});var $n=r(gl);Ai=s($n,"Set grads to none"),$n.forEach(t),os.forEach(t),$a=f(e),ce=i(e,"P",{});var is=r(ce);Fi=s(is,"To save even more memory, pass the "),jl=i(is,"CODE",{});var Vn=r(jl);Bi=s(Vn,"--set_grads_to_none"),Vn.forEach(t),Si=s(is," argument to the script. This will set grads to None instead of zero. However, be aware that it changes certain behaviors, so if you start experiencing any problems, remove this argument."),is.forEach(t),Va=f(e),et=i(e,"P",{});var Pi=r(et);zi=s(Pi,"More info: "),tt=i(Pi,"A",{href:!0,rel:!0});var Gn=r(tt);xi=s(Gn,"https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html"),Gn.forEach(t),Pi.forEach(t),Ga=f(e),x=i(e,"H2",{class:!0});var rs=r(x);fe=i(rs,"A",{id:!0,class:!0,href:!0});var kn=r(fe);Il=i(kn,"SPAN",{});var An=r(Il);m(lt.$$.fragment,An),An.forEach(t),kn.forEach(t),Yi=f(rs),Nl=i(rs,"SPAN",{});var Fn=r(Nl);Qi=s(Fn,"Experimental results"),Fn.forEach(t),rs.forEach(t),ka=f(e),he=i(e,"P",{});var ns=r(he);Hi=s(ns,"You can refer to "),at=i(ns,"A",{href:!0,rel:!0});var Bn=r(at);Li=s(Bn,"our webpage"),Bn.forEach(t),Di=s(ns," that discusses our experiments in detail."),ns.forEach(t),this.h()},h(){h(Z,"name","hf:doc:metadata"),h(Z,"content",JSON.stringify(Dn)),h(Q,"id","custom-diffusion-training-example"),h(Q,"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"),h(Q,"href","#custom-diffusion-training-example"),h(C,"class","relative group"),h(de,"href","https://arxiv.org/abs/2212.04488"),h(de,"rel","nofollow"),h(we,"href","https://nupurkmr9.github.io/"),h(we,"rel","nofollow"),h(L,"id","running-locally-with-pytorch"),h(L,"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"),h(L,"href","#running-locally-with-pytorch"),h(X,"class","relative group"),h(D,"id","installing-the-dependencies"),h(D,"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"),h(D,"href","#installing-the-dependencies"),h(R,"class","relative group"),h(Ue,"href","https://github.com/huggingface/diffusers/tree/main/examples/custom_diffusion"),h(Ue,"rel","nofollow"),h(ve,"href","https://github.com/huggingface/accelerate/"),h(ve,"rel","nofollow"),h(O,"id","cat-example"),h(O,"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"),h(O,"href","#cat-example"),h($,"class","relative group"),h(Ne,"href","https://www.cs.cmu.edu/~custom-diffusion/assets/data.zip"),h(Ne,"rel","nofollow"),h(pt,"href","create_dataset"),h(Ce,"href","https://huggingface.co/stabilityai/stable-diffusion-2"),h(Ce,"rel","nofollow"),h(Xe,"href","https://github.com/facebookresearch/xformers"),h(Xe,"rel","nofollow"),h(Ge,"href","https://wandb.ai/sayakpaul/custom-diffusion/runs/26ghrcau"),h(Ge,"rel","nofollow"),h(ke,"href","https://huggingface.co/sayakpaul/custom-diffusion-cat"),h(ke,"rel","nofollow"),h(le,"id","training-on-multiple-concepts"),h(le,"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"),h(le,"href","#training-on-multiple-concepts"),h(A,"class","relative group"),h(Fe,"href","https://github.com/adobe-research/custom-diffusion/blob/main/assets/concept_list.json"),h(Fe,"rel","nofollow"),h(Be,"href","https://github.com/ShivamShrirao/diffusers/blob/main/examples/dreambooth/train_dreambooth.py"),h(Be,"rel","nofollow"),h(xe,"href","https://wandb.ai/sayakpaul/custom-diffusion/runs/3990tzkg"),h(xe,"rel","nofollow"),h(se,"id","training-on-human-faces"),h(se,"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"),h(se,"href","#training-on-human-faces"),h(F,"class","relative group"),h(oe,"id","inference"),h(oe,"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"),h(oe,"href","#inference"),h(B,"class","relative group"),h(re,"id","inference-from-a-training-checkpoint"),h(re,"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"),h(re,"href","#inference-from-a-training-checkpoint"),h(S,"class","relative group"),h(pe,"id","set-grads-to-none"),h(pe,"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"),h(pe,"href","#set-grads-to-none"),h(z,"class","relative group"),h(tt,"href","https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html"),h(tt,"rel","nofollow"),h(fe,"id","experimental-results"),h(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"),h(fe,"href","#experimental-results"),h(x,"class","relative group"),h(at,"href","https://www.cs.cmu.edu/~custom-diffusion/"),h(at,"rel","nofollow")},m(e,n){l(document.head,Z),p(e,Cl,n),p(e,C,n),l(C,Q),l(Q,It),d(me,It,null),l(C,ps),l(C,Nt),l(Nt,cs),p(e,Wl,n),p(e,W,n),l(W,de),l(de,fs),l(W,hs),l(W,Zt),l(Zt,us),l(W,ms),p(e,Xl,n),p(e,H,n),l(H,ds),l(H,we),l(we,ws),l(H,Ms),p(e,Rl,n),p(e,X,n),l(X,L),l(L,Ct),d(Me,Ct,null),l(X,ys),l(X,Wt),l(Wt,_s),p(e,$l,n),p(e,R,n),l(R,D),l(D,Xt),d(ye,Xt,null),l(R,bs),l(R,Rt),l(Rt,Us),p(e,Vl,n),p(e,st,n),l(st,Js),p(e,Gl,n),p(e,ot,n),l(ot,$t),l($t,Ts),p(e,kl,n),p(e,q,n),l(q,vs),l(q,Vt),l(Vt,Es),l(q,gs),p(e,Al,n),d(_e,e,n),p(e,Fl,n),p(e,be,n),l(be,js),l(be,Ue),l(Ue,Is),p(e,Bl,n),d(Je,e,n),p(e,Sl,n),p(e,it,n),l(it,Ns),p(e,zl,n),d(Te,e,n),p(e,xl,n),p(e,P,n),l(P,Zs),l(P,ve),l(ve,Cs),l(P,Ws),p(e,Yl,n),d(Ee,e,n),p(e,Ql,n),p(e,rt,n),l(rt,Xs),p(e,Hl,n),d(ge,e,n),p(e,Ll,n),p(e,nt,n),l(nt,Rs),p(e,Dl,n),d(je,e,n),p(e,ql,n),p(e,$,n),l($,O),l(O,Gt),d(Ie,Gt,null),l($,$s),l($,kt),l(kt,Vs),p(e,Pl,n),p(e,v,n),l(v,Gs),l(v,Ne),l(Ne,ks),l(v,As),l(v,pt),l(pt,Fs),l(v,Bs),p(e,Ol,n),p(e,_,n),l(_,Ss),l(_,At),l(At,zs),l(_,xs),l(_,Ft),l(Ft,Ys),l(_,Qs),l(_,Bt),l(Bt,Hs),l(_,Ls),l(_,St),l(St,Ds),l(_,qs),l(_,zt),l(zt,Ps),l(_,Os),l(_,xt),l(xt,Ks),l(_,eo),l(_,Yt),l(Yt,to),l(_,lo),l(_,Qt),l(Qt,ao),l(_,so),p(e,Kl,n),d(Ze,e,n),p(e,ea,n),p(e,ct,n),l(ct,Ht),l(Ht,Lt),l(Lt,V),l(V,oo),l(V,Dt),l(Dt,io),l(V,ro),l(V,Ce),l(Ce,no),l(V,po),p(e,ta,n),p(e,K,n),l(K,co),l(K,qt),l(qt,fo),l(K,ho),p(e,la,n),d(We,e,n),p(e,aa,n),p(e,ft,n),l(ft,G),l(G,uo),l(G,Pt),l(Pt,mo),l(G,wo),l(G,Xe),l(Xe,Mo),l(G,yo),p(e,sa,n),p(e,ee,n),l(ee,_o),l(ee,Ot),l(Ot,bo),l(ee,Uo),p(e,oa,n),p(e,E,n),l(E,k),l(k,Jo),l(k,Kt),l(Kt,To),l(k,vo),l(k,el),l(el,Eo),l(k,go),l(E,jo),l(E,Re),l(Re,Io),l(Re,tl),l(tl,No),l(Re,Zo),l(E,Co),l(E,J),l(J,Wo),l(J,ll),l(ll,Xo),l(J,Ro),l(J,al),l(al,$o),l(J,Vo),l(J,sl),l(sl,Go),l(J,ko),l(J,$e),l($e,ol),l(ol,il),l(il,Ao),l($e,Fo),l($e,rl),l(rl,nl),l(nl,Bo),p(e,ia,n),p(e,ht,n),l(ht,So),p(e,ra,n),d(Ve,e,n),p(e,na,n),p(e,te,n),l(te,zo),l(te,Ge),l(Ge,xo),l(te,Yo),p(e,pa,n),p(e,g,n),l(g,Qo),l(g,pl),l(pl,Ho),l(g,Lo),l(g,ke),l(ke,Do),l(g,qo),p(e,ca,n),p(e,A,n),l(A,le),l(le,cl),d(Ae,cl,null),l(A,Po),l(A,fl),l(fl,Oo),p(e,fa,n),p(e,j,n),l(j,Ko),l(j,Fe),l(Fe,ei),l(j,ti),l(j,Be),l(Be,li),l(j,ai),p(e,ha,n),p(e,ut,n),l(ut,si),p(e,ua,n),d(Se,e,n),p(e,ma,n),p(e,mt,n),l(mt,oi),p(e,da,n),d(ze,e,n),p(e,wa,n),p(e,ae,n),l(ae,ii),l(ae,xe),l(xe,ri),l(ae,ni),p(e,Ma,n),p(e,F,n),l(F,se),l(se,hl),d(Ye,hl,null),l(F,pi),l(F,ul),l(ul,ci),p(e,ya,n),p(e,T,n),l(T,fi),l(T,ml),l(ml,hi),l(T,ui),l(T,dl),l(dl,mi),l(T,di),l(T,wl),l(wl,wi),l(T,Mi),p(e,_a,n),p(e,dt,n),l(dt,yi),p(e,ba,n),d(Qe,e,n),p(e,Ua,n),p(e,wt,n),l(wt,_i),p(e,Ja,n),d(He,e,n),p(e,Ta,n),p(e,B,n),l(B,oe),l(oe,Ml),d(Le,Ml,null),l(B,bi),l(B,yl),l(yl,Ui),p(e,va,n),p(e,ie,n),l(ie,Ji),l(ie,_l),l(_l,Ti),l(ie,vi),p(e,Ea,n),d(De,e,n),p(e,ga,n),p(e,Mt,n),l(Mt,Ei),p(e,ja,n),d(qe,e,n),p(e,Ia,n),p(e,yt,n),l(yt,gi),p(e,Na,n),d(Pe,e,n),p(e,Za,n),p(e,I,n),l(I,ji),l(I,bl),l(bl,Ii),l(I,Ni),l(I,Ul),l(Ul,Zi),l(I,Ci),p(e,Ca,n),p(e,S,n),l(S,re),l(re,Jl),d(Oe,Jl,null),l(S,Wi),l(S,Tl),l(Tl,Xi),p(e,Wa,n),p(e,ne,n),l(ne,Ri),l(ne,vl),l(vl,$i),l(ne,Vi),p(e,Xa,n),p(e,_t,n),l(_t,Gi),p(e,Ra,n),p(e,z,n),l(z,pe),l(pe,El),d(Ke,El,null),l(z,ki),l(z,gl),l(gl,Ai),p(e,$a,n),p(e,ce,n),l(ce,Fi),l(ce,jl),l(jl,Bi),l(ce,Si),p(e,Va,n),p(e,et,n),l(et,zi),l(et,tt),l(tt,xi),p(e,Ga,n),p(e,x,n),l(x,fe),l(fe,Il),d(lt,Il,null),l(x,Yi),l(x,Nl),l(Nl,Qi),p(e,ka,n),p(e,he,n),l(he,Hi),l(he,at),l(at,Li),l(he,Di),Aa=!0},p:Qn,i(e){Aa||(w(me.$$.fragment,e),w(Me.$$.fragment,e),w(ye.$$.fragment,e),w(_e.$$.fragment,e),w(Je.$$.fragment,e),w(Te.$$.fragment,e),w(Ee.$$.fragment,e),w(ge.$$.fragment,e),w(je.$$.fragment,e),w(Ie.$$.fragment,e),w(Ze.$$.fragment,e),w(We.$$.fragment,e),w(Ve.$$.fragment,e),w(Ae.$$.fragment,e),w(Se.$$.fragment,e),w(ze.$$.fragment,e),w(Ye.$$.fragment,e),w(Qe.$$.fragment,e),w(He.$$.fragment,e),w(Le.$$.fragment,e),w(De.$$.fragment,e),w(qe.$$.fragment,e),w(Pe.$$.fragment,e),w(Oe.$$.fragment,e),w(Ke.$$.fragment,e),w(lt.$$.fragment,e),Aa=!0)},o(e){M(me.$$.fragment,e),M(Me.$$.fragment,e),M(ye.$$.fragment,e),M(_e.$$.fragment,e),M(Je.$$.fragment,e),M(Te.$$.fragment,e),M(Ee.$$.fragment,e),M(ge.$$.fragment,e),M(je.$$.fragment,e),M(Ie.$$.fragment,e),M(Ze.$$.fragment,e),M(We.$$.fragment,e),M(Ve.$$.fragment,e),M(Ae.$$.fragment,e),M(Se.$$.fragment,e),M(ze.$$.fragment,e),M(Ye.$$.fragment,e),M(Qe.$$.fragment,e),M(He.$$.fragment,e),M(Le.$$.fragment,e),M(De.$$.fragment,e),M(qe.$$.fragment,e),M(Pe.$$.fragment,e),M(Oe.$$.fragment,e),M(Ke.$$.fragment,e),M(lt.$$.fragment,e),Aa=!1},d(e){t(Z),e&&t(Cl),e&&t(C),y(me),e&&t(Wl),e&&t(W),e&&t(Xl),e&&t(H),e&&t(Rl),e&&t(X),y(Me),e&&t($l),e&&t(R),y(ye),e&&t(Vl),e&&t(st),e&&t(Gl),e&&t(ot),e&&t(kl),e&&t(q),e&&t(Al),y(_e,e),e&&t(Fl),e&&t(be),e&&t(Bl),y(Je,e),e&&t(Sl),e&&t(it),e&&t(zl),y(Te,e),e&&t(xl),e&&t(P),e&&t(Yl),y(Ee,e),e&&t(Ql),e&&t(rt),e&&t(Hl),y(ge,e),e&&t(Ll),e&&t(nt),e&&t(Dl),y(je,e),e&&t(ql),e&&t($),y(Ie),e&&t(Pl),e&&t(v),e&&t(Ol),e&&t(_),e&&t(Kl),y(Ze,e),e&&t(ea),e&&t(ct),e&&t(ta),e&&t(K),e&&t(la),y(We,e),e&&t(aa),e&&t(ft),e&&t(sa),e&&t(ee),e&&t(oa),e&&t(E),e&&t(ia),e&&t(ht),e&&t(ra),y(Ve,e),e&&t(na),e&&t(te),e&&t(pa),e&&t(g),e&&t(ca),e&&t(A),y(Ae),e&&t(fa),e&&t(j),e&&t(ha),e&&t(ut),e&&t(ua),y(Se,e),e&&t(ma),e&&t(mt),e&&t(da),y(ze,e),e&&t(wa),e&&t(ae),e&&t(Ma),e&&t(F),y(Ye),e&&t(ya),e&&t(T),e&&t(_a),e&&t(dt),e&&t(ba),y(Qe,e),e&&t(Ua),e&&t(wt),e&&t(Ja),y(He,e),e&&t(Ta),e&&t(B),y(Le),e&&t(va),e&&t(ie),e&&t(Ea),y(De,e),e&&t(ga),e&&t(Mt),e&&t(ja),y(qe,e),e&&t(Ia),e&&t(yt),e&&t(Na),y(Pe,e),e&&t(Za),e&&t(I),e&&t(Ca),e&&t(S),y(Oe),e&&t(Wa),e&&t(ne),e&&t(Xa),e&&t(_t),e&&t(Ra),e&&t(z),y(Ke),e&&t($a),e&&t(ce),e&&t(Va),e&&t(et),e&&t(Ga),e&&t(x),y(lt),e&&t(ka),e&&t(he)}}}const Dn={local:"custom-diffusion-training-example",sections:[{local:"running-locally-with-pytorch",sections:[{local:"installing-the-dependencies",title:"Installing the dependencies"},{local:"cat-example",title:"Cat example \u{1F63A}"},{local:"training-on-multiple-concepts",title:"Training on multiple concepts \u{1F431}\u{1FAB5}"},{local:"training-on-human-faces",title:"Training on human faces"}],title:"Running locally with PyTorch"},{local:"inference",sections:[{local:"inference-from-a-training-checkpoint",title:"Inference from a training checkpoint"}],title:"Inference"},{local:"set-grads-to-none",title:"Set grads to none"},{local:"experimental-results",title:"Experimental results"}],title:"Custom Diffusion training example "};function qn(Oi){return Hn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ep extends Sn{constructor(Z){super();zn(this,Z,qn,Ln,xn,{})}}export{ep as default,Dn as metadata};
