Buckets:
| import{s as $t,o as Jt,n as pe}from"../chunks/scheduler.182ea377.js";import{S as Ct,i as Tt,g as c,s as i,r as d,A as _t,h as u,f as l,c as o,j as bt,u as y,x as m,k as jt,y as kt,a as n,v as h,d as g,t as U,w as b}from"../chunks/index.abf12888.js";import{T as De}from"../chunks/Tip.230e2334.js";import{C as $}from"../chunks/CodeBlock.57fe6e13.js";import{H as Fe,E as Gt}from"../chunks/EditOnGithub.9b8e78e4.js";import{H as Zt,a as wt}from"../chunks/HfOption.fc88c804.js";function It(j){let a,M='🤗 Accelerate is a library for helping you train on multiple GPUs/TPUs or with mixed-precision. It’ll automatically configure your training setup based on your hardware and environment. Take a look at the 🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">Quick tour</a> to learn more.';return{c(){a=c("p"),a.innerHTML=M},l(s){a=u(s,"P",{"data-svelte-h":!0}),m(a)!=="svelte-1qbiqsn"&&(a.innerHTML=M)},m(s,f){n(s,a,f)},p:pe,d(s){s&&l(a)}}}function At(j){let a,M='The following sections highlight parts of the training script that are important for understanding how to modify it, but it doesn’t cover every aspect of the script in detail. If you’re interested in learning more, feel free to read through the <a href="https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/train_unconditional.py" rel="nofollow">script</a> and let us know if you have any questions or concerns.';return{c(){a=c("p"),a.innerHTML=M},l(s){a=u(s,"P",{"data-svelte-h":!0}),m(a)!=="svelte-1efpx6r"&&(a.innerHTML=M)},m(s,f){n(s,a,f)},p:pe,d(s){s&&l(a)}}}function Wt(j){let a,M="A full training run takes 2 hours on 4xV100 GPUs.";return{c(){a=c("p"),a.textContent=M},l(s){a=u(s,"P",{"data-svelte-h":!0}),m(a)!=="svelte-1k3fy07"&&(a.textContent=M)},m(s,f){n(s,a,f)},p:pe,d(s){s&&l(a)}}}function Rt(j){let a,M;return a=new $({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAtLWRhdGFzZXRfbmFtZSUzRCUyMmh1Z2dhbiUyRmZsb3dlcnMtMTAyLWNhdGVnb3JpZXMlMjIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjJkZHBtLWVtYS1mbG93ZXJzLTY0JTIyJTIwJTVDJTBBJTIwJTIwLS1taXhlZF9wcmVjaXNpb24lM0QlMjJmcDE2JTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch train_unconditional.py \\ | |
| --dataset_name=<span class="hljs-string">"huggan/flowers-102-categories"</span> \\ | |
| --output_dir=<span class="hljs-string">"ddpm-ema-flowers-64"</span> \\ | |
| --mixed_precision=<span class="hljs-string">"fp16"</span> \\ | |
| --push_to_hub`,wrap:!1}}),{c(){d(a.$$.fragment)},l(s){y(a.$$.fragment,s)},m(s,f){h(a,s,f),M=!0},p:pe,i(s){M||(g(a.$$.fragment,s),M=!0)},o(s){U(a.$$.fragment,s),M=!1},d(s){b(a,s)}}}function vt(j){let a,M="If you’re training with more than one GPU, add the <code>--multi_gpu</code> parameter to the training command:",s,f,r;return f=new $({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbXVsdGlfZ3B1JTIwdHJhaW5fdW5jb25kaXRpb25hbC5weSUyMCU1QyUwQSUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTIyaHVnZ2FuJTJGZmxvd2Vycy0xMDItY2F0ZWdvcmllcyUyMiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyMmRkcG0tZW1hLWZsb3dlcnMtNjQlMjIlMjAlNUMlMEElMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjIlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`accelerate launch --multi_gpu train_unconditional.py \\ | |
| --dataset_name=<span class="hljs-string">"huggan/flowers-102-categories"</span> \\ | |
| --output_dir=<span class="hljs-string">"ddpm-ema-flowers-64"</span> \\ | |
| --mixed_precision=<span class="hljs-string">"fp16"</span> \\ | |
| --push_to_hub`,wrap:!1}}),{c(){a=c("p"),a.innerHTML=M,s=i(),d(f.$$.fragment)},l(p){a=u(p,"P",{"data-svelte-h":!0}),m(a)!=="svelte-93d1lr"&&(a.innerHTML=M),s=o(p),y(f.$$.fragment,p)},m(p,w){n(p,a,w),n(p,s,w),h(f,p,w),r=!0},p:pe,i(p){r||(g(f.$$.fragment,p),r=!0)},o(p){U(f.$$.fragment,p),r=!1},d(p){p&&(l(a),l(s)),b(f,p)}}}function xt(j){let a,M,s,f;return a=new wt({props:{id:"launchtraining",option:"single GPU",$$slots:{default:[Rt]},$$scope:{ctx:j}}}),s=new wt({props:{id:"launchtraining",option:"multi-GPU",$$slots:{default:[vt]},$$scope:{ctx:j}}}),{c(){d(a.$$.fragment),M=i(),d(s.$$.fragment)},l(r){y(a.$$.fragment,r),M=o(r),y(s.$$.fragment,r)},m(r,p){h(a,r,p),n(r,M,p),h(s,r,p),f=!0},p(r,p){const w={};p&2&&(w.$$scope={dirty:p,ctx:r}),a.$set(w);const oe={};p&2&&(oe.$$scope={dirty:p,ctx:r}),s.$set(oe)},i(r){f||(g(a.$$.fragment,r),g(s.$$.fragment,r),f=!0)},o(r){U(a.$$.fragment,r),U(s.$$.fragment,r),f=!1},d(r){r&&l(M),b(a,r),b(s,r)}}}function Bt(j){let a,M,s,f,r,p,w,oe="Unconditional image generation models are not conditioned on text or images during training. It only generates images that resemble its training data distribution.",ce,k,Pe='This guide will explore the <a href="https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/train_unconditional.py" rel="nofollow">train_unconditional.py</a> training script to help you become familiar with it, and how you can adapt it for your own use-case.',ue,G,Ke="Before running the script, make sure you install the library from source:",Me,Z,fe,I,Oe="Then navigate to the example folder containing the training script and install the required dependencies:",me,A,de,J,ye,W,et="Initialize an 🤗 Accelerate environment:",he,R,ge,v,tt="To setup a default 🤗 Accelerate environment without choosing any configurations:",Ue,x,be,B,lt="Or if your environment doesn’t support an interactive shell like a notebook, you can use:",je,E,we,X,nt='Lastly, if you want to train a model on your own dataset, take a look at the <a href="create_dataset">Create a dataset for training</a> guide to learn how to create a dataset that works with the training script.',$e,Y,Je,C,Ce,N,at='The training script provides many parameters to help you customize your training run. All of the parameters and their descriptions are found in the <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L55" rel="nofollow"><code>parse_args()</code></a> function. It provides default values for each parameter, such as the training batch size and learning rate, but you can also set your own values in the training command if you’d like.',Te,V,st="For example, to speedup training with mixed precision using the bf16 format, add the <code>--mixed_precision</code> parameter to the training command:",_e,Q,ke,H,it="Some basic and important parameters to specify include:",Ge,z,ot="<li><code>--dataset_name</code>: the name of the dataset on the Hub or a local path to the dataset to train on</li> <li><code>--output_dir</code>: where to save the trained model</li> <li><code>--push_to_hub</code>: whether to push the trained model to the Hub</li> <li><code>--checkpointing_steps</code>: frequency of saving a checkpoint as the model trains; this is useful if training is interrupted, you can continue training from that checkpoint by adding <code>--resume_from_checkpoint</code> to your training command</li>",Ze,L,rt="Bring your dataset, and let the training script handle everything else!",Ie,S,Ae,q,pt='The code for preprocessing the dataset and the training loop is found in the <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L275" rel="nofollow"><code>main()</code></a> function. If you need to adapt the training script, this is where you’ll need to make your changes.',We,F,ct='The <code>train_unconditional</code> script <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L356" rel="nofollow">initializes a <code>UNet2DModel</code></a> if you don’t provide a model configuration. You can configure the UNet here if you’d like:',Re,D,ve,P,ut='Next, the script initializes a <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L418" rel="nofollow">scheduler</a> and <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L429" rel="nofollow">optimizer</a>:',xe,K,Be,O,Mt='Then it <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L451" rel="nofollow">loads a dataset</a> and you can specify how to <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L455" rel="nofollow">preprocess</a> it:',Ee,ee,Xe,te,ft='Finally, the <a href="https://github.com/huggingface/diffusers/blob/096f84b05f9514fae9f185cbec0a4d38fbad9919/examples/unconditional_image_generation/train_unconditional.py#L540" rel="nofollow">training loop</a> handles everything else such as adding noise to the images, predicting the noise residual, calculating the loss, saving checkpoints at specified steps, and saving and pushing the model to the Hub. If you want to learn more about how the training loop works, check out the <a href="../using-diffusers/write_own_pipeline">Understanding pipelines, models and schedulers</a> tutorial which breaks down the basic pattern of the denoising process.',Ye,le,Ne,ne,mt="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",Ve,T,Qe,_,He,ae,dt="The training script creates and saves a checkpoint file in your repository. Now you can load and use your trained model for inference:",ze,se,Le,ie,Se,re,qe;return r=new Fe({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),Z=new $({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers | |
| <span class="hljs-built_in">cd</span> diffusers | |
| pip install .`,wrap:!1}}),A=new $({props:{code:"Y2QlMjBleGFtcGxlcyUyRnVuY29uZGl0aW9uYWxfaW1hZ2VfZ2VuZXJhdGlvbiUwQXBpcCUyMGluc3RhbGwlMjAtciUyMHJlcXVpcmVtZW50cy50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/unconditional_image_generation | |
| pip install -r requirements.txt`,wrap:!1}}),J=new De({props:{$$slots:{default:[It]},$$scope:{ctx:j}}}),R=new $({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),x=new $({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),E=new $({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config | |
| write_basic_config()`,wrap:!1}}),Y=new Fe({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),C=new De({props:{$$slots:{default:[At]},$$scope:{ctx:j}}}),Q=new $({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmJmMTYlMjI=",highlighted:`accelerate launch train_unconditional.py \\ | |
| --mixed_precision=<span class="hljs-string">"bf16"</span>`,wrap:!1}}),S=new Fe({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),D=new $({props:{code:"bW9kZWwlMjAlM0QlMjBVTmV0MkRNb2RlbCglMEElMjAlMjAlMjAlMjBzYW1wbGVfc2l6ZSUzRGFyZ3MucmVzb2x1dGlvbiUyQyUwQSUyMCUyMCUyMCUyMGluX2NoYW5uZWxzJTNEMyUyQyUwQSUyMCUyMCUyMCUyMG91dF9jaGFubmVscyUzRDMlMkMlMEElMjAlMjAlMjAlMjBsYXllcnNfcGVyX2Jsb2NrJTNEMiUyQyUwQSUyMCUyMCUyMCUyMGJsb2NrX291dF9jaGFubmVscyUzRCgxMjglMkMlMjAxMjglMkMlMjAyNTYlMkMlMjAyNTYlMkMlMjA1MTIlMkMlMjA1MTIpJTJDJTBBJTIwJTIwJTIwJTIwZG93bl9ibG9ja190eXBlcyUzRCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJEb3duQmxvY2syRCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkRvd25CbG9jazJEJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyRG93bkJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJEb3duQmxvY2syRCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkF0dG5Eb3duQmxvY2syRCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkRvd25CbG9jazJEJTIyJTJDJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMHVwX2Jsb2NrX3R5cGVzJTNEKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlVwQmxvY2syRCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkF0dG5VcEJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJVcEJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJVcEJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJVcEJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJVcEJsb2NrMkQlMjIlMkMlMEElMjAlMjAlMjAlMjApJTJDJTBBKQ==",highlighted:`model = UNet2DModel( | |
| sample_size=args.resolution, | |
| in_channels=<span class="hljs-number">3</span>, | |
| out_channels=<span class="hljs-number">3</span>, | |
| layers_per_block=<span class="hljs-number">2</span>, | |
| block_out_channels=(<span class="hljs-number">128</span>, <span class="hljs-number">128</span>, <span class="hljs-number">256</span>, <span class="hljs-number">256</span>, <span class="hljs-number">512</span>, <span class="hljs-number">512</span>), | |
| down_block_types=( | |
| <span class="hljs-string">"DownBlock2D"</span>, | |
| <span class="hljs-string">"DownBlock2D"</span>, | |
| <span class="hljs-string">"DownBlock2D"</span>, | |
| <span class="hljs-string">"DownBlock2D"</span>, | |
| <span class="hljs-string">"AttnDownBlock2D"</span>, | |
| <span class="hljs-string">"DownBlock2D"</span>, | |
| ), | |
| up_block_types=( | |
| <span class="hljs-string">"UpBlock2D"</span>, | |
| <span class="hljs-string">"AttnUpBlock2D"</span>, | |
| <span class="hljs-string">"UpBlock2D"</span>, | |
| <span class="hljs-string">"UpBlock2D"</span>, | |
| <span class="hljs-string">"UpBlock2D"</span>, | |
| <span class="hljs-string">"UpBlock2D"</span>, | |
| ), | |
| )`,wrap:!1}}),K=new $({props:{code:"JTIzJTIwSW5pdGlhbGl6ZSUyMHRoZSUyMHNjaGVkdWxlciUwQWFjY2VwdHNfcHJlZGljdGlvbl90eXBlJTIwJTNEJTIwJTIycHJlZGljdGlvbl90eXBlJTIyJTIwaW4lMjBzZXQoaW5zcGVjdC5zaWduYXR1cmUoRERQTVNjaGVkdWxlci5fX2luaXRfXykucGFyYW1ldGVycy5rZXlzKCkpJTBBaWYlMjBhY2NlcHRzX3ByZWRpY3Rpb25fdHlwZSUzQSUwQSUyMCUyMCUyMCUyMG5vaXNlX3NjaGVkdWxlciUyMCUzRCUyMEREUE1TY2hlZHVsZXIoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3RyYWluX3RpbWVzdGVwcyUzRGFyZ3MuZGRwbV9udW1fc3RlcHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiZXRhX3NjaGVkdWxlJTNEYXJncy5kZHBtX2JldGFfc2NoZWR1bGUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmVkaWN0aW9uX3R5cGUlM0RhcmdzLnByZWRpY3Rpb25fdHlwZSUyQyUwQSUyMCUyMCUyMCUyMCklMEFlbHNlJTNBJTBBJTIwJTIwJTIwJTIwbm9pc2Vfc2NoZWR1bGVyJTIwJTNEJTIwRERQTVNjaGVkdWxlcihudW1fdHJhaW5fdGltZXN0ZXBzJTNEYXJncy5kZHBtX251bV9zdGVwcyUyQyUyMGJldGFfc2NoZWR1bGUlM0RhcmdzLmRkcG1fYmV0YV9zY2hlZHVsZSklMEElMEElMjMlMjBJbml0aWFsaXplJTIwdGhlJTIwb3B0aW1pemVyJTBBb3B0aW1pemVyJTIwJTNEJTIwdG9yY2gub3B0aW0uQWRhbVcoJTBBJTIwJTIwJTIwJTIwbW9kZWwucGFyYW1ldGVycygpJTJDJTBBJTIwJTIwJTIwJTIwbHIlM0RhcmdzLmxlYXJuaW5nX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBiZXRhcyUzRChhcmdzLmFkYW1fYmV0YTElMkMlMjBhcmdzLmFkYW1fYmV0YTIpJTJDJTBBJTIwJTIwJTIwJTIwd2VpZ2h0X2RlY2F5JTNEYXJncy5hZGFtX3dlaWdodF9kZWNheSUyQyUwQSUyMCUyMCUyMCUyMGVwcyUzRGFyZ3MuYWRhbV9lcHNpbG9uJTJDJTBBKQ==",highlighted:`<span class="hljs-comment"># Initialize the scheduler</span> | |
| accepts_prediction_type = <span class="hljs-string">"prediction_type"</span> <span class="hljs-keyword">in</span> <span class="hljs-built_in">set</span>(inspect.signature(DDPMScheduler.__init__).parameters.keys()) | |
| <span class="hljs-keyword">if</span> accepts_prediction_type: | |
| noise_scheduler = DDPMScheduler( | |
| num_train_timesteps=args.ddpm_num_steps, | |
| beta_schedule=args.ddpm_beta_schedule, | |
| prediction_type=args.prediction_type, | |
| ) | |
| <span class="hljs-keyword">else</span>: | |
| noise_scheduler = DDPMScheduler(num_train_timesteps=args.ddpm_num_steps, beta_schedule=args.ddpm_beta_schedule) | |
| <span class="hljs-comment"># Initialize the optimizer</span> | |
| optimizer = torch.optim.AdamW( | |
| model.parameters(), | |
| lr=args.learning_rate, | |
| betas=(args.adam_beta1, args.adam_beta2), | |
| weight_decay=args.adam_weight_decay, | |
| eps=args.adam_epsilon, | |
| )`,wrap:!1}}),ee=new $({props:{code:"ZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJpbWFnZWZvbGRlciUyMiUyQyUyMGRhdGFfZGlyJTNEYXJncy50cmFpbl9kYXRhX2RpciUyQyUyMGNhY2hlX2RpciUzRGFyZ3MuY2FjaGVfZGlyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiUyMiklMEElMEFhdWdtZW50YXRpb25zJTIwJTNEJTIwdHJhbnNmb3Jtcy5Db21wb3NlKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRyYW5zZm9ybXMuUmVzaXplKGFyZ3MucmVzb2x1dGlvbiUyQyUyMGludGVycG9sYXRpb24lM0R0cmFuc2Zvcm1zLkludGVycG9sYXRpb25Nb2RlLkJJTElORUFSKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRyYW5zZm9ybXMuQ2VudGVyQ3JvcChhcmdzLnJlc29sdXRpb24pJTIwaWYlMjBhcmdzLmNlbnRlcl9jcm9wJTIwZWxzZSUyMHRyYW5zZm9ybXMuUmFuZG9tQ3JvcChhcmdzLnJlc29sdXRpb24pJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdHJhbnNmb3Jtcy5SYW5kb21Ib3Jpem9udGFsRmxpcCgpJTIwaWYlMjBhcmdzLnJhbmRvbV9mbGlwJTIwZWxzZSUyMHRyYW5zZm9ybXMuTGFtYmRhKGxhbWJkYSUyMHglM0ElMjB4KSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRyYW5zZm9ybXMuVG9UZW5zb3IoKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRyYW5zZm9ybXMuTm9ybWFsaXplKCU1QjAuNSU1RCUyQyUyMCU1QjAuNSU1RCklMkMlMEElMjAlMjAlMjAlMjAlNUQlMEEp",highlighted:`dataset = load_dataset(<span class="hljs-string">"imagefolder"</span>, data_dir=args.train_data_dir, cache_dir=args.cache_dir, split=<span class="hljs-string">"train"</span>) | |
| augmentations = transforms.Compose( | |
| [ | |
| transforms.Resize(args.resolution, interpolation=transforms.InterpolationMode.BILINEAR), | |
| transforms.CenterCrop(args.resolution) <span class="hljs-keyword">if</span> args.center_crop <span class="hljs-keyword">else</span> transforms.RandomCrop(args.resolution), | |
| transforms.RandomHorizontalFlip() <span class="hljs-keyword">if</span> args.random_flip <span class="hljs-keyword">else</span> transforms.Lambda(<span class="hljs-keyword">lambda</span> x: x), | |
| transforms.ToTensor(), | |
| transforms.Normalize([<span class="hljs-number">0.5</span>], [<span class="hljs-number">0.5</span>]), | |
| ] | |
| )`,wrap:!1}}),le=new Fe({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),T=new De({props:{warning:!0,$$slots:{default:[Wt]},$$scope:{ctx:j}}}),_=new Zt({props:{id:"launchtraining",options:["single GPU","multi-GPU"],$$slots:{default:[xt]},$$scope:{ctx:j}}}),se=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJhbnRvbi1sJTJGZGRwbS1idXR0ZXJmbGllcy0xMjglMjIpLnRvKCUyMmN1ZGElMjIpJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSgpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| <span class="hljs-keyword">import</span> torch | |
| pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">"anton-l/ddpm-butterflies-128"</span>).to(<span class="hljs-string">"cuda"</span>) | |
| image = pipeline().images[<span class="hljs-number">0</span>]`,wrap:!1}}),ie=new Gt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/unconditional_training.md"}}),{c(){a=c("meta"),M=i(),s=c("p"),f=i(),d(r.$$.fragment),p=i(),w=c("p"),w.textContent=oe,ce=i(),k=c("p"),k.innerHTML=Pe,ue=i(),G=c("p"),G.textContent=Ke,Me=i(),d(Z.$$.fragment),fe=i(),I=c("p"),I.textContent=Oe,me=i(),d(A.$$.fragment),de=i(),d(J.$$.fragment),ye=i(),W=c("p"),W.textContent=et,he=i(),d(R.$$.fragment),ge=i(),v=c("p"),v.textContent=tt,Ue=i(),d(x.$$.fragment),be=i(),B=c("p"),B.textContent=lt,je=i(),d(E.$$.fragment),we=i(),X=c("p"),X.innerHTML=nt,$e=i(),d(Y.$$.fragment),Je=i(),d(C.$$.fragment),Ce=i(),N=c("p"),N.innerHTML=at,Te=i(),V=c("p"),V.innerHTML=st,_e=i(),d(Q.$$.fragment),ke=i(),H=c("p"),H.textContent=it,Ge=i(),z=c("ul"),z.innerHTML=ot,Ze=i(),L=c("p"),L.textContent=rt,Ie=i(),d(S.$$.fragment),Ae=i(),q=c("p"),q.innerHTML=pt,We=i(),F=c("p"),F.innerHTML=ct,Re=i(),d(D.$$.fragment),ve=i(),P=c("p"),P.innerHTML=ut,xe=i(),d(K.$$.fragment),Be=i(),O=c("p"),O.innerHTML=Mt,Ee=i(),d(ee.$$.fragment),Xe=i(),te=c("p"),te.innerHTML=ft,Ye=i(),d(le.$$.fragment),Ne=i(),ne=c("p"),ne.textContent=mt,Ve=i(),d(T.$$.fragment),Qe=i(),d(_.$$.fragment),He=i(),ae=c("p"),ae.textContent=dt,ze=i(),d(se.$$.fragment),Le=i(),d(ie.$$.fragment),Se=i(),re=c("p"),this.h()},l(e){const t=_t("svelte-u9bgzb",document.head);a=u(t,"META",{name:!0,content:!0}),t.forEach(l),M=o(e),s=u(e,"P",{}),bt(s).forEach(l),f=o(e),y(r.$$.fragment,e),p=o(e),w=u(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-ucj57a"&&(w.textContent=oe),ce=o(e),k=u(e,"P",{"data-svelte-h":!0}),m(k)!=="svelte-soku4x"&&(k.innerHTML=Pe),ue=o(e),G=u(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-l7dm2q"&&(G.textContent=Ke),Me=o(e),y(Z.$$.fragment,e),fe=o(e),I=u(e,"P",{"data-svelte-h":!0}),m(I)!=="svelte-9ovw2f"&&(I.textContent=Oe),me=o(e),y(A.$$.fragment,e),de=o(e),y(J.$$.fragment,e),ye=o(e),W=u(e,"P",{"data-svelte-h":!0}),m(W)!=="svelte-60q53m"&&(W.textContent=et),he=o(e),y(R.$$.fragment,e),ge=o(e),v=u(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-di6juu"&&(v.textContent=tt),Ue=o(e),y(x.$$.fragment,e),be=o(e),B=u(e,"P",{"data-svelte-h":!0}),m(B)!=="svelte-130n95n"&&(B.textContent=lt),je=o(e),y(E.$$.fragment,e),we=o(e),X=u(e,"P",{"data-svelte-h":!0}),m(X)!=="svelte-1fkfdql"&&(X.innerHTML=nt),$e=o(e),y(Y.$$.fragment,e),Je=o(e),y(C.$$.fragment,e),Ce=o(e),N=u(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-hnv7r"&&(N.innerHTML=at),Te=o(e),V=u(e,"P",{"data-svelte-h":!0}),m(V)!=="svelte-9pyoon"&&(V.innerHTML=st),_e=o(e),y(Q.$$.fragment,e),ke=o(e),H=u(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-ulgbjj"&&(H.textContent=it),Ge=o(e),z=u(e,"UL",{"data-svelte-h":!0}),m(z)!=="svelte-19ebye9"&&(z.innerHTML=ot),Ze=o(e),L=u(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-1oruhn0"&&(L.textContent=rt),Ie=o(e),y(S.$$.fragment,e),Ae=o(e),q=u(e,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1vr7hoq"&&(q.innerHTML=pt),We=o(e),F=u(e,"P",{"data-svelte-h":!0}),m(F)!=="svelte-ol2pjq"&&(F.innerHTML=ct),Re=o(e),y(D.$$.fragment,e),ve=o(e),P=u(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-1i85dfk"&&(P.innerHTML=ut),xe=o(e),y(K.$$.fragment,e),Be=o(e),O=u(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-b2zk9z"&&(O.innerHTML=Mt),Ee=o(e),y(ee.$$.fragment,e),Xe=o(e),te=u(e,"P",{"data-svelte-h":!0}),m(te)!=="svelte-17tmhpi"&&(te.innerHTML=ft),Ye=o(e),y(le.$$.fragment,e),Ne=o(e),ne=u(e,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-9dei1q"&&(ne.textContent=mt),Ve=o(e),y(T.$$.fragment,e),Qe=o(e),y(_.$$.fragment,e),He=o(e),ae=u(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-b1oixz"&&(ae.textContent=dt),ze=o(e),y(se.$$.fragment,e),Le=o(e),y(ie.$$.fragment,e),Se=o(e),re=u(e,"P",{}),bt(re).forEach(l),this.h()},h(){jt(a,"name","hf:doc:metadata"),jt(a,"content",Et)},m(e,t){kt(document.head,a),n(e,M,t),n(e,s,t),n(e,f,t),h(r,e,t),n(e,p,t),n(e,w,t),n(e,ce,t),n(e,k,t),n(e,ue,t),n(e,G,t),n(e,Me,t),h(Z,e,t),n(e,fe,t),n(e,I,t),n(e,me,t),h(A,e,t),n(e,de,t),h(J,e,t),n(e,ye,t),n(e,W,t),n(e,he,t),h(R,e,t),n(e,ge,t),n(e,v,t),n(e,Ue,t),h(x,e,t),n(e,be,t),n(e,B,t),n(e,je,t),h(E,e,t),n(e,we,t),n(e,X,t),n(e,$e,t),h(Y,e,t),n(e,Je,t),h(C,e,t),n(e,Ce,t),n(e,N,t),n(e,Te,t),n(e,V,t),n(e,_e,t),h(Q,e,t),n(e,ke,t),n(e,H,t),n(e,Ge,t),n(e,z,t),n(e,Ze,t),n(e,L,t),n(e,Ie,t),h(S,e,t),n(e,Ae,t),n(e,q,t),n(e,We,t),n(e,F,t),n(e,Re,t),h(D,e,t),n(e,ve,t),n(e,P,t),n(e,xe,t),h(K,e,t),n(e,Be,t),n(e,O,t),n(e,Ee,t),h(ee,e,t),n(e,Xe,t),n(e,te,t),n(e,Ye,t),h(le,e,t),n(e,Ne,t),n(e,ne,t),n(e,Ve,t),h(T,e,t),n(e,Qe,t),h(_,e,t),n(e,He,t),n(e,ae,t),n(e,ze,t),h(se,e,t),n(e,Le,t),h(ie,e,t),n(e,Se,t),n(e,re,t),qe=!0},p(e,[t]){const yt={};t&2&&(yt.$$scope={dirty:t,ctx:e}),J.$set(yt);const ht={};t&2&&(ht.$$scope={dirty:t,ctx:e}),C.$set(ht);const gt={};t&2&&(gt.$$scope={dirty:t,ctx:e}),T.$set(gt);const Ut={};t&2&&(Ut.$$scope={dirty:t,ctx:e}),_.$set(Ut)},i(e){qe||(g(r.$$.fragment,e),g(Z.$$.fragment,e),g(A.$$.fragment,e),g(J.$$.fragment,e),g(R.$$.fragment,e),g(x.$$.fragment,e),g(E.$$.fragment,e),g(Y.$$.fragment,e),g(C.$$.fragment,e),g(Q.$$.fragment,e),g(S.$$.fragment,e),g(D.$$.fragment,e),g(K.$$.fragment,e),g(ee.$$.fragment,e),g(le.$$.fragment,e),g(T.$$.fragment,e),g(_.$$.fragment,e),g(se.$$.fragment,e),g(ie.$$.fragment,e),qe=!0)},o(e){U(r.$$.fragment,e),U(Z.$$.fragment,e),U(A.$$.fragment,e),U(J.$$.fragment,e),U(R.$$.fragment,e),U(x.$$.fragment,e),U(E.$$.fragment,e),U(Y.$$.fragment,e),U(C.$$.fragment,e),U(Q.$$.fragment,e),U(S.$$.fragment,e),U(D.$$.fragment,e),U(K.$$.fragment,e),U(ee.$$.fragment,e),U(le.$$.fragment,e),U(T.$$.fragment,e),U(_.$$.fragment,e),U(se.$$.fragment,e),U(ie.$$.fragment,e),qe=!1},d(e){e&&(l(M),l(s),l(f),l(p),l(w),l(ce),l(k),l(ue),l(G),l(Me),l(fe),l(I),l(me),l(de),l(ye),l(W),l(he),l(ge),l(v),l(Ue),l(be),l(B),l(je),l(we),l(X),l($e),l(Je),l(Ce),l(N),l(Te),l(V),l(_e),l(ke),l(H),l(Ge),l(z),l(Ze),l(L),l(Ie),l(Ae),l(q),l(We),l(F),l(Re),l(ve),l(P),l(xe),l(Be),l(O),l(Ee),l(Xe),l(te),l(Ye),l(Ne),l(ne),l(Ve),l(Qe),l(He),l(ae),l(ze),l(Le),l(Se),l(re)),l(a),b(r,e),b(Z,e),b(A,e),b(J,e),b(R,e),b(x,e),b(E,e),b(Y,e),b(C,e),b(Q,e),b(S,e),b(D,e),b(K,e),b(ee,e),b(le,e),b(T,e),b(_,e),b(se,e),b(ie,e)}}}const Et='{"title":"Unconditional image generation","local":"unconditional-image-generation","sections":[{"title":"Script parameters","local":"script-parameters","sections":[],"depth":2},{"title":"Training script","local":"training-script","sections":[],"depth":2},{"title":"Launch the script","local":"launch-the-script","sections":[],"depth":2}],"depth":1}';function Xt(j){return Jt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Lt extends Ct{constructor(a){super(),Tt(this,a,Xt,Bt,$t,{})}}export{Lt as component}; | |
Xet Storage Details
- Size:
- 25.9 kB
- Xet hash:
- e27d99ec12f79d20b2413c54a169fa92824bd6a50c4e3332936a390566c7e405
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.