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