import{s as ee,B as le,o as ne,n as ae}from"../chunks/scheduler.94020406.js";import{S as ie,i as se,g as s,s as a,r as f,m as pe,E as me,h as p,f as l,c as i,j as Yt,u,x as $,n as fe,k as U,y as ue,a as n,v as c,d as r,t as M,w as o}from"../chunks/index.a08c8d92.js";import{T as ce}from"../chunks/Tip.3b0aeee8.js";import{C as b}from"../chunks/CodeBlock.b23cf525.js";import{H as et,E as re}from"../chunks/EditOnGithub.b1bceb47.js";function Me(lt){let m,g="💡 전체 학습은 V100 GPU 4개를 사용할 경우, 2시간이 소요됩니다.";return{c(){m=s("p"),m.textContent=g},l(d){m=p(d,"P",{"data-svelte-h":!0}),$(m)!=="svelte-1iy6zbw"&&(m.textContent=g)},m(d,K){n(d,m,K)},p:ae,d(d){d&&l(m)}}}function oe(lt){let m,g,d,K,_,nt,J,Et="unconditional 이미지 생성은 text-to-image 또는 image-to-image 모델과 달리 텍스트나 이미지에 대한 조건이 없이 학습 데이터 분포와 유사한 이미지만을 생성합니다.",at,w,Vt,it,C,Gt='이 가이드에서는 기존에 존재하던 데이터셋과 자신만의 커스텀 데이터셋에 대해 unconditional image generation 모델을 훈련하는 방법을 설명합니다. 훈련 세부 사항에 대해 더 자세히 알고 싶다면 unconditional image generation을 위한 모든 학습 스크립트를 <a href="https://github.com/huggingface/diffusers/tree/main/examples/unconditional_image_generation" rel="nofollow">여기</a>에서 확인할 수 있습니다.',st,j,St="스크립트를 실행하기 전, 먼저 의존성 라이브러리들을 설치해야 합니다.",pt,W,mt,x,At='그 다음 🤗 <a href="https://github.com/huggingface/accelerate/" rel="nofollow">Accelerate</a> 환경을 초기화합니다.',ft,Z,ut,N,Ht='별도의 설정 없이 기본 설정으로 🤗 <a href="https://github.com/huggingface/accelerate/" rel="nofollow">Accelerate</a> 환경을 초기화해봅시다.',ct,v,rt,X,Bt="노트북과 같은 대화형 쉘을 지원하지 않는 환경의 경우, 다음과 같이 사용해볼 수도 있습니다.",Mt,L,ot,I,$t,R,Qt="학습 스크립트에 다음 인자를 추가하여 허브에 모델을 업로드할 수 있습니다.",dt,Y,wt,E,bt,V,Ft="훈련 중 문제가 발생할 경우를 대비하여 체크포인트를 정기적으로 저장하는 것이 좋습니다. 체크포인트를 저장하려면 학습 스크립트에 다음 인자를 전달합니다:",ht,G,Tt,S,kt="전체 훈련 상태는 500스텝마다 <code>output_dir</code>의 하위 폴더에 저장되며, 학습 스크립트에 <code>--resume_from_checkpoint</code> 인자를 전달함으로써 체크포인트를 불러오고 훈련을 재개할 수 있습니다.",yt,A,Ut,H,gt,B,zt='이제 학습 스크립트를 시작할 준비가 되었습니다! <code>--dataset_name</code> 인자에 파인튜닝할 데이터셋 이름을 지정한 다음, <code>--output_dir</code> 인자에 지정된 경로로 저장합니다. 본인만의 데이터셋를 사용하려면, <a href="create_dataset">학습용 데이터셋 만들기</a> 가이드를 참조하세요.',_t,Q,Pt="학습 스크립트는 <code>diffusion_pytorch_model.bin</code> 파일을 생성하고, 그것을 당신의 리포지토리에 저장합니다.",Jt,h,Ct,F,qt='예를 들어, <a href="https://huggingface.co/datasets/huggan/flowers-102-categories" rel="nofollow">Oxford Flowers</a> 데이터셋을 사용해 파인튜닝할 경우:',jt,k,Wt,T,Dt='<img src="https://user-images.githubusercontent.com/26864830/180248660-a0b143d0-b89a-42c5-8656-2ebf6ece7e52.png"/>',xt,z,Zt,y,Ot='<img src="https://user-images.githubusercontent.com/26864830/180248200-928953b4-db38-48db-b0c6-8b740fe6786f.png"/>',Nt,P,vt,q,Kt='<code>accelerate</code>을 사용하면 원활한 다중 GPU 훈련이 가능합니다. <code>accelerate</code>을 사용하여 분산 훈련을 실행하려면 <a href="https://huggingface.co/docs/accelerate/basic_tutorials/launch" rel="nofollow">여기</a> 지침을 따르세요. 다음은 명령어 예제입니다.',Xt,D,Lt,O,It,tt,Rt;return _=new et({props:{title:"Unconditional 이미지 생성",local:"unconditional-이미지-생성",headingTag:"h1"}}),W=new b({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRpZmZ1c2VycyU1QnRyYWluaW5nJTVEJTIwYWNjZWxlcmF0ZSUyMGRhdGFzZXRz",highlighted:"pip install diffusers[training] accelerate datasets",wrap:!1}}),Z=new b({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),v=new b({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),L=new b({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`,wrap:!1}}),I=new et({props:{title:"모델을 허브에 업로드하기",local:"모델을-허브에-업로드하기",headingTag:"h2"}}),Y=new b({props:{code:"LS1wdXNoX3RvX2h1Yg==",highlighted:"--push_to_hub",wrap:!1}}),E=new et({props:{title:"체크포인트 저장하고 불러오기",local:"체크포인트-저장하고-불러오기",headingTag:"h2"}}),G=new b({props:{code:"LS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAw",highlighted:"--checkpointing_steps=500",wrap:!1}}),A=new b({props:{code:"LS1yZXN1bWVfZnJvbV9jaGVja3BvaW50JTNEJTIyY2hlY2twb2ludC0xNTAwJTIy",highlighted:'--resume_from_checkpoint=<span class="hljs-string">&quot;checkpoint-1500&quot;</span>',wrap:!1}}),H=new et({props:{title:"파인튜닝",local:"파인튜닝",headingTag:"h2"}}),h=new ce({props:{$$slots:{default:[Me]},$$scope:{ctx:lt}}}),k=new b({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAtLWRhdGFzZXRfbmFtZSUzRCUyMmh1Z2dhbiUyRmZsb3dlcnMtMTAyLWNhdGVnb3JpZXMlMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q2NCUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyMmRkcG0tZW1hLWZsb3dlcnMtNjQlMjIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxNiUyMCU1QyUwQSUyMCUyMC0tbnVtX2Vwb2NocyUzRDEwMCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTQlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDUwMCUyMCU1QyUwQSUyMCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEbm8lMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`accelerate launch train_unconditional.py \\
  --dataset_name=<span class="hljs-string">&quot;huggan/flowers-102-categories&quot;</span> \\
  --resolution=64 \\
  --output_dir=<span class="hljs-string">&quot;ddpm-ema-flowers-64&quot;</span> \\
  --train_batch_size=16 \\
  --num_epochs=100 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=1e-4 \\
  --lr_warmup_steps=500 \\
  --mixed_precision=no \\
  --push_to_hub`,wrap:!1}}),z=new b({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAtLWRhdGFzZXRfbmFtZSUzRCUyMmxhbWJkYWxhYnMlMkZuYXJ1dG8tYmxpcC1jYXB0aW9ucyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDY0JTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIyZGRwbS1lbWEtbmFydXRvLTY0JTIyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMTYlMjAlNUMlMEElMjAlMjAtLW51bV9lcG9jaHMlM0QxMDAlMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS00JTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0Q1MDAlMjAlNUMlMEElMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRG5vJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch train_unconditional.py \\
  --dataset_name=<span class="hljs-string">&quot;lambdalabs/naruto-blip-captions&quot;</span> \\
  --resolution=64 \\
  --output_dir=<span class="hljs-string">&quot;ddpm-ema-naruto-64&quot;</span> \\
  --train_batch_size=16 \\
  --num_epochs=100 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=1e-4 \\
  --lr_warmup_steps=500 \\
  --mixed_precision=no \\
  --push_to_hub`,wrap:!1}}),P=new et({props:{title:"여러개의 GPU로 훈련하기",local:"여러개의-gpu로-훈련하기",headingTag:"h3"}}),D=new b({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMC0tbXVsdGlfZ3B1JTIwdHJhaW5fdW5jb25kaXRpb25hbC5weSUyMCU1QyUwQSUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTIybGFtYmRhbGFicyUyRm5hcnV0by1ibGlwLWNhcHRpb25zJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENjQlMjAtLWNlbnRlcl9jcm9wJTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyMmRkcG0tZW1hLW5hcnV0by02NCUyMiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDE2JTIwJTVDJTBBJTIwJTIwLS1udW1fZXBvY2hzJTNEMTAwJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwJTVDJTBBJTIwJTIwLS11c2VfZW1hJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMWUtNCUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwLS1taXhlZF9wcmVjaXNpb24lM0QlMjJmcDE2JTIyJTIwJTVDJTBBJTIwJTIwLS1sb2dnZXIlM0QlMjJ3YW5kYiUyMiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> --multi_gpu train_unconditional.py \\
  --dataset_name=<span class="hljs-string">&quot;lambdalabs/naruto-blip-captions&quot;</span> \\
  --resolution=64 --center_crop --random_flip \\
  --output_dir=<span class="hljs-string">&quot;ddpm-ema-naruto-64&quot;</span> \\
  --train_batch_size=16 \\
  --num_epochs=100 \\
  --gradient_accumulation_steps=1 \\
  --use_ema \\
  --learning_rate=1e-4 \\
  --lr_warmup_steps=500 \\
  --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> \\
  --logger=<span class="hljs-string">&quot;wandb&quot;</span> \\
  --push_to_hub`,wrap:!1}}),O=new re({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/training/unconditional_training.md"}}),{c(){m=s("meta"),g=a(),d=s("p"),K=a(),f(_.$$.fragment),nt=a(),J=s("p"),J.textContent=Et,at=a(),w=s("iframe"),it=a(),C=s("p"),C.innerHTML=Gt,st=a(),j=s("p"),j.textContent=St,pt=a(),f(W.$$.fragment),mt=a(),x=s("p"),x.innerHTML=At,ft=a(),f(Z.$$.fragment),ut=a(),N=s("p"),N.innerHTML=Ht,ct=a(),f(v.$$.fragment),rt=a(),X=s("p"),X.textContent=Bt,Mt=a(),f(L.$$.fragment),ot=a(),f(I.$$.fragment),$t=a(),R=s("p"),R.textContent=Qt,dt=a(),f(Y.$$.fragment),wt=a(),f(E.$$.fragment),bt=a(),V=s("p"),V.textContent=Ft,ht=a(),f(G.$$.fragment),Tt=a(),S=s("p"),S.innerHTML=kt,yt=a(),f(A.$$.fragment),Ut=a(),f(H.$$.fragment),gt=a(),B=s("p"),B.innerHTML=zt,_t=a(),Q=s("p"),Q.innerHTML=Pt,Jt=a(),f(h.$$.fragment),Ct=a(),F=s("p"),F.innerHTML=qt,jt=a(),f(k.$$.fragment),Wt=a(),T=s("div"),T.innerHTML=Dt,xt=pe(`
[Naruto](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions) 데이터셋을 사용할 경우:

	`),f(z.$$.fragment),Zt=a(),y=s("div"),y.innerHTML=Ot,Nt=a(),f(P.$$.fragment),vt=a(),q=s("p"),q.innerHTML=Kt,Xt=a(),f(D.$$.fragment),Lt=a(),f(O.$$.fragment),It=a(),tt=s("p"),this.h()},l(t){const e=me("svelte-u9bgzb",document.head);m=p(e,"META",{name:!0,content:!0}),e.forEach(l),g=i(t),d=p(t,"P",{}),Yt(d).forEach(l),K=i(t),u(_.$$.fragment,t),nt=i(t),J=p(t,"P",{"data-svelte-h":!0}),$(J)!=="svelte-11cek6f"&&(J.textContent=Et),at=i(t),w=p(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Yt(w).forEach(l),it=i(t),C=p(t,"P",{"data-svelte-h":!0}),$(C)!=="svelte-1k5g2a5"&&(C.innerHTML=Gt),st=i(t),j=p(t,"P",{"data-svelte-h":!0}),$(j)!=="svelte-3u8bru"&&(j.textContent=St),pt=i(t),u(W.$$.fragment,t),mt=i(t),x=p(t,"P",{"data-svelte-h":!0}),$(x)!=="svelte-1k19jiw"&&(x.innerHTML=At),ft=i(t),u(Z.$$.fragment,t),ut=i(t),N=p(t,"P",{"data-svelte-h":!0}),$(N)!=="svelte-ai9532"&&(N.innerHTML=Ht),ct=i(t),u(v.$$.fragment,t),rt=i(t),X=p(t,"P",{"data-svelte-h":!0}),$(X)!=="svelte-ejz7fm"&&(X.textContent=Bt),Mt=i(t),u(L.$$.fragment,t),ot=i(t),u(I.$$.fragment,t),$t=i(t),R=p(t,"P",{"data-svelte-h":!0}),$(R)!=="svelte-1v07mr9"&&(R.textContent=Qt),dt=i(t),u(Y.$$.fragment,t),wt=i(t),u(E.$$.fragment,t),bt=i(t),V=p(t,"P",{"data-svelte-h":!0}),$(V)!=="svelte-oc22co"&&(V.textContent=Ft),ht=i(t),u(G.$$.fragment,t),Tt=i(t),S=p(t,"P",{"data-svelte-h":!0}),$(S)!=="svelte-snfiee"&&(S.innerHTML=kt),yt=i(t),u(A.$$.fragment,t),Ut=i(t),u(H.$$.fragment,t),gt=i(t),B=p(t,"P",{"data-svelte-h":!0}),$(B)!=="svelte-1apcfe4"&&(B.innerHTML=zt),_t=i(t),Q=p(t,"P",{"data-svelte-h":!0}),$(Q)!=="svelte-j3u7pw"&&(Q.innerHTML=Pt),Jt=i(t),u(h.$$.fragment,t),Ct=i(t),F=p(t,"P",{"data-svelte-h":!0}),$(F)!=="svelte-1mxtjpt"&&(F.innerHTML=qt),jt=i(t),u(k.$$.fragment,t),Wt=i(t),T=p(t,"DIV",{class:!0,"data-svelte-h":!0}),$(T)!=="svelte-bqefob"&&(T.innerHTML=Dt),xt=fe(t,`
[Naruto](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions) 데이터셋을 사용할 경우:

	`),u(z.$$.fragment,t),Zt=i(t),y=p(t,"DIV",{class:!0,"data-svelte-h":!0}),$(y)!=="svelte-kyasla"&&(y.innerHTML=Ot),Nt=i(t),u(P.$$.fragment,t),vt=i(t),q=p(t,"P",{"data-svelte-h":!0}),$(q)!=="svelte-thi158"&&(q.innerHTML=Kt),Xt=i(t),u(D.$$.fragment,t),Lt=i(t),u(O.$$.fragment,t),It=i(t),tt=p(t,"P",{}),Yt(tt).forEach(l),this.h()},h(){U(m,"name","hf:doc:metadata"),U(m,"content",$e),le(w.src,Vt="https://stevhliu-ddpm-butterflies-128.hf.space")||U(w,"src",Vt),U(w,"frameborder","0"),U(w,"width","850"),U(w,"height","550"),U(T,"class","flex justify-center"),U(y,"class","flex justify-center")},m(t,e){ue(document.head,m),n(t,g,e),n(t,d,e),n(t,K,e),c(_,t,e),n(t,nt,e),n(t,J,e),n(t,at,e),n(t,w,e),n(t,it,e),n(t,C,e),n(t,st,e),n(t,j,e),n(t,pt,e),c(W,t,e),n(t,mt,e),n(t,x,e),n(t,ft,e),c(Z,t,e),n(t,ut,e),n(t,N,e),n(t,ct,e),c(v,t,e),n(t,rt,e),n(t,X,e),n(t,Mt,e),c(L,t,e),n(t,ot,e),c(I,t,e),n(t,$t,e),n(t,R,e),n(t,dt,e),c(Y,t,e),n(t,wt,e),c(E,t,e),n(t,bt,e),n(t,V,e),n(t,ht,e),c(G,t,e),n(t,Tt,e),n(t,S,e),n(t,yt,e),c(A,t,e),n(t,Ut,e),c(H,t,e),n(t,gt,e),n(t,B,e),n(t,_t,e),n(t,Q,e),n(t,Jt,e),c(h,t,e),n(t,Ct,e),n(t,F,e),n(t,jt,e),c(k,t,e),n(t,Wt,e),n(t,T,e),n(t,xt,e),c(z,t,e),n(t,Zt,e),n(t,y,e),n(t,Nt,e),c(P,t,e),n(t,vt,e),n(t,q,e),n(t,Xt,e),c(D,t,e),n(t,Lt,e),c(O,t,e),n(t,It,e),n(t,tt,e),Rt=!0},p(t,[e]){const te={};e&2&&(te.$$scope={dirty:e,ctx:t}),h.$set(te)},i(t){Rt||(r(_.$$.fragment,t),r(W.$$.fragment,t),r(Z.$$.fragment,t),r(v.$$.fragment,t),r(L.$$.fragment,t),r(I.$$.fragment,t),r(Y.$$.fragment,t),r(E.$$.fragment,t),r(G.$$.fragment,t),r(A.$$.fragment,t),r(H.$$.fragment,t),r(h.$$.fragment,t),r(k.$$.fragment,t),r(z.$$.fragment,t),r(P.$$.fragment,t),r(D.$$.fragment,t),r(O.$$.fragment,t),Rt=!0)},o(t){M(_.$$.fragment,t),M(W.$$.fragment,t),M(Z.$$.fragment,t),M(v.$$.fragment,t),M(L.$$.fragment,t),M(I.$$.fragment,t),M(Y.$$.fragment,t),M(E.$$.fragment,t),M(G.$$.fragment,t),M(A.$$.fragment,t),M(H.$$.fragment,t),M(h.$$.fragment,t),M(k.$$.fragment,t),M(z.$$.fragment,t),M(P.$$.fragment,t),M(D.$$.fragment,t),M(O.$$.fragment,t),Rt=!1},d(t){t&&(l(g),l(d),l(K),l(nt),l(J),l(at),l(w),l(it),l(C),l(st),l(j),l(pt),l(mt),l(x),l(ft),l(ut),l(N),l(ct),l(rt),l(X),l(Mt),l(ot),l($t),l(R),l(dt),l(wt),l(bt),l(V),l(ht),l(Tt),l(S),l(yt),l(Ut),l(gt),l(B),l(_t),l(Q),l(Jt),l(Ct),l(F),l(jt),l(Wt),l(T),l(xt),l(Zt),l(y),l(Nt),l(vt),l(q),l(Xt),l(Lt),l(It),l(tt)),l(m),o(_,t),o(W,t),o(Z,t),o(v,t),o(L,t),o(I,t),o(Y,t),o(E,t),o(G,t),o(A,t),o(H,t),o(h,t),o(k,t),o(z,t),o(P,t),o(D,t),o(O,t)}}}const $e='{"title":"Unconditional 이미지 생성","local":"unconditional-이미지-생성","sections":[{"title":"모델을 허브에 업로드하기","local":"모델을-허브에-업로드하기","sections":[],"depth":2},{"title":"체크포인트 저장하고 불러오기","local":"체크포인트-저장하고-불러오기","sections":[],"depth":2},{"title":"파인튜닝","local":"파인튜닝","sections":[{"title":"여러개의 GPU로 훈련하기","local":"여러개의-gpu로-훈련하기","sections":[],"depth":3}],"depth":2}],"depth":1}';function de(lt){return ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends ie{constructor(m){super(),se(this,m,de,oe,ee,{})}}export{Ue as component};
