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 f,E as Bt,h as p,f as e,c as i,j as wt,u as d,x as o,k as It,y as vt,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.7c41dfd5.js";import{C as A}from"../chunks/CodeBlock.f1fae7de.js";import{H as Jt,E as Ht}from"../chunks/getInferenceSnippets.a623b4cf.js";function Xt(x){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 Wt(x){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 xt(x){let s,T,M,u,g,Y,C,ct=`<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 생성과 같은 작업에 해당하는 텍스트 캡션이 포함된 텍스트 파일일 수 있습니다.`,D,R,Tt="이 가이드에는 파인 튜닝할 데이터셋을 만드는 두 가지 방법을 소개합니다:",L,j,ut="<li>이미지 폴더를 <code>--train_data_dir</code> 인수에 제공합니다.</li> <li>데이터셋을 Hub에 업로드하고 데이터셋 리포지토리 id를 <code>--dataset_name</code> 인수에 전달합니다.</li>",O,h,N,$,S,Q,ht=`Unconditional 생성을 위해 이미지 폴더로 자신의 데이터셋을 구축할 수 있습니다.
학습 스크립트는 🤗 Datasets의 <a href="https://huggingface.co/docs/datasets/en/image_dataset#imagefolder" rel="nofollow">ImageFolder</a> 빌더를 사용하여
자동으로 폴더에서 데이터셋을 구축합니다. 디렉토리 구조는 다음과 같아야 합니다 :`,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,Rt='[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,jt="이제 데이터셋 이름을 <code>--dataset_name</code> 인수에 전달하여 데이터셋을 학습에 사용할 수 있습니다:",Ut,B,pt,v,ot,H,$t="데이터셋을 생성했으니 이제 학습 스크립트의 <code>train_data_dir</code> (데이터셋이 로컬이면) 혹은 <code>dataset_name</code> (Hub에 데이터셋을 올렸으면) 인수에 연결할 수 있습니다.",ft,X,Qt='다음 단계에서는 데이터셋을 사용하여 <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>을 위한 모델을 학습시켜보세요!',dt,W,rt,z,mt;return g=new Jt({props:{title:"학습을 위한 데이터셋 만들기",local:"학습을-위한-데이터셋-만들기",headingTag:"h1"}}),h=new kt({props:{$$slots:{default:[Xt]},$$scope:{ctx:x}}}),$=new Jt({props:{title:"폴더 형태로 데이터셋 구축하기",local:"폴더-형태로-데이터셋-구축하기",headingTag:"h2"}}),_=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:[Wt]},$$scope:{ctx:x}}}),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:"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}}),B=new A({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}}),v=new Jt({props:{title:"다음 단계",local:"다음-단계",headingTag:"h2"}}),W=new Ht({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(),f(g.$$.fragment),Y=n(),C=U("p"),C.innerHTML=ct,D=n(),R=U("p"),R.textContent=Tt,L=n(),j=U("ul"),j.innerHTML=ut,O=n(),f(h.$$.fragment),N=n(),f($.$$.fragment),S=n(),Q=U("p"),Q.innerHTML=ht,q=n(),f(_.$$.fragment),P=n(),V=U("p"),V.innerHTML=yt,K=n(),f(w.$$.fragment),tt=n(),f(I.$$.fragment),lt=n(),f(y.$$.fragment),et=n(),k=U("p"),k.innerHTML=gt,at=n(),Z=U("p"),Z.innerHTML=Ct,st=n(),f(b.$$.fragment),nt=n(),F=U("p"),F.innerHTML=Rt,it=n(),f(E.$$.fragment),Mt=n(),G=U("p"),G.innerHTML=jt,Ut=n(),f(B.$$.fragment),pt=n(),f(v.$$.fragment),ot=n(),H=U("p"),H.innerHTML=$t,ft=n(),X=U("p"),X.innerHTML=Qt,dt=n(),f(W.$$.fragment),rt=n(),z=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),d(g.$$.fragment,t),Y=i(t),C=p(t,"P",{"data-svelte-h":!0}),o(C)!=="svelte-1kjp0s4"&&(C.innerHTML=ct),D=i(t),R=p(t,"P",{"data-svelte-h":!0}),o(R)!=="svelte-4c8z9"&&(R.textContent=Tt),L=i(t),j=p(t,"UL",{"data-svelte-h":!0}),o(j)!=="svelte-1cjdq4d"&&(j.innerHTML=ut),O=i(t),d(h.$$.fragment,t),N=i(t),d($.$$.fragment,t),S=i(t),Q=p(t,"P",{"data-svelte-h":!0}),o(Q)!=="svelte-1k5jnun"&&(Q.innerHTML=ht),q=i(t),d(_.$$.fragment,t),P=i(t),V=p(t,"P",{"data-svelte-h":!0}),o(V)!=="svelte-1p4bgbz"&&(V.innerHTML=yt),K=i(t),d(w.$$.fragment,t),tt=i(t),d(I.$$.fragment,t),lt=i(t),d(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),d(b.$$.fragment,t),nt=i(t),F=p(t,"P",{"data-svelte-h":!0}),o(F)!=="svelte-1lt9lvo"&&(F.innerHTML=Rt),it=i(t),d(E.$$.fragment,t),Mt=i(t),G=p(t,"P",{"data-svelte-h":!0}),o(G)!=="svelte-dnwxvl"&&(G.innerHTML=jt),Ut=i(t),d(B.$$.fragment,t),pt=i(t),d(v.$$.fragment,t),ot=i(t),H=p(t,"P",{"data-svelte-h":!0}),o(H)!=="svelte-18gini8"&&(H.innerHTML=$t),ft=i(t),X=p(t,"P",{"data-svelte-h":!0}),o(X)!=="svelte-18zbk5o"&&(X.innerHTML=Qt),dt=i(t),d(W.$$.fragment,t),rt=i(t),z=p(t,"P",{}),wt(z).forEach(e),this.h()},h(){It(s,"name","hf:doc:metadata"),It(s,"content",zt)},m(t,l){vt(document.head,s),a(t,T,l),a(t,M,l),a(t,u,l),r(g,t,l),a(t,Y,l),a(t,C,l),a(t,D,l),a(t,R,l),a(t,L,l),a(t,j,l),a(t,O,l),r(h,t,l),a(t,N,l),r($,t,l),a(t,S,l),a(t,Q,l),a(t,q,l),r(_,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(v,t,l),a(t,ot,l),a(t,H,l),a(t,ft,l),a(t,X,l),a(t,dt,l),r(W,t,l),a(t,rt,l),a(t,z,l),mt=!0},p(t,[l]){const _t={};l&2&&(_t.$$scope={dirty:l,ctx:t}),h.$set(_t);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(_.$$.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(v.$$.fragment,t),m(W.$$.fragment,t),mt=!0)},o(t){J(g.$$.fragment,t),J(h.$$.fragment,t),J($.$$.fragment,t),J(_.$$.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(v.$$.fragment,t),J(W.$$.fragment,t),mt=!1},d(t){t&&(e(T),e(M),e(u),e(Y),e(C),e(D),e(R),e(L),e(j),e(O),e(N),e(S),e(Q),e(q),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(H),e(ft),e(X),e(dt),e(rt),e(z)),e(s),c(g,t),c(h,t),c($,t),c(_,t),c(w,t),c(I,t),c(y,t),c(b,t),c(E,t),c(B,t),c(v,t),c(W,t)}}}const zt='{"title":"학습을 위한 데이터셋 만들기","local":"학습을-위한-데이터셋-만들기","sections":[{"title":"폴더 형태로 데이터셋 구축하기","local":"폴더-형태로-데이터셋-구축하기","sections":[],"depth":2},{"title":"Hub에 데이터 올리기","local":"hub에-데이터-올리기","sections":[],"depth":2},{"title":"다음 단계","local":"다음-단계","sections":[],"depth":2}],"depth":1}';function At(x){return Ft(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class St extends Et{constructor(s){super(),Gt(this,s,At,xt,bt,{})}}export{St as component};
