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,c as M,h as ee,a as w,d as a,b as n,f as L,g as y,j as R,k as N,l as te,m as i,n as J,t as T,o as $,p as _}from"../chunks/index.100fac89.js";import{C as ae}from"../chunks/CopyLLMTxtMenu.2cdbb51f.js";import{C as F}from"../chunks/CodeBlock.d30a6509.js";import{D as ie}from"../chunks/DocNotebookDropdown.74a16910.js";import{H as se,E as ne}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fcbbc76.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>.',x,d,E='Start by creating an instance of the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline">StableDiffusionDepth2ImgPipeline</a>:',G,g,Q,f,P="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,Y='<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,S,U,V;return o=new ae({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),p=new ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;",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"}]}}),m=new se({props:{title:"Text-guided depth-to-image generation",local:"text-guided-depth-to-image-generation",headingTag:"h1"}}),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=s(),Z=b("p"),k=s(),M(o.$$.fragment),W=s(),M(p.$$.fragment),v=s(),M(m.$$.fragment),I=s(),r=b("p"),r.innerHTML=z,x=s(),d=b("p"),d.innerHTML=E,G=s(),M(g.$$.fragment),Q=s(),f=b("p"),f.innerHTML=P,C=s(),M(u.$$.fragment),D=s(),h=b("table"),h.innerHTML=Y,H=s(),M(c.$$.fragment),S=s(),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",{}),L(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),x=n(e),d=w(e,"P",{"data-svelte-h":!0}),R(d)!=="svelte-181psnb"&&(d.innerHTML=E),G=n(e),y(g.$$.fragment,e),Q=n(e),f=w(e,"P",{"data-svelte-h":!0}),R(f)!=="svelte-deexa5"&&(f.innerHTML=P),C=n(e),y(u.$$.fragment,e),D=n(e),h=w(e,"TABLE",{"data-svelte-h":!0}),R(h)!=="svelte-175x2as"&&(h.innerHTML=Y),H=n(e),y(c.$$.fragment,e),S=n(e),U=w(e,"P",{}),L(U).forEach(a),this.h()},h(){N(l,"name","hf:doc:metadata"),N(l,"content",oe)},m(e,t){te(document.head,l),i(e,j,t),i(e,Z,t),i(e,k,t),J(o,e,t),i(e,W,t),J(p,e,t),i(e,v,t),J(m,e,t),i(e,I,t),i(e,r,t),i(e,x,t),i(e,d,t),i(e,G,t),J(g,e,t),i(e,Q,t),i(e,f,t),i(e,C,t),J(u,e,t),i(e,D,t),i(e,h,t),i(e,H,t),J(c,e,t),i(e,S,t),i(e,U,t),V=!0},p:q,i(e){V||(T(o.$$.fragment,e),T(p.$$.fragment,e),T(m.$$.fragment,e),T(g.$$.fragment,e),T(u.$$.fragment,e),T(c.$$.fragment,e),V=!0)},o(e){$(o.$$.fragment,e),$(p.$$.fragment,e),$(m.$$.fragment,e),$(g.$$.fragment,e),$(u.$$.fragment,e),$(c.$$.fragment,e),V=!1},d(e){e&&(a(j),a(Z),a(k),a(W),a(v),a(I),a(r),a(x),a(d),a(G),a(Q),a(f),a(C),a(D),a(h),a(H),a(S),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};
