import{s as ie,n as ae,o as oe}from"../chunks/scheduler.94020406.js";import{S as pe,i as me,g as a,s,r as T,E as fe,h as o,f as n,c as i,j as ne,u as g,x as U,k as le,y as de,a as l,v,d as w,t as G,w as W}from"../chunks/index.a08c8d92.js";import{C as D}from"../chunks/CodeBlock.f1fae7de.js";import{H as se,E as ce}from"../chunks/getInferenceSnippets.25ca5d9f.js";function ue(q){let p,C,j,x,m,V,f,Y="많은 diffusion 시스템은 같은 구성 요소들을 공유하므로 한 작업에 대해 사전학습된 모델을 완전히 다른 작업에 적용할 수 있습니다.",B,d,I="이 인페인팅을 위한 가이드는 사전학습된 <code>UNet2DConditionModel</code>의 아키텍처를 초기화하고 수정하여 사전학습된 text-to-image 모델을 어떻게 인페인팅에 적용하는지를 알려줄 것입니다.",k,c,L,u,A='<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>의 수를 확인합니다:',E,r,N,b,O='인페인팅은 입력 샘플에 9개의 채널이 필요합니다. <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow"><code>runwayml/stable-diffusion-inpainting</code></a>와 같은 사전학습된 인페인팅 모델에서 이 값을 확인할 수 있습니다:',F,M,R,h,K="인페인팅에 대한 text-to-image 모델을 적용하기 위해, <code>in_channels</code> 수를 4에서 9로 수정해야 할 것입니다.",P,y,ee="사전학습된 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>를 설정해야 합니다.",Q,Z,S,$,te="Text-to-image 모델로부터 다른 구성 요소의 사전학습된 가중치는 체크포인트로부터 초기화되지만 <code>unet</code>의 입력 채널 가중치 (<code>conv_in.weight</code>)는 랜덤하게 초기화됩니다. 그렇지 않으면 모델이 노이즈를 리턴하기 때문에 인페인팅의 모델을 파인튜닝 할 때 중요합니다.",X,_,H,J,z;return m=new se({props:{title:"새로운 작업에 대한 모델을 적용하기",local:"새로운-작업에-대한-모델을-적용하기",headingTag:"h1"}}),c=new se({props:{title:"UNet2DConditionModel 파라미터 구성",local:"unet2dconditionmodel-파라미터-구성",headingTag:"h2"}}),r=new D({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}}),M=new D({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 D({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}}),_=new ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/training/adapt_a_model.md"}}),{c(){p=a("meta"),C=s(),j=a("p"),x=s(),T(m.$$.fragment),V=s(),f=a("p"),f.textContent=Y,B=s(),d=a("p"),d.innerHTML=I,k=s(),T(c.$$.fragment),L=s(),u=a("p"),u.innerHTML=A,E=s(),T(r.$$.fragment),N=s(),b=a("p"),b.innerHTML=O,F=s(),T(M.$$.fragment),R=s(),h=a("p"),h.innerHTML=K,P=s(),y=a("p"),y.innerHTML=ee,Q=s(),T(Z.$$.fragment),S=s(),$=a("p"),$.innerHTML=te,X=s(),T(_.$$.fragment),H=s(),J=a("p"),this.h()},l(e){const t=fe("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(n),C=i(e),j=o(e,"P",{}),ne(j).forEach(n),x=i(e),g(m.$$.fragment,e),V=i(e),f=o(e,"P",{"data-svelte-h":!0}),U(f)!=="svelte-obt1bb"&&(f.textContent=Y),B=i(e),d=o(e,"P",{"data-svelte-h":!0}),U(d)!=="svelte-1bn5mvh"&&(d.innerHTML=I),k=i(e),g(c.$$.fragment,e),L=i(e),u=o(e,"P",{"data-svelte-h":!0}),U(u)!=="svelte-1ie49sx"&&(u.innerHTML=A),E=i(e),g(r.$$.fragment,e),N=i(e),b=o(e,"P",{"data-svelte-h":!0}),U(b)!=="svelte-n1t961"&&(b.innerHTML=O),F=i(e),g(M.$$.fragment,e),R=i(e),h=o(e,"P",{"data-svelte-h":!0}),U(h)!=="svelte-1nkn0wh"&&(h.innerHTML=K),P=i(e),y=o(e,"P",{"data-svelte-h":!0}),U(y)!=="svelte-oj0rfs"&&(y.innerHTML=ee),Q=i(e),g(Z.$$.fragment,e),S=i(e),$=o(e,"P",{"data-svelte-h":!0}),U($)!=="svelte-rfmg1f"&&($.innerHTML=te),X=i(e),g(_.$$.fragment,e),H=i(e),J=o(e,"P",{}),ne(J).forEach(n),this.h()},h(){le(p,"name","hf:doc:metadata"),le(p,"content",re)},m(e,t){de(document.head,p),l(e,C,t),l(e,j,t),l(e,x,t),v(m,e,t),l(e,V,t),l(e,f,t),l(e,B,t),l(e,d,t),l(e,k,t),v(c,e,t),l(e,L,t),l(e,u,t),l(e,E,t),v(r,e,t),l(e,N,t),l(e,b,t),l(e,F,t),v(M,e,t),l(e,R,t),l(e,h,t),l(e,P,t),l(e,y,t),l(e,Q,t),v(Z,e,t),l(e,S,t),l(e,$,t),l(e,X,t),v(_,e,t),l(e,H,t),l(e,J,t),z=!0},p:ae,i(e){z||(w(m.$$.fragment,e),w(c.$$.fragment,e),w(r.$$.fragment,e),w(M.$$.fragment,e),w(Z.$$.fragment,e),w(_.$$.fragment,e),z=!0)},o(e){G(m.$$.fragment,e),G(c.$$.fragment,e),G(r.$$.fragment,e),G(M.$$.fragment,e),G(Z.$$.fragment,e),G(_.$$.fragment,e),z=!1},d(e){e&&(n(C),n(j),n(x),n(V),n(f),n(B),n(d),n(k),n(L),n(u),n(E),n(N),n(b),n(F),n(R),n(h),n(P),n(y),n(Q),n(S),n($),n(X),n(H),n(J)),n(p),W(m,e),W(c,e),W(r,e),W(M,e),W(Z,e),W(_,e)}}}const re='{"title":"새로운 작업에 대한 모델을 적용하기","local":"새로운-작업에-대한-모델을-적용하기","sections":[{"title":"UNet2DConditionModel 파라미터 구성","local":"unet2dconditionmodel-파라미터-구성","sections":[],"depth":2}],"depth":1}';function be(q){return oe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $e extends pe{constructor(p){super(),me(this,p,be,ue,ie,{})}}export{$e as component};
