import{s as rt,a as mt,n as ut,o as ct}from"../chunks/scheduler.23542ac5.js";import{S as dt,i as ft,e as l,s as i,c as k,h as bt,a as o,d as n,b as s,f as A,g as _,j as Z,k as $,l as gt,m as a,n as W,t as x,o as j,p as v}from"../chunks/index.9b1f405b.js";import{C as ht,H as yt,E as wt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ee52513e.js";import{C as O}from"../chunks/CodeBlock.94dab919.js";import{D as Mt}from"../chunks/DocNotebookDropdown.68a629d2.js";function Jt(tt){let r,C,G,B,u,S,c,R,d,E,f,et='<code>StableDiffusionInpaintPipeline</code>은 마스크와 텍스트 프롬프트를 제공하여 이미지의 특정 부분을 편집할 수 있도록 합니다. 이 기능은 인페인팅 작업을 위해 특별히 훈련된 <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow"><code>runwayml/stable-diffusion-inpainting</code></a>과 같은 Stable Diffusion 버전을 사용합니다.',V,b,nt="먼저 <code>StableDiffusionInpaintPipeline</code> 인스턴스를 불러옵니다:",X,g,F,h,at="나중에 교체할 강아지 이미지와 마스크를 다운로드하세요:",H,y,Q,w,it="이제 마스크를 다른 것으로 교체하라는 프롬프트를 만들 수 있습니다:",Y,M,N,J,st='<thead><tr><th align="center"><code>image</code></th> <th align="center"><code>mask_image</code></th> <th align="center"><code>prompt</code></th> <th align="right">output</th></tr></thead> <tbody><tr><td align="center"><img src="https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png" alt="drawing" width="250"/></td> <td align="center"><img src="https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png" alt="drawing" width="250"/></td> <td align="center"><strong><em>Face of a yellow cat, high resolution, sitting on a park bench</em></strong></td> <td align="right"><img src="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint/yellow_cat_sitting_on_a_park_bench.png" alt="drawing" width="250"/></td></tr></tbody>',z,m,lt="<p>이전의 실험적인 인페인팅 구현에서는 품질이 낮은 다른 프로세스를 사용했습니다. 이전 버전과의 호환성을 보장하기 위해 새 모델이 포함되지 않은 사전학습된 파이프라인을 불러오면 이전 인페인팅 방법이 계속 적용됩니다.</p>",L,T,ot="아래 Space에서 이미지 인페인팅을 직접 해보세요!",P,p,pt,q,U,D,I,K;return u=new ht({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new Mt({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/ko/inpaint.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/inpaint.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/inpaint.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/inpaint.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/inpaint.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/inpaint.ipynb"}]}}),d=new yt({props:{title:"Text-guided 이미지 인페인팅(inpainting)",local:"text-guided-이미지-인페인팅inpainting",headingTag:"h1"}}),g=new O({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW5wYWludFBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnBhaW50UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi1pbnBhaW50aW5nJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQXBpcGVsaW5lJTIwJTNEJTIwcGlwZWxpbmUudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> PIL
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

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

pipeline = StableDiffusionInpaintPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>,
    torch_dtype=torch.float16,
)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),y=new O({props:{code:"ZGVmJTIwZG93bmxvYWRfaW1hZ2UodXJsKSUzQSUwQSUyMCUyMCUyMCUyMHJlc3BvbnNlJTIwJTNEJTIwcmVxdWVzdHMuZ2V0KHVybCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBQSUwuSW1hZ2Uub3BlbihCeXRlc0lPKHJlc3BvbnNlLmNvbnRlbnQpKS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGQ29tcFZpcyUyRmxhdGVudC1kaWZmdXNpb24lMkZtYWluJTJGZGF0YSUyRmlucGFpbnRpbmdfZXhhbXBsZXMlMkZvdmVydHVyZS1jcmVhdGlvbnMtNXNJNmZRZ1lJdW8ucG5nJTIyJTBBbWFza191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZDb21wVmlzJTJGbGF0ZW50LWRpZmZ1c2lvbiUyRm1haW4lMkZkYXRhJTJGaW5wYWludGluZ19leGFtcGxlcyUyRm92ZXJ0dXJlLWNyZWF0aW9ucy01c0k2ZlFnWUl1b19tYXNrLnBuZyUyMiUwQSUwQWluaXRfaW1hZ2UlMjAlM0QlMjBkb3dubG9hZF9pbWFnZShpbWdfdXJsKS5yZXNpemUoKDUxMiUyQyUyMDUxMikpJTBBbWFza19pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKG1hc2tfdXJsKS5yZXNpemUoKDUxMiUyQyUyMDUxMikp",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
    response = requests.get(url)
    <span class="hljs-keyword">return</span> PIL.Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)


img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png&quot;</span>

init_image = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
mask_image = download_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))`,wrap:!1}}),M=new O({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyRmFjZSUyMG9mJTIwYSUyMHllbGxvdyUyMGNhdCUyQyUyMGhpZ2glMjByZXNvbHV0aW9uJTJDJTIwc2l0dGluZyUyMG9uJTIwYSUyMHBhcmslMjBiZW5jaCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRGluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTNEbWFza19pbWFnZSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`prompt = <span class="hljs-string">&quot;Face of a yellow cat, high resolution, sitting on a park bench&quot;</span>
image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]`,wrap:!1}}),U=new wt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/inpaint.md"}}),{c(){r=l("meta"),C=i(),G=l("p"),B=i(),k(u.$$.fragment),S=i(),k(c.$$.fragment),R=i(),k(d.$$.fragment),E=i(),f=l("p"),f.innerHTML=et,V=i(),b=l("p"),b.innerHTML=nt,X=i(),k(g.$$.fragment),F=i(),h=l("p"),h.textContent=at,H=i(),k(y.$$.fragment),Q=i(),w=l("p"),w.textContent=it,Y=i(),k(M.$$.fragment),N=i(),J=l("table"),J.innerHTML=st,z=i(),m=l("blockquote"),m.innerHTML=lt,L=i(),T=l("p"),T.textContent=ot,P=i(),p=l("iframe"),q=i(),k(U.$$.fragment),D=i(),I=l("p"),this.h()},l(t){const e=bt("svelte-u9bgzb",document.head);r=o(e,"META",{name:!0,content:!0}),e.forEach(n),C=s(t),G=o(t,"P",{}),A(G).forEach(n),B=s(t),_(u.$$.fragment,t),S=s(t),_(c.$$.fragment,t),R=s(t),_(d.$$.fragment,t),E=s(t),f=o(t,"P",{"data-svelte-h":!0}),Z(f)!=="svelte-17szr27"&&(f.innerHTML=et),V=s(t),b=o(t,"P",{"data-svelte-h":!0}),Z(b)!=="svelte-10ktvd"&&(b.innerHTML=nt),X=s(t),_(g.$$.fragment,t),F=s(t),h=o(t,"P",{"data-svelte-h":!0}),Z(h)!=="svelte-ut8yeo"&&(h.textContent=at),H=s(t),_(y.$$.fragment,t),Q=s(t),w=o(t,"P",{"data-svelte-h":!0}),Z(w)!=="svelte-fotoc0"&&(w.textContent=it),Y=s(t),_(M.$$.fragment,t),N=s(t),J=o(t,"TABLE",{"data-svelte-h":!0}),Z(J)!=="svelte-1ysshya"&&(J.innerHTML=st),z=s(t),m=o(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),Z(m)!=="svelte-gw231x"&&(m.innerHTML=lt),L=s(t),T=o(t,"P",{"data-svelte-h":!0}),Z(T)!=="svelte-1he2wz8"&&(T.textContent=ot),P=s(t),p=o(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),A(p).forEach(n),q=s(t),_(U.$$.fragment,t),D=s(t),I=o(t,"P",{}),A(I).forEach(n),this.h()},h(){$(r,"name","hf:doc:metadata"),$(r,"content",Tt),$(m,"class","warning"),mt(p.src,pt="https://runwayml-stable-diffusion-inpainting.hf.space")||$(p,"src",pt),$(p,"frameborder","0"),$(p,"width","850"),$(p,"height","500")},m(t,e){gt(document.head,r),a(t,C,e),a(t,G,e),a(t,B,e),W(u,t,e),a(t,S,e),W(c,t,e),a(t,R,e),W(d,t,e),a(t,E,e),a(t,f,e),a(t,V,e),a(t,b,e),a(t,X,e),W(g,t,e),a(t,F,e),a(t,h,e),a(t,H,e),W(y,t,e),a(t,Q,e),a(t,w,e),a(t,Y,e),W(M,t,e),a(t,N,e),a(t,J,e),a(t,z,e),a(t,m,e),a(t,L,e),a(t,T,e),a(t,P,e),a(t,p,e),a(t,q,e),W(U,t,e),a(t,D,e),a(t,I,e),K=!0},p:ut,i(t){K||(x(u.$$.fragment,t),x(c.$$.fragment,t),x(d.$$.fragment,t),x(g.$$.fragment,t),x(y.$$.fragment,t),x(M.$$.fragment,t),x(U.$$.fragment,t),K=!0)},o(t){j(u.$$.fragment,t),j(c.$$.fragment,t),j(d.$$.fragment,t),j(g.$$.fragment,t),j(y.$$.fragment,t),j(M.$$.fragment,t),j(U.$$.fragment,t),K=!1},d(t){t&&(n(C),n(G),n(B),n(S),n(R),n(E),n(f),n(V),n(b),n(X),n(F),n(h),n(H),n(Q),n(w),n(Y),n(N),n(J),n(z),n(m),n(L),n(T),n(P),n(p),n(q),n(D),n(I)),n(r),v(u,t),v(c,t),v(d,t),v(g,t),v(y,t),v(M,t),v(U,t)}}}const Tt='{"title":"Text-guided 이미지 인페인팅(inpainting)","local":"text-guided-이미지-인페인팅inpainting","sections":[],"depth":1}';function Ut(tt){return ct(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xt extends dt{constructor(r){super(),ft(this,r,Ut,Jt,rt,{})}}export{xt as component};
