import{s as oe,n as pe,o as me}from"../chunks/scheduler.23542ac5.js";import{S as fe,i as de,e as a,s,c as U,h as ce,a as o,d as n,b as i,f as se,g as T,j as v,k as ie,l as ue,m as l,n as w,t as G,o as W,p as j}from"../chunks/index.9b1f405b.js";import{C as re,H as ae,E as be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.1d640393.js";import{C as Y}from"../chunks/CodeBlock.e0f68650.js";function Me(I){let p,J,x,V,m,B,f,L,d,A="많은 diffusion 시스템은 같은 구성 요소들을 공유하므로 한 작업에 대해 사전학습된 모델을 완전히 다른 작업에 적용할 수 있습니다.",k,c,O="이 인페인팅을 위한 가이드는 사전학습된 <code>UNet2DConditionModel</code>의 아키텍처를 초기화하고 수정하여 사전학습된 text-to-image 모델을 어떻게 인페인팅에 적용하는지를 알려줄 것입니다.",N,u,E,r,K='<code>UNet2DConditionModel</code>은 <a href="https://huggingface.co/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel.in_channels" rel="nofollow">input sample</a>에서 4개의 채널을 기본적으로 허용합니다. 예를 들어,  <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow"><code>stable-diffusion-v1-5/stable-diffusion-v1-5</code></a>와 같은 사전학습된 text-to-image 모델을 불러오고 <code>in_channels</code>의 수를 확인합니다:',F,b,R,M,ee='인페인팅은 입력 샘플에 9개의 채널이 필요합니다. <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow"><code>runwayml/stable-diffusion-inpainting</code></a>와 같은 사전학습된 인페인팅 모델에서 이 값을 확인할 수 있습니다:',S,y,P,$,te="인페인팅에 대한 text-to-image 모델을 적용하기 위해, <code>in_channels</code> 수를 4에서 9로 수정해야 할 것입니다.",Q,h,ne="사전학습된 text-to-image 모델의 가중치와 <code>UNet2DConditionModel</code>을 초기화하고 <code>in_channels</code>를 9로 수정해 주세요. <code>in_channels</code>의 수를 수정하면 크기가 달라지기 때문에 크기가 안 맞는 오류를 피하기 위해 <code>ignore_mismatched_sizes=True</code> 및 <code>low_cpu_mem_usage=False</code>를 설정해야 합니다.",X,Z,H,_,le="Text-to-image 모델로부터 다른 구성 요소의 사전학습된 가중치는 체크포인트로부터 초기화되지만 <code>unet</code>의 입력 채널 가중치 (<code>conv_in.weight</code>)는 랜덤하게 초기화됩니다. 그렇지 않으면 모델이 노이즈를 리턴하기 때문에 인페인팅의 모델을 파인튜닝 할 때 중요합니다.",z,g,D,C,q;return m=new re({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new ae({props:{title:"새로운 작업에 대한 모델을 적용하기",local:"새로운-작업에-대한-모델을-적용하기",headingTag:"h1"}}),u=new ae({props:{title:"UNet2DConditionModel 파라미터 구성",local:"unet2dconditionmodel-파라미터-구성",headingTag:"h2"}}),b=new Y({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyKSUwQXBpcGVsaW5lLnVuZXQuY29uZmlnJTVCJTIyaW5fY2hhbm5lbHMlMjIlNUQlMEE0",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>)
pipeline.unet.config[<span class="hljs-string">&quot;in_channels&quot;</span>]
<span class="hljs-number">4</span>`,wrap:!1}}),y=new Y({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLWlucGFpbnRpbmclMjIpJTBBcGlwZWxpbmUudW5ldC5jb25maWclNUIlMjJpbl9jaGFubmVscyUyMiU1RCUwQTk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>)
pipeline.unet.config[<span class="hljs-string">&quot;in_channels&quot;</span>]
<span class="hljs-number">9</span>`,wrap:!1}}),Z=new Y({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEF1bmV0JTIwJTNEJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMiUyQyUyMGluX2NoYW5uZWxzJTNEOSUyQyUyMGxvd19jcHVfbWVtX3VzYWdlJTNERmFsc2UlMkMlMjBpZ25vcmVfbWlzbWF0Y2hlZF9zaXplcyUzRFRydWUlMEEp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel

model_id = <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
unet = UNet2DConditionModel.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, in_channels=<span class="hljs-number">9</span>, low_cpu_mem_usage=<span class="hljs-literal">False</span>, ignore_mismatched_sizes=<span class="hljs-literal">True</span>
)`,wrap:!1}}),g=new be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/training/adapt_a_model.md"}}),{c(){p=a("meta"),J=s(),x=a("p"),V=s(),U(m.$$.fragment),B=s(),U(f.$$.fragment),L=s(),d=a("p"),d.textContent=A,k=s(),c=a("p"),c.innerHTML=O,N=s(),U(u.$$.fragment),E=s(),r=a("p"),r.innerHTML=K,F=s(),U(b.$$.fragment),R=s(),M=a("p"),M.innerHTML=ee,S=s(),U(y.$$.fragment),P=s(),$=a("p"),$.innerHTML=te,Q=s(),h=a("p"),h.innerHTML=ne,X=s(),U(Z.$$.fragment),H=s(),_=a("p"),_.innerHTML=le,z=s(),U(g.$$.fragment),D=s(),C=a("p"),this.h()},l(e){const t=ce("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(n),J=i(e),x=o(e,"P",{}),se(x).forEach(n),V=i(e),T(m.$$.fragment,e),B=i(e),T(f.$$.fragment,e),L=i(e),d=o(e,"P",{"data-svelte-h":!0}),v(d)!=="svelte-obt1bb"&&(d.textContent=A),k=i(e),c=o(e,"P",{"data-svelte-h":!0}),v(c)!=="svelte-1bn5mvh"&&(c.innerHTML=O),N=i(e),T(u.$$.fragment,e),E=i(e),r=o(e,"P",{"data-svelte-h":!0}),v(r)!=="svelte-1ie49sx"&&(r.innerHTML=K),F=i(e),T(b.$$.fragment,e),R=i(e),M=o(e,"P",{"data-svelte-h":!0}),v(M)!=="svelte-n1t961"&&(M.innerHTML=ee),S=i(e),T(y.$$.fragment,e),P=i(e),$=o(e,"P",{"data-svelte-h":!0}),v($)!=="svelte-1nkn0wh"&&($.innerHTML=te),Q=i(e),h=o(e,"P",{"data-svelte-h":!0}),v(h)!=="svelte-oj0rfs"&&(h.innerHTML=ne),X=i(e),T(Z.$$.fragment,e),H=i(e),_=o(e,"P",{"data-svelte-h":!0}),v(_)!=="svelte-rfmg1f"&&(_.innerHTML=le),z=i(e),T(g.$$.fragment,e),D=i(e),C=o(e,"P",{}),se(C).forEach(n),this.h()},h(){ie(p,"name","hf:doc:metadata"),ie(p,"content",ye)},m(e,t){ue(document.head,p),l(e,J,t),l(e,x,t),l(e,V,t),w(m,e,t),l(e,B,t),w(f,e,t),l(e,L,t),l(e,d,t),l(e,k,t),l(e,c,t),l(e,N,t),w(u,e,t),l(e,E,t),l(e,r,t),l(e,F,t),w(b,e,t),l(e,R,t),l(e,M,t),l(e,S,t),w(y,e,t),l(e,P,t),l(e,$,t),l(e,Q,t),l(e,h,t),l(e,X,t),w(Z,e,t),l(e,H,t),l(e,_,t),l(e,z,t),w(g,e,t),l(e,D,t),l(e,C,t),q=!0},p:pe,i(e){q||(G(m.$$.fragment,e),G(f.$$.fragment,e),G(u.$$.fragment,e),G(b.$$.fragment,e),G(y.$$.fragment,e),G(Z.$$.fragment,e),G(g.$$.fragment,e),q=!0)},o(e){W(m.$$.fragment,e),W(f.$$.fragment,e),W(u.$$.fragment,e),W(b.$$.fragment,e),W(y.$$.fragment,e),W(Z.$$.fragment,e),W(g.$$.fragment,e),q=!1},d(e){e&&(n(J),n(x),n(V),n(B),n(L),n(d),n(k),n(c),n(N),n(E),n(r),n(F),n(R),n(M),n(S),n(P),n($),n(Q),n(h),n(X),n(H),n(_),n(z),n(D),n(C)),n(p),j(m,e),j(f,e),j(u,e),j(b,e),j(y,e),j(Z,e),j(g,e)}}}const ye='{"title":"새로운 작업에 대한 모델을 적용하기","local":"새로운-작업에-대한-모델을-적용하기","sections":[{"title":"UNet2DConditionModel 파라미터 구성","local":"unet2dconditionmodel-파라미터-구성","sections":[],"depth":2}],"depth":1}';function $e(I){return me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends fe{constructor(p){super(),de(this,p,$e,Me,oe,{})}}export{Ue as component};
