import{S as kn,i as An,s as Sn,e as a,k as f,w as h,t as n,M as Bn,c as i,d as t,m as u,a as s,x as d,h as r,b as c,N as Xn,G as l,g as p,y as m,L as Yn,q as y,o as w,B as _,v as Gn}from"../../chunks/vendor-hf-doc-builder.js";import{I as De}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as x}from"../../chunks/CodeBlock-hf-doc-builder.js";function Fn(ns){let N,Lt,j,B,st,ae,ea,nt,ta,zt,ie,se,la,aa,Ht,ne,re,rs,qt,Ve,ia,Ot,oe,pe,os,Kt,W,sa,rt,na,ra,ce,oa,pa,el,Pe,ot,J,ca,pt,fa,ua,fe,ha,da,ue,ma,ya,he,wa,_a,tl,$,Y,ct,de,Ma,ft,Ja,ll,R,G,ut,me,ga,ht,ba,al,Qe,Ta,il,Le,dt,va,sl,F,Ua,mt,Ea,xa,nl,ye,rl,ze,Wa,ol,we,pl,He,Za,cl,_e,fl,D,Ia,Me,Ca,Na,ul,Je,hl,qe,ja,dl,ge,ml,Oe,$a,yl,be,wl,X,V,yt,Te,Ra,wt,Xa,_l,g,ka,ve,Aa,Sa,Ue,Ba,Ya,Ke,Ga,Fa,Ml,b,Da,_t,Va,Pa,Ee,Mt,Qa,La,Jt,za,Ha,Jl,xe,gl,M,qa,gt,Oa,Ka,bt,ei,ti,Tt,li,ai,vt,ii,si,bl,We,Tl,P,ni,Ut,ri,oi,vl,Ze,Ul,T,pi,Et,ci,fi,xt,ui,hi,Wt,di,mi,El,Ie,Ce,yi,wi,xl,et,Zt,It,_i,Wl,k,Q,Ct,Ne,Mi,Nt,Ji,Zl,E,jt,gi,bi,je,Ti,vi,$t,Ui,Ei,Il,$e,Cl,A,L,Rt,Re,xi,Xt,Wi,Nl,tt,Zi,jl,Xe,$l,z,Ii,ke,Ci,Ni,Rl,lt,ji,Xl,Z,kt,At,$i,Ri,St,Bt,Xi,ki,Yt,Gt,Ai,kl,v,Si,Ft,Bi,Yi,Dt,Gi,Fi,Ae,Di,Vi,Al,H,Pi,Se,Qi,Li,Sl,S,q,Vt,Be,zi,Pt,Hi,Bl,U,qi,Ye,Oi,Ki,Qt,es,ts,Ge,ls,as,Yl;return ae=new De({}),de=new De({}),me=new De({}),ye=new x({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC1lJTIwLg==",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install -e .`}}),we=new x({props:{code:"Y2QlMjBleGFtcGxlcyUyRmluc3RydWN0X3BpeDJwaXg=",highlighted:'<span class="hljs-built_in">cd</span> examples/instruct_pix2pix'}}),_e=new x({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dA==",highlighted:"pip install -r requirements.txt"}}),Je=new x({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),ge=new x({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),be=new x({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`}}),Te=new De({}),xe=new x({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwREFUQVNFVF9JRCUzRCUyMmZ1c2luZyUyRmluc3RydWN0cGl4MnBpeC0xMDAwLXNhbXBsZXMlMjI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> DATASET_ID=<span class="hljs-string">&quot;fusing/instructpix2pix-1000-samples&quot;</span>`}}),We=new x({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMHRyYWluX2luc3RydWN0X3BpeDJwaXgucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTI0REFUQVNFVF9JRCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1yZXNvbHV0aW9uJTNEMjU2JTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDQlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwMCUyMC0tY2hlY2twb2ludHNfdG90YWxfbGltaXQlM0QxJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtMDUlMjAtLW1heF9ncmFkX25vcm0lM0QxJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jb25kaXRpb25pbmdfZHJvcG91dF9wcm9iJTNEMC4wNSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEZnAxNiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tc2VlZCUzRDQyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> train_instruct_pix2pix.py \\
    --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
    --dataset_name=<span class="hljs-variable">$DATASET_ID</span> \\
    --enable_xformers_memory_efficient_attention \\
    --resolution=256 --random_flip \\
    --train_batch_size=4 --gradient_accumulation_steps=4 --gradient_checkpointing \\
    --max_train_steps=15000 \\
    --checkpointing_steps=5000 --checkpoints_total_limit=1 \\
    --learning_rate=5e-05 --max_grad_norm=1 --lr_warmup_steps=0 \\
    --conditioning_dropout_prob=0.05 \\
    --mixed_precision=fp16 \\
    --seed=42 \\
    --push_to_hub`}}),Ze=new x({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMHRyYWluX2luc3RydWN0X3BpeDJwaXgucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZGF0YXNldF9uYW1lJTNEJTI0REFUQVNFVF9JRCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1yZXNvbHV0aW9uJTNEMjU2JTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDQlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwMCUyMC0tY2hlY2twb2ludHNfdG90YWxfbGltaXQlM0QxJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtMDUlMjAtLW1heF9ncmFkX25vcm0lM0QxJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jb25kaXRpb25pbmdfZHJvcG91dF9wcm9iJTNEMC4wNSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEZnAxNiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdmFsX2ltYWdlX3VybCUzRCUyMmh0dHBzJTNBJTJGJTJGaGYuY28lMkZkYXRhc2V0cyUyRmRpZmZ1c2VycyUyRmRpZmZ1c2Vycy1pbWFnZXMtZG9jcyUyRnJlc29sdmUlMkZtYWluJTJGbW91bnRhaW4ucG5nJTIyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMm1ha2UlMjB0aGUlMjBtb3VudGFpbnMlMjBzbm93eSUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tc2VlZCUzRDQyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1yZXBvcnRfdG8lM0R3YW5kYiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> train_instruct_pix2pix.py \\
    --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
    --dataset_name=<span class="hljs-variable">$DATASET_ID</span> \\
    --enable_xformers_memory_efficient_attention \\
    --resolution=256 --random_flip \\
    --train_batch_size=4 --gradient_accumulation_steps=4 --gradient_checkpointing \\
    --max_train_steps=15000 \\
    --checkpointing_steps=5000 --checkpoints_total_limit=1 \\
    --learning_rate=5e-05 --max_grad_norm=1 --lr_warmup_steps=0 \\
    --conditioning_dropout_prob=0.05 \\
    --mixed_precision=fp16 \\
    --val_image_url=<span class="hljs-string">&quot;https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png&quot;</span> \\
    --validation_prompt=<span class="hljs-string">&quot;make the mountains snowy&quot;</span> \\
    --seed=42 \\
    --report_to=wandb \\
    --push_to_hub`}}),Ne=new De({}),$e=new x({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMC0tbXVsdGlfZ3B1JTIwdHJhaW5faW5zdHJ1Y3RfcGl4MnBpeC5weSUyMCU1QyUwQSUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0RydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMCU1QyUwQSUyMC0tZGF0YXNldF9uYW1lJTNEc2F5YWtwYXVsJTJGaW5zdHJ1Y3RwaXgycGl4LTEwMDAtc2FtcGxlcyUyMCU1QyUwQSUyMC0tdXNlX2VtYSUyMCU1QyUwQSUyMC0tZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uJTIwJTVDJTBBJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDQlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTBBJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwMCUyMC0tY2hlY2twb2ludHNfdG90YWxfbGltaXQlM0QxJTIwJTVDJTBBJTIwLS1sZWFybmluZ19yYXRlJTNENWUtMDUlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAtLWNvbmRpdGlvbmluZ19kcm9wb3V0X3Byb2IlM0QwLjA1JTIwJTVDJTBBJTIwLS1taXhlZF9wcmVjaXNpb24lM0RmcDE2JTIwJTVDJTBBJTIwLS1zZWVkJTNENDIlMjAlNUMlMEElMjAtLXB1c2hfdG9faHVi",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> --multi_gpu train_instruct_pix2pix.py \\
 --pretrained_model_name_or_path=runwayml/stable-diffusion-v1-5 \\
 --dataset_name=sayakpaul/instructpix2pix-1000-samples \\
 --use_ema \\
 --enable_xformers_memory_efficient_attention \\
 --resolution=512 --random_flip \\
 --train_batch_size=4 --gradient_accumulation_steps=4 --gradient_checkpointing \\
 --max_train_steps=15000 \\
 --checkpointing_steps=5000 --checkpoints_total_limit=1 \\
 --learning_rate=5e-05 --lr_warmup_steps=0 \\
 --conditioning_dropout_prob=0.05 \\
 --mixed_precision=fp16 \\
 --seed=42 \\
 --push_to_hub`}}),Re=new De({}),Xe=new x({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25JbnN0cnVjdFBpeDJQaXhQaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyeW91cl9tb2RlbF9pZCUyMiUyMCUyMCUyMyUyMCUzQy0lMjByZXBsYWNlJTIwdGhpcyUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnN0cnVjdFBpeDJQaXhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGc2F5YWtwYXVsJTJGc2FtcGxlLWRhdGFzZXRzJTJGcmVzb2x2ZSUyRm1haW4lMkZ0ZXN0X3BpeDJwaXhfNC5wbmclMjIlMEElMEElMEFkZWYlMjBkb3dubG9hZF9pbWFnZSh1cmwpJTNBJTBBJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBQSUwuSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUyMCUyMCUyMGltYWdlJTIwJTNEJTIwUElMLkltYWdlT3BzLmV4aWZfdHJhbnNwb3NlKGltYWdlKSUwQSUyMCUyMCUyMGltYWdlJTIwJTNEJTIwaW1hZ2UuY29udmVydCglMjJSR0IlMjIpJTBBJTIwJTIwJTIwcmV0dXJuJTIwaW1hZ2UlMEElMEElMEFpbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKHVybCklMEFwcm9tcHQlMjAlM0QlMjAlMjJ3aXBlJTIwb3V0JTIwdGhlJTIwbGFrZSUyMiUwQW51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjAyMCUwQWltYWdlX2d1aWRhbmNlX3NjYWxlJTIwJTNEJTIwMS41JTBBZ3VpZGFuY2Vfc2NhbGUlMjAlM0QlMjAxMCUwQSUwQWVkaXRlZF9pbWFnZSUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RudW1faW5mZXJlbmNlX3N0ZXBzJTJDJTBBJTIwJTIwJTIwaW1hZ2VfZ3VpZGFuY2Vfc2NhbGUlM0RpbWFnZV9ndWlkYW5jZV9zY2FsZSUyQyUwQSUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNEZ3VpZGFuY2Vfc2NhbGUlMkMlMEElMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEpLmltYWdlcyU1QjAlNUQlMEFlZGl0ZWRfaW1hZ2Uuc2F2ZSglMjJlZGl0ZWRfaW1hZ2UucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> PIL
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInstructPix2PixPipeline

model_id = <span class="hljs-string">&quot;your_model_id&quot;</span>  <span class="hljs-comment"># &lt;- replace this</span>
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)

url = <span class="hljs-string">&quot;https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/test_pix2pix_4.png&quot;</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
   image = PIL.Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
   image = PIL.ImageOps.exif_transpose(image)
   image = image.convert(<span class="hljs-string">&quot;RGB&quot;</span>)
   <span class="hljs-keyword">return</span> image


image = download_image(url)
prompt = <span class="hljs-string">&quot;wipe out the lake&quot;</span>
num_inference_steps = <span class="hljs-number">20</span>
image_guidance_scale = <span class="hljs-number">1.5</span>
guidance_scale = <span class="hljs-number">10</span>

edited_image = pipe(
   prompt,
   image=image,
   num_inference_steps=num_inference_steps,
   image_guidance_scale=image_guidance_scale,
   guidance_scale=guidance_scale,
   generator=generator,
).images[<span class="hljs-number">0</span>]
edited_image.save(<span class="hljs-string">&quot;edited_image.png&quot;</span>)`}}),Be=new De({}),{c(){N=a("meta"),Lt=f(),j=a("h1"),B=a("a"),st=a("span"),h(ae.$$.fragment),ea=f(),nt=a("span"),ta=n("InstructPix2Pix"),zt=f(),ie=a("p"),se=a("a"),la=n("InstructPix2Pix"),aa=n(" is a method to fine-tune text-conditioned diffusion models such that they can follow an edit instruction for an input image. Models fine-tuned using this method take the following as inputs:"),Ht=f(),ne=a("p"),re=a("img"),qt=f(),Ve=a("p"),ia=n("The output is an \u201Cedited\u201D image that reflects the edit instruction applied on the input image:"),Ot=f(),oe=a("p"),pe=a("img"),Kt=f(),W=a("p"),sa=n("The "),rt=a("code"),na=n("train_instruct_pix2pix.py"),ra=n(" script (you can find the it "),ce=a("a"),oa=n("here"),pa=n(") shows how to implement the training procedure and adapt it for Stable Diffusion."),el=f(),Pe=a("p"),ot=a("strong"),J=a("em"),ca=n("Disclaimer: Even though "),pt=a("code"),fa=n("train_instruct_pix2pix.py"),ua=n(` implements the InstructPix2Pix
training procedure while being faithful to the `),fe=a("a"),ha=n("original implementation"),da=n(" we have only tested it on a "),ue=a("a"),ma=n("small-scale dataset"),ya=n(". This can impact the end results. For better results, we recommend longer training runs with a larger dataset. "),he=a("a"),wa=n("Here"),_a=n(" you can find a large dataset for InstructPix2Pix training."),tl=f(),$=a("h2"),Y=a("a"),ct=a("span"),h(de.$$.fragment),Ma=f(),ft=a("span"),Ja=n("Running locally with PyTorch"),ll=f(),R=a("h3"),G=a("a"),ut=a("span"),h(me.$$.fragment),ga=f(),ht=a("span"),ba=n("Installing the dependencies"),al=f(),Qe=a("p"),Ta=n("Before running the scripts, make sure to install the library\u2019s training dependencies:"),il=f(),Le=a("p"),dt=a("strong"),va=n("Important"),sl=f(),F=a("p"),Ua=n("To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),mt=a("strong"),Ea=n("installing from source"),xa=n(" and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),nl=f(),h(ye.$$.fragment),rl=f(),ze=a("p"),Wa=n("Then cd in the example folder"),ol=f(),h(we.$$.fragment),pl=f(),He=a("p"),Za=n("Now run"),cl=f(),h(_e.$$.fragment),fl=f(),D=a("p"),Ia=n("And initialize an "),Me=a("a"),Ca=n("\u{1F917}Accelerate"),Na=n(" environment with:"),ul=f(),h(Je.$$.fragment),hl=f(),qe=a("p"),ja=n("Or for a default accelerate configuration without answering questions about your environment"),dl=f(),h(ge.$$.fragment),ml=f(),Oe=a("p"),$a=n("Or if your environment doesn\u2019t support an interactive shell e.g. a notebook"),yl=f(),h(be.$$.fragment),wl=f(),X=a("h3"),V=a("a"),yt=a("span"),h(Te.$$.fragment),Ra=f(),wt=a("span"),Xa=n("Toy example"),_l=f(),g=a("p"),ka=n("As mentioned before, we\u2019ll use a "),ve=a("a"),Aa=n("small toy dataset"),Sa=n(` for training. The dataset
is a smaller version of the `),Ue=a("a"),Ba=n("original dataset"),Ya=n(" used in the InstructPix2Pix paper. To use your own dataset, take a look at the "),Ke=a("a"),Ga=n("Create a dataset for training"),Fa=n(" guide."),Ml=f(),b=a("p"),Da=n("Specify the "),_t=a("code"),Va=n("MODEL_NAME"),Pa=n(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Ee=a("a"),Mt=a("code"),Qa=n("pretrained_model_name_or_path"),La=n(" argument. You\u2019ll also need to specify the dataset name in "),Jt=a("code"),za=n("DATASET_ID"),Ha=n(":"),Jl=f(),h(xe.$$.fragment),gl=f(),M=a("p"),qa=n("Now, we can launch training. The script saves all the components ("),gt=a("code"),Oa=n("feature_extractor"),Ka=n(", "),bt=a("code"),ei=n("scheduler"),ti=n(", "),Tt=a("code"),li=n("text_encoder"),ai=n(", "),vt=a("code"),ii=n("unet"),si=n(", etc) in a subfolder in your repository."),bl=f(),h(We.$$.fragment),Tl=f(),P=a("p"),ni=n(`Additionally, we support performing validation inference to monitor training progress
with Weights and Biases. You can enable this feature with `),Ut=a("code"),ri=n('report_to="wandb"'),oi=n(":"),vl=f(),h(Ze.$$.fragment),Ul=f(),T=a("p"),pi=n("We recommend this type of validation as it can be useful for model debugging. Note that you need "),Et=a("code"),ci=n("wandb"),fi=n(" installed to use this. You can install "),xt=a("code"),ui=n("wandb"),hi=n(" by running "),Wt=a("code"),di=n("pip install wandb"),mi=n("."),El=f(),Ie=a("p"),Ce=a("a"),yi=n("Here"),wi=n(", you can find an example training run that includes some validation samples and the training hyperparameters."),xl=f(),et=a("p"),Zt=a("strong"),It=a("em"),_i=n("Note: In the original paper, the authors observed that even when the model is trained with an image resolution of 256x256, it generalizes well to bigger resolutions such as 512x512. This is likely because of the larger dataset they used during training."),Wl=f(),k=a("h2"),Q=a("a"),Ct=a("span"),h(Ne.$$.fragment),Mi=f(),Nt=a("span"),Ji=n("Training with multiple GPUs"),Zl=f(),E=a("p"),jt=a("code"),gi=n("accelerate"),bi=n(" allows for seamless multi-GPU training. Follow the instructions "),je=a("a"),Ti=n("here"),vi=n(`
for running distributed training with `),$t=a("code"),Ui=n("accelerate"),Ei=n(". Here is an example command:"),Il=f(),h($e.$$.fragment),Cl=f(),A=a("h2"),L=a("a"),Rt=a("span"),h(Re.$$.fragment),xi=f(),Xt=a("span"),Wi=n("Inference"),Nl=f(),tt=a("p"),Zi=n("Once training is complete, we can perform inference:"),jl=f(),h(Xe.$$.fragment),$l=f(),z=a("p"),Ii=n(`An example model repo obtained using this training script can be found
here - `),ke=a("a"),Ci=n("sayakpaul/instruct-pix2pix"),Ni=n("."),Rl=f(),lt=a("p"),ji=n(`We encourage you to play with the following three parameters to control
speed and quality during performance:`),Xl=f(),Z=a("ul"),kt=a("li"),At=a("code"),$i=n("num_inference_steps"),Ri=f(),St=a("li"),Bt=a("code"),Xi=n("image_guidance_scale"),ki=f(),Yt=a("li"),Gt=a("code"),Ai=n("guidance_scale"),kl=f(),v=a("p"),Si=n("Particularly, "),Ft=a("code"),Bi=n("image_guidance_scale"),Yi=n(" and "),Dt=a("code"),Gi=n("guidance_scale"),Fi=n(` can have a profound impact
on the generated (\u201Cedited\u201D) image (see `),Ae=a("a"),Di=n("here"),Vi=n(" for an example)."),Al=f(),H=a("p"),Pi=n("If you\u2019re looking for some interesting ways to use the InstructPix2Pix training methodology, we welcome you to check out this blog post: "),Se=a("a"),Qi=n("Instruction-tuning Stable Diffusion with InstructPix2Pix"),Li=n("."),Sl=f(),S=a("h2"),q=a("a"),Vt=a("span"),h(Be.$$.fragment),zi=f(),Pt=a("span"),Hi=n("Stable Diffusion XL"),Bl=f(),U=a("p"),qi=n("Training with "),Ye=a("a"),Oi=n("Stable Diffusion XL"),Ki=n(" is also supported via the "),Qt=a("code"),es=n("train_instruct_pix2pix_sdxl.py"),ts=n(" script. Please refer to the docs "),Ge=a("a"),ls=n("here"),as=n("."),this.h()},l(e){const o=Bn('[data-svelte="svelte-1phssyn"]',document.head);N=i(o,"META",{name:!0,content:!0}),o.forEach(t),Lt=u(e),j=i(e,"H1",{class:!0});var Gl=s(j);B=i(Gl,"A",{id:!0,class:!0,href:!0});var ps=s(B);st=i(ps,"SPAN",{});var cs=s(st);d(ae.$$.fragment,cs),cs.forEach(t),ps.forEach(t),ea=u(Gl),nt=i(Gl,"SPAN",{});var fs=s(nt);ta=r(fs,"InstructPix2Pix"),fs.forEach(t),Gl.forEach(t),zt=u(e),ie=i(e,"P",{});var is=s(ie);se=i(is,"A",{href:!0,rel:!0});var us=s(se);la=r(us,"InstructPix2Pix"),us.forEach(t),aa=r(is," is a method to fine-tune text-conditioned diffusion models such that they can follow an edit instruction for an input image. Models fine-tuned using this method take the following as inputs:"),is.forEach(t),Ht=u(e),ne=i(e,"P",{align:!0});var hs=s(ne);re=i(hs,"IMG",{src:!0,alt:!0,width:!0}),hs.forEach(t),qt=u(e),Ve=i(e,"P",{});var ds=s(Ve);ia=r(ds,"The output is an \u201Cedited\u201D image that reflects the edit instruction applied on the input image:"),ds.forEach(t),Ot=u(e),oe=i(e,"P",{align:!0});var ms=s(oe);pe=i(ms,"IMG",{src:!0,alt:!0,width:!0}),ms.forEach(t),Kt=u(e),W=i(e,"P",{});var at=s(W);sa=r(at,"The "),rt=i(at,"CODE",{});var ys=s(rt);na=r(ys,"train_instruct_pix2pix.py"),ys.forEach(t),ra=r(at," script (you can find the it "),ce=i(at,"A",{href:!0,rel:!0});var ws=s(ce);oa=r(ws,"here"),ws.forEach(t),pa=r(at,") shows how to implement the training procedure and adapt it for Stable Diffusion."),at.forEach(t),el=u(e),Pe=i(e,"P",{});var _s=s(Pe);ot=i(_s,"STRONG",{});var Ms=s(ot);J=i(Ms,"EM",{});var I=s(J);ca=r(I,"Disclaimer: Even though "),pt=i(I,"CODE",{});var Js=s(pt);fa=r(Js,"train_instruct_pix2pix.py"),Js.forEach(t),ua=r(I,` implements the InstructPix2Pix
training procedure while being faithful to the `),fe=i(I,"A",{href:!0,rel:!0});var gs=s(fe);ha=r(gs,"original implementation"),gs.forEach(t),da=r(I," we have only tested it on a "),ue=i(I,"A",{href:!0,rel:!0});var bs=s(ue);ma=r(bs,"small-scale dataset"),bs.forEach(t),ya=r(I,". This can impact the end results. For better results, we recommend longer training runs with a larger dataset. "),he=i(I,"A",{href:!0,rel:!0});var Ts=s(he);wa=r(Ts,"Here"),Ts.forEach(t),_a=r(I," you can find a large dataset for InstructPix2Pix training."),I.forEach(t),Ms.forEach(t),_s.forEach(t),tl=u(e),$=i(e,"H2",{class:!0});var Fl=s($);Y=i(Fl,"A",{id:!0,class:!0,href:!0});var vs=s(Y);ct=i(vs,"SPAN",{});var Us=s(ct);d(de.$$.fragment,Us),Us.forEach(t),vs.forEach(t),Ma=u(Fl),ft=i(Fl,"SPAN",{});var Es=s(ft);Ja=r(Es,"Running locally with PyTorch"),Es.forEach(t),Fl.forEach(t),ll=u(e),R=i(e,"H3",{class:!0});var Dl=s(R);G=i(Dl,"A",{id:!0,class:!0,href:!0});var xs=s(G);ut=i(xs,"SPAN",{});var Ws=s(ut);d(me.$$.fragment,Ws),Ws.forEach(t),xs.forEach(t),ga=u(Dl),ht=i(Dl,"SPAN",{});var Zs=s(ht);ba=r(Zs,"Installing the dependencies"),Zs.forEach(t),Dl.forEach(t),al=u(e),Qe=i(e,"P",{});var Is=s(Qe);Ta=r(Is,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),Is.forEach(t),il=u(e),Le=i(e,"P",{});var Cs=s(Le);dt=i(Cs,"STRONG",{});var Ns=s(dt);va=r(Ns,"Important"),Ns.forEach(t),Cs.forEach(t),sl=u(e),F=i(e,"P",{});var Vl=s(F);Ua=r(Vl,"To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),mt=i(Vl,"STRONG",{});var js=s(mt);Ea=r(js,"installing from source"),js.forEach(t),xa=r(Vl," and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),Vl.forEach(t),nl=u(e),d(ye.$$.fragment,e),rl=u(e),ze=i(e,"P",{});var $s=s(ze);Wa=r($s,"Then cd in the example folder"),$s.forEach(t),ol=u(e),d(we.$$.fragment,e),pl=u(e),He=i(e,"P",{});var Rs=s(He);Za=r(Rs,"Now run"),Rs.forEach(t),cl=u(e),d(_e.$$.fragment,e),fl=u(e),D=i(e,"P",{});var Pl=s(D);Ia=r(Pl,"And initialize an "),Me=i(Pl,"A",{href:!0,rel:!0});var Xs=s(Me);Ca=r(Xs,"\u{1F917}Accelerate"),Xs.forEach(t),Na=r(Pl," environment with:"),Pl.forEach(t),ul=u(e),d(Je.$$.fragment,e),hl=u(e),qe=i(e,"P",{});var ks=s(qe);ja=r(ks,"Or for a default accelerate configuration without answering questions about your environment"),ks.forEach(t),dl=u(e),d(ge.$$.fragment,e),ml=u(e),Oe=i(e,"P",{});var As=s(Oe);$a=r(As,"Or if your environment doesn\u2019t support an interactive shell e.g. a notebook"),As.forEach(t),yl=u(e),d(be.$$.fragment,e),wl=u(e),X=i(e,"H3",{class:!0});var Ql=s(X);V=i(Ql,"A",{id:!0,class:!0,href:!0});var Ss=s(V);yt=i(Ss,"SPAN",{});var Bs=s(yt);d(Te.$$.fragment,Bs),Bs.forEach(t),Ss.forEach(t),Ra=u(Ql),wt=i(Ql,"SPAN",{});var Ys=s(wt);Xa=r(Ys,"Toy example"),Ys.forEach(t),Ql.forEach(t),_l=u(e),g=i(e,"P",{});var O=s(g);ka=r(O,"As mentioned before, we\u2019ll use a "),ve=i(O,"A",{href:!0,rel:!0});var Gs=s(ve);Aa=r(Gs,"small toy dataset"),Gs.forEach(t),Sa=r(O,` for training. The dataset
is a smaller version of the `),Ue=i(O,"A",{href:!0,rel:!0});var Fs=s(Ue);Ba=r(Fs,"original dataset"),Fs.forEach(t),Ya=r(O," used in the InstructPix2Pix paper. To use your own dataset, take a look at the "),Ke=i(O,"A",{href:!0});var Ds=s(Ke);Ga=r(Ds,"Create a dataset for training"),Ds.forEach(t),Fa=r(O," guide."),O.forEach(t),Ml=u(e),b=i(e,"P",{});var K=s(b);Da=r(K,"Specify the "),_t=i(K,"CODE",{});var Vs=s(_t);Va=r(Vs,"MODEL_NAME"),Vs.forEach(t),Pa=r(K," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Ee=i(K,"A",{href:!0,rel:!0});var Ps=s(Ee);Mt=i(Ps,"CODE",{});var Qs=s(Mt);Qa=r(Qs,"pretrained_model_name_or_path"),Qs.forEach(t),Ps.forEach(t),La=r(K," argument. You\u2019ll also need to specify the dataset name in "),Jt=i(K,"CODE",{});var Ls=s(Jt);za=r(Ls,"DATASET_ID"),Ls.forEach(t),Ha=r(K,":"),K.forEach(t),Jl=u(e),d(xe.$$.fragment,e),gl=u(e),M=i(e,"P",{});var C=s(M);qa=r(C,"Now, we can launch training. The script saves all the components ("),gt=i(C,"CODE",{});var zs=s(gt);Oa=r(zs,"feature_extractor"),zs.forEach(t),Ka=r(C,", "),bt=i(C,"CODE",{});var Hs=s(bt);ei=r(Hs,"scheduler"),Hs.forEach(t),ti=r(C,", "),Tt=i(C,"CODE",{});var qs=s(Tt);li=r(qs,"text_encoder"),qs.forEach(t),ai=r(C,", "),vt=i(C,"CODE",{});var Os=s(vt);ii=r(Os,"unet"),Os.forEach(t),si=r(C,", etc) in a subfolder in your repository."),C.forEach(t),bl=u(e),d(We.$$.fragment,e),Tl=u(e),P=i(e,"P",{});var Ll=s(P);ni=r(Ll,`Additionally, we support performing validation inference to monitor training progress
with Weights and Biases. You can enable this feature with `),Ut=i(Ll,"CODE",{});var Ks=s(Ut);ri=r(Ks,'report_to="wandb"'),Ks.forEach(t),oi=r(Ll,":"),Ll.forEach(t),vl=u(e),d(Ze.$$.fragment,e),Ul=u(e),T=i(e,"P",{});var ee=s(T);pi=r(ee,"We recommend this type of validation as it can be useful for model debugging. Note that you need "),Et=i(ee,"CODE",{});var en=s(Et);ci=r(en,"wandb"),en.forEach(t),fi=r(ee," installed to use this. You can install "),xt=i(ee,"CODE",{});var tn=s(xt);ui=r(tn,"wandb"),tn.forEach(t),hi=r(ee," by running "),Wt=i(ee,"CODE",{});var ln=s(Wt);di=r(ln,"pip install wandb"),ln.forEach(t),mi=r(ee,"."),ee.forEach(t),El=u(e),Ie=i(e,"P",{});var ss=s(Ie);Ce=i(ss,"A",{href:!0,rel:!0});var an=s(Ce);yi=r(an,"Here"),an.forEach(t),wi=r(ss,", you can find an example training run that includes some validation samples and the training hyperparameters."),ss.forEach(t),xl=u(e),et=i(e,"P",{});var sn=s(et);Zt=i(sn,"STRONG",{});var nn=s(Zt);It=i(nn,"EM",{});var rn=s(It);_i=r(rn,"Note: In the original paper, the authors observed that even when the model is trained with an image resolution of 256x256, it generalizes well to bigger resolutions such as 512x512. This is likely because of the larger dataset they used during training."),rn.forEach(t),nn.forEach(t),sn.forEach(t),Wl=u(e),k=i(e,"H2",{class:!0});var zl=s(k);Q=i(zl,"A",{id:!0,class:!0,href:!0});var on=s(Q);Ct=i(on,"SPAN",{});var pn=s(Ct);d(Ne.$$.fragment,pn),pn.forEach(t),on.forEach(t),Mi=u(zl),Nt=i(zl,"SPAN",{});var cn=s(Nt);Ji=r(cn,"Training with multiple GPUs"),cn.forEach(t),zl.forEach(t),Zl=u(e),E=i(e,"P",{});var Fe=s(E);jt=i(Fe,"CODE",{});var fn=s(jt);gi=r(fn,"accelerate"),fn.forEach(t),bi=r(Fe," allows for seamless multi-GPU training. Follow the instructions "),je=i(Fe,"A",{href:!0,rel:!0});var un=s(je);Ti=r(un,"here"),un.forEach(t),vi=r(Fe,`
for running distributed training with `),$t=i(Fe,"CODE",{});var hn=s($t);Ui=r(hn,"accelerate"),hn.forEach(t),Ei=r(Fe,". Here is an example command:"),Fe.forEach(t),Il=u(e),d($e.$$.fragment,e),Cl=u(e),A=i(e,"H2",{class:!0});var Hl=s(A);L=i(Hl,"A",{id:!0,class:!0,href:!0});var dn=s(L);Rt=i(dn,"SPAN",{});var mn=s(Rt);d(Re.$$.fragment,mn),mn.forEach(t),dn.forEach(t),xi=u(Hl),Xt=i(Hl,"SPAN",{});var yn=s(Xt);Wi=r(yn,"Inference"),yn.forEach(t),Hl.forEach(t),Nl=u(e),tt=i(e,"P",{});var wn=s(tt);Zi=r(wn,"Once training is complete, we can perform inference:"),wn.forEach(t),jl=u(e),d(Xe.$$.fragment,e),$l=u(e),z=i(e,"P",{});var ql=s(z);Ii=r(ql,`An example model repo obtained using this training script can be found
here - `),ke=i(ql,"A",{href:!0,rel:!0});var _n=s(ke);Ci=r(_n,"sayakpaul/instruct-pix2pix"),_n.forEach(t),Ni=r(ql,"."),ql.forEach(t),Rl=u(e),lt=i(e,"P",{});var Mn=s(lt);ji=r(Mn,`We encourage you to play with the following three parameters to control
speed and quality during performance:`),Mn.forEach(t),Xl=u(e),Z=i(e,"UL",{});var it=s(Z);kt=i(it,"LI",{});var Jn=s(kt);At=i(Jn,"CODE",{});var gn=s(At);$i=r(gn,"num_inference_steps"),gn.forEach(t),Jn.forEach(t),Ri=u(it),St=i(it,"LI",{});var bn=s(St);Bt=i(bn,"CODE",{});var Tn=s(Bt);Xi=r(Tn,"image_guidance_scale"),Tn.forEach(t),bn.forEach(t),ki=u(it),Yt=i(it,"LI",{});var vn=s(Yt);Gt=i(vn,"CODE",{});var Un=s(Gt);Ai=r(Un,"guidance_scale"),Un.forEach(t),vn.forEach(t),it.forEach(t),kl=u(e),v=i(e,"P",{});var te=s(v);Si=r(te,"Particularly, "),Ft=i(te,"CODE",{});var En=s(Ft);Bi=r(En,"image_guidance_scale"),En.forEach(t),Yi=r(te," and "),Dt=i(te,"CODE",{});var xn=s(Dt);Gi=r(xn,"guidance_scale"),xn.forEach(t),Fi=r(te,` can have a profound impact
on the generated (\u201Cedited\u201D) image (see `),Ae=i(te,"A",{href:!0,rel:!0});var Wn=s(Ae);Di=r(Wn,"here"),Wn.forEach(t),Vi=r(te," for an example)."),te.forEach(t),Al=u(e),H=i(e,"P",{});var Ol=s(H);Pi=r(Ol,"If you\u2019re looking for some interesting ways to use the InstructPix2Pix training methodology, we welcome you to check out this blog post: "),Se=i(Ol,"A",{href:!0,rel:!0});var Zn=s(Se);Qi=r(Zn,"Instruction-tuning Stable Diffusion with InstructPix2Pix"),Zn.forEach(t),Li=r(Ol,"."),Ol.forEach(t),Sl=u(e),S=i(e,"H2",{class:!0});var Kl=s(S);q=i(Kl,"A",{id:!0,class:!0,href:!0});var In=s(q);Vt=i(In,"SPAN",{});var Cn=s(Vt);d(Be.$$.fragment,Cn),Cn.forEach(t),In.forEach(t),zi=u(Kl),Pt=i(Kl,"SPAN",{});var Nn=s(Pt);Hi=r(Nn,"Stable Diffusion XL"),Nn.forEach(t),Kl.forEach(t),Bl=u(e),U=i(e,"P",{});var le=s(U);qi=r(le,"Training with "),Ye=i(le,"A",{href:!0,rel:!0});var jn=s(Ye);Oi=r(jn,"Stable Diffusion XL"),jn.forEach(t),Ki=r(le," is also supported via the "),Qt=i(le,"CODE",{});var $n=s(Qt);es=r($n,"train_instruct_pix2pix_sdxl.py"),$n.forEach(t),ts=r(le," script. Please refer to the docs "),Ge=i(le,"A",{href:!0,rel:!0});var Rn=s(Ge);ls=r(Rn,"here"),Rn.forEach(t),as=r(le,"."),le.forEach(t),this.h()},h(){c(N,"name","hf:doc:metadata"),c(N,"content",JSON.stringify(Dn)),c(B,"id","instructpix2pix"),c(B,"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"),c(B,"href","#instructpix2pix"),c(j,"class","relative group"),c(se,"href","https://arxiv.org/abs/2211.09800"),c(se,"rel","nofollow"),Xn(re.src,rs="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/evaluation_diffusion_models/edit-instruction.png")||c(re,"src",rs),c(re,"alt","instructpix2pix-inputs"),c(re,"width","600"),c(ne,"align","center"),Xn(pe.src,os="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/output-gs%407-igs%401-steps%4050.png")||c(pe,"src",os),c(pe,"alt","instructpix2pix-output"),c(pe,"width","600"),c(oe,"align","center"),c(ce,"href","https://github.com/huggingface/diffusers/blob/main/examples/instruct_pix2pix/train_instruct_pix2pix.py"),c(ce,"rel","nofollow"),c(fe,"href","https://github.com/timothybrooks/instruct-pix2pix"),c(fe,"rel","nofollow"),c(ue,"href","https://huggingface.co/datasets/fusing/instructpix2pix-1000-samples"),c(ue,"rel","nofollow"),c(he,"href","https://huggingface.co/datasets/timbrooks/instructpix2pix-clip-filtered"),c(he,"rel","nofollow"),c(Y,"id","running-locally-with-pytorch"),c(Y,"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"),c(Y,"href","#running-locally-with-pytorch"),c($,"class","relative group"),c(G,"id","installing-the-dependencies"),c(G,"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"),c(G,"href","#installing-the-dependencies"),c(R,"class","relative group"),c(Me,"href","https://github.com/huggingface/accelerate/"),c(Me,"rel","nofollow"),c(V,"id","toy-example"),c(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"),c(V,"href","#toy-example"),c(X,"class","relative group"),c(ve,"href","https://huggingface.co/datasets/fusing/instructpix2pix-1000-samples"),c(ve,"rel","nofollow"),c(Ue,"href","https://huggingface.co/datasets/timbrooks/instructpix2pix-clip-filtered"),c(Ue,"rel","nofollow"),c(Ke,"href","create_dataset"),c(Ee,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),c(Ee,"rel","nofollow"),c(Ce,"href","https://wandb.ai/sayakpaul/instruct-pix2pix/runs/ctr3kovq"),c(Ce,"rel","nofollow"),c(Q,"id","training-with-multiple-gpus"),c(Q,"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"),c(Q,"href","#training-with-multiple-gpus"),c(k,"class","relative group"),c(je,"href","https://huggingface.co/docs/accelerate/basic_tutorials/launch"),c(je,"rel","nofollow"),c(L,"id","inference"),c(L,"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"),c(L,"href","#inference"),c(A,"class","relative group"),c(ke,"href","https://huggingface.co/sayakpaul/instruct-pix2pix"),c(ke,"rel","nofollow"),c(Ae,"href","https://twitter.com/RisingSayak/status/1628392199196151808?s=20"),c(Ae,"rel","nofollow"),c(Se,"href","https://huggingface.co/blog/instruction-tuning-sd"),c(Se,"rel","nofollow"),c(q,"id","stable-diffusion-xl"),c(q,"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"),c(q,"href","#stable-diffusion-xl"),c(S,"class","relative group"),c(Ye,"href","https://huggingface.co/papers/2307.01952"),c(Ye,"rel","nofollow"),c(Ge,"href","https://github.com/huggingface/diffusers/blob/main/examples/instruct_pix2pix/README_sdxl.md"),c(Ge,"rel","nofollow")},m(e,o){l(document.head,N),p(e,Lt,o),p(e,j,o),l(j,B),l(B,st),m(ae,st,null),l(j,ea),l(j,nt),l(nt,ta),p(e,zt,o),p(e,ie,o),l(ie,se),l(se,la),l(ie,aa),p(e,Ht,o),p(e,ne,o),l(ne,re),p(e,qt,o),p(e,Ve,o),l(Ve,ia),p(e,Ot,o),p(e,oe,o),l(oe,pe),p(e,Kt,o),p(e,W,o),l(W,sa),l(W,rt),l(rt,na),l(W,ra),l(W,ce),l(ce,oa),l(W,pa),p(e,el,o),p(e,Pe,o),l(Pe,ot),l(ot,J),l(J,ca),l(J,pt),l(pt,fa),l(J,ua),l(J,fe),l(fe,ha),l(J,da),l(J,ue),l(ue,ma),l(J,ya),l(J,he),l(he,wa),l(J,_a),p(e,tl,o),p(e,$,o),l($,Y),l(Y,ct),m(de,ct,null),l($,Ma),l($,ft),l(ft,Ja),p(e,ll,o),p(e,R,o),l(R,G),l(G,ut),m(me,ut,null),l(R,ga),l(R,ht),l(ht,ba),p(e,al,o),p(e,Qe,o),l(Qe,Ta),p(e,il,o),p(e,Le,o),l(Le,dt),l(dt,va),p(e,sl,o),p(e,F,o),l(F,Ua),l(F,mt),l(mt,Ea),l(F,xa),p(e,nl,o),m(ye,e,o),p(e,rl,o),p(e,ze,o),l(ze,Wa),p(e,ol,o),m(we,e,o),p(e,pl,o),p(e,He,o),l(He,Za),p(e,cl,o),m(_e,e,o),p(e,fl,o),p(e,D,o),l(D,Ia),l(D,Me),l(Me,Ca),l(D,Na),p(e,ul,o),m(Je,e,o),p(e,hl,o),p(e,qe,o),l(qe,ja),p(e,dl,o),m(ge,e,o),p(e,ml,o),p(e,Oe,o),l(Oe,$a),p(e,yl,o),m(be,e,o),p(e,wl,o),p(e,X,o),l(X,V),l(V,yt),m(Te,yt,null),l(X,Ra),l(X,wt),l(wt,Xa),p(e,_l,o),p(e,g,o),l(g,ka),l(g,ve),l(ve,Aa),l(g,Sa),l(g,Ue),l(Ue,Ba),l(g,Ya),l(g,Ke),l(Ke,Ga),l(g,Fa),p(e,Ml,o),p(e,b,o),l(b,Da),l(b,_t),l(_t,Va),l(b,Pa),l(b,Ee),l(Ee,Mt),l(Mt,Qa),l(b,La),l(b,Jt),l(Jt,za),l(b,Ha),p(e,Jl,o),m(xe,e,o),p(e,gl,o),p(e,M,o),l(M,qa),l(M,gt),l(gt,Oa),l(M,Ka),l(M,bt),l(bt,ei),l(M,ti),l(M,Tt),l(Tt,li),l(M,ai),l(M,vt),l(vt,ii),l(M,si),p(e,bl,o),m(We,e,o),p(e,Tl,o),p(e,P,o),l(P,ni),l(P,Ut),l(Ut,ri),l(P,oi),p(e,vl,o),m(Ze,e,o),p(e,Ul,o),p(e,T,o),l(T,pi),l(T,Et),l(Et,ci),l(T,fi),l(T,xt),l(xt,ui),l(T,hi),l(T,Wt),l(Wt,di),l(T,mi),p(e,El,o),p(e,Ie,o),l(Ie,Ce),l(Ce,yi),l(Ie,wi),p(e,xl,o),p(e,et,o),l(et,Zt),l(Zt,It),l(It,_i),p(e,Wl,o),p(e,k,o),l(k,Q),l(Q,Ct),m(Ne,Ct,null),l(k,Mi),l(k,Nt),l(Nt,Ji),p(e,Zl,o),p(e,E,o),l(E,jt),l(jt,gi),l(E,bi),l(E,je),l(je,Ti),l(E,vi),l(E,$t),l($t,Ui),l(E,Ei),p(e,Il,o),m($e,e,o),p(e,Cl,o),p(e,A,o),l(A,L),l(L,Rt),m(Re,Rt,null),l(A,xi),l(A,Xt),l(Xt,Wi),p(e,Nl,o),p(e,tt,o),l(tt,Zi),p(e,jl,o),m(Xe,e,o),p(e,$l,o),p(e,z,o),l(z,Ii),l(z,ke),l(ke,Ci),l(z,Ni),p(e,Rl,o),p(e,lt,o),l(lt,ji),p(e,Xl,o),p(e,Z,o),l(Z,kt),l(kt,At),l(At,$i),l(Z,Ri),l(Z,St),l(St,Bt),l(Bt,Xi),l(Z,ki),l(Z,Yt),l(Yt,Gt),l(Gt,Ai),p(e,kl,o),p(e,v,o),l(v,Si),l(v,Ft),l(Ft,Bi),l(v,Yi),l(v,Dt),l(Dt,Gi),l(v,Fi),l(v,Ae),l(Ae,Di),l(v,Vi),p(e,Al,o),p(e,H,o),l(H,Pi),l(H,Se),l(Se,Qi),l(H,Li),p(e,Sl,o),p(e,S,o),l(S,q),l(q,Vt),m(Be,Vt,null),l(S,zi),l(S,Pt),l(Pt,Hi),p(e,Bl,o),p(e,U,o),l(U,qi),l(U,Ye),l(Ye,Oi),l(U,Ki),l(U,Qt),l(Qt,es),l(U,ts),l(U,Ge),l(Ge,ls),l(U,as),Yl=!0},p:Yn,i(e){Yl||(y(ae.$$.fragment,e),y(de.$$.fragment,e),y(me.$$.fragment,e),y(ye.$$.fragment,e),y(we.$$.fragment,e),y(_e.$$.fragment,e),y(Je.$$.fragment,e),y(ge.$$.fragment,e),y(be.$$.fragment,e),y(Te.$$.fragment,e),y(xe.$$.fragment,e),y(We.$$.fragment,e),y(Ze.$$.fragment,e),y(Ne.$$.fragment,e),y($e.$$.fragment,e),y(Re.$$.fragment,e),y(Xe.$$.fragment,e),y(Be.$$.fragment,e),Yl=!0)},o(e){w(ae.$$.fragment,e),w(de.$$.fragment,e),w(me.$$.fragment,e),w(ye.$$.fragment,e),w(we.$$.fragment,e),w(_e.$$.fragment,e),w(Je.$$.fragment,e),w(ge.$$.fragment,e),w(be.$$.fragment,e),w(Te.$$.fragment,e),w(xe.$$.fragment,e),w(We.$$.fragment,e),w(Ze.$$.fragment,e),w(Ne.$$.fragment,e),w($e.$$.fragment,e),w(Re.$$.fragment,e),w(Xe.$$.fragment,e),w(Be.$$.fragment,e),Yl=!1},d(e){t(N),e&&t(Lt),e&&t(j),_(ae),e&&t(zt),e&&t(ie),e&&t(Ht),e&&t(ne),e&&t(qt),e&&t(Ve),e&&t(Ot),e&&t(oe),e&&t(Kt),e&&t(W),e&&t(el),e&&t(Pe),e&&t(tl),e&&t($),_(de),e&&t(ll),e&&t(R),_(me),e&&t(al),e&&t(Qe),e&&t(il),e&&t(Le),e&&t(sl),e&&t(F),e&&t(nl),_(ye,e),e&&t(rl),e&&t(ze),e&&t(ol),_(we,e),e&&t(pl),e&&t(He),e&&t(cl),_(_e,e),e&&t(fl),e&&t(D),e&&t(ul),_(Je,e),e&&t(hl),e&&t(qe),e&&t(dl),_(ge,e),e&&t(ml),e&&t(Oe),e&&t(yl),_(be,e),e&&t(wl),e&&t(X),_(Te),e&&t(_l),e&&t(g),e&&t(Ml),e&&t(b),e&&t(Jl),_(xe,e),e&&t(gl),e&&t(M),e&&t(bl),_(We,e),e&&t(Tl),e&&t(P),e&&t(vl),_(Ze,e),e&&t(Ul),e&&t(T),e&&t(El),e&&t(Ie),e&&t(xl),e&&t(et),e&&t(Wl),e&&t(k),_(Ne),e&&t(Zl),e&&t(E),e&&t(Il),_($e,e),e&&t(Cl),e&&t(A),_(Re),e&&t(Nl),e&&t(tt),e&&t(jl),_(Xe,e),e&&t($l),e&&t(z),e&&t(Rl),e&&t(lt),e&&t(Xl),e&&t(Z),e&&t(kl),e&&t(v),e&&t(Al),e&&t(H),e&&t(Sl),e&&t(S),_(Be),e&&t(Bl),e&&t(U)}}}const Dn={local:"instructpix2pix",sections:[{local:"running-locally-with-pytorch",sections:[{local:"installing-the-dependencies",title:"Installing the dependencies"},{local:"toy-example",title:"Toy example"}],title:"Running locally with PyTorch"},{local:"stable-diffusion-xl",title:"Stable Diffusion XL"}],title:"InstructPix2Pix "};function Vn(ns){return Gn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zn extends kn{constructor(N){super();An(this,N,Vn,Fn,Sn,{})}}export{zn as default,Dn as metadata};
