import{S as Bn,i as kn,s as Sn,e as a,k as f,w as h,t as n,M as An,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 Vn(ns){let N,zt,j,A,st,ae,ea,nt,ta,Lt,ie,se,la,aa,Ht,ne,re,rs,qt,Fe,ia,Ot,oe,pe,os,Kt,W,sa,rt,na,ra,ce,oa,pa,el,Pe,ot,g,ca,pt,fa,ua,fe,ha,da,ue,ma,ya,he,wa,_a,tl,$,Y,ct,de,Ma,ft,ga,ll,R,G,ut,me,Ja,ht,Ua,al,Qe,ba,il,ze,dt,Ta,sl,V,va,mt,Ea,xa,nl,ye,rl,Le,Wa,ol,we,pl,He,Za,cl,_e,fl,D,Ia,Me,Ca,Na,ul,ge,hl,qe,ja,dl,Je,ml,Oe,$a,yl,Ue,wl,X,F,yt,be,Ra,wt,Xa,_l,J,Ba,Te,ka,Sa,ve,Aa,Ya,Ke,Ga,Va,Ml,U,Da,_t,Fa,Pa,Ee,Mt,Qa,za,gt,La,Ha,gl,xe,Jl,M,qa,Jt,Oa,Ka,Ut,ei,ti,bt,li,ai,Tt,ii,si,Ul,We,bl,P,ni,vt,ri,oi,Tl,Ze,vl,b,pi,Et,ci,fi,xt,ui,hi,Wt,di,mi,El,Ie,Ce,yi,wi,xl,et,Zt,It,_i,Wl,B,Q,Ct,Ne,Mi,Nt,gi,Zl,E,jt,Ji,Ui,je,bi,Ti,$t,vi,Ei,Il,$e,Cl,k,z,Rt,Re,xi,Xt,Wi,Nl,tt,Zi,jl,Xe,$l,L,Ii,Be,Ci,Ni,Rl,lt,ji,Xl,Z,Bt,kt,$i,Ri,St,At,Xi,Bi,Yt,Gt,ki,Bl,T,Si,Vt,Ai,Yi,Dt,Gi,Vi,ke,Di,Fi,kl,H,Pi,Se,Qi,zi,Sl,S,q,Ft,Ae,Li,Pt,Hi,Al,v,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"}}),ge=new x({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),Je=new x({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),Ue=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()`}}),be=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:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25JbnN0cnVjdFBpeDJQaXhQaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyeW91cl9tb2RlbF9pZCUyMiUyMCUyMCUyMyUyMCUzQy0lMjByZXBsYWNlJTIwdGhpcyUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnN0cnVjdFBpeDJQaXhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwbW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRnNheWFrcGF1bCUyRnNhbXBsZS1kYXRhc2V0cyUyRnJlc29sdmUlMkZtYWluJTJGdGVzdF9waXgycGl4XzQucG5nJTIyJTBBJTBBJTBBZGVmJTIwZG93bmxvYWRfaW1hZ2UodXJsKSUzQSUwQSUyMCUyMCUyMGltYWdlJTIwJTNEJTIwUElMLkltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMjAlMjAlMjBpbWFnZSUyMCUzRCUyMFBJTC5JbWFnZU9wcy5leGlmX3RyYW5zcG9zZShpbWFnZSklMEElMjAlMjAlMjBpbWFnZSUyMCUzRCUyMGltYWdlLmNvbnZlcnQoJTIyUkdCJTIyKSUwQSUyMCUyMCUyMHJldHVybiUyMGltYWdlJTBBJTBBJTBBaW1hZ2UlMjAlM0QlMjBkb3dubG9hZF9pbWFnZSh1cmwpJTBBcHJvbXB0JTIwJTNEJTIwJTIyd2lwZSUyMG91dCUyMHRoZSUyMGxha2UlMjIlMEFudW1faW5mZXJlbmNlX3N0ZXBzJTIwJTNEJTIwMjAlMEFpbWFnZV9ndWlkYW5jZV9zY2FsZSUyMCUzRCUyMDEuNSUwQWd1aWRhbmNlX3NjYWxlJTIwJTNEJTIwMTAlMEElMEFlZGl0ZWRfaW1hZ2UlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMHByb21wdCUyQyUwQSUyMCUyMCUyMGltYWdlJTNEaW1hZ2UlMkMlMEElMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEbnVtX2luZmVyZW5jZV9zdGVwcyUyQyUwQSUyMCUyMCUyMGltYWdlX2d1aWRhbmNlX3NjYWxlJTNEaW1hZ2VfZ3VpZGFuY2Vfc2NhbGUlMkMlMEElMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRGd1aWRhbmNlX3NjYWxlJTJDJTBBJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBKS5pbWFnZXMlNUIwJTVEJTBBZWRpdGVkX2ltYWdlLnNhdmUoJTIyZWRpdGVkX2ltYWdlLnBuZyUyMik=",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, use_safetensors=<span class="hljs-literal">True</span>
).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>)`}}),Ae=new De({}),{c(){N=a("meta"),zt=f(),j=a("h1"),A=a("a"),st=a("span"),h(ae.$$.fragment),ea=f(),nt=a("span"),ta=n("InstructPix2Pix"),Lt=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(),Fe=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"),g=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"),ga=n("Running locally with PyTorch"),ll=f(),R=a("h3"),G=a("a"),ut=a("span"),h(me.$$.fragment),Ja=f(),ht=a("span"),Ua=n("Installing the dependencies"),al=f(),Qe=a("p"),ba=n("Before running the scripts, make sure to install the library\u2019s training dependencies:"),il=f(),ze=a("p"),dt=a("strong"),Ta=n("Important"),sl=f(),V=a("p"),va=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(),Le=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(ge.$$.fragment),hl=f(),qe=a("p"),ja=n("Or for a default accelerate configuration without answering questions about your environment"),dl=f(),h(Je.$$.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(Ue.$$.fragment),wl=f(),X=a("h3"),F=a("a"),yt=a("span"),h(be.$$.fragment),Ra=f(),wt=a("span"),Xa=n("Toy example"),_l=f(),J=a("p"),Ba=n("As mentioned before, we\u2019ll use a "),Te=a("a"),ka=n("small toy dataset"),Sa=n(` for training. The dataset
is a smaller version of the `),ve=a("a"),Aa=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"),Va=n(" guide."),Ml=f(),U=a("p"),Da=n("Specify the "),_t=a("code"),Fa=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"),za=n(" argument. You\u2019ll also need to specify the dataset name in "),gt=a("code"),La=n("DATASET_ID"),Ha=n(":"),gl=f(),h(xe.$$.fragment),Jl=f(),M=a("p"),qa=n("Now, we can launch training. The script saves all the components ("),Jt=a("code"),Oa=n("feature_extractor"),Ka=n(", "),Ut=a("code"),ei=n("scheduler"),ti=n(", "),bt=a("code"),li=n("text_encoder"),ai=n(", "),Tt=a("code"),ii=n("unet"),si=n(", etc) in a subfolder in your repository."),Ul=f(),h(We.$$.fragment),bl=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 `),vt=a("code"),ri=n('report_to="wandb"'),oi=n(":"),Tl=f(),h(Ze.$$.fragment),vl=f(),b=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(),B=a("h2"),Q=a("a"),Ct=a("span"),h(Ne.$$.fragment),Mi=f(),Nt=a("span"),gi=n("Training with multiple GPUs"),Zl=f(),E=a("p"),jt=a("code"),Ji=n("accelerate"),Ui=n(" allows for seamless multi-GPU training. Follow the instructions "),je=a("a"),bi=n("here"),Ti=n(`
for running distributed training with `),$t=a("code"),vi=n("accelerate"),Ei=n(". Here is an example command:"),Il=f(),h($e.$$.fragment),Cl=f(),k=a("h2"),z=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(),L=a("p"),Ii=n(`An example model repo obtained using this training script can be found
here - `),Be=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"),Bt=a("li"),kt=a("code"),$i=n("num_inference_steps"),Ri=f(),St=a("li"),At=a("code"),Xi=n("image_guidance_scale"),Bi=f(),Yt=a("li"),Gt=a("code"),ki=n("guidance_scale"),Bl=f(),T=a("p"),Si=n("Particularly, "),Vt=a("code"),Ai=n("image_guidance_scale"),Yi=n(" and "),Dt=a("code"),Gi=n("guidance_scale"),Vi=n(` can have a profound impact
on the generated (\u201Cedited\u201D) image (see `),ke=a("a"),Di=n("here"),Fi=n(" for an example)."),kl=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"),zi=n("."),Sl=f(),S=a("h2"),q=a("a"),Ft=a("span"),h(Ae.$$.fragment),Li=f(),Pt=a("span"),Hi=n("Stable Diffusion XL"),Al=f(),v=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=An('[data-svelte="svelte-1phssyn"]',document.head);N=i(o,"META",{name:!0,content:!0}),o.forEach(t),zt=u(e),j=i(e,"H1",{class:!0});var Gl=s(j);A=i(Gl,"A",{id:!0,class:!0,href:!0});var ps=s(A);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),Lt=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),Fe=i(e,"P",{});var ds=s(Fe);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);g=i(Ms,"EM",{});var I=s(g);ca=r(I,"Disclaimer: Even though "),pt=i(I,"CODE",{});var gs=s(pt);fa=r(gs,"train_instruct_pix2pix.py"),gs.forEach(t),ua=r(I,` implements the InstructPix2Pix
training procedure while being faithful to the `),fe=i(I,"A",{href:!0,rel:!0});var Js=s(fe);ha=r(Js,"original implementation"),Js.forEach(t),da=r(I," we have only tested it on a "),ue=i(I,"A",{href:!0,rel:!0});var Us=s(ue);ma=r(Us,"small-scale dataset"),Us.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 bs=s(he);wa=r(bs,"Here"),bs.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 Vl=s($);Y=i(Vl,"A",{id:!0,class:!0,href:!0});var Ts=s(Y);ct=i(Ts,"SPAN",{});var vs=s(ct);d(de.$$.fragment,vs),vs.forEach(t),Ts.forEach(t),Ma=u(Vl),ft=i(Vl,"SPAN",{});var Es=s(ft);ga=r(Es,"Running locally with PyTorch"),Es.forEach(t),Vl.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),Ja=u(Dl),ht=i(Dl,"SPAN",{});var Zs=s(ht);Ua=r(Zs,"Installing the dependencies"),Zs.forEach(t),Dl.forEach(t),al=u(e),Qe=i(e,"P",{});var Is=s(Qe);ba=r(Is,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),Is.forEach(t),il=u(e),ze=i(e,"P",{});var Cs=s(ze);dt=i(Cs,"STRONG",{});var Ns=s(dt);Ta=r(Ns,"Important"),Ns.forEach(t),Cs.forEach(t),sl=u(e),V=i(e,"P",{});var Fl=s(V);va=r(Fl,"To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),mt=i(Fl,"STRONG",{});var js=s(mt);Ea=r(js,"installing from source"),js.forEach(t),xa=r(Fl," 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:"),Fl.forEach(t),nl=u(e),d(ye.$$.fragment,e),rl=u(e),Le=i(e,"P",{});var $s=s(Le);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(ge.$$.fragment,e),hl=u(e),qe=i(e,"P",{});var Bs=s(qe);ja=r(Bs,"Or for a default accelerate configuration without answering questions about your environment"),Bs.forEach(t),dl=u(e),d(Je.$$.fragment,e),ml=u(e),Oe=i(e,"P",{});var ks=s(Oe);$a=r(ks,"Or if your environment doesn\u2019t support an interactive shell e.g. a notebook"),ks.forEach(t),yl=u(e),d(Ue.$$.fragment,e),wl=u(e),X=i(e,"H3",{class:!0});var Ql=s(X);F=i(Ql,"A",{id:!0,class:!0,href:!0});var Ss=s(F);yt=i(Ss,"SPAN",{});var As=s(yt);d(be.$$.fragment,As),As.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),J=i(e,"P",{});var O=s(J);Ba=r(O,"As mentioned before, we\u2019ll use a "),Te=i(O,"A",{href:!0,rel:!0});var Gs=s(Te);ka=r(Gs,"small toy dataset"),Gs.forEach(t),Sa=r(O,` for training. The dataset
is a smaller version of the `),ve=i(O,"A",{href:!0,rel:!0});var Vs=s(ve);Aa=r(Vs,"original dataset"),Vs.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),Va=r(O," guide."),O.forEach(t),Ml=u(e),U=i(e,"P",{});var K=s(U);Da=r(K,"Specify the "),_t=i(K,"CODE",{});var Fs=s(_t);Fa=r(Fs,"MODEL_NAME"),Fs.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),za=r(K," argument. You\u2019ll also need to specify the dataset name in "),gt=i(K,"CODE",{});var zs=s(gt);La=r(zs,"DATASET_ID"),zs.forEach(t),Ha=r(K,":"),K.forEach(t),gl=u(e),d(xe.$$.fragment,e),Jl=u(e),M=i(e,"P",{});var C=s(M);qa=r(C,"Now, we can launch training. The script saves all the components ("),Jt=i(C,"CODE",{});var Ls=s(Jt);Oa=r(Ls,"feature_extractor"),Ls.forEach(t),Ka=r(C,", "),Ut=i(C,"CODE",{});var Hs=s(Ut);ei=r(Hs,"scheduler"),Hs.forEach(t),ti=r(C,", "),bt=i(C,"CODE",{});var qs=s(bt);li=r(qs,"text_encoder"),qs.forEach(t),ai=r(C,", "),Tt=i(C,"CODE",{});var Os=s(Tt);ii=r(Os,"unet"),Os.forEach(t),si=r(C,", etc) in a subfolder in your repository."),C.forEach(t),Ul=u(e),d(We.$$.fragment,e),bl=u(e),P=i(e,"P",{});var zl=s(P);ni=r(zl,`Additionally, we support performing validation inference to monitor training progress
with Weights and Biases. You can enable this feature with `),vt=i(zl,"CODE",{});var Ks=s(vt);ri=r(Ks,'report_to="wandb"'),Ks.forEach(t),oi=r(zl,":"),zl.forEach(t),Tl=u(e),d(Ze.$$.fragment,e),vl=u(e),b=i(e,"P",{});var ee=s(b);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),B=i(e,"H2",{class:!0});var Ll=s(B);Q=i(Ll,"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(Ll),Nt=i(Ll,"SPAN",{});var cn=s(Nt);gi=r(cn,"Training with multiple GPUs"),cn.forEach(t),Ll.forEach(t),Zl=u(e),E=i(e,"P",{});var Ve=s(E);jt=i(Ve,"CODE",{});var fn=s(jt);Ji=r(fn,"accelerate"),fn.forEach(t),Ui=r(Ve," allows for seamless multi-GPU training. Follow the instructions "),je=i(Ve,"A",{href:!0,rel:!0});var un=s(je);bi=r(un,"here"),un.forEach(t),Ti=r(Ve,`
for running distributed training with `),$t=i(Ve,"CODE",{});var hn=s($t);vi=r(hn,"accelerate"),hn.forEach(t),Ei=r(Ve,". Here is an example command:"),Ve.forEach(t),Il=u(e),d($e.$$.fragment,e),Cl=u(e),k=i(e,"H2",{class:!0});var Hl=s(k);z=i(Hl,"A",{id:!0,class:!0,href:!0});var dn=s(z);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),L=i(e,"P",{});var ql=s(L);Ii=r(ql,`An example model repo obtained using this training script can be found
here - `),Be=i(ql,"A",{href:!0,rel:!0});var _n=s(Be);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);Bt=i(it,"LI",{});var gn=s(Bt);kt=i(gn,"CODE",{});var Jn=s(kt);$i=r(Jn,"num_inference_steps"),Jn.forEach(t),gn.forEach(t),Ri=u(it),St=i(it,"LI",{});var Un=s(St);At=i(Un,"CODE",{});var bn=s(At);Xi=r(bn,"image_guidance_scale"),bn.forEach(t),Un.forEach(t),Bi=u(it),Yt=i(it,"LI",{});var Tn=s(Yt);Gt=i(Tn,"CODE",{});var vn=s(Gt);ki=r(vn,"guidance_scale"),vn.forEach(t),Tn.forEach(t),it.forEach(t),Bl=u(e),T=i(e,"P",{});var te=s(T);Si=r(te,"Particularly, "),Vt=i(te,"CODE",{});var En=s(Vt);Ai=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),Vi=r(te,` can have a profound impact
on the generated (\u201Cedited\u201D) image (see `),ke=i(te,"A",{href:!0,rel:!0});var Wn=s(ke);Di=r(Wn,"here"),Wn.forEach(t),Fi=r(te," for an example)."),te.forEach(t),kl=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),zi=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);Ft=i(In,"SPAN",{});var Cn=s(Ft);d(Ae.$$.fragment,Cn),Cn.forEach(t),In.forEach(t),Li=u(Kl),Pt=i(Kl,"SPAN",{});var Nn=s(Pt);Hi=r(Nn,"Stable Diffusion XL"),Nn.forEach(t),Kl.forEach(t),Al=u(e),v=i(e,"P",{});var le=s(v);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(A,"id","instructpix2pix"),c(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"),c(A,"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(F,"id","toy-example"),c(F,"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(F,"href","#toy-example"),c(X,"class","relative group"),c(Te,"href","https://huggingface.co/datasets/fusing/instructpix2pix-1000-samples"),c(Te,"rel","nofollow"),c(ve,"href","https://huggingface.co/datasets/timbrooks/instructpix2pix-clip-filtered"),c(ve,"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(B,"class","relative group"),c(je,"href","https://huggingface.co/docs/accelerate/basic_tutorials/launch"),c(je,"rel","nofollow"),c(z,"id","inference"),c(z,"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(z,"href","#inference"),c(k,"class","relative group"),c(Be,"href","https://huggingface.co/sayakpaul/instruct-pix2pix"),c(Be,"rel","nofollow"),c(ke,"href","https://twitter.com/RisingSayak/status/1628392199196151808?s=20"),c(ke,"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,zt,o),p(e,j,o),l(j,A),l(A,st),m(ae,st,null),l(j,ea),l(j,nt),l(nt,ta),p(e,Lt,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,Fe,o),l(Fe,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,g),l(g,ca),l(g,pt),l(pt,fa),l(g,ua),l(g,fe),l(fe,ha),l(g,da),l(g,ue),l(ue,ma),l(g,ya),l(g,he),l(he,wa),l(g,_a),p(e,tl,o),p(e,$,o),l($,Y),l(Y,ct),m(de,ct,null),l($,Ma),l($,ft),l(ft,ga),p(e,ll,o),p(e,R,o),l(R,G),l(G,ut),m(me,ut,null),l(R,Ja),l(R,ht),l(ht,Ua),p(e,al,o),p(e,Qe,o),l(Qe,ba),p(e,il,o),p(e,ze,o),l(ze,dt),l(dt,Ta),p(e,sl,o),p(e,V,o),l(V,va),l(V,mt),l(mt,Ea),l(V,xa),p(e,nl,o),m(ye,e,o),p(e,rl,o),p(e,Le,o),l(Le,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(ge,e,o),p(e,hl,o),p(e,qe,o),l(qe,ja),p(e,dl,o),m(Je,e,o),p(e,ml,o),p(e,Oe,o),l(Oe,$a),p(e,yl,o),m(Ue,e,o),p(e,wl,o),p(e,X,o),l(X,F),l(F,yt),m(be,yt,null),l(X,Ra),l(X,wt),l(wt,Xa),p(e,_l,o),p(e,J,o),l(J,Ba),l(J,Te),l(Te,ka),l(J,Sa),l(J,ve),l(ve,Aa),l(J,Ya),l(J,Ke),l(Ke,Ga),l(J,Va),p(e,Ml,o),p(e,U,o),l(U,Da),l(U,_t),l(_t,Fa),l(U,Pa),l(U,Ee),l(Ee,Mt),l(Mt,Qa),l(U,za),l(U,gt),l(gt,La),l(U,Ha),p(e,gl,o),m(xe,e,o),p(e,Jl,o),p(e,M,o),l(M,qa),l(M,Jt),l(Jt,Oa),l(M,Ka),l(M,Ut),l(Ut,ei),l(M,ti),l(M,bt),l(bt,li),l(M,ai),l(M,Tt),l(Tt,ii),l(M,si),p(e,Ul,o),m(We,e,o),p(e,bl,o),p(e,P,o),l(P,ni),l(P,vt),l(vt,ri),l(P,oi),p(e,Tl,o),m(Ze,e,o),p(e,vl,o),p(e,b,o),l(b,pi),l(b,Et),l(Et,ci),l(b,fi),l(b,xt),l(xt,ui),l(b,hi),l(b,Wt),l(Wt,di),l(b,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,B,o),l(B,Q),l(Q,Ct),m(Ne,Ct,null),l(B,Mi),l(B,Nt),l(Nt,gi),p(e,Zl,o),p(e,E,o),l(E,jt),l(jt,Ji),l(E,Ui),l(E,je),l(je,bi),l(E,Ti),l(E,$t),l($t,vi),l(E,Ei),p(e,Il,o),m($e,e,o),p(e,Cl,o),p(e,k,o),l(k,z),l(z,Rt),m(Re,Rt,null),l(k,xi),l(k,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,L,o),l(L,Ii),l(L,Be),l(Be,Ci),l(L,Ni),p(e,Rl,o),p(e,lt,o),l(lt,ji),p(e,Xl,o),p(e,Z,o),l(Z,Bt),l(Bt,kt),l(kt,$i),l(Z,Ri),l(Z,St),l(St,At),l(At,Xi),l(Z,Bi),l(Z,Yt),l(Yt,Gt),l(Gt,ki),p(e,Bl,o),p(e,T,o),l(T,Si),l(T,Vt),l(Vt,Ai),l(T,Yi),l(T,Dt),l(Dt,Gi),l(T,Vi),l(T,ke),l(ke,Di),l(T,Fi),p(e,kl,o),p(e,H,o),l(H,Pi),l(H,Se),l(Se,Qi),l(H,zi),p(e,Sl,o),p(e,S,o),l(S,q),l(q,Ft),m(Ae,Ft,null),l(S,Li),l(S,Pt),l(Pt,Hi),p(e,Al,o),p(e,v,o),l(v,qi),l(v,Ye),l(Ye,Oi),l(v,Ki),l(v,Qt),l(Qt,es),l(v,ts),l(v,Ge),l(Ge,ls),l(v,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(ge.$$.fragment,e),y(Je.$$.fragment,e),y(Ue.$$.fragment,e),y(be.$$.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(Ae.$$.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(ge.$$.fragment,e),w(Je.$$.fragment,e),w(Ue.$$.fragment,e),w(be.$$.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(Ae.$$.fragment,e),Yl=!1},d(e){t(N),e&&t(zt),e&&t(j),_(ae),e&&t(Lt),e&&t(ie),e&&t(Ht),e&&t(ne),e&&t(qt),e&&t(Fe),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(ze),e&&t(sl),e&&t(V),e&&t(nl),_(ye,e),e&&t(rl),e&&t(Le),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),_(ge,e),e&&t(hl),e&&t(qe),e&&t(dl),_(Je,e),e&&t(ml),e&&t(Oe),e&&t(yl),_(Ue,e),e&&t(wl),e&&t(X),_(be),e&&t(_l),e&&t(J),e&&t(Ml),e&&t(U),e&&t(gl),_(xe,e),e&&t(Jl),e&&t(M),e&&t(Ul),_(We,e),e&&t(bl),e&&t(P),e&&t(Tl),_(Ze,e),e&&t(vl),e&&t(b),e&&t(El),e&&t(Ie),e&&t(xl),e&&t(et),e&&t(Wl),e&&t(B),_(Ne),e&&t(Zl),e&&t(E),e&&t(Il),_($e,e),e&&t(Cl),e&&t(k),_(Re),e&&t(Nl),e&&t(tt),e&&t(jl),_(Xe,e),e&&t($l),e&&t(L),e&&t(Rl),e&&t(lt),e&&t(Xl),e&&t(Z),e&&t(Bl),e&&t(T),e&&t(kl),e&&t(H),e&&t(Sl),e&&t(S),_(Ae),e&&t(Al),e&&t(v)}}}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 Fn(ns){return Gn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ln extends Bn{constructor(N){super();kn(this,N,Fn,Vn,Sn,{})}}export{Ln as default,Dn as metadata};
