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

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

	`),f(F.$$.fragment,t),Nt=i(t),h=p(t,"DIV",{class:!0,"data-svelte-h":!0}),o(h)!=="svelte-kyasla"&&(h.innerHTML=ee),vt=i(t),f(z.$$.fragment,t),Xt=i(t),q=p(t,"P",{"data-svelte-h":!0}),o(q)!=="svelte-thi158"&&(q.innerHTML=le),Lt=i(t),f(P.$$.fragment,t),It=i(t),f(D.$$.fragment,t),Rt=i(t),K=p(t,"P",{}),Et(K).forEach(l),this.h()},h(){w(b,"name","hf:doc:metadata"),w(b,"content",de),ae($.src,St="https://stevhliu-ddpm-butterflies-128.hf.space")||w($,"src",St),w($,"frameborder","0"),w($,"width","850"),w($,"height","550"),w(y,"class","tip"),w(T,"class","flex justify-center"),w(h,"class","flex justify-center")},m(t,e){re(document.head,b),n(t,et,e),n(t,O,e),n(t,lt,e),u(U,t,e),n(t,nt,e),u(g,t,e),n(t,at,e),n(t,_,e),n(t,it,e),n(t,$,e),n(t,st,e),n(t,J,e),n(t,pt,e),n(t,C,e),n(t,mt,e),u(j,t,e),n(t,ft,e),n(t,W,e),n(t,ut,e),u(x,t,e),n(t,ct,e),n(t,Z,e),n(t,rt,e),u(N,t,e),n(t,Mt,e),n(t,v,e),n(t,ot,e),u(X,t,e),n(t,$t,e),u(L,t,e),n(t,dt,e),n(t,I,e),n(t,bt,e),u(R,t,e),n(t,wt,e),u(Y,t,e),n(t,yt,e),n(t,E,e),n(t,Tt,e),u(V,t,e),n(t,ht,e),n(t,G,e),n(t,Ut,e),u(S,t,e),n(t,gt,e),u(H,t,e),n(t,_t,e),n(t,A,e),n(t,Jt,e),n(t,B,e),n(t,Ct,e),n(t,y,e),n(t,jt,e),n(t,Q,e),n(t,Wt,e),u(k,t,e),n(t,xt,e),n(t,T,e),n(t,Zt,e),u(F,t,e),n(t,Nt,e),n(t,h,e),n(t,vt,e),u(z,t,e),n(t,Xt,e),n(t,q,e),n(t,Lt,e),u(P,t,e),n(t,It,e),u(D,t,e),n(t,Rt,e),n(t,K,e),Yt=!0},p:ie,i(t){Yt||(c(U.$$.fragment,t),c(g.$$.fragment,t),c(j.$$.fragment,t),c(x.$$.fragment,t),c(N.$$.fragment,t),c(X.$$.fragment,t),c(L.$$.fragment,t),c(R.$$.fragment,t),c(Y.$$.fragment,t),c(V.$$.fragment,t),c(S.$$.fragment,t),c(H.$$.fragment,t),c(k.$$.fragment,t),c(F.$$.fragment,t),c(z.$$.fragment,t),c(P.$$.fragment,t),c(D.$$.fragment,t),Yt=!0)},o(t){r(U.$$.fragment,t),r(g.$$.fragment,t),r(j.$$.fragment,t),r(x.$$.fragment,t),r(N.$$.fragment,t),r(X.$$.fragment,t),r(L.$$.fragment,t),r(R.$$.fragment,t),r(Y.$$.fragment,t),r(V.$$.fragment,t),r(S.$$.fragment,t),r(H.$$.fragment,t),r(k.$$.fragment,t),r(F.$$.fragment,t),r(z.$$.fragment,t),r(P.$$.fragment,t),r(D.$$.fragment,t),Yt=!1},d(t){t&&(l(et),l(O),l(lt),l(nt),l(at),l(_),l(it),l($),l(st),l(J),l(pt),l(C),l(mt),l(ft),l(W),l(ut),l(ct),l(Z),l(rt),l(Mt),l(v),l(ot),l($t),l(dt),l(I),l(bt),l(wt),l(yt),l(E),l(Tt),l(ht),l(G),l(Ut),l(gt),l(_t),l(A),l(Jt),l(B),l(Ct),l(y),l(jt),l(Q),l(Wt),l(xt),l(T),l(Zt),l(Nt),l(h),l(vt),l(Xt),l(q),l(Lt),l(It),l(Rt),l(K)),l(b),M(U,t),M(g,t),M(j,t),M(x,t),M(N,t),M(X,t),M(L,t),M(R,t),M(Y,t),M(V,t),M(S,t),M(H,t),M(k,t),M(F,t),M(z,t),M(P,t),M(D,t)}}}const de='{"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 be(Vt){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends pe{constructor(b){super(),me(this,b,be,$e,ne,{})}}export{Ue as component};
