import{S as qn,i as On,s as Nn,e as i,k as p,w as y,t as s,M as Un,c as a,d as n,m as d,a as o,x as w,h as r,b as l,G as e,g as u,y as I,q as P,o as $,B as S,v as zn,L as Gn}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as re}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as Wn}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as jn}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Vn}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Fn(Ae){let g,M,b,_,x;return _=new Wn({props:{code:`import torch
import requests
from PIL import Image

from diffusers import StableDiffusionDepth2ImgPipeline

pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-depth",
    torch_dtype=torch.float16,
)
pipe.to("cuda")


url = "http://images.cocodataset.org/val2017/000000039769.jpg"
init_image = Image.open(requests.get(url, stream=True).raw)
prompt = "two tigers"
n_propmt = "bad, deformed, ugly, bad anotomy"
image = pipe(prompt=prompt, image=init_image, negative_prompt=n_propmt, strength=0.7).images[0]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionDepth2ImgPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-depth&quot;</span>,
<span class="hljs-meta">... </span>    torch_dtype=torch.float16,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;two tigers&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>n_propmt = <span class="hljs-string">&quot;bad, deformed, ugly, bad anotomy&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt=prompt, image=init_image, negative_prompt=n_propmt, strength=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]`}}),{c(){g=i("p"),M=s("Examples:"),b=p(),y(_.$$.fragment)},l(c){g=a(c,"P",{});var E=o(g);M=r(E,"Examples:"),E.forEach(n),b=d(c),w(_.$$.fragment,c)},m(c,E){u(c,g,E),e(g,M),u(c,b,E),I(_,c,E),x=!0},p:Gn,i(c){x||(P(_.$$.fragment,c),x=!0)},o(c){$(_.$$.fragment,c),x=!1},d(c){c&&n(g),c&&n(b),S(_,c)}}}function Bn(Ae){let g,M,b,_,x,c,E,ge,Ye,Me,L,j,_e,G,Ze,be,et,je,v,tt,W,nt,it,V,at,ot,F,st,rt,B,lt,pt,qe,A,le,dt,ft,ve,ct,mt,Oe,pe,ut,Ne,de,K,De,ht,gt,H,_t,Ue,fe,bt,ze,ce,J,ye,vt,Dt,R,yt,Ge,m,Q,wt,we,It,Pt,X,$t,me,St,xt,Et,k,Y,kt,Ie,Tt,Ct,q,Lt,T,Z,At,Pe,Mt,jt,$e,qt,Ot,O,ee,Nt,te,Ut,Se,zt,Gt,Wt,D,ne,Vt,xe,Ft,Bt,Ee,Kt,Ht,ke,Jt,Rt,N,ie,Qt,Te,Xt,Yt,U,ae,Zt,oe,en,Ce,tn,nn,We;return c=new jn({}),G=new jn({}),Q=new re({props:{name:"class diffusers.StableDiffusionDepth2ImgPipeline",anchor:"diffusers.StableDiffusionDepth2ImgPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"depth_estimator",val:": DPTForDepthEstimation"},{name:"feature_extractor",val:": DPTFeatureExtractor"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L58"}}),Y=new re({props:{name:"__call__",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image]"},{name:"depth_map",val:": typing.Optional[torch.FloatTensor] = None"},{name:"strength",val:": float = 0.8"},{name:"num_inference_steps",val:": typing.Optional[int] = 50"},{name:"guidance_scale",val:": typing.Optional[float] = 7.5"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": typing.Optional[float] = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": typing.Optional[int] = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch, that will be used as the starting point for the
process.`,name:"image"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.strength",description:`<strong>strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Conceptually, indicates how much to transform the reference <code>image</code>. Must be between 0 and 1. <code>image</code>
will be used as a starting point, adding more noise to it the larger the <code>strength</code>. The number of
denoising steps depends on the amount of noise initially added. When <code>strength</code> is 1, added noise will
be maximum and the denoising process will run for the full number of iterations specified in
<code>num_inference_steps</code>. A value of 1, therefore, essentially ignores <code>image</code>.`,name:"strength"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference. This parameter will be modulated by <code>strength</code>.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
if <code>guidance_scale</code> is less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that will be called every <code>callback_steps</code> steps during inference. The function will be
called with the following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L424",returnDescription:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),q=new Vn({props:{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.example",$$slots:{default:[Fn]},$$scope:{ctx:Ae}}}),Z=new re({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_attention_slicing.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, halves the input to the attention heads, so attention will be computed in two steps. If
<code>&quot;max&quot;</code>, maxium amount of memory will be saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L876"}}),ee=new re({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L892"}}),ne=new re({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L841"}}),ie=new re({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L853"}}),ae=new re({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L125"}}),{c(){g=i("meta"),M=p(),b=i("h1"),_=i("a"),x=i("span"),y(c.$$.fragment),E=p(),ge=i("span"),Ye=s("Depth-to-Image Generation"),Me=p(),L=i("h2"),j=i("a"),_e=i("span"),y(G.$$.fragment),Ze=p(),be=i("span"),et=s("StableDiffusionDepth2ImgPipeline"),je=p(),v=i("p"),tt=s("The depth-guided stable diffusion model was created by the researchers and engineers from "),W=i("a"),nt=s("CompVis"),it=s(", "),V=i("a"),at=s("Stability AI"),ot=s(", and "),F=i("a"),st=s("LAION"),rt=s(", as part of Stable Diffusion 2.0. It uses "),B=i("a"),lt=s("MiDas"),pt=s(" to infer depth based on an image."),qe=p(),A=i("p"),le=i("a"),dt=s("StableDiffusionDepth2ImgPipeline"),ft=s(" lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),ve=i("code"),ct=s("depth_map"),mt=s(" to preserve the images\u2019 structure."),Oe=p(),pe=i("p"),ut=s("The original codebase can be found here:"),Ne=p(),de=i("ul"),K=i("li"),De=i("em"),ht=s("Stable Diffusion v2"),gt=s(": "),H=i("a"),_t=s("Stability-AI/stablediffusion"),Ue=p(),fe=i("p"),bt=s("Available Checkpoints are:"),ze=p(),ce=i("ul"),J=i("li"),ye=i("em"),vt=s("stable-diffusion-2-depth"),Dt=s(": "),R=i("a"),yt=s("stabilityai/stable-diffusion-2-depth"),Ge=p(),m=i("div"),y(Q.$$.fragment),wt=p(),we=i("p"),It=s("Pipeline for text-guided image to image generation using Stable Diffusion."),Pt=p(),X=i("p"),$t=s("This model inherits from "),me=i("a"),St=s("DiffusionPipeline"),xt=s(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Et=p(),k=i("div"),y(Y.$$.fragment),kt=p(),Ie=i("p"),Tt=s("Function invoked when calling the pipeline for generation."),Ct=p(),y(q.$$.fragment),Lt=p(),T=i("div"),y(Z.$$.fragment),At=p(),Pe=i("p"),Mt=s("Enable sliced attention computation."),jt=p(),$e=i("p"),qt=s(`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),Ot=p(),O=i("div"),y(ee.$$.fragment),Nt=p(),te=i("p"),Ut=s("Disable sliced attention computation. If "),Se=i("code"),zt=s("enable_attention_slicing"),Gt=s(` was previously invoked, this method will go
back to computing attention in one step.`),Wt=p(),D=i("div"),y(ne.$$.fragment),Vt=p(),xe=i("p"),Ft=s("Enable memory efficient attention as implemented in xformers."),Bt=p(),Ee=i("p"),Kt=s(`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Ht=p(),ke=i("p"),Jt=s(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Rt=p(),N=i("div"),y(ie.$$.fragment),Qt=p(),Te=i("p"),Xt=s("Disable memory efficient attention as implemented in xformers."),Yt=p(),U=i("div"),y(ae.$$.fragment),Zt=p(),oe=i("p"),en=s(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Ce=i("code"),tn=s("torch.device('meta') and loaded to GPU only when their specific submodule has its "),nn=s("forward` method called."),this.h()},l(t){const f=Un('[data-svelte="svelte-1phssyn"]',document.head);g=a(f,"META",{name:!0,content:!0}),f.forEach(n),M=d(t),b=a(t,"H1",{class:!0});var se=o(b);_=a(se,"A",{id:!0,class:!0,href:!0});var an=o(_);x=a(an,"SPAN",{});var on=o(x);w(c.$$.fragment,on),on.forEach(n),an.forEach(n),E=d(se),ge=a(se,"SPAN",{});var sn=o(ge);Ye=r(sn,"Depth-to-Image Generation"),sn.forEach(n),se.forEach(n),Me=d(t),L=a(t,"H2",{class:!0});var Ve=o(L);j=a(Ve,"A",{id:!0,class:!0,href:!0});var rn=o(j);_e=a(rn,"SPAN",{});var ln=o(_e);w(G.$$.fragment,ln),ln.forEach(n),rn.forEach(n),Ze=d(Ve),be=a(Ve,"SPAN",{});var pn=o(be);et=r(pn,"StableDiffusionDepth2ImgPipeline"),pn.forEach(n),Ve.forEach(n),je=d(t),v=a(t,"P",{});var C=o(v);tt=r(C,"The depth-guided stable diffusion model was created by the researchers and engineers from "),W=a(C,"A",{href:!0,rel:!0});var dn=o(W);nt=r(dn,"CompVis"),dn.forEach(n),it=r(C,", "),V=a(C,"A",{href:!0,rel:!0});var fn=o(V);at=r(fn,"Stability AI"),fn.forEach(n),ot=r(C,", and "),F=a(C,"A",{href:!0,rel:!0});var cn=o(F);st=r(cn,"LAION"),cn.forEach(n),rt=r(C,", as part of Stable Diffusion 2.0. It uses "),B=a(C,"A",{href:!0,rel:!0});var mn=o(B);lt=r(mn,"MiDas"),mn.forEach(n),pt=r(C," to infer depth based on an image."),C.forEach(n),qe=d(t),A=a(t,"P",{});var Le=o(A);le=a(Le,"A",{href:!0});var un=o(le);dt=r(un,"StableDiffusionDepth2ImgPipeline"),un.forEach(n),ft=r(Le," lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),ve=a(Le,"CODE",{});var hn=o(ve);ct=r(hn,"depth_map"),hn.forEach(n),mt=r(Le," to preserve the images\u2019 structure."),Le.forEach(n),Oe=d(t),pe=a(t,"P",{});var gn=o(pe);ut=r(gn,"The original codebase can be found here:"),gn.forEach(n),Ne=d(t),de=a(t,"UL",{});var _n=o(de);K=a(_n,"LI",{});var Fe=o(K);De=a(Fe,"EM",{});var bn=o(De);ht=r(bn,"Stable Diffusion v2"),bn.forEach(n),gt=r(Fe,": "),H=a(Fe,"A",{href:!0,rel:!0});var vn=o(H);_t=r(vn,"Stability-AI/stablediffusion"),vn.forEach(n),Fe.forEach(n),_n.forEach(n),Ue=d(t),fe=a(t,"P",{});var Dn=o(fe);bt=r(Dn,"Available Checkpoints are:"),Dn.forEach(n),ze=d(t),ce=a(t,"UL",{});var yn=o(ce);J=a(yn,"LI",{});var Be=o(J);ye=a(Be,"EM",{});var wn=o(ye);vt=r(wn,"stable-diffusion-2-depth"),wn.forEach(n),Dt=r(Be,": "),R=a(Be,"A",{href:!0,rel:!0});var In=o(R);yt=r(In,"stabilityai/stable-diffusion-2-depth"),In.forEach(n),Be.forEach(n),yn.forEach(n),Ge=d(t),m=a(t,"DIV",{class:!0});var h=o(m);w(Q.$$.fragment,h),wt=d(h),we=a(h,"P",{});var Pn=o(we);It=r(Pn,"Pipeline for text-guided image to image generation using Stable Diffusion."),Pn.forEach(n),Pt=d(h),X=a(h,"P",{});var Ke=o(X);$t=r(Ke,"This model inherits from "),me=a(Ke,"A",{href:!0});var $n=o(me);St=r($n,"DiffusionPipeline"),$n.forEach(n),xt=r(Ke,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Ke.forEach(n),Et=d(h),k=a(h,"DIV",{class:!0});var ue=o(k);w(Y.$$.fragment,ue),kt=d(ue),Ie=a(ue,"P",{});var Sn=o(Ie);Tt=r(Sn,"Function invoked when calling the pipeline for generation."),Sn.forEach(n),Ct=d(ue),w(q.$$.fragment,ue),ue.forEach(n),Lt=d(h),T=a(h,"DIV",{class:!0});var he=o(T);w(Z.$$.fragment,he),At=d(he),Pe=a(he,"P",{});var xn=o(Pe);Mt=r(xn,"Enable sliced attention computation."),xn.forEach(n),jt=d(he),$e=a(he,"P",{});var En=o($e);qt=r(En,`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),En.forEach(n),he.forEach(n),Ot=d(h),O=a(h,"DIV",{class:!0});var He=o(O);w(ee.$$.fragment,He),Nt=d(He),te=a(He,"P",{});var Je=o(te);Ut=r(Je,"Disable sliced attention computation. If "),Se=a(Je,"CODE",{});var kn=o(Se);zt=r(kn,"enable_attention_slicing"),kn.forEach(n),Gt=r(Je,` was previously invoked, this method will go
back to computing attention in one step.`),Je.forEach(n),He.forEach(n),Wt=d(h),D=a(h,"DIV",{class:!0});var z=o(D);w(ne.$$.fragment,z),Vt=d(z),xe=a(z,"P",{});var Tn=o(xe);Ft=r(Tn,"Enable memory efficient attention as implemented in xformers."),Tn.forEach(n),Bt=d(z),Ee=a(z,"P",{});var Cn=o(Ee);Kt=r(Cn,`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Cn.forEach(n),Ht=d(z),ke=a(z,"P",{});var Ln=o(ke);Jt=r(Ln,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Ln.forEach(n),z.forEach(n),Rt=d(h),N=a(h,"DIV",{class:!0});var Re=o(N);w(ie.$$.fragment,Re),Qt=d(Re),Te=a(Re,"P",{});var An=o(Te);Xt=r(An,"Disable memory efficient attention as implemented in xformers."),An.forEach(n),Re.forEach(n),Yt=d(h),U=a(h,"DIV",{class:!0});var Qe=o(U);w(ae.$$.fragment,Qe),Zt=d(Qe),oe=a(Qe,"P",{});var Xe=o(oe);en=r(Xe,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Ce=a(Xe,"CODE",{});var Mn=o(Ce);tn=r(Mn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Mn.forEach(n),nn=r(Xe,"forward` method called."),Xe.forEach(n),Qe.forEach(n),h.forEach(n),this.h()},h(){l(g,"name","hf:doc:metadata"),l(g,"content",JSON.stringify(Kn)),l(_,"id","depthtoimage-generation"),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"),l(_,"href","#depthtoimage-generation"),l(b,"class","relative group"),l(j,"id","diffusers.StableDiffusionDepth2ImgPipeline"),l(j,"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"),l(j,"href","#diffusers.StableDiffusionDepth2ImgPipeline"),l(L,"class","relative group"),l(W,"href","https://github.com/CompVis"),l(W,"rel","nofollow"),l(V,"href","https://stability.ai/"),l(V,"rel","nofollow"),l(F,"href","https://laion.ai/"),l(F,"rel","nofollow"),l(B,"href","https://github.com/isl-org/MiDaS"),l(B,"rel","nofollow"),l(le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline"),l(H,"href","https://github.com/Stability-AI/stablediffusion#depth-conditional-stable-diffusion"),l(H,"rel","nofollow"),l(R,"href","https://huggingface.co/stabilityai/stable-diffusion-2-depth"),l(R,"rel","nofollow"),l(me,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),l(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,g),u(t,M,f),u(t,b,f),e(b,_),e(_,x),I(c,x,null),e(b,E),e(b,ge),e(ge,Ye),u(t,Me,f),u(t,L,f),e(L,j),e(j,_e),I(G,_e,null),e(L,Ze),e(L,be),e(be,et),u(t,je,f),u(t,v,f),e(v,tt),e(v,W),e(W,nt),e(v,it),e(v,V),e(V,at),e(v,ot),e(v,F),e(F,st),e(v,rt),e(v,B),e(B,lt),e(v,pt),u(t,qe,f),u(t,A,f),e(A,le),e(le,dt),e(A,ft),e(A,ve),e(ve,ct),e(A,mt),u(t,Oe,f),u(t,pe,f),e(pe,ut),u(t,Ne,f),u(t,de,f),e(de,K),e(K,De),e(De,ht),e(K,gt),e(K,H),e(H,_t),u(t,Ue,f),u(t,fe,f),e(fe,bt),u(t,ze,f),u(t,ce,f),e(ce,J),e(J,ye),e(ye,vt),e(J,Dt),e(J,R),e(R,yt),u(t,Ge,f),u(t,m,f),I(Q,m,null),e(m,wt),e(m,we),e(we,It),e(m,Pt),e(m,X),e(X,$t),e(X,me),e(me,St),e(X,xt),e(m,Et),e(m,k),I(Y,k,null),e(k,kt),e(k,Ie),e(Ie,Tt),e(k,Ct),I(q,k,null),e(m,Lt),e(m,T),I(Z,T,null),e(T,At),e(T,Pe),e(Pe,Mt),e(T,jt),e(T,$e),e($e,qt),e(m,Ot),e(m,O),I(ee,O,null),e(O,Nt),e(O,te),e(te,Ut),e(te,Se),e(Se,zt),e(te,Gt),e(m,Wt),e(m,D),I(ne,D,null),e(D,Vt),e(D,xe),e(xe,Ft),e(D,Bt),e(D,Ee),e(Ee,Kt),e(D,Ht),e(D,ke),e(ke,Jt),e(m,Rt),e(m,N),I(ie,N,null),e(N,Qt),e(N,Te),e(Te,Xt),e(m,Yt),e(m,U),I(ae,U,null),e(U,Zt),e(U,oe),e(oe,en),e(oe,Ce),e(Ce,tn),e(oe,nn),We=!0},p(t,[f]){const se={};f&2&&(se.$$scope={dirty:f,ctx:t}),q.$set(se)},i(t){We||(P(c.$$.fragment,t),P(G.$$.fragment,t),P(Q.$$.fragment,t),P(Y.$$.fragment,t),P(q.$$.fragment,t),P(Z.$$.fragment,t),P(ee.$$.fragment,t),P(ne.$$.fragment,t),P(ie.$$.fragment,t),P(ae.$$.fragment,t),We=!0)},o(t){$(c.$$.fragment,t),$(G.$$.fragment,t),$(Q.$$.fragment,t),$(Y.$$.fragment,t),$(q.$$.fragment,t),$(Z.$$.fragment,t),$(ee.$$.fragment,t),$(ne.$$.fragment,t),$(ie.$$.fragment,t),$(ae.$$.fragment,t),We=!1},d(t){n(g),t&&n(M),t&&n(b),S(c),t&&n(Me),t&&n(L),S(G),t&&n(je),t&&n(v),t&&n(qe),t&&n(A),t&&n(Oe),t&&n(pe),t&&n(Ne),t&&n(de),t&&n(Ue),t&&n(fe),t&&n(ze),t&&n(ce),t&&n(Ge),t&&n(m),S(Q),S(Y),S(q),S(Z),S(ee),S(ne),S(ie),S(ae)}}}const Kn={local:"depthtoimage-generation",sections:[{local:"diffusers.StableDiffusionDepth2ImgPipeline",title:"StableDiffusionDepth2ImgPipeline"}],title:"Depth-to-Image Generation"};function Hn(Ae){return zn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zn extends qn{constructor(g){super();On(this,g,Hn,Bn,Nn,{})}}export{Zn as default,Kn as metadata};
