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