import{s as at,n as st,o as it}from"../chunks/scheduler.23542ac5.js";import{S as lt,i as ot,e as o,s,c as k,h as pt,a as p,d as n,b as i,f as nt,g as J,j as W,k as L,l as mt,m as a,n as Z,t as _,o as $,p as T}from"../chunks/index.9b1f405b.js";import{C as rt,H as ut,E as ct}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.cf8449cd.js";import{C as P}from"../chunks/CodeBlock.6a4e8f39.js";import{D as dt}from"../chunks/DocNotebookDropdown.68a629d2.js";function ft(q){let l,x,j,C,r,G,u,B,c,S,d,D='<code>StableDiffusionInpaintPipeline</code>은 마스크와 텍스트 프롬프트를 제공하여 이미지의 특정 부분을 편집할 수 있도록 합니다. 이 기능은 인페인팅 작업을 위해 특별히 훈련된 <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-inpainting" rel="nofollow"><code>stable-diffusion-v1-5/stable-diffusion-inpainting</code></a>과 같은 Stable Diffusion 버전을 사용합니다.',I,f,K="먼저 <code>StableDiffusionInpaintPipeline</code> 인스턴스를 불러옵니다:",X,b,R,g,A="나중에 교체할 강아지 이미지와 마스크를 다운로드하세요:",E,h,N,y,O="이제 마스크를 다른 것으로 교체하라는 프롬프트를 만들 수 있습니다:",Q,M,V,w,tt='<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>',H,m,et="<p>이전의 실험적인 인페인팅 구현에서는 품질이 낮은 다른 프로세스를 사용했습니다. 이전 버전과의 호환성을 보장하기 위해 새 모델이 포함되지 않은 사전학습된 파이프라인을 불러오면 이전 인페인팅 방법이 계속 적용됩니다.</p>",F,U,Y,v,z;return r=new rt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new dt({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"}]}}),c=new ut({props:{title:"Text-guided 이미지 인페인팅(inpainting)",local:"text-guided-이미지-인페인팅inpainting",headingTag:"h1"}}),b=new P({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW5wYWludFBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnBhaW50UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSklMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lLnRvKCUyMmN1ZGElMjIp",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;stable-diffusion-v1-5/stable-diffusion-inpainting&quot;</span>,
    torch_dtype=torch.float16,
)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),h=new P({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 P({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 ct({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/inpaint.md"}}),{c(){l=o("meta"),x=s(),j=o("p"),C=s(),k(r.$$.fragment),G=s(),k(u.$$.fragment),B=s(),k(c.$$.fragment),S=s(),d=o("p"),d.innerHTML=D,I=s(),f=o("p"),f.innerHTML=K,X=s(),k(b.$$.fragment),R=s(),g=o("p"),g.textContent=A,E=s(),k(h.$$.fragment),N=s(),y=o("p"),y.textContent=O,Q=s(),k(M.$$.fragment),V=s(),w=o("table"),w.innerHTML=tt,H=s(),m=o("blockquote"),m.innerHTML=et,F=s(),k(U.$$.fragment),Y=s(),v=o("p"),this.h()},l(t){const e=pt("svelte-u9bgzb",document.head);l=p(e,"META",{name:!0,content:!0}),e.forEach(n),x=i(t),j=p(t,"P",{}),nt(j).forEach(n),C=i(t),J(r.$$.fragment,t),G=i(t),J(u.$$.fragment,t),B=i(t),J(c.$$.fragment,t),S=i(t),d=p(t,"P",{"data-svelte-h":!0}),W(d)!=="svelte-1oz3pvj"&&(d.innerHTML=D),I=i(t),f=p(t,"P",{"data-svelte-h":!0}),W(f)!=="svelte-10ktvd"&&(f.innerHTML=K),X=i(t),J(b.$$.fragment,t),R=i(t),g=p(t,"P",{"data-svelte-h":!0}),W(g)!=="svelte-ut8yeo"&&(g.textContent=A),E=i(t),J(h.$$.fragment,t),N=i(t),y=p(t,"P",{"data-svelte-h":!0}),W(y)!=="svelte-fotoc0"&&(y.textContent=O),Q=i(t),J(M.$$.fragment,t),V=i(t),w=p(t,"TABLE",{"data-svelte-h":!0}),W(w)!=="svelte-1ysshya"&&(w.innerHTML=tt),H=i(t),m=p(t,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),W(m)!=="svelte-gw231x"&&(m.innerHTML=et),F=i(t),J(U.$$.fragment,t),Y=i(t),v=p(t,"P",{}),nt(v).forEach(n),this.h()},h(){L(l,"name","hf:doc:metadata"),L(l,"content",bt),L(m,"class","warning")},m(t,e){mt(document.head,l),a(t,x,e),a(t,j,e),a(t,C,e),Z(r,t,e),a(t,G,e),Z(u,t,e),a(t,B,e),Z(c,t,e),a(t,S,e),a(t,d,e),a(t,I,e),a(t,f,e),a(t,X,e),Z(b,t,e),a(t,R,e),a(t,g,e),a(t,E,e),Z(h,t,e),a(t,N,e),a(t,y,e),a(t,Q,e),Z(M,t,e),a(t,V,e),a(t,w,e),a(t,H,e),a(t,m,e),a(t,F,e),Z(U,t,e),a(t,Y,e),a(t,v,e),z=!0},p:st,i(t){z||(_(r.$$.fragment,t),_(u.$$.fragment,t),_(c.$$.fragment,t),_(b.$$.fragment,t),_(h.$$.fragment,t),_(M.$$.fragment,t),_(U.$$.fragment,t),z=!0)},o(t){$(r.$$.fragment,t),$(u.$$.fragment,t),$(c.$$.fragment,t),$(b.$$.fragment,t),$(h.$$.fragment,t),$(M.$$.fragment,t),$(U.$$.fragment,t),z=!1},d(t){t&&(n(x),n(j),n(C),n(G),n(B),n(S),n(d),n(I),n(f),n(X),n(R),n(g),n(E),n(N),n(y),n(Q),n(V),n(w),n(H),n(m),n(F),n(Y),n(v)),n(l),T(r,t),T(u,t),T(c,t),T(b,t),T(h,t),T(M,t),T(U,t)}}}const bt='{"title":"Text-guided 이미지 인페인팅(inpainting)","local":"text-guided-이미지-인페인팅inpainting","sections":[],"depth":1}';function gt(q){return it(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class kt extends lt{constructor(l){super(),ot(this,l,gt,ft,at,{})}}export{kt as component};
