import{s as $e,j as je,o as Ge,n as ve}from"../chunks/scheduler.6e0d5ff7.js";import{S as ke,i as _e,g as p,s as i,r as h,E as Ie,h as m,f as s,c as n,j as ce,u as M,x as o,k as u,y as We,a as l,v as y,d as J,t as T,w}from"../chunks/index.d7c1b260.js";import{T as Ue}from"../chunks/Tip.c000e27b.js";import{C as x}from"../chunks/CodeBlock.09a08494.js";import{D as Be}from"../chunks/DocNotebookDropdown.b1b23d60.js";import{H as Ce}from"../chunks/Heading.30a009b0.js";function Re(E){let a,Z="💡 <code>strength</code>는 입력 이미지에 추가되는 노이즈의 양을 제어하는 0.0에서 1.0 사이의 값입니다. 1.0에 가까운 값은 다양한 변형을 허용하지만 입력 이미지와 의미적으로 일치하지 않는 이미지를 생성합니다.";return{c(){a=p("p"),a.innerHTML=Z},l(c){a=m(c,"P",{"data-svelte-h":!0}),o(a)!=="svelte-yusq37"&&(a.innerHTML=Z)},m(c,H){l(c,a,H)},p:ve,d(c){c&&s(a)}}}function Xe(E){let a,Z,c,H,$,V,j,Y,G,re="<code>StableDiffusionImg2ImgPipeline</code>을 사용하면 텍스트 프롬프트와 시작 이미지를 전달하여 새 이미지 생성의 조건을 지정할 수 있습니다.",L,v,ue="시작하기 전에 필요한 라이브러리가 모두 설치되어 있는지 확인하세요:",z,k,D,_,fe='<a href="https://huggingface.co/nitrosocke/Ghibli-Diffusion" rel="nofollow"><code>nitrosocke/Ghibli-Diffusion</code></a>과 같은 사전학습된 stable diffusion 모델로 <code>StableDiffusionImg2ImgPipeline</code>을 생성하여 시작하세요.',Q,I,P,W,ge="초기 이미지를 다운로드하고 사전 처리하여 파이프라인에 전달할 수 있습니다:",q,U,A,f,be='<img src="https://huggingface.co/datasets/YiYiXu/test-doc-assets/resolve/main/image_2_image_using_diffusers_cell_8_output_0.jpeg"/>',K,g,O,B,de="프롬프트를 정의하고(지브리 스타일(Ghibli-style)에 맞게 조정된 이 체크포인트의 경우 프롬프트 앞에 <code>ghibli style</code> 토큰을 붙여야 합니다) 파이프라인을 실행합니다:",ee,C,te,b,he='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ghibli-castles.png"/>',se,R,Me="다른 스케줄러로 실험하여 출력에 어떤 영향을 미치는지 확인할 수도 있습니다:",le,X,ie,d,ye='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/lms-ghibli.png"/>',ne,F,Je="아래 공백을 확인하고 <code>strength</code> 값을 다르게 설정하여 이미지를 생성해 보세요. <code>strength</code>를 낮게 설정하면 원본 이미지와 더 유사한 이미지가 생성되는 것을 확인할 수 있습니다.",ae,N,Te="자유롭게 스케줄러를 <code>LMSDiscreteScheduler</code>로 전환하여 출력에 어떤 영향을 미치는지 확인해 보세요.",pe,r,we,me,S,oe;return $=new Ce({props:{title:"텍스트 기반 image-to-image 생성",local:"텍스트-기반-image-to-image-생성",headingTag:"h1"}}),j=new Be({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/img2img.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/img2img.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/img2img.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/img2img.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/pytorch/img2img.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/ko/tensorflow/img2img.ipynb"}]}}),k=new x({props:{code:"IXBpcCUyMGluc3RhbGwlMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBmdGZ5JTIwYWNjZWxlcmF0ZQ==",highlighted:"!pip install diffusers transformers ftfy accelerate",wrap:!1}}),I=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW1nMkltZ1BpcGVsaW5lJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbWcySW1nUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMm5pdHJvc29ja2UlMkZHaGlibGktRGlmZnVzaW9uJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMEElMjAlMjAlMjAlMjBkZXZpY2UlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionImg2ImgPipeline

device = <span class="hljs-string">&quot;cuda&quot;</span>
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(<span class="hljs-string">&quot;nitrosocke/Ghibli-Diffusion&quot;</span>, torch_dtype=torch.float16).to(
    device
)`,wrap:!1}}),U=new x({props:{code:"dXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGQ29tcFZpcyUyRnN0YWJsZS1kaWZmdXNpb24lMkZtYWluJTJGYXNzZXRzJTJGc3RhYmxlLXNhbXBsZXMlMkZpbWcyaW1nJTJGc2tldGNoLW1vdW50YWlucy1pbnB1dC5qcGclMjIlMEElMEFyZXNwb25zZSUyMCUzRCUyMHJlcXVlc3RzLmdldCh1cmwpJTBBaW5pdF9pbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBaW5pdF9pbWFnZS50aHVtYm5haWwoKDc2OCUyQyUyMDc2OCkpJTBBaW5pdF9pbWFnZQ==",highlighted:`url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>

response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image.thumbnail((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))
init_image`,wrap:!1}}),g=new Ue({props:{$$slots:{default:[Re]},$$scope:{ctx:E}}}),C=new x({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyZ2hpYmxpJTIwc3R5bGUlMkMlMjBhJTIwZmFudGFzeSUyMGxhbmRzY2FwZSUyMHdpdGglMjBjYXN0bGVzJTIyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRGRldmljZSkubWFudWFsX3NlZWQoMTAyNCklMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwc3RyZW5ndGglM0QwLjc1JTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`prompt = <span class="hljs-string">&quot;ghibli style, a fantasy landscape with castles&quot;</span>
generator = torch.Generator(device=device).manual_seed(<span class="hljs-number">1024</span>)
image = pipe(prompt=prompt, image=init_image, strength=<span class="hljs-number">0.75</span>, guidance_scale=<span class="hljs-number">7.5</span>, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),X=new x({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExNU0Rpc2NyZXRlU2NoZWR1bGVyJTBBJTBBbG1zJTIwJTNEJTIwTE1TRGlzY3JldGVTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZS5zY2hlZHVsZXIuY29uZmlnKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwbG1zJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRGRldmljZSkubWFudWFsX3NlZWQoMTAyNCklMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwc3RyZW5ndGglM0QwLjc1JTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LMSDiscreteScheduler

lms = LMSDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.scheduler = lms
generator = torch.Generator(device=device).manual_seed(<span class="hljs-number">1024</span>)
image = pipe(prompt=prompt, image=init_image, strength=<span class="hljs-number">0.75</span>, guidance_scale=<span class="hljs-number">7.5</span>, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){a=p("meta"),Z=i(),c=p("p"),H=i(),h($.$$.fragment),V=i(),h(j.$$.fragment),Y=i(),G=p("p"),G.innerHTML=re,L=i(),v=p("p"),v.textContent=ue,z=i(),h(k.$$.fragment),D=i(),_=p("p"),_.innerHTML=fe,Q=i(),h(I.$$.fragment),P=i(),W=p("p"),W.textContent=ge,q=i(),h(U.$$.fragment),A=i(),f=p("div"),f.innerHTML=be,K=i(),h(g.$$.fragment),O=i(),B=p("p"),B.innerHTML=de,ee=i(),h(C.$$.fragment),te=i(),b=p("div"),b.innerHTML=he,se=i(),R=p("p"),R.textContent=Me,le=i(),h(X.$$.fragment),ie=i(),d=p("div"),d.innerHTML=ye,ne=i(),F=p("p"),F.innerHTML=Je,ae=i(),N=p("p"),N.innerHTML=Te,pe=i(),r=p("iframe"),me=i(),S=p("p"),this.h()},l(e){const t=Ie("svelte-u9bgzb",document.head);a=m(t,"META",{name:!0,content:!0}),t.forEach(s),Z=n(e),c=m(e,"P",{}),ce(c).forEach(s),H=n(e),M($.$$.fragment,e),V=n(e),M(j.$$.fragment,e),Y=n(e),G=m(e,"P",{"data-svelte-h":!0}),o(G)!=="svelte-1ksg2hu"&&(G.innerHTML=re),L=n(e),v=m(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-1k0z9pm"&&(v.textContent=ue),z=n(e),M(k.$$.fragment,e),D=n(e),_=m(e,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1uexkpx"&&(_.innerHTML=fe),Q=n(e),M(I.$$.fragment,e),P=n(e),W=m(e,"P",{"data-svelte-h":!0}),o(W)!=="svelte-104cnjb"&&(W.textContent=ge),q=n(e),M(U.$$.fragment,e),A=n(e),f=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(f)!=="svelte-12g1e6p"&&(f.innerHTML=be),K=n(e),M(g.$$.fragment,e),O=n(e),B=m(e,"P",{"data-svelte-h":!0}),o(B)!=="svelte-sq88z3"&&(B.innerHTML=de),ee=n(e),M(C.$$.fragment,e),te=n(e),b=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(b)!=="svelte-2udrp4"&&(b.innerHTML=he),se=n(e),R=m(e,"P",{"data-svelte-h":!0}),o(R)!=="svelte-1hn6w3l"&&(R.textContent=Me),le=n(e),M(X.$$.fragment,e),ie=n(e),d=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(d)!=="svelte-12227f3"&&(d.innerHTML=ye),ne=n(e),F=m(e,"P",{"data-svelte-h":!0}),o(F)!=="svelte-19pmm5g"&&(F.innerHTML=Je),ae=n(e),N=m(e,"P",{"data-svelte-h":!0}),o(N)!=="svelte-slo2yq"&&(N.innerHTML=Te),pe=n(e),r=m(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ce(r).forEach(s),me=n(e),S=m(e,"P",{}),ce(S).forEach(s),this.h()},h(){u(a,"name","hf:doc:metadata"),u(a,"content",Fe),u(f,"class","flex justify-center"),u(b,"class","flex justify-center"),u(d,"class","flex justify-center"),je(r.src,we="https://stevhliu-ghibli-img2img.hf.space")||u(r,"src",we),u(r,"frameborder","0"),u(r,"width","850"),u(r,"height","500")},m(e,t){We(document.head,a),l(e,Z,t),l(e,c,t),l(e,H,t),y($,e,t),l(e,V,t),y(j,e,t),l(e,Y,t),l(e,G,t),l(e,L,t),l(e,v,t),l(e,z,t),y(k,e,t),l(e,D,t),l(e,_,t),l(e,Q,t),y(I,e,t),l(e,P,t),l(e,W,t),l(e,q,t),y(U,e,t),l(e,A,t),l(e,f,t),l(e,K,t),y(g,e,t),l(e,O,t),l(e,B,t),l(e,ee,t),y(C,e,t),l(e,te,t),l(e,b,t),l(e,se,t),l(e,R,t),l(e,le,t),y(X,e,t),l(e,ie,t),l(e,d,t),l(e,ne,t),l(e,F,t),l(e,ae,t),l(e,N,t),l(e,pe,t),l(e,r,t),l(e,me,t),l(e,S,t),oe=!0},p(e,[t]){const Ze={};t&2&&(Ze.$$scope={dirty:t,ctx:e}),g.$set(Ze)},i(e){oe||(J($.$$.fragment,e),J(j.$$.fragment,e),J(k.$$.fragment,e),J(I.$$.fragment,e),J(U.$$.fragment,e),J(g.$$.fragment,e),J(C.$$.fragment,e),J(X.$$.fragment,e),oe=!0)},o(e){T($.$$.fragment,e),T(j.$$.fragment,e),T(k.$$.fragment,e),T(I.$$.fragment,e),T(U.$$.fragment,e),T(g.$$.fragment,e),T(C.$$.fragment,e),T(X.$$.fragment,e),oe=!1},d(e){e&&(s(Z),s(c),s(H),s(V),s(Y),s(G),s(L),s(v),s(z),s(D),s(_),s(Q),s(P),s(W),s(q),s(A),s(f),s(K),s(O),s(B),s(ee),s(te),s(b),s(se),s(R),s(le),s(ie),s(d),s(ne),s(F),s(ae),s(N),s(pe),s(r),s(me),s(S)),s(a),w($,e),w(j,e),w(k,e),w(I,e),w(U,e),w(g,e),w(C,e),w(X,e)}}}const Fe='{"title":"텍스트 기반 image-to-image 생성","local":"텍스트-기반-image-to-image-생성","sections":[],"depth":1}';function Ne(E){return Ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends ke{constructor(a){super(),_e(this,a,Ne,Xe,$e,{})}}export{Le as component};
