import{s as Bt,o as Vt,n as Gt}from"../chunks/scheduler.53228c21.js";import{S as At,i as Ft,e as p,s as n,c,h as Ht,a as f,d as l,b as i,f as Et,g as d,j as u,k as ce,l as Qt,m as a,n as y,t as M,o as g,p as _}from"../chunks/index.100fac89.js";import{C as Nt}from"../chunks/CopyLLMTxtMenu.999d3d86.js";import{C as U}from"../chunks/CodeBlock.d30a6509.js";import{H as ye,E as St}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d27ae4df.js";import{H as Yt,a as It}from"../chunks/HfOption.fad27e59.js";function qt(T){let o,w='Diffusers uses <a href="https://huggingface.co/docs/peft/main/en/package_reference/lora#peft.LoraConfig" rel="nofollow">LoraConfig</a> from the <a href="https://hf.co/docs/peft" rel="nofollow">PEFT</a> library to set up the parameters of the LoRA adapter such as the rank, alpha, and which modules to insert the LoRA weights into. The adapter is added to the UNet, and only the LoRA layers are filtered for optimization in <code>lora_layers</code>.',h,m,r;return m=new U({props:{code:"dW5ldF9sb3JhX2NvbmZpZyUyMCUzRCUyMExvcmFDb25maWcoJTBBJTIwJTIwJTIwJTIwciUzRGFyZ3MucmFuayUyQyUwQSUyMCUyMCUyMCUyMGxvcmFfYWxwaGElM0RhcmdzLnJhbmslMkMlMEElMjAlMjAlMjAlMjBpbml0X2xvcmFfd2VpZ2h0cyUzRCUyMmdhdXNzaWFuJTIyJTJDJTBBJTIwJTIwJTIwJTIwdGFyZ2V0X21vZHVsZXMlM0QlNUIlMjJ0b19rJTIyJTJDJTIwJTIydG9fcSUyMiUyQyUyMCUyMnRvX3YlMjIlMkMlMjAlMjJ0b19vdXQuMCUyMiU1RCUyQyUwQSklMEElMEF1bmV0LmFkZF9hZGFwdGVyKHVuZXRfbG9yYV9jb25maWcpJTBBbG9yYV9sYXllcnMlMjAlM0QlMjBmaWx0ZXIobGFtYmRhJTIwcCUzQSUyMHAucmVxdWlyZXNfZ3JhZCUyQyUyMHVuZXQucGFyYW1ldGVycygpKQ==",highlighted:`unet_lora_config = LoraConfig(
    r=args.rank,
    lora_alpha=args.rank,
    init_lora_weights=<span class="hljs-string">&quot;gaussian&quot;</span>,
    target_modules=[<span class="hljs-string">&quot;to_k&quot;</span>, <span class="hljs-string">&quot;to_q&quot;</span>, <span class="hljs-string">&quot;to_v&quot;</span>, <span class="hljs-string">&quot;to_out.0&quot;</span>],
)

unet.add_adapter(unet_lora_config)
lora_layers = <span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> p: p.requires_grad, unet.parameters())`,wrap:!1}}),{c(){o=p("p"),o.innerHTML=w,h=n(),c(m.$$.fragment)},l(s){o=f(s,"P",{"data-svelte-h":!0}),u(o)!=="svelte-1tyivyh"&&(o.innerHTML=w),h=i(s),d(m.$$.fragment,s)},m(s,b){a(s,o,b),a(s,h,b),y(m,s,b),r=!0},p:Gt,i(s){r||(M(m.$$.fragment,s),r=!0)},o(s){g(m.$$.fragment,s),r=!1},d(s){s&&(l(o),l(h)),_(m,s)}}}function zt(T){let o,w='Diffusers also supports finetuning the text encoder with LoRA from the <a href="https://hf.co/docs/peft" rel="nofollow">PEFT</a> library when necessary such as finetuning Stable Diffusion XL (SDXL). The <a href="https://huggingface.co/docs/peft/main/en/package_reference/lora#peft.LoraConfig" rel="nofollow">LoraConfig</a> is used to configure the parameters of the LoRA adapter which are then added to the text encoder, and only the LoRA layers are filtered for training.',h,m,r;return m=new U({props:{code:"dGV4dF9sb3JhX2NvbmZpZyUyMCUzRCUyMExvcmFDb25maWcoJTBBJTIwJTIwJTIwJTIwciUzRGFyZ3MucmFuayUyQyUwQSUyMCUyMCUyMCUyMGxvcmFfYWxwaGElM0RhcmdzLnJhbmslMkMlMEElMjAlMjAlMjAlMjBpbml0X2xvcmFfd2VpZ2h0cyUzRCUyMmdhdXNzaWFuJTIyJTJDJTBBJTIwJTIwJTIwJTIwdGFyZ2V0X21vZHVsZXMlM0QlNUIlMjJxX3Byb2olMjIlMkMlMjAlMjJrX3Byb2olMjIlMkMlMjAlMjJ2X3Byb2olMjIlMkMlMjAlMjJvdXRfcHJvaiUyMiU1RCUyQyUwQSklMEElMEF0ZXh0X2VuY29kZXJfb25lLmFkZF9hZGFwdGVyKHRleHRfbG9yYV9jb25maWcpJTBBdGV4dF9lbmNvZGVyX3R3by5hZGRfYWRhcHRlcih0ZXh0X2xvcmFfY29uZmlnKSUwQXRleHRfbG9yYV9wYXJhbWV0ZXJzX29uZSUyMCUzRCUyMGxpc3QoZmlsdGVyKGxhbWJkYSUyMHAlM0ElMjBwLnJlcXVpcmVzX2dyYWQlMkMlMjB0ZXh0X2VuY29kZXJfb25lLnBhcmFtZXRlcnMoKSkpJTBBdGV4dF9sb3JhX3BhcmFtZXRlcnNfdHdvJTIwJTNEJTIwbGlzdChmaWx0ZXIobGFtYmRhJTIwcCUzQSUyMHAucmVxdWlyZXNfZ3JhZCUyQyUyMHRleHRfZW5jb2Rlcl90d28ucGFyYW1ldGVycygpKSk=",highlighted:`text_lora_config = LoraConfig(
    r=args.rank,
    lora_alpha=args.rank,
    init_lora_weights=<span class="hljs-string">&quot;gaussian&quot;</span>,
    target_modules=[<span class="hljs-string">&quot;q_proj&quot;</span>, <span class="hljs-string">&quot;k_proj&quot;</span>, <span class="hljs-string">&quot;v_proj&quot;</span>, <span class="hljs-string">&quot;out_proj&quot;</span>],
)

text_encoder_one.add_adapter(text_lora_config)
text_encoder_two.add_adapter(text_lora_config)
text_lora_parameters_one = <span class="hljs-built_in">list</span>(<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> p: p.requires_grad, text_encoder_one.parameters()))
text_lora_parameters_two = <span class="hljs-built_in">list</span>(<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> p: p.requires_grad, text_encoder_two.parameters()))`,wrap:!1}}),{c(){o=p("p"),o.innerHTML=w,h=n(),c(m.$$.fragment)},l(s){o=f(s,"P",{"data-svelte-h":!0}),u(o)!=="svelte-12kpwrx"&&(o.innerHTML=w),h=i(s),d(m.$$.fragment,s)},m(s,b){a(s,o,b),a(s,h,b),y(m,s,b),r=!0},p:Gt,i(s){r||(M(m.$$.fragment,s),r=!0)},o(s){g(m.$$.fragment,s),r=!1},d(s){s&&(l(o),l(h)),_(m,s)}}}function Dt(T){let o,w,h,m;return o=new It({props:{id:"lora",option:"UNet",$$slots:{default:[qt]},$$scope:{ctx:T}}}),h=new It({props:{id:"lora",option:"text encoder",$$slots:{default:[zt]},$$scope:{ctx:T}}}),{c(){c(o.$$.fragment),w=n(),c(h.$$.fragment)},l(r){d(o.$$.fragment,r),w=i(r),d(h.$$.fragment,r)},m(r,s){y(o,r,s),a(r,w,s),y(h,r,s),m=!0},p(r,s){const b={};s&2&&(b.$$scope={dirty:s,ctx:r}),o.$set(b);const Z={};s&2&&(Z.$$scope={dirty:s,ctx:r}),h.$set(Z)},i(r){m||(M(o.$$.fragment,r),M(h.$$.fragment,r),m=!0)},o(r){g(o.$$.fragment,r),g(h.$$.fragment,r),m=!1},d(r){r&&l(w),_(o,r),_(h,r)}}}function Pt(T){let o,w,h,m,r,s,b,Z,$,rt="<p>This is experimental and the API may change in the future.</p>",Me,R,ot='<a href="https://hf.co/papers/2106.09685" rel="nofollow">LoRA (Low-Rank Adaptation of Large Language Models)</a> is a popular and lightweight training technique that significantly reduces the number of trainable parameters. It works by inserting a smaller number of new weights into the model and only these are trained. This makes training with LoRA much faster, memory-efficient, and produces smaller model weights (a few hundred MBs), which are easier to store and share. LoRA can also be combined with other training techniques like DreamBooth to speedup training.',ge,x,pt='<p>LoRA is very versatile and supported for <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">DreamBooth</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/kandinsky2_2/text_to_image/train_text_to_image_lora_decoder.py" rel="nofollow">Kandinsky 2.2</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora_sdxl.py" rel="nofollow">Stable Diffusion XL</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py" rel="nofollow">text-to-image</a>, and <a href="https://github.com/huggingface/diffusers/blob/main/examples/wuerstchen/text_to_image/train_text_to_image_lora_prior.py" rel="nofollow">Wuerstchen</a>.</p>',_e,X,ft='This guide will explore the <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py" rel="nofollow">train_text_to_image_lora.py</a> script to help you become more familiar with it, and how you can adapt it for your own use-case.',be,L,ut="Before running the script, make sure you install the library from source:",we,k,Ue,W,mt="Navigate to the example folder with the training script and install the required dependencies for the script you’re using:",Te,E,$e,J,ht='<p>🤗 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.</p>',xe,I,ct="Initialize an 🤗 Accelerate environment:",Je,G,je,B,dt="To setup a default 🤗 Accelerate environment without choosing any configurations:",Ce,V,ve,A,yt="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",Ze,F,Re,H,Mt='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.',Xe,j,gt='<p>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/text_to_image/train_text_to_image_lora.py" rel="nofollow">script</a> and let us know if you have any questions or concerns.</p>',Le,Q,ke,N,_t='The training script has 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/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L85" rel="nofollow"><code>parse_args()</code></a> function. Default values are provided for most parameters that work pretty well, but you can also set your own values in the training command if you’d like.',We,S,bt="For example, to increase the number of epochs to train:",Ee,Y,Ie,q,wt='Many of the basic and important parameters are described in the <a href="text2image#script-parameters">Text-to-image</a> training guide, so this guide just focuses on the LoRA relevant parameters:',Ge,z,Ut="<li><code>--rank</code>: the inner dimension of the low-rank matrices to train; a higher rank means more trainable parameters</li> <li><code>--learning_rate</code>: the default learning rate is 1e-4, but with LoRA, you can use a higher learning rate</li>",Be,D,Ve,P,Tt='The dataset preprocessing code and training loop are found in the <a href="https://github.com/huggingface/diffusers/blob/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L371" rel="nofollow"><code>main()</code></a> function, and if you need to adapt the training script, this is where you’ll make your changes.',Ae,O,$t='As with the script parameters, a walkthrough of the training script is provided in the <a href="text2image#training-script">Text-to-image</a> training guide. Instead, this guide takes a look at the LoRA relevant parts of the script.',Fe,C,He,K,xt='The <a href="https://github.com/huggingface/diffusers/blob/e4b8f173b97731686e290b2eb98e7f5df2b1b322/examples/text_to_image/train_text_to_image_lora.py#L529" rel="nofollow">optimizer</a> is initialized with the <code>lora_layers</code> because these are the only weights that’ll be optimized:',Qe,ee,Ne,te,Jt="Aside from setting up the LoRA layers, the training script is more or less the same as train_text_to_image.py!",Se,le,Ye,ae,jt="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",qe,ne,Ct='Let’s train on the <a href="https://huggingface.co/datasets/lambdalabs/naruto-blip-captions" rel="nofollow">Naruto BLIP captions</a> dataset to generate your own Naruto characters. Set the environment variables <code>MODEL_NAME</code> and <code>DATASET_NAME</code> to the model and dataset respectively. You should also specify where to save the model in <code>OUTPUT_DIR</code>, and the name of the model to save to on the Hub with <code>HUB_MODEL_ID</code>. The script creates and saves the following files to your repository:',ze,ie,vt="<li>saved model checkpoints</li> <li><code>pytorch_lora_weights.safetensors</code> (the trained LoRA weights)</li>",De,se,Zt="If you’re training on more than one GPU, add the <code>--multi_gpu</code> parameter to the <code>accelerate launch</code> command.",Pe,v,Rt="<p>A full training run takes ~5 hours on a 2080 Ti GPU with 11GB of VRAM.</p>",Oe,re,Ke,oe,Xt="Once training has been completed, you can use your model for inference:",et,pe,tt,fe,lt,ue,Lt="Congratulations on training a new model with LoRA! To learn more about how to use your new model, the following guides may be helpful:",at,me,kt='<li>Learn how to <a href="../tutorials/using_peft_for_inference">load different LoRA formats</a> trained using community trainers like Kohya and TheLastBen.</li> <li>Learn how to use and <a href="../tutorials/using_peft_for_inference">combine multiple LoRA’s</a> with PEFT for inference.</li>',nt,he,it,de,st;return r=new Nt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new ye({props:{title:"LoRA",local:"lora",headingTag:"h1"}}),k=new U({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}}),E=new U({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image
pip install -r requirements.txt`,wrap:!1}}),G=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),V=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),F=new U({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}}),Q=new ye({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),Y=new U({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3RleHRfdG9faW1hZ2VfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tbnVtX3RyYWluX2Vwb2NocyUzRDE1MCUyMCU1Qw==",highlighted:`accelerate launch train_text_to_image_lora.py \\
  --num_train_epochs=150 \\`,wrap:!1}}),D=new ye({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),C=new Yt({props:{id:"lora",options:["UNet","text encoder"],$$slots:{default:[Dt]},$$scope:{ctx:T}}}),ee=new U({props:{code:"b3B0aW1pemVyJTIwJTNEJTIwb3B0aW1pemVyX2NscyglMEElMjAlMjAlMjAlMjBsb3JhX2xheWVycyUyQyUwQSUyMCUyMCUyMCUyMGxyJTNEYXJncy5sZWFybmluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwYmV0YXMlM0QoYXJncy5hZGFtX2JldGExJTJDJTIwYXJncy5hZGFtX2JldGEyKSUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRGFyZ3MuYWRhbV93ZWlnaHRfZGVjYXklMkMlMEElMjAlMjAlMjAlMjBlcHMlM0RhcmdzLmFkYW1fZXBzaWxvbiUyQyUwQSk=",highlighted:`optimizer = optimizer_cls(
    lora_layers,
    lr=args.learning_rate,
    betas=(args.adam_beta1, args.adam_beta2),
    weight_decay=args.adam_weight_decay,
    eps=args.adam_epsilon,
)`,wrap:!1}}),le=new ye({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),re=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjIlMkZzZGRhdGElMkZmaW5ldHVuZSUyRmxvcmElMkZuYXJ1dG8lMjIlMEFleHBvcnQlMjBIVUJfTU9ERUxfSUQlM0QlMjJuYXJ1dG8tbG9yYSUyMiUwQWV4cG9ydCUyMERBVEFTRVRfTkFNRSUzRCUyMmxhbWJkYWxhYnMlMkZuYXJ1dG8tYmxpcC1jYXB0aW9ucyUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjIlMjAlMjB0cmFpbl90ZXh0X3RvX2ltYWdlX2xvcmEucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTI0REFUQVNFVF9OQU1FJTIwJTVDJTBBJTIwJTIwLS1kYXRhbG9hZGVyX251bV93b3JrZXJzJTNEOCUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCU1QyUwQSUyMCUyMC0tY2VudGVyX2Nyb3AlMjAlNUMlMEElMjAlMjAtLXJhbmRvbV9mbGlwJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMTUwMDAlMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS0wNCUyMCU1QyUwQSUyMCUyMC0tbWF4X2dyYWRfbm9ybSUzRDElMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvc2luZSUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNCU3Qk9VVFBVVF9ESVIlN0QlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHViJTIwJTVDJTBBJTIwJTIwLS1odWJfbW9kZWxfaWQlM0QlMjQlN0JIVUJfTU9ERUxfSUQlN0QlMjAlNUMlMEElMjAlMjAtLXJlcG9ydF90byUzRHdhbmRiJTIwJTVDJTBBJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMkElMjBuYXJ1dG8lMjB3aXRoJTIwYmx1ZSUyMGV5ZXMuJTIyJTIwJTVDJTBBJTIwJTIwLS1zZWVkJTNEMTMzNw==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;/sddata/finetune/lora/naruto&quot;</span>
<span class="hljs-built_in">export</span> HUB_MODEL_ID=<span class="hljs-string">&quot;naruto-lora&quot;</span>
<span class="hljs-built_in">export</span> DATASET_NAME=<span class="hljs-string">&quot;lambdalabs/naruto-blip-captions&quot;</span>

accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>  train_text_to_image_lora.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$DATASET_NAME</span> \\
  --dataloader_num_workers=8 \\
  --resolution=512 \\
  --center_crop \\
  --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --max_train_steps=15000 \\
  --learning_rate=1e-04 \\
  --max_grad_norm=1 \\
  --lr_scheduler=<span class="hljs-string">&quot;cosine&quot;</span> \\
  --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-variable">\${OUTPUT_DIR}</span> \\
  --push_to_hub \\
  --hub_model_id=<span class="hljs-variable">\${HUB_MODEL_ID}</span> \\
  --report_to=wandb \\
  --checkpointing_steps=500 \\
  --validation_prompt=<span class="hljs-string">&quot;A naruto with blue eyes.&quot;</span> \\
  --seed=1337`,wrap:!1}}),pe=new U({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUyMnBhdGglMkZ0byUyRmxvcmElMkZtb2RlbCUyMiUyQyUyMHdlaWdodF9uYW1lJTNEJTIycHl0b3JjaF9sb3JhX3dlaWdodHMuc2FmZXRlbnNvcnMlMjIpJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMjJBJTIwbmFydXRvJTIwd2l0aCUyMGJsdWUlMjBleWVzJTIyKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(<span class="hljs-string">&quot;path/to/lora/model&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_lora_weights.safetensors&quot;</span>)
image = pipeline(<span class="hljs-string">&quot;A naruto with blue eyes&quot;</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),fe=new ye({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),he=new St({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/lora.md"}}),{c(){o=p("meta"),w=n(),h=p("p"),m=n(),c(r.$$.fragment),s=n(),c(b.$$.fragment),Z=n(),$=p("blockquote"),$.innerHTML=rt,Me=n(),R=p("p"),R.innerHTML=ot,ge=n(),x=p("blockquote"),x.innerHTML=pt,_e=n(),X=p("p"),X.innerHTML=ft,be=n(),L=p("p"),L.textContent=ut,we=n(),c(k.$$.fragment),Ue=n(),W=p("p"),W.textContent=mt,Te=n(),c(E.$$.fragment),$e=n(),J=p("blockquote"),J.innerHTML=ht,xe=n(),I=p("p"),I.textContent=ct,Je=n(),c(G.$$.fragment),je=n(),B=p("p"),B.textContent=dt,Ce=n(),c(V.$$.fragment),ve=n(),A=p("p"),A.textContent=yt,Ze=n(),c(F.$$.fragment),Re=n(),H=p("p"),H.innerHTML=Mt,Xe=n(),j=p("blockquote"),j.innerHTML=gt,Le=n(),c(Q.$$.fragment),ke=n(),N=p("p"),N.innerHTML=_t,We=n(),S=p("p"),S.textContent=bt,Ee=n(),c(Y.$$.fragment),Ie=n(),q=p("p"),q.innerHTML=wt,Ge=n(),z=p("ul"),z.innerHTML=Ut,Be=n(),c(D.$$.fragment),Ve=n(),P=p("p"),P.innerHTML=Tt,Ae=n(),O=p("p"),O.innerHTML=$t,Fe=n(),c(C.$$.fragment),He=n(),K=p("p"),K.innerHTML=xt,Qe=n(),c(ee.$$.fragment),Ne=n(),te=p("p"),te.textContent=Jt,Se=n(),c(le.$$.fragment),Ye=n(),ae=p("p"),ae.textContent=jt,qe=n(),ne=p("p"),ne.innerHTML=Ct,ze=n(),ie=p("ul"),ie.innerHTML=vt,De=n(),se=p("p"),se.innerHTML=Zt,Pe=n(),v=p("blockquote"),v.innerHTML=Rt,Oe=n(),c(re.$$.fragment),Ke=n(),oe=p("p"),oe.textContent=Xt,et=n(),c(pe.$$.fragment),tt=n(),c(fe.$$.fragment),lt=n(),ue=p("p"),ue.textContent=Lt,at=n(),me=p("ul"),me.innerHTML=kt,nt=n(),c(he.$$.fragment),it=n(),de=p("p"),this.h()},l(e){const t=Ht("svelte-u9bgzb",document.head);o=f(t,"META",{name:!0,content:!0}),t.forEach(l),w=i(e),h=f(e,"P",{}),Et(h).forEach(l),m=i(e),d(r.$$.fragment,e),s=i(e),d(b.$$.fragment,e),Z=i(e),$=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u($)!=="svelte-1hxqi8m"&&($.innerHTML=rt),Me=i(e),R=f(e,"P",{"data-svelte-h":!0}),u(R)!=="svelte-175koj4"&&(R.innerHTML=ot),ge=i(e),x=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(x)!=="svelte-1iy95is"&&(x.innerHTML=pt),_e=i(e),X=f(e,"P",{"data-svelte-h":!0}),u(X)!=="svelte-96n353"&&(X.innerHTML=ft),be=i(e),L=f(e,"P",{"data-svelte-h":!0}),u(L)!=="svelte-l7dm2q"&&(L.textContent=ut),we=i(e),d(k.$$.fragment,e),Ue=i(e),W=f(e,"P",{"data-svelte-h":!0}),u(W)!=="svelte-1nancx8"&&(W.textContent=mt),Te=i(e),d(E.$$.fragment,e),$e=i(e),J=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(J)!=="svelte-1in84qc"&&(J.innerHTML=ht),xe=i(e),I=f(e,"P",{"data-svelte-h":!0}),u(I)!=="svelte-60q53m"&&(I.textContent=ct),Je=i(e),d(G.$$.fragment,e),je=i(e),B=f(e,"P",{"data-svelte-h":!0}),u(B)!=="svelte-di6juu"&&(B.textContent=dt),Ce=i(e),d(V.$$.fragment,e),ve=i(e),A=f(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-tsz4qp"&&(A.textContent=yt),Ze=i(e),d(F.$$.fragment,e),Re=i(e),H=f(e,"P",{"data-svelte-h":!0}),u(H)!=="svelte-1fkfdql"&&(H.innerHTML=Mt),Xe=i(e),j=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(j)!=="svelte-reu802"&&(j.innerHTML=gt),Le=i(e),d(Q.$$.fragment,e),ke=i(e),N=f(e,"P",{"data-svelte-h":!0}),u(N)!=="svelte-iombk1"&&(N.innerHTML=_t),We=i(e),S=f(e,"P",{"data-svelte-h":!0}),u(S)!=="svelte-1tuocui"&&(S.textContent=bt),Ee=i(e),d(Y.$$.fragment,e),Ie=i(e),q=f(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-91isnp"&&(q.innerHTML=wt),Ge=i(e),z=f(e,"UL",{"data-svelte-h":!0}),u(z)!=="svelte-1vnjzvi"&&(z.innerHTML=Ut),Be=i(e),d(D.$$.fragment,e),Ve=i(e),P=f(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-3k8m7y"&&(P.innerHTML=Tt),Ae=i(e),O=f(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-18vf99y"&&(O.innerHTML=$t),Fe=i(e),d(C.$$.fragment,e),He=i(e),K=f(e,"P",{"data-svelte-h":!0}),u(K)!=="svelte-tizalo"&&(K.innerHTML=xt),Qe=i(e),d(ee.$$.fragment,e),Ne=i(e),te=f(e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-gtrt4e"&&(te.textContent=Jt),Se=i(e),d(le.$$.fragment,e),Ye=i(e),ae=f(e,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-9dei1q"&&(ae.textContent=jt),qe=i(e),ne=f(e,"P",{"data-svelte-h":!0}),u(ne)!=="svelte-vqlj4l"&&(ne.innerHTML=Ct),ze=i(e),ie=f(e,"UL",{"data-svelte-h":!0}),u(ie)!=="svelte-1qgx1zz"&&(ie.innerHTML=vt),De=i(e),se=f(e,"P",{"data-svelte-h":!0}),u(se)!=="svelte-mj0rx7"&&(se.innerHTML=Zt),Pe=i(e),v=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(v)!=="svelte-1pptu1w"&&(v.innerHTML=Rt),Oe=i(e),d(re.$$.fragment,e),Ke=i(e),oe=f(e,"P",{"data-svelte-h":!0}),u(oe)!=="svelte-17edgey"&&(oe.textContent=Xt),et=i(e),d(pe.$$.fragment,e),tt=i(e),d(fe.$$.fragment,e),lt=i(e),ue=f(e,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-7dh2u5"&&(ue.textContent=Lt),at=i(e),me=f(e,"UL",{"data-svelte-h":!0}),u(me)!=="svelte-ylrgwx"&&(me.innerHTML=kt),nt=i(e),d(he.$$.fragment,e),it=i(e),de=f(e,"P",{}),Et(de).forEach(l),this.h()},h(){ce(o,"name","hf:doc:metadata"),ce(o,"content",Ot),ce($,"class","warning"),ce(x,"class","tip"),ce(J,"class","tip"),ce(j,"class","tip"),ce(v,"class","warning")},m(e,t){Qt(document.head,o),a(e,w,t),a(e,h,t),a(e,m,t),y(r,e,t),a(e,s,t),y(b,e,t),a(e,Z,t),a(e,$,t),a(e,Me,t),a(e,R,t),a(e,ge,t),a(e,x,t),a(e,_e,t),a(e,X,t),a(e,be,t),a(e,L,t),a(e,we,t),y(k,e,t),a(e,Ue,t),a(e,W,t),a(e,Te,t),y(E,e,t),a(e,$e,t),a(e,J,t),a(e,xe,t),a(e,I,t),a(e,Je,t),y(G,e,t),a(e,je,t),a(e,B,t),a(e,Ce,t),y(V,e,t),a(e,ve,t),a(e,A,t),a(e,Ze,t),y(F,e,t),a(e,Re,t),a(e,H,t),a(e,Xe,t),a(e,j,t),a(e,Le,t),y(Q,e,t),a(e,ke,t),a(e,N,t),a(e,We,t),a(e,S,t),a(e,Ee,t),y(Y,e,t),a(e,Ie,t),a(e,q,t),a(e,Ge,t),a(e,z,t),a(e,Be,t),y(D,e,t),a(e,Ve,t),a(e,P,t),a(e,Ae,t),a(e,O,t),a(e,Fe,t),y(C,e,t),a(e,He,t),a(e,K,t),a(e,Qe,t),y(ee,e,t),a(e,Ne,t),a(e,te,t),a(e,Se,t),y(le,e,t),a(e,Ye,t),a(e,ae,t),a(e,qe,t),a(e,ne,t),a(e,ze,t),a(e,ie,t),a(e,De,t),a(e,se,t),a(e,Pe,t),a(e,v,t),a(e,Oe,t),y(re,e,t),a(e,Ke,t),a(e,oe,t),a(e,et,t),y(pe,e,t),a(e,tt,t),y(fe,e,t),a(e,lt,t),a(e,ue,t),a(e,at,t),a(e,me,t),a(e,nt,t),y(he,e,t),a(e,it,t),a(e,de,t),st=!0},p(e,[t]){const Wt={};t&2&&(Wt.$$scope={dirty:t,ctx:e}),C.$set(Wt)},i(e){st||(M(r.$$.fragment,e),M(b.$$.fragment,e),M(k.$$.fragment,e),M(E.$$.fragment,e),M(G.$$.fragment,e),M(V.$$.fragment,e),M(F.$$.fragment,e),M(Q.$$.fragment,e),M(Y.$$.fragment,e),M(D.$$.fragment,e),M(C.$$.fragment,e),M(ee.$$.fragment,e),M(le.$$.fragment,e),M(re.$$.fragment,e),M(pe.$$.fragment,e),M(fe.$$.fragment,e),M(he.$$.fragment,e),st=!0)},o(e){g(r.$$.fragment,e),g(b.$$.fragment,e),g(k.$$.fragment,e),g(E.$$.fragment,e),g(G.$$.fragment,e),g(V.$$.fragment,e),g(F.$$.fragment,e),g(Q.$$.fragment,e),g(Y.$$.fragment,e),g(D.$$.fragment,e),g(C.$$.fragment,e),g(ee.$$.fragment,e),g(le.$$.fragment,e),g(re.$$.fragment,e),g(pe.$$.fragment,e),g(fe.$$.fragment,e),g(he.$$.fragment,e),st=!1},d(e){e&&(l(w),l(h),l(m),l(s),l(Z),l($),l(Me),l(R),l(ge),l(x),l(_e),l(X),l(be),l(L),l(we),l(Ue),l(W),l(Te),l($e),l(J),l(xe),l(I),l(Je),l(je),l(B),l(Ce),l(ve),l(A),l(Ze),l(Re),l(H),l(Xe),l(j),l(Le),l(ke),l(N),l(We),l(S),l(Ee),l(Ie),l(q),l(Ge),l(z),l(Be),l(Ve),l(P),l(Ae),l(O),l(Fe),l(He),l(K),l(Qe),l(Ne),l(te),l(Se),l(Ye),l(ae),l(qe),l(ne),l(ze),l(ie),l(De),l(se),l(Pe),l(v),l(Oe),l(Ke),l(oe),l(et),l(tt),l(lt),l(ue),l(at),l(me),l(nt),l(it),l(de)),l(o),_(r,e),_(b,e),_(k,e),_(E,e),_(G,e),_(V,e),_(F,e),_(Q,e),_(Y,e),_(D,e),_(C,e),_(ee,e),_(le,e),_(re,e),_(pe,e),_(fe,e),_(he,e)}}}const Ot='{"title":"LoRA","local":"lora","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},{"title":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function Kt(T){return Vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class sl extends At{constructor(o){super(),Ft(this,o,Kt,Pt,Bt,{})}}export{sl as component};
