import{S as Y,i as Z,s as ee,e as r,k as P,w as F,t as d,M as te,c as p,d as a,m as k,a as h,x as K,h as c,b as g,G as t,g as I,y as Q,L as ae,q as V,o as W,B as X,v as se}from"../../chunks/vendor-hf-doc-builder.js";import{I as ie}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as oe}from"../../chunks/CodeBlock-hf-doc-builder.js";function ne(O){let i,$,o,l,v,u,S,y,E,j,s,T,_,G,C,w,A,L,b,M,N,q,f,D;return u=new ie({}),f=new oe({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,
).to("cuda")


url = "http://images.cocodataset.org/val2017/000000039769.jpg"
init_image = Image.open(requests.get(url, stream=True).raw)
prompt = "two tigers"
n_prompt = "bad, deformed, ugly, bad anatomy"
image = pipe(prompt=prompt, image=init_image, negative_prompt=n_prompt, strength=0.7).images[0]`,highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionDepth2ImgPipeline

pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-depth&quot;</span>,
    torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)


url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
init_image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
prompt = <span class="hljs-string">&quot;two tigers&quot;</span>
n_prompt = <span class="hljs-string">&quot;bad, deformed, ugly, bad anatomy&quot;</span>
image = pipe(prompt=prompt, image=init_image, negative_prompt=n_prompt, strength=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]`}}),{c(){i=r("meta"),$=P(),o=r("h1"),l=r("a"),v=r("span"),F(u.$$.fragment),S=P(),y=r("span"),E=d("Text-Guided Image-to-Image Generation"),j=P(),s=r("p"),T=d("The "),_=r("a"),G=d("StableDiffusionDepth2ImgPipeline"),C=d(" lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),w=r("code"),A=d("depth_map"),L=d(" to preserve the images\u2019 structure. If no "),b=r("code"),M=d("depth_map"),N=d(" is provided, the pipeline will automatically predict the depth via an integrated depth-estimation model."),q=P(),F(f.$$.fragment),this.h()},l(e){const n=te('[data-svelte="svelte-1phssyn"]',document.head);i=p(n,"META",{name:!0,content:!0}),n.forEach(a),$=k(e),o=p(e,"H1",{class:!0});var x=h(o);l=p(x,"A",{id:!0,class:!0,href:!0});var B=h(l);v=p(B,"SPAN",{});var H=h(v);K(u.$$.fragment,H),H.forEach(a),B.forEach(a),S=k(x),y=p(x,"SPAN",{});var J=h(y);E=c(J,"Text-Guided Image-to-Image Generation"),J.forEach(a),x.forEach(a),j=k(e),s=p(e,"P",{});var m=h(s);T=c(m,"The "),_=p(m,"A",{href:!0});var R=h(_);G=c(R,"StableDiffusionDepth2ImgPipeline"),R.forEach(a),C=c(m," lets you pass a text prompt and an initial image to condition the generation of new images as well as a "),w=p(m,"CODE",{});var U=h(w);A=c(U,"depth_map"),U.forEach(a),L=c(m," to preserve the images\u2019 structure. If no "),b=p(m,"CODE",{});var z=h(b);M=c(z,"depth_map"),z.forEach(a),N=c(m," is provided, the pipeline will automatically predict the depth via an integrated depth-estimation model."),m.forEach(a),q=k(e),K(f.$$.fragment,e),this.h()},h(){g(i,"name","hf:doc:metadata"),g(i,"content",JSON.stringify(re)),g(l,"id","textguided-imagetoimage-generation"),g(l,"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"),g(l,"href","#textguided-imagetoimage-generation"),g(o,"class","relative group"),g(_,"href","/docs/diffusers/v0.12.0/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline")},m(e,n){t(document.head,i),I(e,$,n),I(e,o,n),t(o,l),t(l,v),Q(u,v,null),t(o,S),t(o,y),t(y,E),I(e,j,n),I(e,s,n),t(s,T),t(s,_),t(_,G),t(s,C),t(s,w),t(w,A),t(s,L),t(s,b),t(b,M),t(s,N),I(e,q,n),Q(f,e,n),D=!0},p:ae,i(e){D||(V(u.$$.fragment,e),V(f.$$.fragment,e),D=!0)},o(e){W(u.$$.fragment,e),W(f.$$.fragment,e),D=!1},d(e){a(i),e&&a($),e&&a(o),X(u),e&&a(j),e&&a(s),e&&a(q),X(f,e)}}}const re={local:"textguided-imagetoimage-generation",title:"Text-Guided Image-to-Image Generation"};function pe(O){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class he extends Y{constructor(i){super();Z(this,i,pe,ne,ee,{})}}export{he as default,re as metadata};
