import{s as le,n as se,o as ae}from"../chunks/scheduler.6e0d5ff7.js";import{S as ie,i as oe,g as i,s,r as $,E as pe,h as o,f as n,c as a,j as ee,u as j,x as _,k as te,y as me,a as l,v as g,d as W,t as G,w as J}from"../chunks/index.d7c1b260.js";import{C as q}from"../chunks/CodeBlock.09a08494.js";import{H as ne}from"../chunks/Heading.30a009b0.js";function de(F){let p,v,T,B,m,C,d,I="많은 diffusion 시스템은 같은 구성 요소들을 공유하므로 한 작업에 대해 사전학습된 모델을 완전히 다른 작업에 적용할 수 있습니다.",x,c,Y="이 인페인팅을 위한 가이드는 사전학습된 <code>UNet2DConditionModel</code>의 아키텍처를 초기화하고 수정하여 사전학습된 text-to-image 모델을 어떻게 인페인팅에 적용하는지를 알려줄 것입니다.",k,f,N,u,z='<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/runwayml/stable-diffusion-v1-5" rel="nofollow"><code>runwayml/stable-diffusion-v1-5</code></a>와 같은 사전학습된 text-to-image 모델을 불러오고 <code>in_channels</code>의 수를 확인합니다:',V,r,X,b,E='인페인팅은 입력 샘플에 9개의 채널이 필요합니다. <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow"><code>runwayml/stable-diffusion-inpainting</code></a>와 같은 사전학습된 인페인팅 모델에서 이 값을 확인할 수 있습니다:',Q,M,R,y,A="인페인팅에 대한 text-to-image 모델을 적용하기 위해, <code>in_channels</code> 수를 4에서 9로 수정해야 할 것입니다.",P,h,O="사전학습된 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>를 설정해야 합니다.",S,w,H,Z,K="Text-to-image 모델로부터 다른 구성 요소의 사전학습된 가중치는 체크포인트로부터 초기화되지만 <code>unet</code>의 입력 채널 가중치 (<code>conv_in.weight</code>)는 랜덤하게 초기화됩니다. 그렇지 않으면 모델이 노이즈를 리턴하기 때문에 인페인팅의 모델을 파인튜닝 할 때 중요합니다.",L,U,D;return m=new ne({props:{title:"새로운 작업에 대한 모델을 적용하기",local:"새로운-작업에-대한-모델을-적용하기",headingTag:"h1"}}),f=new ne({props:{title:"UNet2DConditionModel 파라미터 구성",local:"unet2dconditionmodel-파라미터-구성",headingTag:"h2"}}),r=new q({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIpJTBBcGlwZWxpbmUudW5ldC5jb25maWclNUIlMjJpbl9jaGFubmVscyUyMiU1RCUwQTQ=",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-v1-5&quot;</span>)
pipeline.unet.config[<span class="hljs-string">&quot;in_channels&quot;</span>]
<span class="hljs-number">4</span>`,wrap:!1}}),M=new q({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}}),w=new q({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQXVuZXQlMjAlM0QlMjBVTmV0MkRDb25kaXRpb25Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwaW5fY2hhbm5lbHMlM0Q5JTJDJTIwbG93X2NwdV9tZW1fdXNhZ2UlM0RGYWxzZSUyQyUyMGlnbm9yZV9taXNtYXRjaGVkX3NpemVzJTNEVHJ1ZSUwQSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel

model_id = <span class="hljs-string">&quot;runwayml/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}}),{c(){p=i("meta"),v=s(),T=i("p"),B=s(),$(m.$$.fragment),C=s(),d=i("p"),d.textContent=I,x=s(),c=i("p"),c.innerHTML=Y,k=s(),$(f.$$.fragment),N=s(),u=i("p"),u.innerHTML=z,V=s(),$(r.$$.fragment),X=s(),b=i("p"),b.innerHTML=E,Q=s(),$(M.$$.fragment),R=s(),y=i("p"),y.innerHTML=A,P=s(),h=i("p"),h.innerHTML=O,S=s(),$(w.$$.fragment),H=s(),Z=i("p"),Z.innerHTML=K,L=s(),U=i("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(n),v=a(e),T=o(e,"P",{}),ee(T).forEach(n),B=a(e),j(m.$$.fragment,e),C=a(e),d=o(e,"P",{"data-svelte-h":!0}),_(d)!=="svelte-obt1bb"&&(d.textContent=I),x=a(e),c=o(e,"P",{"data-svelte-h":!0}),_(c)!=="svelte-1bn5mvh"&&(c.innerHTML=Y),k=a(e),j(f.$$.fragment,e),N=a(e),u=o(e,"P",{"data-svelte-h":!0}),_(u)!=="svelte-pq1ajp"&&(u.innerHTML=z),V=a(e),j(r.$$.fragment,e),X=a(e),b=o(e,"P",{"data-svelte-h":!0}),_(b)!=="svelte-n1t961"&&(b.innerHTML=E),Q=a(e),j(M.$$.fragment,e),R=a(e),y=o(e,"P",{"data-svelte-h":!0}),_(y)!=="svelte-1nkn0wh"&&(y.innerHTML=A),P=a(e),h=o(e,"P",{"data-svelte-h":!0}),_(h)!=="svelte-oj0rfs"&&(h.innerHTML=O),S=a(e),j(w.$$.fragment,e),H=a(e),Z=o(e,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-rfmg1f"&&(Z.innerHTML=K),L=a(e),U=o(e,"P",{}),ee(U).forEach(n),this.h()},h(){te(p,"name","hf:doc:metadata"),te(p,"content",ce)},m(e,t){me(document.head,p),l(e,v,t),l(e,T,t),l(e,B,t),g(m,e,t),l(e,C,t),l(e,d,t),l(e,x,t),l(e,c,t),l(e,k,t),g(f,e,t),l(e,N,t),l(e,u,t),l(e,V,t),g(r,e,t),l(e,X,t),l(e,b,t),l(e,Q,t),g(M,e,t),l(e,R,t),l(e,y,t),l(e,P,t),l(e,h,t),l(e,S,t),g(w,e,t),l(e,H,t),l(e,Z,t),l(e,L,t),l(e,U,t),D=!0},p:se,i(e){D||(W(m.$$.fragment,e),W(f.$$.fragment,e),W(r.$$.fragment,e),W(M.$$.fragment,e),W(w.$$.fragment,e),D=!0)},o(e){G(m.$$.fragment,e),G(f.$$.fragment,e),G(r.$$.fragment,e),G(M.$$.fragment,e),G(w.$$.fragment,e),D=!1},d(e){e&&(n(v),n(T),n(B),n(C),n(d),n(x),n(c),n(k),n(N),n(u),n(V),n(X),n(b),n(Q),n(R),n(y),n(P),n(h),n(S),n(H),n(Z),n(L),n(U)),n(p),J(m,e),J(f,e),J(r,e),J(M,e),J(w,e)}}}const ce='{"title":"새로운 작업에 대한 모델을 적용하기","local":"새로운-작업에-대한-모델을-적용하기","sections":[{"title":"UNet2DConditionModel 파라미터 구성","local":"unet2dconditionmodel-파라미터-구성","sections":[],"depth":2}],"depth":1}';function fe(F){return ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ye extends ie{constructor(p){super(),oe(this,p,fe,de,le,{})}}export{ye as component};
