import{s as O,j as tt,n as et,o as st}from"../chunks/scheduler.6e0d5ff7.js";import{S as at,i as lt,g as p,s as l,r as J,E as it,h as m,f as s,c as i,j as P,u as _,x as $,k as y,y as ot,a,v as k,d as B,t as v,w as Z}from"../chunks/index.d7c1b260.js";import{C as K}from"../chunks/CodeBlock.09a08494.js";import{D as nt}from"../chunks/DocNotebookDropdown.b1b23d60.js";import{H as pt,E as mt}from"../chunks/EditOnGithub.733546da.js";function rt(R){let n,U,j,W,r,I,d,Q,c,N='<code>StableDiffusionDepth2ImgPipeline</code>을 사용하면 텍스트 프롬프트와 초기 이미지를 전달하여 새 이미지의 생성을 조절할 수 있습니다. 또한 이미지 구조를 보존하기 위해 <code>depth_map</code>을 전달할 수도 있습니다. <code>depth_map</code>이 제공되지 않으면 파이프라인은 통합된 <a href="https://github.com/isl-org/MiDaS" rel="nofollow">depth-estimation model</a>을 통해 자동으로 깊이를 예측합니다.',X,u,Y="먼저 <code>StableDiffusionDepth2ImgPipeline</code>의 인스턴스를 생성합니다:",E,g,G,h,q="이제 프롬프트를 파이프라인에 전달합니다. 특정 단어가 이미지 생성을 가이드 하는것을 방지하기 위해 <code>negative_prompt</code>를 전달할 수도 있습니다:",H,f,x,b,A='<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>',S,M,z="아래의 Spaces를 가지고 놀며 depth map이 있는 이미지와 없는 이미지의 차이가 있는지 확인해 보세요!",D,o,V,F,w,C,T,L;return r=new pt({props:{title:"Text-guided depth-to-image 생성",local:"text-guided-depth-to-image-생성",headingTag:"h1"}}),d=new nt({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/ko/depth2img.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/depth2img.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/depth2img.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/depth2img.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/depth2img.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/depth2img.ipynb"}]}}),g=new K({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25EZXB0aDJJbWdQaXBlbGluZSUwQSUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25EZXB0aDJJbWdQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItZGVwdGglMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEEpLnRvKCUyMmN1ZGElMjIp",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>)`,wrap:!1}}),f=new K({props:{code:"dXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWluaXRfaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBcHJvbXB0JTIwJTNEJTIwJTIydHdvJTIwdGlnZXJzJTIyJTBBbl9wcm9tcHQlMjAlM0QlMjAlMjJiYWQlMkMlMjBkZWZvcm1lZCUyQyUyMHVnbHklMkMlMjBiYWQlMjBhbmF0b215JTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG5lZ2F0aXZlX3Byb21wdCUzRG5fcHJvbXB0JTJDJTIwc3RyZW5ndGglM0QwLjcpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`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>]
image`,wrap:!1}}),w=new mt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/depth2img.md"}}),{c(){n=p("meta"),U=l(),j=p("p"),W=l(),J(r.$$.fragment),I=l(),J(d.$$.fragment),Q=l(),c=p("p"),c.innerHTML=N,X=l(),u=p("p"),u.innerHTML=Y,E=l(),J(g.$$.fragment),G=l(),h=p("p"),h.innerHTML=q,H=l(),J(f.$$.fragment),x=l(),b=p("table"),b.innerHTML=A,S=l(),M=p("p"),M.textContent=z,D=l(),o=p("iframe"),F=l(),J(w.$$.fragment),C=l(),T=p("p"),this.h()},l(t){const e=it("svelte-u9bgzb",document.head);n=m(e,"META",{name:!0,content:!0}),e.forEach(s),U=i(t),j=m(t,"P",{}),P(j).forEach(s),W=i(t),_(r.$$.fragment,t),I=i(t),_(d.$$.fragment,t),Q=i(t),c=m(t,"P",{"data-svelte-h":!0}),$(c)!=="svelte-1nwb6xh"&&(c.innerHTML=N),X=i(t),u=m(t,"P",{"data-svelte-h":!0}),$(u)!=="svelte-b7rzk"&&(u.innerHTML=Y),E=i(t),_(g.$$.fragment,t),G=i(t),h=m(t,"P",{"data-svelte-h":!0}),$(h)!=="svelte-1ospw27"&&(h.innerHTML=q),H=i(t),_(f.$$.fragment,t),x=i(t),b=m(t,"TABLE",{"data-svelte-h":!0}),$(b)!=="svelte-175x2as"&&(b.innerHTML=A),S=i(t),M=m(t,"P",{"data-svelte-h":!0}),$(M)!=="svelte-1vexnbo"&&(M.textContent=z),D=i(t),o=m(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),P(o).forEach(s),F=i(t),_(w.$$.fragment,t),C=i(t),T=m(t,"P",{}),P(T).forEach(s),this.h()},h(){y(n,"name","hf:doc:metadata"),y(n,"content",dt),tt(o.src,V="https://radames-stable-diffusion-depth2img.hf.space")||y(o,"src",V),y(o,"frameborder","0"),y(o,"width","850"),y(o,"height","500")},m(t,e){ot(document.head,n),a(t,U,e),a(t,j,e),a(t,W,e),k(r,t,e),a(t,I,e),k(d,t,e),a(t,Q,e),a(t,c,e),a(t,X,e),a(t,u,e),a(t,E,e),k(g,t,e),a(t,G,e),a(t,h,e),a(t,H,e),k(f,t,e),a(t,x,e),a(t,b,e),a(t,S,e),a(t,M,e),a(t,D,e),a(t,o,e),a(t,F,e),k(w,t,e),a(t,C,e),a(t,T,e),L=!0},p:et,i(t){L||(B(r.$$.fragment,t),B(d.$$.fragment,t),B(g.$$.fragment,t),B(f.$$.fragment,t),B(w.$$.fragment,t),L=!0)},o(t){v(r.$$.fragment,t),v(d.$$.fragment,t),v(g.$$.fragment,t),v(f.$$.fragment,t),v(w.$$.fragment,t),L=!1},d(t){t&&(s(U),s(j),s(W),s(I),s(Q),s(c),s(X),s(u),s(E),s(G),s(h),s(H),s(x),s(b),s(S),s(M),s(D),s(o),s(F),s(C),s(T)),s(n),Z(r,t),Z(d,t),Z(g,t),Z(f,t),Z(w,t)}}}const dt='{"title":"Text-guided depth-to-image 생성","local":"text-guided-depth-to-image-생성","sections":[],"depth":1}';function ct(R){return st(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Mt extends at{constructor(n){super(),lt(this,n,ct,rt,O,{})}}export{Mt as component};
