import{s as bt,n as Ft,o as Et}from"../chunks/scheduler.23542ac5.js";import{S as Bt,i as Gt,e as i,s,c as p,h as xt,a as M,d as e,b as n,f as Zt,g as o,j as U,k as rt,l as vt,m as a,n as d,t as f,o as J,p as m}from"../chunks/index.9b1f405b.js";import{C as Ht,H as Tt,E as Xt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a0107385.js";import{C as z}from"../chunks/CodeBlock.a47c827a.js";function zt(ut){let c,W,H,A,u,L,y,O,h,yt=`<a href="https://huggingface.co/datasets?task_categories=task_categories:text-to-image&amp;sort=downloads" rel="nofollow">Hub</a> 에는 모델 교육을 위한 많은 데이터셋이 있지만,
관심이 있거나 사용하고 싶은 데이터셋을 찾을 수 없는 경우 🤗 <a href="https://huggingface.co/docs/datasets" rel="nofollow">Datasets</a> 라이브러리를 사용하여 데이터셋을 만들 수 있습니다.
데이터셋 구조는 모델을 학습하려는 작업에 따라 달라집니다.
가장 기본적인 데이터셋 구조는 unconditional 이미지 생성과 같은 작업을 위한 이미지 디렉토리입니다.
또 다른 데이터셋 구조는 이미지 디렉토리와 text-to-image 생성과 같은 작업에 해당하는 텍스트 캡션이 포함된 텍스트 파일일 수 있습니다.`,Y,g,ht="이 가이드에는 파인 튜닝할 데이터셋을 만드는 두 가지 방법을 소개합니다:",D,C,gt="<li>이미지 폴더를 <code>--train_data_dir</code> 인수에 제공합니다.</li> <li>데이터셋을 Hub에 업로드하고 데이터셋 리포지토리 id를 <code>--dataset_name</code> 인수에 전달합니다.</li>",q,r,Ct='<p>💡 학습에 사용할 이미지 데이터셋을 만드는 방법에 대한 자세한 내용은 <a href="https://huggingface.co/docs/datasets/image_dataset" rel="nofollow">이미지 데이터셋 만들기</a> 가이드를 참고하세요.</p>',N,R,S,j,Rt=`Unconditional 생성을 위해 이미지 폴더로 자신의 데이터셋을 구축할 수 있습니다.
학습 스크립트는 🤗 Datasets의 <a href="https://huggingface.co/docs/datasets/en/image_dataset#imagefolder" rel="nofollow">ImageFolder</a> 빌더를 사용하여
자동으로 폴더에서 데이터셋을 구축합니다. 디렉토리 구조는 다음과 같아야 합니다 :`,P,Q,K,_,jt="데이터셋 디렉터리의 경로를 <code>--train_data_dir</code> 인수로 전달한 다음 학습을 시작할 수 있습니다:",tt,V,lt,$,et,T,Qt='<p>💡 데이터셋을 만들고 Hub에 업로드하는 것에 대한 자세한 내용은 <a href="https://huggingface.co/blog/image-search-datasets" rel="nofollow">🤗 Datasets을 사용한 이미지 검색</a> 게시물을 참고하세요.</p>',at,w,_t='PIL 인코딩된 이미지가 포함된 <code>이미지</code> 열을 생성하는 <a href="https://huggingface.co/docs/datasets/image_load#imagefolder" rel="nofollow">이미지 폴더</a> 기능을 사용하여 데이터셋 생성을 시작합니다.',st,I,Vt=`<code>data_dir</code> 또는 <code>data_files</code> 매개 변수를 사용하여 데이터셋의 위치를 지정할 수 있습니다.
<code>data_files</code> 매개변수는 특정 파일을 <code>train</code> 이나 <code>test</code> 로 분리한 데이터셋에 매핑하는 것을 지원합니다:`,nt,k,it,Z,$t='[push_to_hub(<a href="https://huggingface.co/docs/datasets/v2.13.1/en/package_reference/main_classes#datasets.Dataset.push_to_hub" rel="nofollow">https://huggingface.co/docs/datasets/v2.13.1/en/package_reference/main_classes#datasets.Dataset.push_to_hub</a>) 을 사용해서 Hub에 데이터셋을 업로드 합니다:',Mt,b,Ut,F,wt="이제 데이터셋 이름을 <code>--dataset_name</code> 인수에 전달하여 데이터셋을 학습에 사용할 수 있습니다:",pt,E,ot,B,dt,G,It="데이터셋을 생성했으니 이제 학습 스크립트의 <code>train_data_dir</code> (데이터셋이 로컬이면) 혹은 <code>dataset_name</code> (Hub에 데이터셋을 올렸으면) 인수에 연결할 수 있습니다.",ft,x,kt='다음 단계에서는 데이터셋을 사용하여 <a href="https://huggingface.co/docs/diffusers/v0.18.2/en/training/unconditional_training" rel="nofollow">unconditional 생성</a> 또는 <a href="https://huggingface.co/docs/diffusers/training/text2image" rel="nofollow">텍스트-이미지 생성</a>을 위한 모델을 학습시켜보세요!',Jt,v,mt,X,ct;return u=new Ht({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new Tt({props:{title:"학습을 위한 데이터셋 만들기",local:"학습을-위한-데이터셋-만들기",headingTag:"h1"}}),R=new Tt({props:{title:"폴더 형태로 데이터셋 구축하기",local:"폴더-형태로-데이터셋-구축하기",headingTag:"h2"}}),Q=new z({props:{code:"ZGF0YV9kaXIlMkZ4eHgucG5nJTBBZGF0YV9kaXIlMkZ4eHkucG5nJTBBZGF0YV9kaXIlMkYlNUIuLi4lNUQlMkZ4eHoucG5n",highlighted:`data_dir/xxx.png
data_dir/xxy.png
data_dir/[...]/xxz.png`,wrap:!1}}),V=new z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAlMjAlMjAlMjMlMjBhcmd1bWVudCVFQiVBMSU5QyUyMCVFRCU4RiVCNCVFQiU4RCU5NCUyMCVFQyVBNyU4MCVFQyVBMCU5NSVFRCU5NSU5OCVFQSVCOCVCMCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fZGF0YV9kaXIlMjAlM0NwYXRoLXRvLXRyYWluLWRpcmVjdG9yeSUzRSUyMCU1QyUwQSUyMCUyMCUyMCUyMCUzQ290aGVyLWFyZ3VtZW50cyUzRQ==",highlighted:`accelerate launch train_unconditional.py \\
    <span class="hljs-comment"># argument로 폴더 지정하기 \\</span>
    --train_data_dir &lt;path-to-train-directory&gt; \\
    &lt;other-arguments&gt;`,wrap:!1}}),$=new Tt({props:{title:"Hub에 데이터 올리기",local:"hub에-데이터-올리기",headingTag:"h2"}}),k=new z({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBJTIzJTIwJUVDJTk4JTg4JUVDJThCJTlDJTIwMSUzQSUyMCVFQiVBMSU5QyVFQyVCQi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yMiUyQyUwQSklMEElMEElMjMlMjAlRUMlOTglODglRUMlOEIlOUMlMjA0JTNBJTIwJUVDJTk3JUFDJUVCJTlGJUFDJUVBJUIwJTlDJUVCJUExJTlDJTIwJUVCJUI2JTg0JUVEJTk1JUEwJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMEElMjAlMjAlMjAlMjAlMjJpbWFnZWZvbGRlciUyMiUyQyUyMGRhdGFfZmlsZXMlM0QlN0IlMjJ0cmFpbiUyMiUzQSUyMCU1QiUyMnBhdGglMkZ0byUyRmZpbGUxJTIyJTJDJTIwJTIycGF0aCUyRnRvJTJGZmlsZTIlMjIlNUQlMkMlMjAlMjJ0ZXN0JTIyJTNBJTIwJTVCJTIycGF0aCUyRnRvJTJGZmlsZTMlMjIlMkMlMjAlMjJwYXRoJTJGdG8lMkZmaWxlNCUyMiU1RCU3RCUwQSk=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-comment"># 예시 1: 로컬 폴더</span>
dataset = load_dataset(<span class="hljs-string">&quot;imagefolder&quot;</span>, data_dir=<span class="hljs-string">&quot;path_to_your_folder&quot;</span>)

<span class="hljs-comment"># 예시 2: 로컬 파일 (지원 포맷 : tar, gzip, zip, xz, rar, zstd)</span>
dataset = load_dataset(<span class="hljs-string">&quot;imagefolder&quot;</span>, data_files=<span class="hljs-string">&quot;path_to_zip_file&quot;</span>)

<span class="hljs-comment"># 예시 3: 원격 파일 (지원 포맷 : tar, gzip, zip, xz, rar, zstd)</span>
dataset = load_dataset(
    <span class="hljs-string">&quot;imagefolder&quot;</span>,
    data_files=<span class="hljs-string">&quot;https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_3367a.zip&quot;</span>,
)

<span class="hljs-comment"># 예시 4: 여러개로 분할</span>
dataset = load_dataset(
    <span class="hljs-string">&quot;imagefolder&quot;</span>, data_files={<span class="hljs-string">&quot;train&quot;</span>: [<span class="hljs-string">&quot;path/to/file1&quot;</span>, <span class="hljs-string">&quot;path/to/file2&quot;</span>], <span class="hljs-string">&quot;test&quot;</span>: [<span class="hljs-string">&quot;path/to/file3&quot;</span>, <span class="hljs-string">&quot;path/to/file4&quot;</span>]}
)`,wrap:!1}}),b=new z({props:{code:"JTIzJTIwJUVEJTg0JUIwJUVCJUFGJUI4JUVCJTg0JTkwJUVDJTk3JTkwJUVDJTg0JTlDJTIwaGYlMjBhdXRoJTIwbG9naW4lMjAlRUMlQkIlQTQlRUIlQTclQTglRUIlOTMlOUMlRUIlQTUlQkMlMjAlRUMlOUQlQjQlRUIlQUYlQjglMjAlRUMlOEIlQTQlRUQlOTYlODklRUQlOTYlODglRUIlOEIlQTQlRUElQjMlQTAlMjAlRUElQjAlODAlRUMlQTAlOTUlRUQlOTUlQTklRUIlOEIlODglRUIlOEIlQTQlMEFkYXRhc2V0LnB1c2hfdG9faHViKCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyKSUwQSUwQSUyMyUyMCVFQSVCMCU5QyVFQyU5RCVCOCUyMHJlcG8lRUIlQTElOUMlMjBwdXNoJTIwJUVEJTk1JTk4JUVBJUIzJUEwJTIwJUVDJThCJUI2JUVCJThCJUE0JUVCJUE5JUI0JTJDJTIwJTYwcHJpdmF0ZSUzRFRydWUlNjAlMjAlRUMlOUQlODQlMjAlRUMlQjYlOTQlRUElQjAlODAlRUQlOTUlOTglRUMlODQlQjglRUMlOUElOTQlM0ElMEFkYXRhc2V0LnB1c2hfdG9faHViKCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyJTJDJTIwcHJpdmF0ZSUzRFRydWUp",highlighted:`<span class="hljs-comment"># 터미널에서 hf auth login 커맨드를 이미 실행했다고 가정합니다</span>
dataset.push_to_hub(<span class="hljs-string">&quot;name_of_your_dataset&quot;</span>)

<span class="hljs-comment"># 개인 repo로 push 하고 싶다면, \`private=True\` 을 추가하세요:</span>
dataset.push_to_hub(<span class="hljs-string">&quot;name_of_your_dataset&quot;</span>, private=<span class="hljs-literal">True</span>)`,wrap:!1}}),E=new z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCUyMHRyYWluX3RleHRfdG9faW1hZ2UucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTIwJTVDJTBBJTIwJTIwLS1kYXRhc2V0X25hbWUlM0QlMjJuYW1lX29mX3lvdXJfZGF0YXNldCUyMiUyMCU1QyUwQSUyMCUyMCUzQ290aGVyLWFyZ3VtZW50cyUzRQ==",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>  train_text_to_image.py \\
  --pretrained_model_name_or_path=<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span> \\
  --dataset_name=<span class="hljs-string">&quot;name_of_your_dataset&quot;</span> \\
  &lt;other-arguments&gt;`,wrap:!1}}),B=new Tt({props:{title:"다음 단계",local:"다음-단계",headingTag:"h2"}}),v=new Xt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/training/create_dataset.md"}}),{c(){c=i("meta"),W=s(),H=i("p"),A=s(),p(u.$$.fragment),L=s(),p(y.$$.fragment),O=s(),h=i("p"),h.innerHTML=yt,Y=s(),g=i("p"),g.textContent=ht,D=s(),C=i("ul"),C.innerHTML=gt,q=s(),r=i("blockquote"),r.innerHTML=Ct,N=s(),p(R.$$.fragment),S=s(),j=i("p"),j.innerHTML=Rt,P=s(),p(Q.$$.fragment),K=s(),_=i("p"),_.innerHTML=jt,tt=s(),p(V.$$.fragment),lt=s(),p($.$$.fragment),et=s(),T=i("blockquote"),T.innerHTML=Qt,at=s(),w=i("p"),w.innerHTML=_t,st=s(),I=i("p"),I.innerHTML=Vt,nt=s(),p(k.$$.fragment),it=s(),Z=i("p"),Z.innerHTML=$t,Mt=s(),p(b.$$.fragment),Ut=s(),F=i("p"),F.innerHTML=wt,pt=s(),p(E.$$.fragment),ot=s(),p(B.$$.fragment),dt=s(),G=i("p"),G.innerHTML=It,ft=s(),x=i("p"),x.innerHTML=kt,Jt=s(),p(v.$$.fragment),mt=s(),X=i("p"),this.h()},l(t){const l=xt("svelte-u9bgzb",document.head);c=M(l,"META",{name:!0,content:!0}),l.forEach(e),W=n(t),H=M(t,"P",{}),Zt(H).forEach(e),A=n(t),o(u.$$.fragment,t),L=n(t),o(y.$$.fragment,t),O=n(t),h=M(t,"P",{"data-svelte-h":!0}),U(h)!=="svelte-1kjp0s4"&&(h.innerHTML=yt),Y=n(t),g=M(t,"P",{"data-svelte-h":!0}),U(g)!=="svelte-4c8z9"&&(g.textContent=ht),D=n(t),C=M(t,"UL",{"data-svelte-h":!0}),U(C)!=="svelte-1cjdq4d"&&(C.innerHTML=gt),q=n(t),r=M(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),U(r)!=="svelte-1p5ulhk"&&(r.innerHTML=Ct),N=n(t),o(R.$$.fragment,t),S=n(t),j=M(t,"P",{"data-svelte-h":!0}),U(j)!=="svelte-1k5jnun"&&(j.innerHTML=Rt),P=n(t),o(Q.$$.fragment,t),K=n(t),_=M(t,"P",{"data-svelte-h":!0}),U(_)!=="svelte-1p4bgbz"&&(_.innerHTML=jt),tt=n(t),o(V.$$.fragment,t),lt=n(t),o($.$$.fragment,t),et=n(t),T=M(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),U(T)!=="svelte-58qijq"&&(T.innerHTML=Qt),at=n(t),w=M(t,"P",{"data-svelte-h":!0}),U(w)!=="svelte-16cf1kv"&&(w.innerHTML=_t),st=n(t),I=M(t,"P",{"data-svelte-h":!0}),U(I)!=="svelte-e3mk3h"&&(I.innerHTML=Vt),nt=n(t),o(k.$$.fragment,t),it=n(t),Z=M(t,"P",{"data-svelte-h":!0}),U(Z)!=="svelte-1lt9lvo"&&(Z.innerHTML=$t),Mt=n(t),o(b.$$.fragment,t),Ut=n(t),F=M(t,"P",{"data-svelte-h":!0}),U(F)!=="svelte-dnwxvl"&&(F.innerHTML=wt),pt=n(t),o(E.$$.fragment,t),ot=n(t),o(B.$$.fragment,t),dt=n(t),G=M(t,"P",{"data-svelte-h":!0}),U(G)!=="svelte-18gini8"&&(G.innerHTML=It),ft=n(t),x=M(t,"P",{"data-svelte-h":!0}),U(x)!=="svelte-18zbk5o"&&(x.innerHTML=kt),Jt=n(t),o(v.$$.fragment,t),mt=n(t),X=M(t,"P",{}),Zt(X).forEach(e),this.h()},h(){rt(c,"name","hf:doc:metadata"),rt(c,"content",Wt),rt(r,"class","tip"),rt(T,"class","tip")},m(t,l){vt(document.head,c),a(t,W,l),a(t,H,l),a(t,A,l),d(u,t,l),a(t,L,l),d(y,t,l),a(t,O,l),a(t,h,l),a(t,Y,l),a(t,g,l),a(t,D,l),a(t,C,l),a(t,q,l),a(t,r,l),a(t,N,l),d(R,t,l),a(t,S,l),a(t,j,l),a(t,P,l),d(Q,t,l),a(t,K,l),a(t,_,l),a(t,tt,l),d(V,t,l),a(t,lt,l),d($,t,l),a(t,et,l),a(t,T,l),a(t,at,l),a(t,w,l),a(t,st,l),a(t,I,l),a(t,nt,l),d(k,t,l),a(t,it,l),a(t,Z,l),a(t,Mt,l),d(b,t,l),a(t,Ut,l),a(t,F,l),a(t,pt,l),d(E,t,l),a(t,ot,l),d(B,t,l),a(t,dt,l),a(t,G,l),a(t,ft,l),a(t,x,l),a(t,Jt,l),d(v,t,l),a(t,mt,l),a(t,X,l),ct=!0},p:Ft,i(t){ct||(f(u.$$.fragment,t),f(y.$$.fragment,t),f(R.$$.fragment,t),f(Q.$$.fragment,t),f(V.$$.fragment,t),f($.$$.fragment,t),f(k.$$.fragment,t),f(b.$$.fragment,t),f(E.$$.fragment,t),f(B.$$.fragment,t),f(v.$$.fragment,t),ct=!0)},o(t){J(u.$$.fragment,t),J(y.$$.fragment,t),J(R.$$.fragment,t),J(Q.$$.fragment,t),J(V.$$.fragment,t),J($.$$.fragment,t),J(k.$$.fragment,t),J(b.$$.fragment,t),J(E.$$.fragment,t),J(B.$$.fragment,t),J(v.$$.fragment,t),ct=!1},d(t){t&&(e(W),e(H),e(A),e(L),e(O),e(h),e(Y),e(g),e(D),e(C),e(q),e(r),e(N),e(S),e(j),e(P),e(K),e(_),e(tt),e(lt),e(et),e(T),e(at),e(w),e(st),e(I),e(nt),e(it),e(Z),e(Mt),e(Ut),e(F),e(pt),e(ot),e(dt),e(G),e(ft),e(x),e(Jt),e(mt),e(X)),e(c),m(u,t),m(y,t),m(R,t),m(Q,t),m(V,t),m($,t),m(k,t),m(b,t),m(E,t),m(B,t),m(v,t)}}}const Wt='{"title":"학습을 위한 데이터셋 만들기","local":"학습을-위한-데이터셋-만들기","sections":[{"title":"폴더 형태로 데이터셋 구축하기","local":"폴더-형태로-데이터셋-구축하기","sections":[],"depth":2},{"title":"Hub에 데이터 올리기","local":"hub에-데이터-올리기","sections":[],"depth":2},{"title":"다음 단계","local":"다음-단계","sections":[],"depth":2}],"depth":1}';function At(ut){return Et(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends Bt{constructor(c){super(),Gt(this,c,At,zt,bt,{})}}export{qt as component};
