import{s as de,n as ge,o as Me}from"../chunks/scheduler.e3739aa0.js";import{S as he,i as ye,g as p,s as a,r as c,E as $e,h as i,f as s,c as n,j as fe,u as o,x as m,k as ue,y as be,a as l,v as f,d as u,t as d,w as g}from"../chunks/index.13f5b837.js";import{C as H}from"../chunks/CodeBlock.de02009a.js";import{H as we,E as je}from"../chunks/EditOnGithub.72bac8d8.js";function Je(se){let r,B,G,E,M,R,h,le='생성된 이미지의 품질을 개선하는 일반적인 방법은 <em>결정적 batch(배치) 생성</em>을 사용하는 것입니다. 이 방법은 이미지 batch(배치)를 생성하고 두 번째 추론 라운드에서 더 자세한 프롬프트와 함께 개선할 이미지 하나를 선택하는 것입니다. 핵심은 일괄 이미지 생성을 위해 파이프라인에 <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html#generator" rel="nofollow"><code>torch.Generator</code></a> 목록을 전달하고, 각 <code>Generator</code>를 시드에 연결하여 이미지에 재사용할 수 있도록 하는 것입니다.',q,y,ae='예를 들어 <a href="runwayml/stable-diffusion-v1-5"><code>runwayml/stable-diffusion-v1-5</code></a>를 사용하여 다음 프롬프트의 여러 버전을 생성해 봅시다.',L,$,P,b,ne="(가능하다면) 파이프라인을 <code>DiffusionPipeline.from_pretrained()</code>로 인스턴스화하여 GPU에 배치합니다.",Q,w,S,j,pe="이제 네 개의 서로 다른 <code>Generator</code>를 정의하고 각 <code>Generator</code>에 시드(<code>0</code> ~ <code>3</code>)를 할당하여 나중에 특정 이미지에 대해 <code>Generator</code>를 재사용할 수 있도록 합니다.",N,J,Y,T,ie="이미지를 생성하고 살펴봅니다.",X,v,F,U,re='<img src="https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/reusabe_seeds.jpg" alt="img"/>',V,Z,me="이 예제에서는 첫 번째 이미지를 개선했지만 실제로는 원하는 모든 이미지를 사용할 수 있습니다(심지어 두 개의 눈이 있는 이미지도!). 첫 번째 이미지에서는 시드가 ‘0’인 ‘생성기’를 사용했기 때문에 두 번째 추론 라운드에서는 이 ‘생성기’를 재사용할 것입니다. 이미지의 품질을 개선하려면 프롬프트에 몇 가지 텍스트를 추가합니다:",D,_,z,W,ce="시드가 <code>0</code>인 제너레이터 4개를 생성하고, 이전 라운드의 첫 번째 이미지처럼 보이는 다른 이미지 batch(배치)를 생성합니다!",K,k,A,C,oe='<img src="https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/reusabe_seeds_2.jpg" alt="img"/>',O,I,ee,x,te;return M=new we({props:{title:"Deterministic(결정적) 생성을 통한 이미지 품질 개선",local:"deterministic결정적-생성을-통한-이미지-품질-개선",headingTag:"h1"}}),$=new H({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyTGFicmFkb3IlMjBpbiUyMHRoZSUyMHN0eWxlJTIwb2YlMjBWZXJtZWVyJTIy",highlighted:'prompt = <span class="hljs-string">&quot;Labrador in the style of Vermeer&quot;</span>',wrap:!1}}),w=new H({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),J=new H({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFnZW5lcmF0b3IlMjAlM0QlMjAlNUJ0b3JjaC5HZW5lcmF0b3IoZGV2aWNlJTNEJTIyY3VkYSUyMikubWFudWFsX3NlZWQoaSklMjBmb3IlMjBpJTIwaW4lMjByYW5nZSg0KSU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>generator = [torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(i) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">4</span>)]`,wrap:!1}}),v=new H({props:{code:"aW1hZ2VzJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0Q0KS5pbWFnZXMlMEFpbWFnZXM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>images = pipe(prompt, generator=generator, num_images_per_prompt=<span class="hljs-number">4</span>).images
<span class="hljs-meta">&gt;&gt;&gt; </span>images`,wrap:!1}}),_=new H({props:{code:"cHJvbXB0JTIwJTNEJTIwJTVCcHJvbXB0JTIwJTJCJTIwdCUyMGZvciUyMHQlMjBpbiUyMCU1QiUyMiUyQyUyMGhpZ2hseSUyMHJlYWxpc3RpYyUyMiUyQyUyMCUyMiUyQyUyMGFydHN5JTIyJTJDJTIwJTIyJTJDJTIwdHJlbmRpbmclMjIlMkMlMjAlMjIlMkMlMjBjb2xvcmZ1bCUyMiU1RCU1RCUwQWdlbmVyYXRvciUyMCUzRCUyMCU1QnRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSUyMGZvciUyMGklMjBpbiUyMHJhbmdlKDQpJTVE",highlighted:`prompt = [prompt + t <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;, highly realistic&quot;</span>, <span class="hljs-string">&quot;, artsy&quot;</span>, <span class="hljs-string">&quot;, trending&quot;</span>, <span class="hljs-string">&quot;, colorful&quot;</span>]]
generator = [torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">4</span>)]`,wrap:!1}}),k=new H({props:{code:"aW1hZ2VzJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyUwQWltYWdlcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>images = pipe(prompt, generator=generator).images
<span class="hljs-meta">&gt;&gt;&gt; </span>images`,wrap:!1}}),I=new je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/reusing_seeds.md"}}),{c(){r=p("meta"),B=a(),G=p("p"),E=a(),c(M.$$.fragment),R=a(),h=p("p"),h.innerHTML=le,q=a(),y=p("p"),y.innerHTML=ae,L=a(),c($.$$.fragment),P=a(),b=p("p"),b.innerHTML=ne,Q=a(),c(w.$$.fragment),S=a(),j=p("p"),j.innerHTML=pe,N=a(),c(J.$$.fragment),Y=a(),T=p("p"),T.textContent=ie,X=a(),c(v.$$.fragment),F=a(),U=p("p"),U.innerHTML=re,V=a(),Z=p("p"),Z.textContent=me,D=a(),c(_.$$.fragment),z=a(),W=p("p"),W.innerHTML=ce,K=a(),c(k.$$.fragment),A=a(),C=p("p"),C.innerHTML=oe,O=a(),c(I.$$.fragment),ee=a(),x=p("p"),this.h()},l(e){const t=$e("svelte-u9bgzb",document.head);r=i(t,"META",{name:!0,content:!0}),t.forEach(s),B=n(e),G=i(e,"P",{}),fe(G).forEach(s),E=n(e),o(M.$$.fragment,e),R=n(e),h=i(e,"P",{"data-svelte-h":!0}),m(h)!=="svelte-1vonp5w"&&(h.innerHTML=le),q=n(e),y=i(e,"P",{"data-svelte-h":!0}),m(y)!=="svelte-gvc3qa"&&(y.innerHTML=ae),L=n(e),o($.$$.fragment,e),P=n(e),b=i(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-16ygecj"&&(b.innerHTML=ne),Q=n(e),o(w.$$.fragment,e),S=n(e),j=i(e,"P",{"data-svelte-h":!0}),m(j)!=="svelte-1dutbmp"&&(j.innerHTML=pe),N=n(e),o(J.$$.fragment,e),Y=n(e),T=i(e,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1k0bpz"&&(T.textContent=ie),X=n(e),o(v.$$.fragment,e),F=n(e),U=i(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-ohfhuy"&&(U.innerHTML=re),V=n(e),Z=i(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-13620rq"&&(Z.textContent=me),D=n(e),o(_.$$.fragment,e),z=n(e),W=i(e,"P",{"data-svelte-h":!0}),m(W)!=="svelte-mermk5"&&(W.innerHTML=ce),K=n(e),o(k.$$.fragment,e),A=n(e),C=i(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-ufx7w5"&&(C.innerHTML=oe),O=n(e),o(I.$$.fragment,e),ee=n(e),x=i(e,"P",{}),fe(x).forEach(s),this.h()},h(){ue(r,"name","hf:doc:metadata"),ue(r,"content",Te)},m(e,t){be(document.head,r),l(e,B,t),l(e,G,t),l(e,E,t),f(M,e,t),l(e,R,t),l(e,h,t),l(e,q,t),l(e,y,t),l(e,L,t),f($,e,t),l(e,P,t),l(e,b,t),l(e,Q,t),f(w,e,t),l(e,S,t),l(e,j,t),l(e,N,t),f(J,e,t),l(e,Y,t),l(e,T,t),l(e,X,t),f(v,e,t),l(e,F,t),l(e,U,t),l(e,V,t),l(e,Z,t),l(e,D,t),f(_,e,t),l(e,z,t),l(e,W,t),l(e,K,t),f(k,e,t),l(e,A,t),l(e,C,t),l(e,O,t),f(I,e,t),l(e,ee,t),l(e,x,t),te=!0},p:ge,i(e){te||(u(M.$$.fragment,e),u($.$$.fragment,e),u(w.$$.fragment,e),u(J.$$.fragment,e),u(v.$$.fragment,e),u(_.$$.fragment,e),u(k.$$.fragment,e),u(I.$$.fragment,e),te=!0)},o(e){d(M.$$.fragment,e),d($.$$.fragment,e),d(w.$$.fragment,e),d(J.$$.fragment,e),d(v.$$.fragment,e),d(_.$$.fragment,e),d(k.$$.fragment,e),d(I.$$.fragment,e),te=!1},d(e){e&&(s(B),s(G),s(E),s(R),s(h),s(q),s(y),s(L),s(P),s(b),s(Q),s(S),s(j),s(N),s(Y),s(T),s(X),s(F),s(U),s(V),s(Z),s(D),s(z),s(W),s(K),s(A),s(C),s(O),s(ee),s(x)),s(r),g(M,e),g($,e),g(w,e),g(J,e),g(v,e),g(_,e),g(k,e),g(I,e)}}}const Te='{"title":"Deterministic(결정적) 생성을 통한 이미지 품질 개선","local":"deterministic결정적-생성을-통한-이미지-품질-개선","sections":[],"depth":1}';function ve(se){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends he{constructor(r){super(),ye(this,r,ve,Je,de,{})}}export{ke as component};
