import{s as ot,B as pt,o as rt,n as mt}from"../chunks/scheduler.94020406.js";import{S as ut,i as ct,g as p,s as i,r as _,E as dt,h as r,f as n,c as l,j as K,u as $,x as G,k as x,y as ft,a,v as Z,d as W,t as j,w as v}from"../chunks/index.a08c8d92.js";import{T as bt}from"../chunks/Tip.3b0aeee8.js";import{C as A}from"../chunks/CodeBlock.f1fae7de.js";import{D as ht}from"../chunks/DocNotebookDropdown.a1753374.js";import{H as gt,E as wt}from"../chunks/index.b61e04a5.js";function yt(B){let s,c="이전의 실험적인 인페인팅 구현에서는 품질이 낮은 다른 프로세스를 사용했습니다. 이전 버전과의 호환성을 보장하기 위해 새 모델이 포함되지 않은 사전학습된 파이프라인을 불러오면 이전 인페인팅 방법이 계속 적용됩니다.";return{c(){s=p("p"),s.textContent=c},l(o){s=r(o,"P",{"data-svelte-h":!0}),G(s)!=="svelte-aloub7"&&(s.textContent=c)},m(o,I){a(o,s,I)},p:mt,d(o){o&&n(s)}}}function Mt(B){let s,c,o,I,d,R,f,S,b,O='<code>StableDiffusionInpaintPipeline</code>은 마스크와 텍스트 프롬프트를 제공하여 이미지의 특정 부분을 편집할 수 있도록 합니다. 이 기능은 인페인팅 작업을 위해 특별히 훈련된 <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow"><code>runwayml/stable-diffusion-inpainting</code></a>과 같은 Stable Diffusion 버전을 사용합니다.',E,h,tt="먼저 <code>StableDiffusionInpaintPipeline</code> 인스턴스를 불러옵니다:",V,g,X,w,et="나중에 교체할 강아지 이미지와 마스크를 다운로드하세요:",F,y,Q,M,nt="이제 마스크를 다른 것으로 교체하라는 프롬프트를 만들 수 있습니다:",H,J,Y,T,at='<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>',N,u,z,U,st="아래 Space에서 이미지 인페인팅을 직접 해보세요!",P,m,it,D,k,q,C,L;return d=new gt({props:{title:"Text-guided 이미지 인페인팅(inpainting)",local:"text-guided-이미지-인페인팅inpainting",headingTag:"h1"}}),f=new ht({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/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"}]}}),g=new A({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 A({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}}),J=new A({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 bt({props:{warning:!0,$$slots:{default:[yt]},$$scope:{ctx:B}}}),k=new wt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/inpaint.md"}}),{c(){s=p("meta"),c=i(),o=p("p"),I=i(),_(d.$$.fragment),R=i(),_(f.$$.fragment),S=i(),b=p("p"),b.innerHTML=O,E=i(),h=p("p"),h.innerHTML=tt,V=i(),_(g.$$.fragment),X=i(),w=p("p"),w.textContent=et,F=i(),_(y.$$.fragment),Q=i(),M=p("p"),M.textContent=nt,H=i(),_(J.$$.fragment),Y=i(),T=p("table"),T.innerHTML=at,N=i(),_(u.$$.fragment),z=i(),U=p("p"),U.textContent=st,P=i(),m=p("iframe"),D=i(),_(k.$$.fragment),q=i(),C=p("p"),this.h()},l(t){const e=dt("svelte-u9bgzb",document.head);s=r(e,"META",{name:!0,content:!0}),e.forEach(n),c=l(t),o=r(t,"P",{}),K(o).forEach(n),I=l(t),$(d.$$.fragment,t),R=l(t),$(f.$$.fragment,t),S=l(t),b=r(t,"P",{"data-svelte-h":!0}),G(b)!=="svelte-17szr27"&&(b.innerHTML=O),E=l(t),h=r(t,"P",{"data-svelte-h":!0}),G(h)!=="svelte-10ktvd"&&(h.innerHTML=tt),V=l(t),$(g.$$.fragment,t),X=l(t),w=r(t,"P",{"data-svelte-h":!0}),G(w)!=="svelte-ut8yeo"&&(w.textContent=et),F=l(t),$(y.$$.fragment,t),Q=l(t),M=r(t,"P",{"data-svelte-h":!0}),G(M)!=="svelte-fotoc0"&&(M.textContent=nt),H=l(t),$(J.$$.fragment,t),Y=l(t),T=r(t,"TABLE",{"data-svelte-h":!0}),G(T)!=="svelte-1ysshya"&&(T.innerHTML=at),N=l(t),$(u.$$.fragment,t),z=l(t),U=r(t,"P",{"data-svelte-h":!0}),G(U)!=="svelte-1he2wz8"&&(U.textContent=st),P=l(t),m=r(t,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),K(m).forEach(n),D=l(t),$(k.$$.fragment,t),q=l(t),C=r(t,"P",{}),K(C).forEach(n),this.h()},h(){x(s,"name","hf:doc:metadata"),x(s,"content",Jt),pt(m.src,it="https://runwayml-stable-diffusion-inpainting.hf.space")||x(m,"src",it),x(m,"frameborder","0"),x(m,"width","850"),x(m,"height","500")},m(t,e){ft(document.head,s),a(t,c,e),a(t,o,e),a(t,I,e),Z(d,t,e),a(t,R,e),Z(f,t,e),a(t,S,e),a(t,b,e),a(t,E,e),a(t,h,e),a(t,V,e),Z(g,t,e),a(t,X,e),a(t,w,e),a(t,F,e),Z(y,t,e),a(t,Q,e),a(t,M,e),a(t,H,e),Z(J,t,e),a(t,Y,e),a(t,T,e),a(t,N,e),Z(u,t,e),a(t,z,e),a(t,U,e),a(t,P,e),a(t,m,e),a(t,D,e),Z(k,t,e),a(t,q,e),a(t,C,e),L=!0},p(t,[e]){const lt={};e&2&&(lt.$$scope={dirty:e,ctx:t}),u.$set(lt)},i(t){L||(W(d.$$.fragment,t),W(f.$$.fragment,t),W(g.$$.fragment,t),W(y.$$.fragment,t),W(J.$$.fragment,t),W(u.$$.fragment,t),W(k.$$.fragment,t),L=!0)},o(t){j(d.$$.fragment,t),j(f.$$.fragment,t),j(g.$$.fragment,t),j(y.$$.fragment,t),j(J.$$.fragment,t),j(u.$$.fragment,t),j(k.$$.fragment,t),L=!1},d(t){t&&(n(c),n(o),n(I),n(R),n(S),n(b),n(E),n(h),n(V),n(X),n(w),n(F),n(Q),n(M),n(H),n(Y),n(T),n(N),n(z),n(U),n(P),n(m),n(D),n(q),n(C)),n(s),v(d,t),v(f,t),v(g,t),v(y,t),v(J,t),v(u,t),v(k,t)}}}const Jt='{"title":"Text-guided 이미지 인페인팅(inpainting)","local":"text-guided-이미지-인페인팅inpainting","sections":[],"depth":1}';function Tt(B){return rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends ut{constructor(s){super(),ct(this,s,Tt,Mt,ot,{})}}export{jt as component};
