import{s as bt,o as Ft,n as Zt}from"../chunks/scheduler.94020406.js";import{S as Et,i as Gt,g as U,s as n,r as d,E as Bt,h as p,f as e,c as i,j as wt,u as f,x as o,k as It,y as Ht,a,v as r,d as m,t as J,w as c}from"../chunks/index.a08c8d92.js";import{T as kt}from"../chunks/Tip.3b0aeee8.js";import{C as A}from"../chunks/CodeBlock.b23cf525.js";import{H as Jt,E as zt}from"../chunks/EditOnGithub.b1bceb47.js";function Wt(v){let s,T='💡 학습에 사용할 이미지 데이터셋을 만드는 방법에 대한 자세한 내용은 <a href="https://huggingface.co/docs/datasets/image_dataset" rel="nofollow">이미지 데이터셋 만들기</a> 가이드를 참고하세요.';return{c(){s=U("p"),s.innerHTML=T},l(M){s=p(M,"P",{"data-svelte-h":!0}),o(s)!=="svelte-12snu9f"&&(s.innerHTML=T)},m(M,u){a(M,s,u)},p:Zt,d(M){M&&e(s)}}}function Xt(v){let s,T='💡 데이터셋을 만들고 Hub에 업로드하는 것에 대한 자세한 내용은 <a href="https://huggingface.co/blog/image-search-datasets" rel="nofollow">🤗 Datasets을 사용한 이미지 검색</a> 게시물을 참고하세요.';return{c(){s=U("p"),s.innerHTML=T},l(M){s=p(M,"P",{"data-svelte-h":!0}),o(s)!=="svelte-t4tr1t"&&(s.innerHTML=T)},m(M,u){a(M,s,u)},p:Zt,d(M){M&&e(s)}}}function vt(v){let s,T,M,u,g,D,C,ct=`<a href="https://huggingface.co/datasets?task_categories=task_categories:text-to-image&amp;sort=downloads" rel="nofollow">Hub</a> 에는 모델 교육을 위한 많은 데이터셋이 있지만,
관심이 있거나 사용하고 싶은 데이터셋을 찾을 수 없는 경우 🤗 <a href="hf.co/docs/datasets">Datasets</a> 라이브러리를 사용하여 데이터셋을 만들 수 있습니다.
데이터셋 구조는 모델을 학습하려는 작업에 따라 달라집니다.
가장 기본적인 데이터셋 구조는 unconditional 이미지 생성과 같은 작업을 위한 이미지 디렉토리입니다.
또 다른 데이터셋 구조는 이미지 디렉토리와 text-to-image 생성과 같은 작업에 해당하는 텍스트 캡션이 포함된 텍스트 파일일 수 있습니다.`,Y,j,Tt="이 가이드에는 파인 튜닝할 데이터셋을 만드는 두 가지 방법을 소개합니다:",N,R,ut="<li>이미지 폴더를 <code>--train_data_dir</code> 인수에 제공합니다.</li> <li>데이터셋을 Hub에 업로드하고 데이터셋 리포지토리 id를 <code>--dataset_name</code> 인수에 전달합니다.</li>",O,h,L,$,q,_,ht=`Unconditional 생성을 위해 이미지 폴더로 자신의 데이터셋을 구축할 수 있습니다.
학습 스크립트는 🤗 Datasets의 <a href="https://huggingface.co/docs/datasets/en/image_dataset#imagefolder" rel="nofollow">ImageFolder</a> 빌더를 사용하여
자동으로 폴더에서 데이터셋을 구축합니다. 디렉토리 구조는 다음과 같아야 합니다 :`,S,Q,P,V,yt="데이터셋 디렉터리의 경로를 <code>--train_data_dir</code> 인수로 전달한 다음 학습을 시작할 수 있습니다:",K,w,tt,I,lt,y,et,k,gt='PIL 인코딩된 이미지가 포함된 <code>이미지</code> 열을 생성하는 <a href="https://huggingface.co/docs/datasets/image_load#imagefolder" rel="nofollow">이미지 폴더</a> 기능을 사용하여 데이터셋 생성을 시작합니다.',at,Z,Ct=`<code>data_dir</code> 또는 <code>data_files</code> 매개 변수를 사용하여 데이터셋의 위치를 지정할 수 있습니다.
<code>data_files</code> 매개변수는 특정 파일을 <code>train</code> 이나 <code>test</code> 로 분리한 데이터셋에 매핑하는 것을 지원합니다:`,st,b,nt,F,jt='[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에 데이터셋을 업로드 합니다:',it,E,Mt,G,Rt="이제 데이터셋 이름을 <code>--dataset_name</code> 인수에 전달하여 데이터셋을 학습에 사용할 수 있습니다:",Ut,B,pt,H,ot,z,$t="데이터셋을 생성했으니 이제 학습 스크립트의 <code>train_data_dir</code> (데이터셋이 로컬이면) 혹은 <code>dataset_name</code> (Hub에 데이터셋을 올렸으면) 인수에 연결할 수 있습니다.",dt,W,_t='다음 단계에서는 데이터셋을 사용하여 <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>을 위한 모델을 학습시켜보세요!',ft,X,rt,x,mt;return g=new Jt({props:{title:"학습을 위한 데이터셋 만들기",local:"학습을-위한-데이터셋-만들기",headingTag:"h1"}}),h=new kt({props:{$$slots:{default:[Wt]},$$scope:{ctx:v}}}),$=new Jt({props:{title:"폴더 형태로 데이터셋 구축하기",local:"폴더-형태로-데이터셋-구축하기",headingTag:"h2"}}),Q=new A({props:{code:"ZGF0YV9kaXIlMkZ4eHgucG5nJTBBZGF0YV9kaXIlMkZ4eHkucG5nJTBBZGF0YV9kaXIlMkYlNUIuLi4lNUQlMkZ4eHoucG5n",highlighted:`data_dir/xxx.png
data_dir/xxy.png
data_dir/[...]/xxz.png`,wrap:!1}}),w=new A({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}}),I=new Jt({props:{title:"Hub에 데이터 올리기",local:"hub에-데이터-올리기",headingTag:"h2"}}),y=new kt({props:{$$slots:{default:[Xt]},$$scope:{ctx:v}}}),b=new A({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBJTIzJTIwJUVDJTk4JTg4JUVDJThCJTlDJTIwMSUzQSUyMCVFQiVBMSU5QyVFQyVCQiVBQyUyMCVFRCU4RiVCNCVFQiU4RCU5NCUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaW1hZ2Vmb2xkZXIlMjIlMkMlMjBkYXRhX2RpciUzRCUyMnBhdGhfdG9feW91cl9mb2xkZXIlMjIpJTBBJTBBJTIzJTIwJUVDJTk4JTg4JUVDJThCJTlDJTIwMiUzQSUyMCVFQiVBMSU5QyVFQyVCQiVBQyUyMCVFRCU4QyU4QyVFQyU5RCVCQyUyMCglRUMlQTclODAlRUMlOUIlOTAlMjAlRUQlOEYlQUMlRUIlQTclQjclMjAlM0ElMjB0YXIlMkMlMjBnemlwJTJDJTIwemlwJTJDJTIweHolMkMlMjByYXIlMkMlMjB6c3RkKSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaW1hZ2Vmb2xkZXIlMjIlMkMlMjBkYXRhX2ZpbGVzJTNEJTIycGF0aF90b196aXBfZmlsZSUyMiklMEElMEElMjMlMjAlRUMlOTglODglRUMlOEIlOUMlMjAzJTNBJTIwJUVDJTlCJTkwJUVBJUIyJUE5JTIwJUVEJThDJThDJUVDJTlEJUJDJTIwKCVFQyVBNyU4MCVFQyU5QiU5MCUyMCVFRCU4RiVBQyVFQiVBNyVCNyUyMCUzQSUyMHRhciUyQyUyMGd6aXAlMkMlMjB6aXAlMkMlMjB4eiUyQyUyMHJhciUyQyUyMHpzdGQpJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMEElMjAlMjAlMjAlMjAlMjJpbWFnZWZvbGRlciUyMiUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfZmlsZXMlM0QlMjJodHRwcyUzQSUyRiUyRmRvd25sb2FkLm1pY3Jvc29mdC5jb20lMkZkb3dubG9hZCUyRjMlMkZFJTJGMSUyRjNFMUMzRjIxLUVDREItNDg2OS04MzY4LTZERUJBNzdCOTE5RiUyRmthZ2dsZWNhdHNhbmRkb2dzXzMzNjdhLnppcCUyMiUyQyUwQSklMEElMEElMjMlMjAlRUMlOTglODglRUMlOEIlOUMlMjA0JTNBJTIwJUVDJTk3JUFDJUVCJTlGJUFDJUVBJUIwJTlDJUVCJUExJTlDJTIwJUVCJUI2JTg0JUVEJTk1JUEwJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMEElMjAlMjAlMjAlMjAlMjJpbWFnZWZvbGRlciUyMiUyQyUyMGRhdGFfZmlsZXMlM0QlN0IlMjJ0cmFpbiUyMiUzQSUyMCU1QiUyMnBhdGglMkZ0byUyRmZpbGUxJTIyJTJDJTIwJTIycGF0aCUyRnRvJTJGZmlsZTIlMjIlNUQlMkMlMjAlMjJ0ZXN0JTIyJTNBJTIwJTVCJTIycGF0aCUyRnRvJTJGZmlsZTMlMjIlMkMlMjAlMjJwYXRoJTJGdG8lMkZmaWxlNCUyMiU1RCU3RCUwQSk=",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}}),E=new A({props:{code:"JTIzJTIwJUVEJTg0JUIwJUVCJUFGJUI4JUVCJTg0JTkwJUVDJTk3JTkwJUVDJTg0JTlDJTIwaHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4lMjAlRUMlQkIlQTQlRUIlQTclQTglRUIlOTMlOUMlRUIlQTUlQkMlMjAlRUMlOUQlQjQlRUIlQUYlQjglMjAlRUMlOEIlQTQlRUQlOTYlODklRUQlOTYlODglRUIlOEIlQTQlRUElQjMlQTAlMjAlRUElQjAlODAlRUMlQTAlOTUlRUQlOTUlQTklRUIlOEIlODglRUIlOEIlQTQlMEFkYXRhc2V0LnB1c2hfdG9faHViKCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyKSUwQSUwQSUyMyUyMCVFQSVCMCU5QyVFQyU5RCVCOCUyMHJlcG8lRUIlQTElOUMlMjBwdXNoJTIwJUVEJTk1JTk4JUVBJUIzJUEwJTIwJUVDJThCJUI2JUVCJThCJUE0JUVCJUE5JUI0JTJDJTIwJTYwcHJpdmF0ZSUzRFRydWUlNjAlMjAlRUMlOUQlODQlMjAlRUMlQjYlOTQlRUElQjAlODAlRUQlOTUlOTglRUMlODQlQjglRUMlOUElOTQlM0ElMEFkYXRhc2V0LnB1c2hfdG9faHViKCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyJTJDJTIwcHJpdmF0ZSUzRFRydWUp",highlighted:`<span class="hljs-comment"># 터미널에서 huggingface-cli 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}}),B=new A({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCUyMHRyYWluX3RleHRfdG9faW1hZ2UucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMjAlNUMlMEElMjAlMjAtLWRhdGFzZXRfbmFtZSUzRCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyJTIwJTVDJTBBJTIwJTIwJTNDb3RoZXItYXJndW1lbnRzJTNF",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;runwayml/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}}),H=new Jt({props:{title:"다음 단계",local:"다음-단계",headingTag:"h2"}}),X=new zt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/training/create_dataset.md"}}),{c(){s=U("meta"),T=n(),M=U("p"),u=n(),d(g.$$.fragment),D=n(),C=U("p"),C.innerHTML=ct,Y=n(),j=U("p"),j.textContent=Tt,N=n(),R=U("ul"),R.innerHTML=ut,O=n(),d(h.$$.fragment),L=n(),d($.$$.fragment),q=n(),_=U("p"),_.innerHTML=ht,S=n(),d(Q.$$.fragment),P=n(),V=U("p"),V.innerHTML=yt,K=n(),d(w.$$.fragment),tt=n(),d(I.$$.fragment),lt=n(),d(y.$$.fragment),et=n(),k=U("p"),k.innerHTML=gt,at=n(),Z=U("p"),Z.innerHTML=Ct,st=n(),d(b.$$.fragment),nt=n(),F=U("p"),F.innerHTML=jt,it=n(),d(E.$$.fragment),Mt=n(),G=U("p"),G.innerHTML=Rt,Ut=n(),d(B.$$.fragment),pt=n(),d(H.$$.fragment),ot=n(),z=U("p"),z.innerHTML=$t,dt=n(),W=U("p"),W.innerHTML=_t,ft=n(),d(X.$$.fragment),rt=n(),x=U("p"),this.h()},l(t){const l=Bt("svelte-u9bgzb",document.head);s=p(l,"META",{name:!0,content:!0}),l.forEach(e),T=i(t),M=p(t,"P",{}),wt(M).forEach(e),u=i(t),f(g.$$.fragment,t),D=i(t),C=p(t,"P",{"data-svelte-h":!0}),o(C)!=="svelte-1oiutet"&&(C.innerHTML=ct),Y=i(t),j=p(t,"P",{"data-svelte-h":!0}),o(j)!=="svelte-4c8z9"&&(j.textContent=Tt),N=i(t),R=p(t,"UL",{"data-svelte-h":!0}),o(R)!=="svelte-1cjdq4d"&&(R.innerHTML=ut),O=i(t),f(h.$$.fragment,t),L=i(t),f($.$$.fragment,t),q=i(t),_=p(t,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1k5jnun"&&(_.innerHTML=ht),S=i(t),f(Q.$$.fragment,t),P=i(t),V=p(t,"P",{"data-svelte-h":!0}),o(V)!=="svelte-1p4bgbz"&&(V.innerHTML=yt),K=i(t),f(w.$$.fragment,t),tt=i(t),f(I.$$.fragment,t),lt=i(t),f(y.$$.fragment,t),et=i(t),k=p(t,"P",{"data-svelte-h":!0}),o(k)!=="svelte-16cf1kv"&&(k.innerHTML=gt),at=i(t),Z=p(t,"P",{"data-svelte-h":!0}),o(Z)!=="svelte-e3mk3h"&&(Z.innerHTML=Ct),st=i(t),f(b.$$.fragment,t),nt=i(t),F=p(t,"P",{"data-svelte-h":!0}),o(F)!=="svelte-1lt9lvo"&&(F.innerHTML=jt),it=i(t),f(E.$$.fragment,t),Mt=i(t),G=p(t,"P",{"data-svelte-h":!0}),o(G)!=="svelte-dnwxvl"&&(G.innerHTML=Rt),Ut=i(t),f(B.$$.fragment,t),pt=i(t),f(H.$$.fragment,t),ot=i(t),z=p(t,"P",{"data-svelte-h":!0}),o(z)!=="svelte-18gini8"&&(z.innerHTML=$t),dt=i(t),W=p(t,"P",{"data-svelte-h":!0}),o(W)!=="svelte-18zbk5o"&&(W.innerHTML=_t),ft=i(t),f(X.$$.fragment,t),rt=i(t),x=p(t,"P",{}),wt(x).forEach(e),this.h()},h(){It(s,"name","hf:doc:metadata"),It(s,"content",xt)},m(t,l){Ht(document.head,s),a(t,T,l),a(t,M,l),a(t,u,l),r(g,t,l),a(t,D,l),a(t,C,l),a(t,Y,l),a(t,j,l),a(t,N,l),a(t,R,l),a(t,O,l),r(h,t,l),a(t,L,l),r($,t,l),a(t,q,l),a(t,_,l),a(t,S,l),r(Q,t,l),a(t,P,l),a(t,V,l),a(t,K,l),r(w,t,l),a(t,tt,l),r(I,t,l),a(t,lt,l),r(y,t,l),a(t,et,l),a(t,k,l),a(t,at,l),a(t,Z,l),a(t,st,l),r(b,t,l),a(t,nt,l),a(t,F,l),a(t,it,l),r(E,t,l),a(t,Mt,l),a(t,G,l),a(t,Ut,l),r(B,t,l),a(t,pt,l),r(H,t,l),a(t,ot,l),a(t,z,l),a(t,dt,l),a(t,W,l),a(t,ft,l),r(X,t,l),a(t,rt,l),a(t,x,l),mt=!0},p(t,[l]){const Qt={};l&2&&(Qt.$$scope={dirty:l,ctx:t}),h.$set(Qt);const Vt={};l&2&&(Vt.$$scope={dirty:l,ctx:t}),y.$set(Vt)},i(t){mt||(m(g.$$.fragment,t),m(h.$$.fragment,t),m($.$$.fragment,t),m(Q.$$.fragment,t),m(w.$$.fragment,t),m(I.$$.fragment,t),m(y.$$.fragment,t),m(b.$$.fragment,t),m(E.$$.fragment,t),m(B.$$.fragment,t),m(H.$$.fragment,t),m(X.$$.fragment,t),mt=!0)},o(t){J(g.$$.fragment,t),J(h.$$.fragment,t),J($.$$.fragment,t),J(Q.$$.fragment,t),J(w.$$.fragment,t),J(I.$$.fragment,t),J(y.$$.fragment,t),J(b.$$.fragment,t),J(E.$$.fragment,t),J(B.$$.fragment,t),J(H.$$.fragment,t),J(X.$$.fragment,t),mt=!1},d(t){t&&(e(T),e(M),e(u),e(D),e(C),e(Y),e(j),e(N),e(R),e(O),e(L),e(q),e(_),e(S),e(P),e(V),e(K),e(tt),e(lt),e(et),e(k),e(at),e(Z),e(st),e(nt),e(F),e(it),e(Mt),e(G),e(Ut),e(pt),e(ot),e(z),e(dt),e(W),e(ft),e(rt),e(x)),e(s),c(g,t),c(h,t),c($,t),c(Q,t),c(w,t),c(I,t),c(y,t),c(b,t),c(E,t),c(B,t),c(H,t),c(X,t)}}}const xt='{"title":"학습을 위한 데이터셋 만들기","local":"학습을-위한-데이터셋-만들기","sections":[{"title":"폴더 형태로 데이터셋 구축하기","local":"폴더-형태로-데이터셋-구축하기","sections":[],"depth":2},{"title":"Hub에 데이터 올리기","local":"hub에-데이터-올리기","sections":[],"depth":2},{"title":"다음 단계","local":"다음-단계","sections":[],"depth":2}],"depth":1}';function At(v){return Ft(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends Et{constructor(s){super(),Gt(this,s,At,vt,bt,{})}}export{qt as component};
