import{S as zn,i as Wn,s as Gn,e as o,k as p,w as $,t as s,M as Vn,c as i,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 On}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Nn}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=o("p"),k=s("Examples:"),_=p(),$(m.$$.fragment)},l(l){u=i(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=o("p"),k=s("Examples:"),_=p(),$(m.$$.fragment)},l(l){u=i(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,Oe,y,ot,G,it,at,V,st,rt,B,lt,pt,K,ft,dt,Ne,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,O,Lt,A,ee,Mt,xe,qt,Ot,Se,Nt,Ft,N,te,Ut,ne,zt,Ee,Wt,Gt,Vt,w,oe,Bt,ke,Kt,Ht,je,Jt,Rt,Ae,Qt,Xt,F,Yt,U,ie,Zt,Te,en,tn,z,ae,nn,se,on,Ce,an,sn,Ve;return l=new On({}),W=new On({}),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/v0.12.0/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/v0.12.0/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/v0.12.0/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/v0.12.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.12.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.12.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L58"}}),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:": typing.Optional[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/v0.12.0/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/v0.12.0/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/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L486",returnDescription:`
<p><a
  href="/docs/diffusers/v0.12.0/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/v0.12.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),O=new Nn({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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L902"}}),te=new le({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionDepth2ImgPipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L918"}}),oe=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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L845"}}),F=new Nn({props:{anchor:"diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[Hn]},$$scope:{ctx:pe}}}),ie=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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L877"}}),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/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py#L125"}}),{c(){u=o("meta"),k=p(),_=o("h1"),m=o("a"),D=o("span"),$(l.$$.fragment),v=p(),be=o("span"),et=s("Depth-to-Image Generation"),qe=p(),L=o("h2"),q=o("a"),ve=o("span"),$(W.$$.fragment),tt=p(),De=o("span"),nt=s("StableDiffusionDepth2ImgPipeline"),Oe=p(),y=o("p"),ot=s("The depth-guided stable diffusion model was created by the researchers and engineers from "),G=o("a"),it=s("CompVis"),at=s(", "),V=o("a"),st=s("Stability AI"),rt=s(", and "),B=o("a"),lt=s("LAION"),pt=s(", as part of Stable Diffusion 2.0. It uses "),K=o("a"),ft=s("MiDas"),dt=s(" to infer depth based on an image."),Ne=p(),M=o("p"),fe=o("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=o("code"),ut=s("depth_map"),ht=s(" to preserve the images\u2019 structure."),Fe=p(),de=o("p"),gt=s("The original codebase can be found here:"),Ue=p(),ce=o("ul"),H=o("li"),we=o("em"),_t=s("Stable Diffusion v2"),bt=s(": "),J=o("a"),vt=s("Stability-AI/stablediffusion"),ze=p(),me=o("p"),Dt=s("Available Checkpoints are:"),We=p(),ue=o("ul"),R=o("li"),$e=o("em"),yt=s("stable-diffusion-2-depth"),wt=s(": "),Q=o("a"),$t=s("stabilityai/stable-diffusion-2-depth"),Ge=p(),h=o("div"),$(X.$$.fragment),Pt=p(),Pe=o("p"),It=s("Pipeline for text-guided image to image generation using Stable Diffusion."),xt=p(),Y=o("p"),St=s("This model inherits from "),he=o("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=o("div"),$(Z.$$.fragment),At=p(),Ie=o("p"),Tt=s("Function invoked when calling the pipeline for generation."),Ct=p(),$(O.$$.fragment),Lt=p(),A=o("div"),$(ee.$$.fragment),Mt=p(),xe=o("p"),qt=s("Enable sliced attention computation."),Ot=p(),Se=o("p"),Nt=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(),N=o("div"),$(te.$$.fragment),Ut=p(),ne=o("p"),zt=s("Disable sliced attention computation. If "),Ee=o("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=o("div"),$(oe.$$.fragment),Bt=p(),ke=o("p"),Kt=s("Enable memory efficient attention as implemented in xformers."),Ht=p(),je=o("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=o("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=o("div"),$(ie.$$.fragment),Zt=p(),Te=o("p"),en=s("Disable memory efficient attention as implemented in xformers."),tn=p(),z=o("div"),$(ae.$$.fragment),nn=p(),se=o("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=o("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=i(c,"META",{name:!0,content:!0}),c.forEach(n),k=f(t),_=i(t,"H1",{class:!0});var re=a(_);m=i(re,"A",{id:!0,class:!0,href:!0});var Le=a(m);D=i(Le,"SPAN",{});var rn=a(D);P(l.$$.fragment,rn),rn.forEach(n),Le.forEach(n),v=f(re),be=i(re,"SPAN",{});var ln=a(be);et=r(ln,"Depth-to-Image Generation"),ln.forEach(n),re.forEach(n),qe=f(t),L=i(t,"H2",{class:!0});var Be=a(L);q=i(Be,"A",{id:!0,class:!0,href:!0});var pn=a(q);ve=i(pn,"SPAN",{});var fn=a(ve);P(W.$$.fragment,fn),fn.forEach(n),pn.forEach(n),tt=f(Be),De=i(Be,"SPAN",{});var dn=a(De);nt=r(dn,"StableDiffusionDepth2ImgPipeline"),dn.forEach(n),Be.forEach(n),Oe=f(t),y=i(t,"P",{});var T=a(y);ot=r(T,"The depth-guided stable diffusion model was created by the researchers and engineers from "),G=i(T,"A",{href:!0,rel:!0});var cn=a(G);it=r(cn,"CompVis"),cn.forEach(n),at=r(T,", "),V=i(T,"A",{href:!0,rel:!0});var mn=a(V);st=r(mn,"Stability AI"),mn.forEach(n),rt=r(T,", and "),B=i(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=i(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),Ne=f(t),M=i(t,"P",{});var Me=a(M);fe=i(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=i(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=i(t,"P",{});var bn=a(de);gt=r(bn,"The original codebase can be found here:"),bn.forEach(n),Ue=f(t),ce=i(t,"UL",{});var vn=a(ce);H=i(vn,"LI",{});var Ke=a(H);we=i(Ke,"EM",{});var Dn=a(we);_t=r(Dn,"Stable Diffusion v2"),Dn.forEach(n),bt=r(Ke,": "),J=i(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=i(t,"P",{});var wn=a(me);Dt=r(wn,"Available Checkpoints are:"),wn.forEach(n),We=f(t),ue=i(t,"UL",{});var $n=a(ue);R=i($n,"LI",{});var He=a(R);$e=i(He,"EM",{});var Pn=a($e);yt=r(Pn,"stable-diffusion-2-depth"),Pn.forEach(n),wt=r(He,": "),Q=i(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=i(t,"DIV",{class:!0});var b=a(h);P(X.$$.fragment,b),Pt=f(b),Pe=i(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=i(b,"P",{});var Je=a(Y);St=r(Je,"This model inherits from "),he=i(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=i(b,"DIV",{class:!0});var ge=a(j);P(Z.$$.fragment,ge),At=f(ge),Ie=i(ge,"P",{});var En=a(Ie);Tt=r(En,"Function invoked when calling the pipeline for generation."),En.forEach(n),Ct=f(ge),P(O.$$.fragment,ge),ge.forEach(n),Lt=f(b),A=i(b,"DIV",{class:!0});var _e=a(A);P(ee.$$.fragment,_e),Mt=f(_e),xe=i(_e,"P",{});var kn=a(xe);qt=r(kn,"Enable sliced attention computation."),kn.forEach(n),Ot=f(_e),Se=i(_e,"P",{});var jn=a(Se);Nt=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),N=i(b,"DIV",{class:!0});var Re=a(N);P(te.$$.fragment,Re),Ut=f(Re),ne=i(Re,"P",{});var Qe=a(ne);zt=r(Qe,"Disable sliced attention computation. If "),Ee=i(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=i(b,"DIV",{class:!0});var C=a(w);P(oe.$$.fragment,C),Bt=f(C),ke=i(C,"P",{});var Tn=a(ke);Kt=r(Tn,"Enable memory efficient attention as implemented in xformers."),Tn.forEach(n),Ht=f(C),je=i(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=i(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=i(b,"DIV",{class:!0});var Xe=a(U);P(ie.$$.fragment,Xe),Zt=f(Xe),Te=i(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=i(b,"DIV",{class:!0});var Ye=a(z);P(ae.$$.fragment,Ye),nn=f(Ye),se=i(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=i(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/v0.12.0/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/v0.12.0/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(N,"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,Oe,c),g(t,y,c),e(y,ot),e(y,G),e(G,it),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,Ne,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(O,j,null),e(h,Lt),e(h,A),I(ee,A,null),e(A,Mt),e(A,xe),e(xe,qt),e(A,Ot),e(A,Se),e(Se,Nt),e(h,Ft),e(h,N),I(te,N,null),e(N,Ut),e(N,ne),e(ne,zt),e(ne,Ee),e(Ee,Wt),e(ne,Gt),e(h,Vt),e(h,w),I(oe,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(ie,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}),O.$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(O.$$.fragment,t),x(ee.$$.fragment,t),x(te.$$.fragment,t),x(oe.$$.fragment,t),x(F.$$.fragment,t),x(ie.$$.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(O.$$.fragment,t),S(ee.$$.fragment,t),S(te.$$.fragment,t),S(oe.$$.fragment,t),S(F.$$.fragment,t),S(ie.$$.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(Oe),t&&n(y),t&&n(Ne),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(O),E(ee),E(te),E(oe),E(F),E(ie),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 no extends zn{constructor(u){super();Wn(this,u,Qn,Jn,Gn,{})}}export{no as default,Rn as metadata};
