import{s as vt,o as xt,n as Bt}from"../chunks/scheduler.8c3d61f6.js";import{S as Rt,i as Ht,g as r,s as n,r as m,A as Yt,h as d,f as a,c as o,j as It,u,x as p,k as Gt,y as Ct,a as l,v as f,d as c,t as M,w as h}from"../chunks/index.da70eac4.js";import{T as Xt}from"../chunks/Tip.1d9b8c37.js";import{C as q}from"../chunks/CodeBlock.00a903b3.js";import{H as Mt,E as Wt}from"../chunks/EditOnGithub.1e64e623.js";function zt(E){let s,g='💡 Learn more about how to create an image dataset for training in the <a href="https://huggingface.co/docs/datasets/image_dataset" rel="nofollow">Create an image dataset</a> guide.';return{c(){s=r("p"),s.innerHTML=g},l(i){s=d(i,"P",{"data-svelte-h":!0}),p(s)!=="svelte-yz61dz"&&(s.innerHTML=g)},m(i,T){l(i,s,T)},p:Bt,d(i){i&&a(s)}}}function Ft(E){let s,g='💡 For more details and context about creating and uploading a dataset to the Hub, take a look at the <a href="https://huggingface.co/blog/image-search-datasets" rel="nofollow">Image search with 🤗 Datasets</a> post.';return{c(){s=r("p"),s.innerHTML=g},l(i){s=d(i,"P",{"data-svelte-h":!0}),p(s)!=="svelte-1wagfs8"&&(s.innerHTML=g)},m(i,T){l(i,s,T)},p:Bt,d(i){i&&a(s)}}}function Et(E){let s,g,i,T,J,L,w,ht='There are many datasets on the <a href="https://huggingface.co/datasets?task_categories=task_categories:text-to-image&amp;sort=downloads" rel="nofollow">Hub</a> to train a model on, but if you can’t find one you’re interested in or want to use your own, you can create a dataset with the 🤗 <a href="hf.co/docs/datasets">Datasets</a> library. The dataset structure depends on the task you want to train your model on. The most basic dataset structure is a directory of images for tasks like unconditional image generation. Another dataset structure may be a directory of images and a text file containing their corresponding text captions for tasks like text-to-image generation.',A,j,gt="This guide will show you two ways to create a dataset to finetune on:",Q,_,Tt="<li>provide a folder of images to the <code>--train_data_dir</code> argument</li> <li>upload a dataset to the Hub and pass the dataset repository id to the <code>--dataset_name</code> argument</li>",V,y,S,b,P,Z,yt='For unconditional generation, you can provide your own dataset as a folder of images. The training script uses the <a href="https://huggingface.co/docs/datasets/en/image_dataset#imagefolder" rel="nofollow"><code>ImageFolder</code></a> builder from 🤗 Datasets to automatically build a dataset from the folder. Your directory structure should look like:',D,U,K,k,$t="Pass the path to the dataset directory to the <code>--train_data_dir</code> argument, and then you can start training:",O,I,tt,G,et,$,at,X,Jt='Start by creating a dataset with the <a href="https://huggingface.co/docs/datasets/image_load#imagefolder" rel="nofollow"><code>ImageFolder</code></a> feature, which creates an <code>image</code> column containing the PIL-encoded images.',lt,B,wt="You can use the <code>data_dir</code> or <code>data_files</code> parameters to specify the location of the dataset. The <code>data_files</code> parameter supports mapping specific files to dataset splits like <code>train</code> or <code>test</code>:",st,v,nt,x,jt='Then use the <a href="https://huggingface.co/docs/datasets/v3.0.0/en/package_reference/main_classes#datasets.Dataset.push_to_hub" rel="nofollow">push_to_hub</a> method to upload the dataset to the Hub:',ot,R,it,H,_t="Now the dataset is available for training by passing the dataset name to the <code>--dataset_name</code> argument:",rt,Y,dt,C,pt,W,bt="Now that you’ve created a dataset, you can plug it into the <code>train_data_dir</code> (if your dataset is local) or <code>dataset_name</code> (if your dataset is on the Hub) arguments of a training script.",mt,z,Zt='For your next steps, feel free to try and use your dataset to train a model for <a href="unconditional_training">unconditional generation</a> or <a href="text2image">text-to-image generation</a>!',ut,F,ft,N,ct;return J=new Mt({props:{title:"Create a dataset for training",local:"create-a-dataset-for-training",headingTag:"h1"}}),y=new Xt({props:{$$slots:{default:[zt]},$$scope:{ctx:E}}}),b=new Mt({props:{title:"Provide a dataset as a folder",local:"provide-a-dataset-as-a-folder",headingTag:"h2"}}),U=new q({props:{code:"ZGF0YV9kaXIlMkZ4eHgucG5nJTBBZGF0YV9kaXIlMkZ4eHkucG5nJTBBZGF0YV9kaXIlMkYlNUIuLi4lNUQlMkZ4eHoucG5n",highlighted:`data_dir/xxx.png
data_dir/xxy.png
data_dir/[...]/xxz.png`,wrap:!1}}),I=new q({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRyYWluX2RhdGFfZGlyJTIwJTNDcGF0aC10by10cmFpbi1kaXJlY3RvcnklM0UlMjAlNUMlMEElMjAlMjAlMjAlMjAlM0NvdGhlci1hcmd1bWVudHMlM0U=",highlighted:`accelerate launch train_unconditional.py \\
    --train_data_dir &lt;path-to-train-directory&gt; \\
    &lt;other-arguments&gt;`,wrap:!1}}),G=new Mt({props:{title:"Upload your data to the Hub",local:"upload-your-data-to-the-hub",headingTag:"h2"}}),$=new Xt({props:{$$slots:{default:[Ft]},$$scope:{ctx:E}}}),v=new q({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBJTIzJTIwZXhhbXBsZSUyMDElM0ElMjBsb2NhbCUyMGZvbGRlciUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaW1hZ2Vmb2xkZXIlMjIlMkMlMjBkYXRhX2RpciUzRCUyMnBhdGhfdG9feW91cl9mb2xkZXIlMjIpJTBBJTBBJTIzJTIwZXhhbXBsZSUyMDIlM0ElMjBsb2NhbCUyMGZpbGVzJTIwKHN1cHBvcnRlZCUyMGZvcm1hdHMlMjBhcmUlMjB0YXIlMkMlMjBnemlwJTJDJTIwemlwJTJDJTIweHolMkMlMjByYXIlMkMlMjB6c3RkKSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaW1hZ2Vmb2xkZXIlMjIlMkMlMjBkYXRhX2ZpbGVzJTNEJTIycGF0aF90b196aXBfZmlsZSUyMiklMEElMEElMjMlMjBleGFtcGxlJTIwMyUzQSUyMHJlbW90ZSUyMGZpbGVzJTIwKHN1cHBvcnRlZCUyMGZvcm1hdHMlMjBhcmUlMjB0YXIlMkMlMjBnemlwJTJDJTIwemlwJTJDJTIweHolMkMlMjByYXIlMkMlMjB6c3RkKSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwJTIyaW1hZ2Vmb2xkZXIlMjIlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2ZpbGVzJTNEJTIyaHR0cHMlM0ElMkYlMkZkb3dubG9hZC5taWNyb3NvZnQuY29tJTJGZG93bmxvYWQlMkYzJTJGRSUyRjElMkYzRTFDM0YyMS1FQ0RCLTQ4NjktODM2OC02REVCQTc3QjkxOUYlMkZrYWdnbGVjYXRzYW5kZG9nc18zMzY3YS56aXAlMjIlMkMlMEEpJTBBJTBBJTIzJTIwZXhhbXBsZSUyMDQlM0ElMjBwcm92aWRpbmclMjBzZXZlcmFsJTIwc3BsaXRzJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMEElMjAlMjAlMjAlMjAlMjJpbWFnZWZvbGRlciUyMiUyQyUyMGRhdGFfZmlsZXMlM0QlN0IlMjJ0cmFpbiUyMiUzQSUyMCU1QiUyMnBhdGglMkZ0byUyRmZpbGUxJTIyJTJDJTIwJTIycGF0aCUyRnRvJTJGZmlsZTIlMjIlNUQlMkMlMjAlMjJ0ZXN0JTIyJTNBJTIwJTVCJTIycGF0aCUyRnRvJTJGZmlsZTMlMjIlMkMlMjAlMjJwYXRoJTJGdG8lMkZmaWxlNCUyMiU1RCU3RCUwQSk=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-comment"># example 1: local folder</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"># example 2: local files (supported formats are 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"># example 3: remote files (supported formats are 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"># example 4: providing several splits</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}}),R=new q({props:{code:"JTIzJTIwYXNzdW1pbmclMjB5b3UlMjBoYXZlJTIwcmFuJTIwdGhlJTIwaHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4lMjBjb21tYW5kJTIwaW4lMjBhJTIwdGVybWluYWwlMEFkYXRhc2V0LnB1c2hfdG9faHViKCUyMm5hbWVfb2ZfeW91cl9kYXRhc2V0JTIyKSUwQSUwQSUyMyUyMGlmJTIweW91JTIwd2FudCUyMHRvJTIwcHVzaCUyMHRvJTIwYSUyMHByaXZhdGUlMjByZXBvJTJDJTIwc2ltcGx5JTIwcGFzcyUyMHByaXZhdGUlM0RUcnVlJTNBJTBBZGF0YXNldC5wdXNoX3RvX2h1YiglMjJuYW1lX29mX3lvdXJfZGF0YXNldCUyMiUyQyUyMHByaXZhdGUlM0RUcnVlKQ==",highlighted:`<span class="hljs-comment"># assuming you have ran the huggingface-cli login command in a terminal</span>
dataset.push_to_hub(<span class="hljs-string">&quot;name_of_your_dataset&quot;</span>)

<span class="hljs-comment"># if you want to push to a private repo, simply pass 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}}),Y=new q({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}}),C=new Mt({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),F=new Wt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/create_dataset.md"}}),{c(){s=r("meta"),g=n(),i=r("p"),T=n(),m(J.$$.fragment),L=n(),w=r("p"),w.innerHTML=ht,A=n(),j=r("p"),j.textContent=gt,Q=n(),_=r("ul"),_.innerHTML=Tt,V=n(),m(y.$$.fragment),S=n(),m(b.$$.fragment),P=n(),Z=r("p"),Z.innerHTML=yt,D=n(),m(U.$$.fragment),K=n(),k=r("p"),k.innerHTML=$t,O=n(),m(I.$$.fragment),tt=n(),m(G.$$.fragment),et=n(),m($.$$.fragment),at=n(),X=r("p"),X.innerHTML=Jt,lt=n(),B=r("p"),B.innerHTML=wt,st=n(),m(v.$$.fragment),nt=n(),x=r("p"),x.innerHTML=jt,ot=n(),m(R.$$.fragment),it=n(),H=r("p"),H.innerHTML=_t,rt=n(),m(Y.$$.fragment),dt=n(),m(C.$$.fragment),pt=n(),W=r("p"),W.innerHTML=bt,mt=n(),z=r("p"),z.innerHTML=Zt,ut=n(),m(F.$$.fragment),ft=n(),N=r("p"),this.h()},l(t){const e=Yt("svelte-u9bgzb",document.head);s=d(e,"META",{name:!0,content:!0}),e.forEach(a),g=o(t),i=d(t,"P",{}),It(i).forEach(a),T=o(t),u(J.$$.fragment,t),L=o(t),w=d(t,"P",{"data-svelte-h":!0}),p(w)!=="svelte-x3y1lw"&&(w.innerHTML=ht),A=o(t),j=d(t,"P",{"data-svelte-h":!0}),p(j)!=="svelte-1ki6nhc"&&(j.textContent=gt),Q=o(t),_=d(t,"UL",{"data-svelte-h":!0}),p(_)!=="svelte-136e0w1"&&(_.innerHTML=Tt),V=o(t),u(y.$$.fragment,t),S=o(t),u(b.$$.fragment,t),P=o(t),Z=d(t,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-1tbm8ke"&&(Z.innerHTML=yt),D=o(t),u(U.$$.fragment,t),K=o(t),k=d(t,"P",{"data-svelte-h":!0}),p(k)!=="svelte-16r2a6g"&&(k.innerHTML=$t),O=o(t),u(I.$$.fragment,t),tt=o(t),u(G.$$.fragment,t),et=o(t),u($.$$.fragment,t),at=o(t),X=d(t,"P",{"data-svelte-h":!0}),p(X)!=="svelte-117nzzz"&&(X.innerHTML=Jt),lt=o(t),B=d(t,"P",{"data-svelte-h":!0}),p(B)!=="svelte-10hf74w"&&(B.innerHTML=wt),st=o(t),u(v.$$.fragment,t),nt=o(t),x=d(t,"P",{"data-svelte-h":!0}),p(x)!=="svelte-nvyg5i"&&(x.innerHTML=jt),ot=o(t),u(R.$$.fragment,t),it=o(t),H=d(t,"P",{"data-svelte-h":!0}),p(H)!=="svelte-19t9o3p"&&(H.innerHTML=_t),rt=o(t),u(Y.$$.fragment,t),dt=o(t),u(C.$$.fragment,t),pt=o(t),W=d(t,"P",{"data-svelte-h":!0}),p(W)!=="svelte-1ata9m5"&&(W.innerHTML=bt),mt=o(t),z=d(t,"P",{"data-svelte-h":!0}),p(z)!=="svelte-oyixgb"&&(z.innerHTML=Zt),ut=o(t),u(F.$$.fragment,t),ft=o(t),N=d(t,"P",{}),It(N).forEach(a),this.h()},h(){Gt(s,"name","hf:doc:metadata"),Gt(s,"content",Nt)},m(t,e){Ct(document.head,s),l(t,g,e),l(t,i,e),l(t,T,e),f(J,t,e),l(t,L,e),l(t,w,e),l(t,A,e),l(t,j,e),l(t,Q,e),l(t,_,e),l(t,V,e),f(y,t,e),l(t,S,e),f(b,t,e),l(t,P,e),l(t,Z,e),l(t,D,e),f(U,t,e),l(t,K,e),l(t,k,e),l(t,O,e),f(I,t,e),l(t,tt,e),f(G,t,e),l(t,et,e),f($,t,e),l(t,at,e),l(t,X,e),l(t,lt,e),l(t,B,e),l(t,st,e),f(v,t,e),l(t,nt,e),l(t,x,e),l(t,ot,e),f(R,t,e),l(t,it,e),l(t,H,e),l(t,rt,e),f(Y,t,e),l(t,dt,e),f(C,t,e),l(t,pt,e),l(t,W,e),l(t,mt,e),l(t,z,e),l(t,ut,e),f(F,t,e),l(t,ft,e),l(t,N,e),ct=!0},p(t,[e]){const Ut={};e&2&&(Ut.$$scope={dirty:e,ctx:t}),y.$set(Ut);const kt={};e&2&&(kt.$$scope={dirty:e,ctx:t}),$.$set(kt)},i(t){ct||(c(J.$$.fragment,t),c(y.$$.fragment,t),c(b.$$.fragment,t),c(U.$$.fragment,t),c(I.$$.fragment,t),c(G.$$.fragment,t),c($.$$.fragment,t),c(v.$$.fragment,t),c(R.$$.fragment,t),c(Y.$$.fragment,t),c(C.$$.fragment,t),c(F.$$.fragment,t),ct=!0)},o(t){M(J.$$.fragment,t),M(y.$$.fragment,t),M(b.$$.fragment,t),M(U.$$.fragment,t),M(I.$$.fragment,t),M(G.$$.fragment,t),M($.$$.fragment,t),M(v.$$.fragment,t),M(R.$$.fragment,t),M(Y.$$.fragment,t),M(C.$$.fragment,t),M(F.$$.fragment,t),ct=!1},d(t){t&&(a(g),a(i),a(T),a(L),a(w),a(A),a(j),a(Q),a(_),a(V),a(S),a(P),a(Z),a(D),a(K),a(k),a(O),a(tt),a(et),a(at),a(X),a(lt),a(B),a(st),a(nt),a(x),a(ot),a(it),a(H),a(rt),a(dt),a(pt),a(W),a(mt),a(z),a(ut),a(ft),a(N)),a(s),h(J,t),h(y,t),h(b,t),h(U,t),h(I,t),h(G,t),h($,t),h(v,t),h(R,t),h(Y,t),h(C,t),h(F,t)}}}const Nt='{"title":"Create a dataset for training","local":"create-a-dataset-for-training","sections":[{"title":"Provide a dataset as a folder","local":"provide-a-dataset-as-a-folder","sections":[],"depth":2},{"title":"Upload your data to the Hub","local":"upload-your-data-to-the-hub","sections":[],"depth":2},{"title":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function qt(E){return xt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pt extends Rt{constructor(s){super(),Ht(this,s,qt,Et,vt,{})}}export{Pt as component};
