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