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