import{s as X,n as q,o as A}from"../chunks/scheduler.53228c21.js";import{S as K,i as O,e as b,s as i,c as M,h as ee,a as w,d as a,b as n,f as Y,g as y,j as R,k as L,l as te,m as s,n as J,t as T,o as $,p as _}from"../chunks/index.100fac89.js";import{C as ae}from"../chunks/CopyLLMTxtMenu.4f0519ef.js";import{C as F}from"../chunks/CodeBlock.d30a6509.js";import{D as se}from"../chunks/DocNotebookDropdown.1a28089c.js";import{H as ie,E as ne}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.62dbb7c4.js";function le(B){let l,j,Z,k,o,W,p,v,m,I,r,z='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>.',G,d,E='Start by creating an instance of the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline">StableDiffusionDepth2ImgPipeline</a>:',x,g,Q,f,N="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:",C,u,D,h,P='<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>',H,c,V,U,S;return o=new ae({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),p=new ie({props:{title:"Text-guided depth-to-image generation",local:"text-guided-depth-to-image-generation",headingTag:"h1"}}),m=new se({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"}]}}),g=new F({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}}),u=new F({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=new ne({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/depth2img.md"}}),{c(){l=b("meta"),j=i(),Z=b("p"),k=i(),M(o.$$.fragment),W=i(),M(p.$$.fragment),v=i(),M(m.$$.fragment),I=i(),r=b("p"),r.innerHTML=z,G=i(),d=b("p"),d.innerHTML=E,x=i(),M(g.$$.fragment),Q=i(),f=b("p"),f.innerHTML=N,C=i(),M(u.$$.fragment),D=i(),h=b("table"),h.innerHTML=P,H=i(),M(c.$$.fragment),V=i(),U=b("p"),this.h()},l(e){const t=ee("svelte-u9bgzb",document.head);l=w(t,"META",{name:!0,content:!0}),t.forEach(a),j=n(e),Z=w(e,"P",{}),Y(Z).forEach(a),k=n(e),y(o.$$.fragment,e),W=n(e),y(p.$$.fragment,e),v=n(e),y(m.$$.fragment,e),I=n(e),r=w(e,"P",{"data-svelte-h":!0}),R(r)!=="svelte-du0wp2"&&(r.innerHTML=z),G=n(e),d=w(e,"P",{"data-svelte-h":!0}),R(d)!=="svelte-181psnb"&&(d.innerHTML=E),x=n(e),y(g.$$.fragment,e),Q=n(e),f=w(e,"P",{"data-svelte-h":!0}),R(f)!=="svelte-deexa5"&&(f.innerHTML=N),C=n(e),y(u.$$.fragment,e),D=n(e),h=w(e,"TABLE",{"data-svelte-h":!0}),R(h)!=="svelte-175x2as"&&(h.innerHTML=P),H=n(e),y(c.$$.fragment,e),V=n(e),U=w(e,"P",{}),Y(U).forEach(a),this.h()},h(){L(l,"name","hf:doc:metadata"),L(l,"content",oe)},m(e,t){te(document.head,l),s(e,j,t),s(e,Z,t),s(e,k,t),J(o,e,t),s(e,W,t),J(p,e,t),s(e,v,t),J(m,e,t),s(e,I,t),s(e,r,t),s(e,G,t),s(e,d,t),s(e,x,t),J(g,e,t),s(e,Q,t),s(e,f,t),s(e,C,t),J(u,e,t),s(e,D,t),s(e,h,t),s(e,H,t),J(c,e,t),s(e,V,t),s(e,U,t),S=!0},p:q,i(e){S||(T(o.$$.fragment,e),T(p.$$.fragment,e),T(m.$$.fragment,e),T(g.$$.fragment,e),T(u.$$.fragment,e),T(c.$$.fragment,e),S=!0)},o(e){$(o.$$.fragment,e),$(p.$$.fragment,e),$(m.$$.fragment,e),$(g.$$.fragment,e),$(u.$$.fragment,e),$(c.$$.fragment,e),S=!1},d(e){e&&(a(j),a(Z),a(k),a(W),a(v),a(I),a(r),a(G),a(d),a(x),a(Q),a(f),a(C),a(D),a(h),a(H),a(V),a(U)),a(l),_(o,e),_(p,e),_(m,e),_(g,e),_(u,e),_(c,e)}}}const oe='{"title":"Text-guided depth-to-image generation","local":"text-guided-depth-to-image-generation","sections":[],"depth":1}';function pe(B){return A(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class he extends K{constructor(l){super(),O(this,l,pe,le,X,{})}}export{he as component};
