import{s as Y,n as E,o as F}from"../chunks/scheduler.182ea377.js";import{S as L,i as A,g as u,s as i,r as I,A as X,h as f,f as a,c as l,j as z,u as $,x as G,k as N,y as q,a as s,v as Q,d as D,t as H,w as V}from"../chunks/index.abf12888.js";import{C as P}from"../chunks/CodeBlock.57fe6e13.js";import{D as K}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as O}from"../chunks/Heading.16916d63.js";function ee(x){let n,M,b,y,o,J,p,T,m,C='The <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline">StableDiffusionDepth2ImgPipeline</a> lets you pass a text prompt and an initial image to condition the generation of new images. In addition, you can also pass a <code>depth_map</code> to preserve the image structure. If no <code>depth_map</code> is provided, the pipeline automatically predicts the depth via an integrated <a href="https://github.com/isl-org/MiDaS" rel="nofollow">depth-estimation model</a>.',_,r,R='Start by creating an instance of the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline">StableDiffusionDepth2ImgPipeline</a>:',Z,d,U,g,S="Now pass your prompt to the pipeline. You can also pass a <code>negative_prompt</code> to prevent certain words from guiding how an image is generated:",j,h,k,c,B='<thead><tr><th>Input</th> <th>Output</th></tr></thead> <tbody><tr><td><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/coco-cats.png" width="500"/></td> <td><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/depth2img-tigers.png" width="500"/></td></tr></tbody>',W,w,v;return o=new O({props:{title:"Text-guided depth-to-image generation",local:"text-guided-depth-to-image-generation",headingTag:"h1"}}),p=new K({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/depth2img.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/depth2img.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/depth2img.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/depth2img.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/depth2img.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/depth2img.ipynb"}]}}),d=new P({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uRGVwdGgySW1nUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUyQyUyMG1ha2VfaW1hZ2VfZ3JpZCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uRGVwdGgySW1nUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi0yLWRlcHRoJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUyQyUwQSkudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionDepth2ImgPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = StableDiffusionDepth2ImgPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-depth&quot;</span>,
    torch_dtype=torch.float16,
    use_safetensors=<span class="hljs-literal">True</span>,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),h=new P({props:{code:"dXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWluaXRfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKHVybCklMEFwcm9tcHQlMjAlM0QlMjAlMjJ0d28lMjB0aWdlcnMlMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAlMjJiYWQlMkMlMjBkZWZvcm1lZCUyQyUyMHVnbHklMkMlMjBiYWQlMjBhbmF0b215JTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRGluaXRfaW1hZ2UlMkMlMjBuZWdhdGl2ZV9wcm9tcHQlM0RuZWdhdGl2ZV9wcm9tcHQlMkMlMjBzdHJlbmd0aCUzRDAuNykuaW1hZ2VzJTVCMCU1RCUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbml0X2ltYWdlJTJDJTIwaW1hZ2UlNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QyKQ==",highlighted:`url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
init_image = load_image(url)
prompt = <span class="hljs-string">&quot;two tigers&quot;</span>
negative_prompt = <span class="hljs-string">&quot;bad, deformed, ugly, bad anatomy&quot;</span>
image = pipeline(prompt=prompt, image=init_image, negative_prompt=negative_prompt, strength=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){n=u("meta"),M=i(),b=u("p"),y=i(),I(o.$$.fragment),J=i(),I(p.$$.fragment),T=i(),m=u("p"),m.innerHTML=C,_=i(),r=u("p"),r.innerHTML=R,Z=i(),I(d.$$.fragment),U=i(),g=u("p"),g.innerHTML=S,j=i(),I(h.$$.fragment),k=i(),c=u("table"),c.innerHTML=B,W=i(),w=u("p"),this.h()},l(e){const t=X("svelte-u9bgzb",document.head);n=f(t,"META",{name:!0,content:!0}),t.forEach(a),M=l(e),b=f(e,"P",{}),z(b).forEach(a),y=l(e),$(o.$$.fragment,e),J=l(e),$(p.$$.fragment,e),T=l(e),m=f(e,"P",{"data-svelte-h":!0}),G(m)!=="svelte-du0wp2"&&(m.innerHTML=C),_=l(e),r=f(e,"P",{"data-svelte-h":!0}),G(r)!=="svelte-181psnb"&&(r.innerHTML=R),Z=l(e),$(d.$$.fragment,e),U=l(e),g=f(e,"P",{"data-svelte-h":!0}),G(g)!=="svelte-deexa5"&&(g.innerHTML=S),j=l(e),$(h.$$.fragment,e),k=l(e),c=f(e,"TABLE",{"data-svelte-h":!0}),G(c)!=="svelte-175x2as"&&(c.innerHTML=B),W=l(e),w=f(e,"P",{}),z(w).forEach(a),this.h()},h(){N(n,"name","hf:doc:metadata"),N(n,"content",te)},m(e,t){q(document.head,n),s(e,M,t),s(e,b,t),s(e,y,t),Q(o,e,t),s(e,J,t),Q(p,e,t),s(e,T,t),s(e,m,t),s(e,_,t),s(e,r,t),s(e,Z,t),Q(d,e,t),s(e,U,t),s(e,g,t),s(e,j,t),Q(h,e,t),s(e,k,t),s(e,c,t),s(e,W,t),s(e,w,t),v=!0},p:E,i(e){v||(D(o.$$.fragment,e),D(p.$$.fragment,e),D(d.$$.fragment,e),D(h.$$.fragment,e),v=!0)},o(e){H(o.$$.fragment,e),H(p.$$.fragment,e),H(d.$$.fragment,e),H(h.$$.fragment,e),v=!1},d(e){e&&(a(M),a(b),a(y),a(J),a(T),a(m),a(_),a(r),a(Z),a(U),a(g),a(j),a(k),a(c),a(W),a(w)),a(n),V(o,e),V(p,e),V(d,e),V(h,e)}}}const te='{"title":"Text-guided depth-to-image generation","local":"text-guided-depth-to-image-generation","sections":[],"depth":1}';function ae(x){return F(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pe extends L{constructor(n){super(),A(this,n,ae,ee,Y,{})}}export{pe as component};
