import{S as zn,i as Wn,s as Gn,e as i,k as p,w as $,t as s,M as Vn,c as o,d as n,m as f,a,x as P,h as r,b as d,G as e,g,y as I,q as x,o as S,B as E,v as Bn,L as Fn}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as le}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as Un}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Nn}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as On}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Kn(pe){let u,k,_,m,D;return m=new Un({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(){u=i("p"),k=s("Examples:"),_=p(),$(m.$$.fragment)},l(l){u=o(l,"P",{});var v=a(u);k=r(v,"Examples:"),v.forEach(n),_=f(l),P(m.$$.fragment,l)},m(l,v){g(l,u,v),e(u,k),g(l,_,v),I(m,l,v),D=!0},p:Fn,i(l){D||(x(m.$$.fragment,l),D=!0)},o(l){S(m.$$.fragment,l),D=!1},d(l){l&&n(u),l&&n(_),E(m,l)}}}function Hn(pe){let u,k,_,m,D;return m=new Un({props:{code:`import torch
from diffusers import DiffusionPipeline
from xformers.ops import MemoryEfficientAttentionFlashAttentionOp

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
# Workaround for not accepting attention shape using VAE for Flash Attention
pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)`,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">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> xformers.ops <span class="hljs-keyword">import</span> MemoryEfficientAttentionFlashAttentionOp

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Workaround for not accepting attention shape using VAE for Flash Attention</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.vae.enable_xformers_memory_efficient_attention(attention_op=<span class="hljs-literal">None</span>)`}}),{c(){u=i("p"),k=s("Examples:"),_=p(),$(m.$$.fragment)},l(l){u=o(l,"P",{});var v=a(u);k=r(v,"Examples:"),v.forEach(n),_=f(l),P(m.$$.fragment,l)},m(l,v){g(l,u,v),e(u,k),g(l,_,v),I(m,l,v),D=!0},p:Fn,i(l){D||(x(m.$$.fragment,l),D=!0)},o(l){S(m.$$.fragment,l),D=!1},d(l){l&&n(u),l&&n(_),E(m,l)}}}function Jn(pe){let u,k,_,m,D,l,v,be,et,qe,L,q,ve,W,tt,De,nt,Ne,y,it,G,ot,at,V,st,rt,B,lt,pt,K,ft,dt,Oe,M,fe,ct,mt,ye,ut,ht,Fe,de,gt,Ue,ce,H,we,_t,bt,J,vt,ze,me,Dt,We,ue,R,$e,yt,wt,Q,$t,Ge,h,X,Pt,Pe,It,xt,Y,St,he,Et,kt,jt,j,Z,At,Ie,Tt,Ct,N,Lt,A,ee,Mt,xe,qt,Nt,Se,Ot,Ft,O,te,Ut,ne,zt,Ee,Wt,Gt,Vt,w,ie,Bt,ke,Kt,Ht,je,Jt,Rt,Ae,Qt,Xt,F,Yt,U,oe,Zt,Te,en,tn,z,ae,nn,se,on,Ce,an,sn,Ve;return l=new Nn({}),W=new Nn({}),X=new le({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#L57"}}),Z=new le({props:{name:"__call__",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{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:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = 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:": int = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,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. If not defined, one has to pass
<code>negative_prompt_embeds</code>. instead. 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__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{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#L482",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>
`}}),N=new On({props:{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.__call__.example",$$slots:{default:[Kn]},$$scope:{ctx:pe}}}),ee=new le({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#L1033"}}),te=new le({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#L1049"}}),ie=new le({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention",parameters:[{name:"attention_op",val:": typing.Optional[typing.Callable] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention.attention_op",description:`<strong>attention_op</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
Override the default <code>None</code> operator for use as <code>op</code> argument to the
<a href="https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention" rel="nofollow"><code>memory_efficient_attention()</code></a>
function of xFormers.`,name:"attention_op"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L976"}}),F=new On({props:{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[Hn]},$$scope:{ctx:pe}}}),oe=new le({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#L1008"}}),ae=new le({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#L124"}}),{c(){u=i("meta"),k=p(),_=i("h1"),m=i("a"),D=i("span"),$(l.$$.fragment),v=p(),be=i("span"),et=s("Depth-to-Image Generation"),qe=p(),L=i("h2"),q=i("a"),ve=i("span"),$(W.$$.fragment),tt=p(),De=i("span"),nt=s("StableDiffusionDepth2ImgPipeline"),Ne=p(),y=i("p"),it=s("The depth-guided stable diffusion model was created by the researchers and engineers from "),G=i("a"),ot=s("CompVis"),at=s(", "),V=i("a"),st=s("Stability AI"),rt=s(", and "),B=i("a"),lt=s("LAION"),pt=s(", as part of Stable Diffusion 2.0. It uses "),K=i("a"),ft=s("MiDas"),dt=s(" to infer depth based on an image."),Oe=p(),M=i("p"),fe=i("a"),ct=s("StableDiffusionDepth2ImgPipeline"),mt=s(" lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),ye=i("code"),ut=s("depth_map"),ht=s(" to preserve the images\u2019 structure."),Fe=p(),de=i("p"),gt=s("The original codebase can be found here:"),Ue=p(),ce=i("ul"),H=i("li"),we=i("em"),_t=s("Stable Diffusion v2"),bt=s(": "),J=i("a"),vt=s("Stability-AI/stablediffusion"),ze=p(),me=i("p"),Dt=s("Available Checkpoints are:"),We=p(),ue=i("ul"),R=i("li"),$e=i("em"),yt=s("stable-diffusion-2-depth"),wt=s(": "),Q=i("a"),$t=s("stabilityai/stable-diffusion-2-depth"),Ge=p(),h=i("div"),$(X.$$.fragment),Pt=p(),Pe=i("p"),It=s("Pipeline for text-guided image to image generation using Stable Diffusion."),xt=p(),Y=i("p"),St=s("This model inherits from "),he=i("a"),Et=s("DiffusionPipeline"),kt=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.)`),jt=p(),j=i("div"),$(Z.$$.fragment),At=p(),Ie=i("p"),Tt=s("Function invoked when calling the pipeline for generation."),Ct=p(),$(N.$$.fragment),Lt=p(),A=i("div"),$(ee.$$.fragment),Mt=p(),xe=i("p"),qt=s("Enable sliced attention computation."),Nt=p(),Se=i("p"),Ot=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.`),Ft=p(),O=i("div"),$(te.$$.fragment),Ut=p(),ne=i("p"),zt=s("Disable sliced attention computation. If "),Ee=i("code"),Wt=s("enable_attention_slicing"),Gt=s(` was previously invoked, this method will go
back to computing attention in one step.`),Vt=p(),w=i("div"),$(ie.$$.fragment),Bt=p(),ke=i("p"),Kt=s("Enable memory efficient attention as implemented in xformers."),Ht=p(),je=i("p"),Jt=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.`),Rt=p(),Ae=i("p"),Qt=s(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Xt=p(),$(F.$$.fragment),Yt=p(),U=i("div"),$(oe.$$.fragment),Zt=p(),Te=i("p"),en=s("Disable memory efficient attention as implemented in xformers."),tn=p(),z=i("div"),$(ae.$$.fragment),nn=p(),se=i("p"),on=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"),an=s("torch.device('meta') and loaded to GPU only when their specific submodule has its "),sn=s("forward` method called."),this.h()},l(t){const c=Vn('[data-svelte="svelte-1phssyn"]',document.head);u=o(c,"META",{name:!0,content:!0}),c.forEach(n),k=f(t),_=o(t,"H1",{class:!0});var re=a(_);m=o(re,"A",{id:!0,class:!0,href:!0});var Le=a(m);D=o(Le,"SPAN",{});var rn=a(D);P(l.$$.fragment,rn),rn.forEach(n),Le.forEach(n),v=f(re),be=o(re,"SPAN",{});var ln=a(be);et=r(ln,"Depth-to-Image Generation"),ln.forEach(n),re.forEach(n),qe=f(t),L=o(t,"H2",{class:!0});var Be=a(L);q=o(Be,"A",{id:!0,class:!0,href:!0});var pn=a(q);ve=o(pn,"SPAN",{});var fn=a(ve);P(W.$$.fragment,fn),fn.forEach(n),pn.forEach(n),tt=f(Be),De=o(Be,"SPAN",{});var dn=a(De);nt=r(dn,"StableDiffusionDepth2ImgPipeline"),dn.forEach(n),Be.forEach(n),Ne=f(t),y=o(t,"P",{});var T=a(y);it=r(T,"The depth-guided stable diffusion model was created by the researchers and engineers from "),G=o(T,"A",{href:!0,rel:!0});var cn=a(G);ot=r(cn,"CompVis"),cn.forEach(n),at=r(T,", "),V=o(T,"A",{href:!0,rel:!0});var mn=a(V);st=r(mn,"Stability AI"),mn.forEach(n),rt=r(T,", and "),B=o(T,"A",{href:!0,rel:!0});var un=a(B);lt=r(un,"LAION"),un.forEach(n),pt=r(T,", as part of Stable Diffusion 2.0. It uses "),K=o(T,"A",{href:!0,rel:!0});var hn=a(K);ft=r(hn,"MiDas"),hn.forEach(n),dt=r(T," to infer depth based on an image."),T.forEach(n),Oe=f(t),M=o(t,"P",{});var Me=a(M);fe=o(Me,"A",{href:!0});var gn=a(fe);ct=r(gn,"StableDiffusionDepth2ImgPipeline"),gn.forEach(n),mt=r(Me," lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),ye=o(Me,"CODE",{});var _n=a(ye);ut=r(_n,"depth_map"),_n.forEach(n),ht=r(Me," to preserve the images\u2019 structure."),Me.forEach(n),Fe=f(t),de=o(t,"P",{});var bn=a(de);gt=r(bn,"The original codebase can be found here:"),bn.forEach(n),Ue=f(t),ce=o(t,"UL",{});var vn=a(ce);H=o(vn,"LI",{});var Ke=a(H);we=o(Ke,"EM",{});var Dn=a(we);_t=r(Dn,"Stable Diffusion v2"),Dn.forEach(n),bt=r(Ke,": "),J=o(Ke,"A",{href:!0,rel:!0});var yn=a(J);vt=r(yn,"Stability-AI/stablediffusion"),yn.forEach(n),Ke.forEach(n),vn.forEach(n),ze=f(t),me=o(t,"P",{});var wn=a(me);Dt=r(wn,"Available Checkpoints are:"),wn.forEach(n),We=f(t),ue=o(t,"UL",{});var $n=a(ue);R=o($n,"LI",{});var He=a(R);$e=o(He,"EM",{});var Pn=a($e);yt=r(Pn,"stable-diffusion-2-depth"),Pn.forEach(n),wt=r(He,": "),Q=o(He,"A",{href:!0,rel:!0});var In=a(Q);$t=r(In,"stabilityai/stable-diffusion-2-depth"),In.forEach(n),He.forEach(n),$n.forEach(n),Ge=f(t),h=o(t,"DIV",{class:!0});var b=a(h);P(X.$$.fragment,b),Pt=f(b),Pe=o(b,"P",{});var xn=a(Pe);It=r(xn,"Pipeline for text-guided image to image generation using Stable Diffusion."),xn.forEach(n),xt=f(b),Y=o(b,"P",{});var Je=a(Y);St=r(Je,"This model inherits from "),he=o(Je,"A",{href:!0});var Sn=a(he);Et=r(Sn,"DiffusionPipeline"),Sn.forEach(n),kt=r(Je,`. 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.)`),Je.forEach(n),jt=f(b),j=o(b,"DIV",{class:!0});var ge=a(j);P(Z.$$.fragment,ge),At=f(ge),Ie=o(ge,"P",{});var En=a(Ie);Tt=r(En,"Function invoked when calling the pipeline for generation."),En.forEach(n),Ct=f(ge),P(N.$$.fragment,ge),ge.forEach(n),Lt=f(b),A=o(b,"DIV",{class:!0});var _e=a(A);P(ee.$$.fragment,_e),Mt=f(_e),xe=o(_e,"P",{});var kn=a(xe);qt=r(kn,"Enable sliced attention computation."),kn.forEach(n),Nt=f(_e),Se=o(_e,"P",{});var jn=a(Se);Ot=r(jn,`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.`),jn.forEach(n),_e.forEach(n),Ft=f(b),O=o(b,"DIV",{class:!0});var Re=a(O);P(te.$$.fragment,Re),Ut=f(Re),ne=o(Re,"P",{});var Qe=a(ne);zt=r(Qe,"Disable sliced attention computation. If "),Ee=o(Qe,"CODE",{});var An=a(Ee);Wt=r(An,"enable_attention_slicing"),An.forEach(n),Gt=r(Qe,` was previously invoked, this method will go
back to computing attention in one step.`),Qe.forEach(n),Re.forEach(n),Vt=f(b),w=o(b,"DIV",{class:!0});var C=a(w);P(ie.$$.fragment,C),Bt=f(C),ke=o(C,"P",{});var Tn=a(ke);Kt=r(Tn,"Enable memory efficient attention as implemented in xformers."),Tn.forEach(n),Ht=f(C),je=o(C,"P",{});var Cn=a(je);Jt=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),Rt=f(C),Ae=o(C,"P",{});var Ln=a(Ae);Qt=r(Ln,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Ln.forEach(n),Xt=f(C),P(F.$$.fragment,C),C.forEach(n),Yt=f(b),U=o(b,"DIV",{class:!0});var Xe=a(U);P(oe.$$.fragment,Xe),Zt=f(Xe),Te=o(Xe,"P",{});var Mn=a(Te);en=r(Mn,"Disable memory efficient attention as implemented in xformers."),Mn.forEach(n),Xe.forEach(n),tn=f(b),z=o(b,"DIV",{class:!0});var Ye=a(z);P(ae.$$.fragment,Ye),nn=f(Ye),se=o(Ye,"P",{});var Ze=a(se);on=r(Ze,`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=o(Ze,"CODE",{});var qn=a(Ce);an=r(qn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),qn.forEach(n),sn=r(Ze,"forward` method called."),Ze.forEach(n),Ye.forEach(n),b.forEach(n),this.h()},h(){d(u,"name","hf:doc:metadata"),d(u,"content",JSON.stringify(Rn)),d(m,"id","depthtoimage-generation"),d(m,"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"),d(m,"href","#depthtoimage-generation"),d(_,"class","relative group"),d(q,"id","diffusers.StableDiffusionDepth2ImgPipeline"),d(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"),d(q,"href","#diffusers.StableDiffusionDepth2ImgPipeline"),d(L,"class","relative group"),d(G,"href","https://github.com/CompVis"),d(G,"rel","nofollow"),d(V,"href","https://stability.ai/"),d(V,"rel","nofollow"),d(B,"href","https://laion.ai/"),d(B,"rel","nofollow"),d(K,"href","https://github.com/isl-org/MiDaS"),d(K,"rel","nofollow"),d(fe,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline"),d(J,"href","https://github.com/Stability-AI/stablediffusion#depth-conditional-stable-diffusion"),d(J,"rel","nofollow"),d(Q,"href","https://huggingface.co/stabilityai/stable-diffusion-2-depth"),d(Q,"rel","nofollow"),d(he,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(h,"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,c){e(document.head,u),g(t,k,c),g(t,_,c),e(_,m),e(m,D),I(l,D,null),e(_,v),e(_,be),e(be,et),g(t,qe,c),g(t,L,c),e(L,q),e(q,ve),I(W,ve,null),e(L,tt),e(L,De),e(De,nt),g(t,Ne,c),g(t,y,c),e(y,it),e(y,G),e(G,ot),e(y,at),e(y,V),e(V,st),e(y,rt),e(y,B),e(B,lt),e(y,pt),e(y,K),e(K,ft),e(y,dt),g(t,Oe,c),g(t,M,c),e(M,fe),e(fe,ct),e(M,mt),e(M,ye),e(ye,ut),e(M,ht),g(t,Fe,c),g(t,de,c),e(de,gt),g(t,Ue,c),g(t,ce,c),e(ce,H),e(H,we),e(we,_t),e(H,bt),e(H,J),e(J,vt),g(t,ze,c),g(t,me,c),e(me,Dt),g(t,We,c),g(t,ue,c),e(ue,R),e(R,$e),e($e,yt),e(R,wt),e(R,Q),e(Q,$t),g(t,Ge,c),g(t,h,c),I(X,h,null),e(h,Pt),e(h,Pe),e(Pe,It),e(h,xt),e(h,Y),e(Y,St),e(Y,he),e(he,Et),e(Y,kt),e(h,jt),e(h,j),I(Z,j,null),e(j,At),e(j,Ie),e(Ie,Tt),e(j,Ct),I(N,j,null),e(h,Lt),e(h,A),I(ee,A,null),e(A,Mt),e(A,xe),e(xe,qt),e(A,Nt),e(A,Se),e(Se,Ot),e(h,Ft),e(h,O),I(te,O,null),e(O,Ut),e(O,ne),e(ne,zt),e(ne,Ee),e(Ee,Wt),e(ne,Gt),e(h,Vt),e(h,w),I(ie,w,null),e(w,Bt),e(w,ke),e(ke,Kt),e(w,Ht),e(w,je),e(je,Jt),e(w,Rt),e(w,Ae),e(Ae,Qt),e(w,Xt),I(F,w,null),e(h,Yt),e(h,U),I(oe,U,null),e(U,Zt),e(U,Te),e(Te,en),e(h,tn),e(h,z),I(ae,z,null),e(z,nn),e(z,se),e(se,on),e(se,Ce),e(Ce,an),e(se,sn),Ve=!0},p(t,[c]){const re={};c&2&&(re.$$scope={dirty:c,ctx:t}),N.$set(re);const Le={};c&2&&(Le.$$scope={dirty:c,ctx:t}),F.$set(Le)},i(t){Ve||(x(l.$$.fragment,t),x(W.$$.fragment,t),x(X.$$.fragment,t),x(Z.$$.fragment,t),x(N.$$.fragment,t),x(ee.$$.fragment,t),x(te.$$.fragment,t),x(ie.$$.fragment,t),x(F.$$.fragment,t),x(oe.$$.fragment,t),x(ae.$$.fragment,t),Ve=!0)},o(t){S(l.$$.fragment,t),S(W.$$.fragment,t),S(X.$$.fragment,t),S(Z.$$.fragment,t),S(N.$$.fragment,t),S(ee.$$.fragment,t),S(te.$$.fragment,t),S(ie.$$.fragment,t),S(F.$$.fragment,t),S(oe.$$.fragment,t),S(ae.$$.fragment,t),Ve=!1},d(t){n(u),t&&n(k),t&&n(_),E(l),t&&n(qe),t&&n(L),E(W),t&&n(Ne),t&&n(y),t&&n(Oe),t&&n(M),t&&n(Fe),t&&n(de),t&&n(Ue),t&&n(ce),t&&n(ze),t&&n(me),t&&n(We),t&&n(ue),t&&n(Ge),t&&n(h),E(X),E(Z),E(N),E(ee),E(te),E(ie),E(F),E(oe),E(ae)}}}const Rn={local:"depthtoimage-generation",sections:[{local:"diffusers.StableDiffusionDepth2ImgPipeline",title:"StableDiffusionDepth2ImgPipeline"}],title:"Depth-to-Image Generation"};function Qn(pe){return Bn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ni extends zn{constructor(u){super();Wn(this,u,Qn,Jn,Gn,{})}}export{ni as default,Rn as metadata};
