import{s as fe,n as de,o as ue}from"../chunks/scheduler.6e0d5ff7.js";import{S as ge,i as Me,g as p,s as a,r as U,E as ye,h as i,f as s,c as n,j as ce,u as Z,x as m,k as oe,y as he,a as l,v as _,d as W,t as C,w as I}from"../chunks/index.d7c1b260.js";import{C as k}from"../chunks/CodeBlock.09a08494.js";import{H as we}from"../chunks/Heading.30a009b0.js";function je(ee){let r,x,H,B,c,R,o,te='생성된 이미지의 품질을 개선하는 일반적인 방법은 <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,f,se='예를 들어 <a href="runwayml/stable-diffusion-v1-5"><code>runwayml/stable-diffusion-v1-5</code></a>를 사용하여 다음 프롬프트의 여러 버전을 생성해 봅시다.',E,d,L,u,le="(가능하다면) 파이프라인을 <code>DiffusionPipeline.from_pretrained()</code>로 인스턴스화하여 GPU에 배치합니다.",P,g,Q,M,ae="이제 네 개의 서로 다른 <code>Generator</code>를 정의하고 각 <code>Generator</code>에 시드(<code>0</code> ~ <code>3</code>)를 할당하여 나중에 특정 이미지에 대해 <code>Generator</code>를 재사용할 수 있도록 합니다.",S,y,N,h,ne="이미지를 생성하고 살펴봅니다.",Y,w,X,j,pe='<img src="https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/reusabe_seeds.jpg" alt="img"/>',F,b,ie="이 예제에서는 첫 번째 이미지를 개선했지만 실제로는 원하는 모든 이미지를 사용할 수 있습니다(심지어 두 개의 눈이 있는 이미지도!). 첫 번째 이미지에서는 시드가 ‘0’인 ‘생성기’를 사용했기 때문에 두 번째 추론 라운드에서는 이 ‘생성기’를 재사용할 것입니다. 이미지의 품질을 개선하려면 프롬프트에 몇 가지 텍스트를 추가합니다:",V,J,D,$,re="시드가 <code>0</code>인 제너레이터 4개를 생성하고, 이전 라운드의 첫 번째 이미지처럼 보이는 다른 이미지 batch(배치)를 생성합니다!",z,T,K,v,me='<img src="https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/reusabe_seeds_2.jpg" alt="img"/>',A,G,O;return c=new we({props:{title:"Deterministic(결정적) 생성을 통한 이미지 품질 개선",local:"deterministic결정적-생성을-통한-이미지-품질-개선",headingTag:"h1"}}),d=new k({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyTGFicmFkb3IlMjBpbiUyMHRoZSUyMHN0eWxlJTIwb2YlMjBWZXJtZWVyJTIy",highlighted:'prompt = <span class="hljs-string">&quot;Labrador in the style of Vermeer&quot;</span>',wrap:!1}}),g=new k({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}}),y=new k({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}}),w=new k({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}}),J=new k({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}}),T=new k({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}}),{c(){r=p("meta"),x=a(),H=p("p"),B=a(),U(c.$$.fragment),R=a(),o=p("p"),o.innerHTML=te,q=a(),f=p("p"),f.innerHTML=se,E=a(),U(d.$$.fragment),L=a(),u=p("p"),u.innerHTML=le,P=a(),U(g.$$.fragment),Q=a(),M=p("p"),M.innerHTML=ae,S=a(),U(y.$$.fragment),N=a(),h=p("p"),h.textContent=ne,Y=a(),U(w.$$.fragment),X=a(),j=p("p"),j.innerHTML=pe,F=a(),b=p("p"),b.textContent=ie,V=a(),U(J.$$.fragment),D=a(),$=p("p"),$.innerHTML=re,z=a(),U(T.$$.fragment),K=a(),v=p("p"),v.innerHTML=me,A=a(),G=p("p"),this.h()},l(e){const t=ye("svelte-u9bgzb",document.head);r=i(t,"META",{name:!0,content:!0}),t.forEach(s),x=n(e),H=i(e,"P",{}),ce(H).forEach(s),B=n(e),Z(c.$$.fragment,e),R=n(e),o=i(e,"P",{"data-svelte-h":!0}),m(o)!=="svelte-1vonp5w"&&(o.innerHTML=te),q=n(e),f=i(e,"P",{"data-svelte-h":!0}),m(f)!=="svelte-gvc3qa"&&(f.innerHTML=se),E=n(e),Z(d.$$.fragment,e),L=n(e),u=i(e,"P",{"data-svelte-h":!0}),m(u)!=="svelte-16ygecj"&&(u.innerHTML=le),P=n(e),Z(g.$$.fragment,e),Q=n(e),M=i(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1dutbmp"&&(M.innerHTML=ae),S=n(e),Z(y.$$.fragment,e),N=n(e),h=i(e,"P",{"data-svelte-h":!0}),m(h)!=="svelte-1k0bpz"&&(h.textContent=ne),Y=n(e),Z(w.$$.fragment,e),X=n(e),j=i(e,"P",{"data-svelte-h":!0}),m(j)!=="svelte-ohfhuy"&&(j.innerHTML=pe),F=n(e),b=i(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-13620rq"&&(b.textContent=ie),V=n(e),Z(J.$$.fragment,e),D=n(e),$=i(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-mermk5"&&($.innerHTML=re),z=n(e),Z(T.$$.fragment,e),K=n(e),v=i(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-ufx7w5"&&(v.innerHTML=me),A=n(e),G=i(e,"P",{}),ce(G).forEach(s),this.h()},h(){oe(r,"name","hf:doc:metadata"),oe(r,"content",be)},m(e,t){he(document.head,r),l(e,x,t),l(e,H,t),l(e,B,t),_(c,e,t),l(e,R,t),l(e,o,t),l(e,q,t),l(e,f,t),l(e,E,t),_(d,e,t),l(e,L,t),l(e,u,t),l(e,P,t),_(g,e,t),l(e,Q,t),l(e,M,t),l(e,S,t),_(y,e,t),l(e,N,t),l(e,h,t),l(e,Y,t),_(w,e,t),l(e,X,t),l(e,j,t),l(e,F,t),l(e,b,t),l(e,V,t),_(J,e,t),l(e,D,t),l(e,$,t),l(e,z,t),_(T,e,t),l(e,K,t),l(e,v,t),l(e,A,t),l(e,G,t),O=!0},p:de,i(e){O||(W(c.$$.fragment,e),W(d.$$.fragment,e),W(g.$$.fragment,e),W(y.$$.fragment,e),W(w.$$.fragment,e),W(J.$$.fragment,e),W(T.$$.fragment,e),O=!0)},o(e){C(c.$$.fragment,e),C(d.$$.fragment,e),C(g.$$.fragment,e),C(y.$$.fragment,e),C(w.$$.fragment,e),C(J.$$.fragment,e),C(T.$$.fragment,e),O=!1},d(e){e&&(s(x),s(H),s(B),s(R),s(o),s(q),s(f),s(E),s(L),s(u),s(P),s(Q),s(M),s(S),s(N),s(h),s(Y),s(X),s(j),s(F),s(b),s(V),s(D),s($),s(z),s(K),s(v),s(A),s(G)),s(r),I(c,e),I(d,e),I(g,e),I(y,e),I(w,e),I(J,e),I(T,e)}}}const be='{"title":"Deterministic(결정적) 생성을 통한 이미지 품질 개선","local":"deterministic결정적-생성을-통한-이미지-품질-개선","sections":[],"depth":1}';function Je(ee){return ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends ge{constructor(r){super(),Me(this,r,Je,je,fe,{})}}export{Ze as component};
