Buckets:
| import{s as ll,o as nl,n as Jt}from"../chunks/scheduler.182ea377.js";import{S as al,i as il,g as s,s as a,p as u,x as jt,A as sl,h as o,f as l,c as i,j,q as M,m as p,y as wt,k as m,v as g,a as n,r as h,d,t as f,u as y}from"../chunks/index.008d68e4.js";import{T as Ct}from"../chunks/Tip.4f096367.js";import{I as yt}from"../chunks/IconCopyLink.96bbb92b.js";import{C as w}from"../chunks/CodeBlock.5ed6eb7b.js";function ol(_){let r,b='🤗 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(){r=s("p"),r.innerHTML=b},l(c){r=o(c,"P",{"data-svelte-h":!0}),p(r)!=="svelte-1qbiqsn"&&(r.innerHTML=b)},m(c,U){n(c,r,U)},p:Jt,d(c){c&&l(r)}}}function rl(_){let r,b='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(){r=s("p"),r.innerHTML=b},l(c){r=o(c,"P",{"data-svelte-h":!0}),p(r)!=="svelte-1efpx6r"&&(r.innerHTML=b)},m(c,U){n(c,r,U)},p:Jt,d(c){c&&l(r)}}}function pl(_){let r,b="A full training run takes 2 hours on 4xV100 GPUs.";return{c(){r=s("p"),r.textContent=b},l(c){r=o(c,"P",{"data-svelte-h":!0}),p(r)!=="svelte-1k3fy07"&&(r.textContent=b)},m(c,U){n(c,r,U)},p:Jt,d(c){c&&l(r)}}}function cl(_){let r,b,c,U,je,Z,mt,me,Tt="Unconditional image generation",$e,I,_t="Unconditional image generation models are not conditioned on text or images during training. It only generates images that resemble its training data distribution.",ve,W,$t='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.',ke,R,vt="Before running the script, make sure you install the library from source:",Ae,E,xe,B,kt="Then navigate to the example folder containing the training script and install the required dependencies:",Ge,N,Ze,$,Ie,X,At="Initialize an 🤗 Accelerate environment:",We,Y,Re,V,xt="To setup a default 🤗 Accelerate environment without choosing any configurations:",Ee,Q,Be,z,Gt="Or if your environment doesn’t support an interactive shell like a notebook, you can use:",Ne,H,Xe,S,Zt='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.',Ye,C,v,we,L,gt,ge,It="Script parameters",Ve,k,Qe,q,Wt='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.',ze,F,Rt="For example, to speedup training with mixed precision using the bf16 format, add the <code>--mixed_precision</code> parameter to the training command:",He,P,Se,D,Et="Some basic and important parameters to specify include:",Le,K,Bt="<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>",qe,O,Nt="Bring your dataset, and let the training script handle everything else!",Fe,J,A,Ce,ee,Ut,Ue,Xt="Training script",Pe,te,Yt='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.',De,le,Vt='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:',Ke,ne,Oe,ae,Qt='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>:',et,ie,tt,se,zt='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:',lt,oe,nt,re,Ht='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.',at,T,x,Je,pe,bt,be,St="Launch the script",it,ce,Lt="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",st,G,ot,ue,rt,Me,qt="If you’re training with more than one GPU, add the <code>--multi_gpu</code> parameter to the training command:",pt,he,ct,de,Ft="The training script creates and saves a checkpoint file in your repository. Now you can load and use your trained model for inference:",ut,fe,Mt;return Z=new yt({}),E=new w({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 .`}}),N=new w({props:{code:"Y2QlMjBleGFtcGxlcyUyRnVuY29uZGl0aW9uYWxfaW1hZ2VfZ2VuZXJhdGlvbiUwQXBpcCUyMGluc3RhbGwlMjAtciUyMHJlcXVpcmVtZW50cy50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/unconditional_image_generation | |
| pip install -r requirements.txt`}}),$=new Ct({props:{$$slots:{default:[ol]},$$scope:{ctx:_}}}),Y=new w({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),Q=new w({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),H=new w({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`from accelerate.utils import write_basic_config | |
| write_basic_config()`}}),L=new yt({}),k=new Ct({props:{$$slots:{default:[rl]},$$scope:{ctx:_}}}),P=new w({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3VuY29uZGl0aW9uYWwucHklMjAlNUMlMEElMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmJmMTYlMjI=",highlighted:`accelerate launch train_unconditional.py \\ | |
| --mixed_precision=<span class="hljs-string">"bf16"</span>`}}),ee=new yt({}),ne=new w({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>, | |
| ), | |
| )`}}),ie=new w({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, | |
| )`}}),oe=new w({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>]), | |
| ] | |
| )`}}),pe=new yt({}),G=new Ct({props:{warning:!0,$$slots:{default:[pl]},$$scope:{ctx:_}}}),ue=new w({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`}}),he=new w({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`}}),fe=new w({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>]`}}),{c(){r=s("meta"),b=a(),c=s("h1"),U=s("a"),je=s("span"),u(Z.$$.fragment),mt=a(),me=s("span"),me.textContent=Tt,$e=a(),I=s("p"),I.textContent=_t,ve=a(),W=s("p"),W.innerHTML=$t,ke=a(),R=s("p"),R.textContent=vt,Ae=a(),u(E.$$.fragment),xe=a(),B=s("p"),B.textContent=kt,Ge=a(),u(N.$$.fragment),Ze=a(),u($.$$.fragment),Ie=a(),X=s("p"),X.textContent=At,We=a(),u(Y.$$.fragment),Re=a(),V=s("p"),V.textContent=xt,Ee=a(),u(Q.$$.fragment),Be=a(),z=s("p"),z.textContent=Gt,Ne=a(),u(H.$$.fragment),Xe=a(),S=s("p"),S.innerHTML=Zt,Ye=a(),C=s("h2"),v=s("a"),we=s("span"),u(L.$$.fragment),gt=a(),ge=s("span"),ge.textContent=It,Ve=a(),u(k.$$.fragment),Qe=a(),q=s("p"),q.innerHTML=Wt,ze=a(),F=s("p"),F.innerHTML=Rt,He=a(),u(P.$$.fragment),Se=a(),D=s("p"),D.textContent=Et,Le=a(),K=s("ul"),K.innerHTML=Bt,qe=a(),O=s("p"),O.textContent=Nt,Fe=a(),J=s("h2"),A=s("a"),Ce=s("span"),u(ee.$$.fragment),Ut=a(),Ue=s("span"),Ue.textContent=Xt,Pe=a(),te=s("p"),te.innerHTML=Yt,De=a(),le=s("p"),le.innerHTML=Vt,Ke=a(),u(ne.$$.fragment),Oe=a(),ae=s("p"),ae.innerHTML=Qt,et=a(),u(ie.$$.fragment),tt=a(),se=s("p"),se.innerHTML=zt,lt=a(),u(oe.$$.fragment),nt=a(),re=s("p"),re.innerHTML=Ht,at=a(),T=s("h2"),x=s("a"),Je=s("span"),u(pe.$$.fragment),bt=a(),be=s("span"),be.textContent=St,it=a(),ce=s("p"),ce.textContent=Lt,st=a(),u(G.$$.fragment),ot=jt(` | |
| <hfoptions id="launchtraining"> | |
| <hfoption id="single GPU"> | |
| `),u(ue.$$.fragment),rt=jt(` | |
| </hfoption> | |
| <hfoption id="multi-GPU"> | |
| `),Me=s("p"),Me.innerHTML=qt,pt=a(),u(he.$$.fragment),ct=jt(` | |
| </hfoption> | |
| </hfoptions> | |
| `),de=s("p"),de.textContent=Ft,ut=a(),u(fe.$$.fragment),this.h()},l(e){const t=sl("svelte-1phssyn",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(l),b=i(e),c=o(e,"H1",{class:!0});var ye=j(c);U=o(ye,"A",{id:!0,class:!0,href:!0});var Te=j(U);je=o(Te,"SPAN",{});var _e=j(je);M(Z.$$.fragment,_e),_e.forEach(l),Te.forEach(l),mt=i(ye),me=o(ye,"SPAN",{"data-svelte-h":!0}),p(me)!=="svelte-sygj17"&&(me.textContent=Tt),ye.forEach(l),$e=i(e),I=o(e,"P",{"data-svelte-h":!0}),p(I)!=="svelte-ucj57a"&&(I.textContent=_t),ve=i(e),W=o(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-soku4x"&&(W.innerHTML=$t),ke=i(e),R=o(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-l7dm2q"&&(R.textContent=vt),Ae=i(e),M(E.$$.fragment,e),xe=i(e),B=o(e,"P",{"data-svelte-h":!0}),p(B)!=="svelte-9ovw2f"&&(B.textContent=kt),Ge=i(e),M(N.$$.fragment,e),Ze=i(e),M($.$$.fragment,e),Ie=i(e),X=o(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-60q53m"&&(X.textContent=At),We=i(e),M(Y.$$.fragment,e),Re=i(e),V=o(e,"P",{"data-svelte-h":!0}),p(V)!=="svelte-di6juu"&&(V.textContent=xt),Ee=i(e),M(Q.$$.fragment,e),Be=i(e),z=o(e,"P",{"data-svelte-h":!0}),p(z)!=="svelte-130n95n"&&(z.textContent=Gt),Ne=i(e),M(H.$$.fragment,e),Xe=i(e),S=o(e,"P",{"data-svelte-h":!0}),p(S)!=="svelte-1fkfdql"&&(S.innerHTML=Zt),Ye=i(e),C=o(e,"H2",{class:!0});var ht=j(C);v=o(ht,"A",{id:!0,class:!0,href:!0});var Pt=j(v);we=o(Pt,"SPAN",{});var Dt=j(we);M(L.$$.fragment,Dt),Dt.forEach(l),Pt.forEach(l),gt=i(ht),ge=o(ht,"SPAN",{"data-svelte-h":!0}),p(ge)!=="svelte-r00uw2"&&(ge.textContent=It),ht.forEach(l),Ve=i(e),M(k.$$.fragment,e),Qe=i(e),q=o(e,"P",{"data-svelte-h":!0}),p(q)!=="svelte-hnv7r"&&(q.innerHTML=Wt),ze=i(e),F=o(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-9pyoon"&&(F.innerHTML=Rt),He=i(e),M(P.$$.fragment,e),Se=i(e),D=o(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-ulgbjj"&&(D.textContent=Et),Le=i(e),K=o(e,"UL",{"data-svelte-h":!0}),p(K)!=="svelte-19ebye9"&&(K.innerHTML=Bt),qe=i(e),O=o(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-1oruhn0"&&(O.textContent=Nt),Fe=i(e),J=o(e,"H2",{class:!0});var dt=j(J);A=o(dt,"A",{id:!0,class:!0,href:!0});var Kt=j(A);Ce=o(Kt,"SPAN",{});var Ot=j(Ce);M(ee.$$.fragment,Ot),Ot.forEach(l),Kt.forEach(l),Ut=i(dt),Ue=o(dt,"SPAN",{"data-svelte-h":!0}),p(Ue)!=="svelte-339bde"&&(Ue.textContent=Xt),dt.forEach(l),Pe=i(e),te=o(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-1vr7hoq"&&(te.innerHTML=Yt),De=i(e),le=o(e,"P",{"data-svelte-h":!0}),p(le)!=="svelte-ol2pjq"&&(le.innerHTML=Vt),Ke=i(e),M(ne.$$.fragment,e),Oe=i(e),ae=o(e,"P",{"data-svelte-h":!0}),p(ae)!=="svelte-1i85dfk"&&(ae.innerHTML=Qt),et=i(e),M(ie.$$.fragment,e),tt=i(e),se=o(e,"P",{"data-svelte-h":!0}),p(se)!=="svelte-b2zk9z"&&(se.innerHTML=zt),lt=i(e),M(oe.$$.fragment,e),nt=i(e),re=o(e,"P",{"data-svelte-h":!0}),p(re)!=="svelte-17tmhpi"&&(re.innerHTML=Ht),at=i(e),T=o(e,"H2",{class:!0});var ft=j(T);x=o(ft,"A",{id:!0,class:!0,href:!0});var el=j(x);Je=o(el,"SPAN",{});var tl=j(Je);M(pe.$$.fragment,tl),tl.forEach(l),el.forEach(l),bt=i(ft),be=o(ft,"SPAN",{"data-svelte-h":!0}),p(be)!=="svelte-zp6p5k"&&(be.textContent=St),ft.forEach(l),it=i(e),ce=o(e,"P",{"data-svelte-h":!0}),p(ce)!=="svelte-9dei1q"&&(ce.textContent=Lt),st=i(e),M(G.$$.fragment,e),ot=wt(e,` | |
| <hfoptions id="launchtraining"> | |
| <hfoption id="single GPU"> | |
| `),M(ue.$$.fragment,e),rt=wt(e,` | |
| </hfoption> | |
| <hfoption id="multi-GPU"> | |
| `),Me=o(e,"P",{"data-svelte-h":!0}),p(Me)!=="svelte-93d1lr"&&(Me.innerHTML=qt),pt=i(e),M(he.$$.fragment,e),ct=wt(e,` | |
| </hfoption> | |
| </hfoptions> | |
| `),de=o(e,"P",{"data-svelte-h":!0}),p(de)!=="svelte-b1oixz"&&(de.textContent=Ft),ut=i(e),M(fe.$$.fragment,e),this.h()},h(){m(r,"name","hf:doc:metadata"),m(r,"content",JSON.stringify(ul)),m(U,"id","unconditional-image-generation"),m(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(U,"href","#unconditional-image-generation"),m(c,"class","relative group"),m(v,"id","script-parameters"),m(v,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(v,"href","#script-parameters"),m(C,"class","relative group"),m(A,"id","training-script"),m(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(A,"href","#training-script"),m(J,"class","relative group"),m(x,"id","launch-the-script"),m(x,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(x,"href","#launch-the-script"),m(T,"class","relative group")},m(e,t){g(document.head,r),n(e,b,t),n(e,c,t),g(c,U),g(U,je),h(Z,je,null),g(c,mt),g(c,me),n(e,$e,t),n(e,I,t),n(e,ve,t),n(e,W,t),n(e,ke,t),n(e,R,t),n(e,Ae,t),h(E,e,t),n(e,xe,t),n(e,B,t),n(e,Ge,t),h(N,e,t),n(e,Ze,t),h($,e,t),n(e,Ie,t),n(e,X,t),n(e,We,t),h(Y,e,t),n(e,Re,t),n(e,V,t),n(e,Ee,t),h(Q,e,t),n(e,Be,t),n(e,z,t),n(e,Ne,t),h(H,e,t),n(e,Xe,t),n(e,S,t),n(e,Ye,t),n(e,C,t),g(C,v),g(v,we),h(L,we,null),g(C,gt),g(C,ge),n(e,Ve,t),h(k,e,t),n(e,Qe,t),n(e,q,t),n(e,ze,t),n(e,F,t),n(e,He,t),h(P,e,t),n(e,Se,t),n(e,D,t),n(e,Le,t),n(e,K,t),n(e,qe,t),n(e,O,t),n(e,Fe,t),n(e,J,t),g(J,A),g(A,Ce),h(ee,Ce,null),g(J,Ut),g(J,Ue),n(e,Pe,t),n(e,te,t),n(e,De,t),n(e,le,t),n(e,Ke,t),h(ne,e,t),n(e,Oe,t),n(e,ae,t),n(e,et,t),h(ie,e,t),n(e,tt,t),n(e,se,t),n(e,lt,t),h(oe,e,t),n(e,nt,t),n(e,re,t),n(e,at,t),n(e,T,t),g(T,x),g(x,Je),h(pe,Je,null),g(T,bt),g(T,be),n(e,it,t),n(e,ce,t),n(e,st,t),h(G,e,t),n(e,ot,t),h(ue,e,t),n(e,rt,t),n(e,Me,t),n(e,pt,t),h(he,e,t),n(e,ct,t),n(e,de,t),n(e,ut,t),h(fe,e,t),Mt=!0},p(e,[t]){const ye={};t&2&&(ye.$$scope={dirty:t,ctx:e}),$.$set(ye);const Te={};t&2&&(Te.$$scope={dirty:t,ctx:e}),k.$set(Te);const _e={};t&2&&(_e.$$scope={dirty:t,ctx:e}),G.$set(_e)},i(e){Mt||(d(Z.$$.fragment,e),d(E.$$.fragment,e),d(N.$$.fragment,e),d($.$$.fragment,e),d(Y.$$.fragment,e),d(Q.$$.fragment,e),d(H.$$.fragment,e),d(L.$$.fragment,e),d(k.$$.fragment,e),d(P.$$.fragment,e),d(ee.$$.fragment,e),d(ne.$$.fragment,e),d(ie.$$.fragment,e),d(oe.$$.fragment,e),d(pe.$$.fragment,e),d(G.$$.fragment,e),d(ue.$$.fragment,e),d(he.$$.fragment,e),d(fe.$$.fragment,e),Mt=!0)},o(e){f(Z.$$.fragment,e),f(E.$$.fragment,e),f(N.$$.fragment,e),f($.$$.fragment,e),f(Y.$$.fragment,e),f(Q.$$.fragment,e),f(H.$$.fragment,e),f(L.$$.fragment,e),f(k.$$.fragment,e),f(P.$$.fragment,e),f(ee.$$.fragment,e),f(ne.$$.fragment,e),f(ie.$$.fragment,e),f(oe.$$.fragment,e),f(pe.$$.fragment,e),f(G.$$.fragment,e),f(ue.$$.fragment,e),f(he.$$.fragment,e),f(fe.$$.fragment,e),Mt=!1},d(e){e&&(l(b),l(c),l($e),l(I),l(ve),l(W),l(ke),l(R),l(Ae),l(xe),l(B),l(Ge),l(Ze),l(Ie),l(X),l(We),l(Re),l(V),l(Ee),l(Be),l(z),l(Ne),l(Xe),l(S),l(Ye),l(C),l(Ve),l(Qe),l(q),l(ze),l(F),l(He),l(Se),l(D),l(Le),l(K),l(qe),l(O),l(Fe),l(J),l(Pe),l(te),l(De),l(le),l(Ke),l(Oe),l(ae),l(et),l(tt),l(se),l(lt),l(nt),l(re),l(at),l(T),l(it),l(ce),l(st),l(ot),l(rt),l(Me),l(pt),l(ct),l(de),l(ut)),l(r),y(Z),y(E,e),y(N,e),y($,e),y(Y,e),y(Q,e),y(H,e),y(L),y(k,e),y(P,e),y(ee),y(ne,e),y(ie,e),y(oe,e),y(pe),y(G,e),y(ue,e),y(he,e),y(fe,e)}}}const ul={local:"unconditional-image-generation",sections:[{local:"script-parameters",title:"Script parameters"},{local:"training-script",title:"Training script"},{local:"launch-the-script",title:"Launch the script"}],title:"Unconditional image generation"};function Ml(_){return nl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gl extends al{constructor(r){super(),il(this,r,Ml,cl,ll,{})}}export{gl as component}; | |
Xet Storage Details
- Size:
- 26.9 kB
- Xet hash:
- ad24b03d0b5d256c1b51ff73880537a5457ff9251a0f8dbee206aba7589db55f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.