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