import{s as Ge,B as ve,o as ke,n as _e}from"../chunks/scheduler.94020406.js";import{S as Ie,i as We,g as p,s as i,r as u,E as Ue,h as m,f as s,c as n,j as ue,u as f,x as o,k as g,y as Be,a as l,v as b,d,t as h,w as M}from"../chunks/index.a08c8d92.js";import{T as Ce}from"../chunks/Tip.3b0aeee8.js";import{C as x}from"../chunks/CodeBlock.f1fae7de.js";import{D as Re}from"../chunks/DocNotebookDropdown.a1753374.js";import{H as Xe,E as Fe}from"../chunks/getInferenceSnippets.58cd4b84.js";function Ne(V){let a,Z="💡 <code>strength</code>는 입력 이미지에 추가되는 노이즈의 양을 제어하는 0.0에서 1.0 사이의 값입니다. 1.0에 가까운 값은 다양한 변형을 허용하지만 입력 이미지와 의미적으로 일치하지 않는 이미지를 생성합니다.";return{c(){a=p("p"),a.innerHTML=Z},l(r){a=m(r,"P",{"data-svelte-h":!0}),o(a)!=="svelte-yusq37"&&(a.innerHTML=Z)},m(r,H){l(r,a,H)},p:_e,d(r){r&&s(a)}}}function Ee(V){let a,Z,r,H,$,Y,j,L,G,fe="<code>StableDiffusionImg2ImgPipeline</code>을 사용하면 텍스트 프롬프트와 시작 이미지를 전달하여 새 이미지 생성의 조건을 지정할 수 있습니다.",z,v,ge="시작하기 전에 필요한 라이브러리가 모두 설치되어 있는지 확인하세요:",D,k,Q,_,be='<a href="https://huggingface.co/nitrosocke/Ghibli-Diffusion" rel="nofollow"><code>nitrosocke/Ghibli-Diffusion</code></a>과 같은 사전학습된 stable diffusion 모델로 <code>StableDiffusionImg2ImgPipeline</code>을 생성하여 시작하세요.',P,I,q,W,de="초기 이미지를 다운로드하고 사전 처리하여 파이프라인에 전달할 수 있습니다:",A,U,K,y,he='<img src="https://huggingface.co/datasets/YiYiXu/test-doc-assets/resolve/main/image_2_image_using_diffusers_cell_8_output_0.jpeg"/>',O,J,ee,B,Me="프롬프트를 정의하고(지브리 스타일(Ghibli-style)에 맞게 조정된 이 체크포인트의 경우 프롬프트 앞에 <code>ghibli style</code> 토큰을 붙여야 합니다) 파이프라인을 실행합니다:",te,C,se,T,ye='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ghibli-castles.png"/>',le,R,Je="다른 스케줄러로 실험하여 출력에 어떤 영향을 미치는지 확인할 수도 있습니다:",ie,X,ne,w,Te='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/lms-ghibli.png"/>',ae,F,we="아래 공백을 확인하고 <code>strength</code> 값을 다르게 설정하여 이미지를 생성해 보세요. <code>strength</code>를 낮게 설정하면 원본 이미지와 더 유사한 이미지가 생성되는 것을 확인할 수 있습니다.",pe,N,Ze="자유롭게 스케줄러를 <code>LMSDiscreteScheduler</code>로 전환하여 출력에 어떤 영향을 미치는지 확인해 보세요.",me,c,$e,oe,E,re,S,ce;return $=new Xe({props:{title:"텍스트 기반 image-to-image 생성",local:"텍스트-기반-image-to-image-생성",headingTag:"h1"}}),j=new Re({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}}),J=new Ce({props:{$$slots:{default:[Ne]},$$scope:{ctx:V}}}),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}}),E=new Fe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/using-diffusers/img2img.md"}}),{c(){a=p("meta"),Z=i(),r=p("p"),H=i(),u($.$$.fragment),Y=i(),u(j.$$.fragment),L=i(),G=p("p"),G.innerHTML=fe,z=i(),v=p("p"),v.textContent=ge,D=i(),u(k.$$.fragment),Q=i(),_=p("p"),_.innerHTML=be,P=i(),u(I.$$.fragment),q=i(),W=p("p"),W.textContent=de,A=i(),u(U.$$.fragment),K=i(),y=p("div"),y.innerHTML=he,O=i(),u(J.$$.fragment),ee=i(),B=p("p"),B.innerHTML=Me,te=i(),u(C.$$.fragment),se=i(),T=p("div"),T.innerHTML=ye,le=i(),R=p("p"),R.textContent=Je,ie=i(),u(X.$$.fragment),ne=i(),w=p("div"),w.innerHTML=Te,ae=i(),F=p("p"),F.innerHTML=we,pe=i(),N=p("p"),N.innerHTML=Ze,me=i(),c=p("iframe"),oe=i(),u(E.$$.fragment),re=i(),S=p("p"),this.h()},l(e){const t=Ue("svelte-u9bgzb",document.head);a=m(t,"META",{name:!0,content:!0}),t.forEach(s),Z=n(e),r=m(e,"P",{}),ue(r).forEach(s),H=n(e),f($.$$.fragment,e),Y=n(e),f(j.$$.fragment,e),L=n(e),G=m(e,"P",{"data-svelte-h":!0}),o(G)!=="svelte-1ksg2hu"&&(G.innerHTML=fe),z=n(e),v=m(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-1k0z9pm"&&(v.textContent=ge),D=n(e),f(k.$$.fragment,e),Q=n(e),_=m(e,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1uexkpx"&&(_.innerHTML=be),P=n(e),f(I.$$.fragment,e),q=n(e),W=m(e,"P",{"data-svelte-h":!0}),o(W)!=="svelte-104cnjb"&&(W.textContent=de),A=n(e),f(U.$$.fragment,e),K=n(e),y=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(y)!=="svelte-12g1e6p"&&(y.innerHTML=he),O=n(e),f(J.$$.fragment,e),ee=n(e),B=m(e,"P",{"data-svelte-h":!0}),o(B)!=="svelte-sq88z3"&&(B.innerHTML=Me),te=n(e),f(C.$$.fragment,e),se=n(e),T=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(T)!=="svelte-2udrp4"&&(T.innerHTML=ye),le=n(e),R=m(e,"P",{"data-svelte-h":!0}),o(R)!=="svelte-1hn6w3l"&&(R.textContent=Je),ie=n(e),f(X.$$.fragment,e),ne=n(e),w=m(e,"DIV",{class:!0,"data-svelte-h":!0}),o(w)!=="svelte-12227f3"&&(w.innerHTML=Te),ae=n(e),F=m(e,"P",{"data-svelte-h":!0}),o(F)!=="svelte-19pmm5g"&&(F.innerHTML=we),pe=n(e),N=m(e,"P",{"data-svelte-h":!0}),o(N)!=="svelte-slo2yq"&&(N.innerHTML=Ze),me=n(e),c=m(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ue(c).forEach(s),oe=n(e),f(E.$$.fragment,e),re=n(e),S=m(e,"P",{}),ue(S).forEach(s),this.h()},h(){g(a,"name","hf:doc:metadata"),g(a,"content",He),g(y,"class","flex justify-center"),g(T,"class","flex justify-center"),g(w,"class","flex justify-center"),ve(c.src,$e="https://stevhliu-ghibli-img2img.hf.space")||g(c,"src",$e),g(c,"frameborder","0"),g(c,"width","850"),g(c,"height","500")},m(e,t){Be(document.head,a),l(e,Z,t),l(e,r,t),l(e,H,t),b($,e,t),l(e,Y,t),b(j,e,t),l(e,L,t),l(e,G,t),l(e,z,t),l(e,v,t),l(e,D,t),b(k,e,t),l(e,Q,t),l(e,_,t),l(e,P,t),b(I,e,t),l(e,q,t),l(e,W,t),l(e,A,t),b(U,e,t),l(e,K,t),l(e,y,t),l(e,O,t),b(J,e,t),l(e,ee,t),l(e,B,t),l(e,te,t),b(C,e,t),l(e,se,t),l(e,T,t),l(e,le,t),l(e,R,t),l(e,ie,t),b(X,e,t),l(e,ne,t),l(e,w,t),l(e,ae,t),l(e,F,t),l(e,pe,t),l(e,N,t),l(e,me,t),l(e,c,t),l(e,oe,t),b(E,e,t),l(e,re,t),l(e,S,t),ce=!0},p(e,[t]){const je={};t&2&&(je.$$scope={dirty:t,ctx:e}),J.$set(je)},i(e){ce||(d($.$$.fragment,e),d(j.$$.fragment,e),d(k.$$.fragment,e),d(I.$$.fragment,e),d(U.$$.fragment,e),d(J.$$.fragment,e),d(C.$$.fragment,e),d(X.$$.fragment,e),d(E.$$.fragment,e),ce=!0)},o(e){h($.$$.fragment,e),h(j.$$.fragment,e),h(k.$$.fragment,e),h(I.$$.fragment,e),h(U.$$.fragment,e),h(J.$$.fragment,e),h(C.$$.fragment,e),h(X.$$.fragment,e),h(E.$$.fragment,e),ce=!1},d(e){e&&(s(Z),s(r),s(H),s(Y),s(L),s(G),s(z),s(v),s(D),s(Q),s(_),s(P),s(q),s(W),s(A),s(K),s(y),s(O),s(ee),s(B),s(te),s(se),s(T),s(le),s(R),s(ie),s(ne),s(w),s(ae),s(F),s(pe),s(N),s(me),s(c),s(oe),s(re),s(S)),s(a),M($,e),M(j,e),M(k,e),M(I,e),M(U,e),M(J,e),M(C,e),M(X,e),M(E,e)}}}const He='{"title":"텍스트 기반 image-to-image 생성","local":"텍스트-기반-image-to-image-생성","sections":[],"depth":1}';function Se(V){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends Ie{constructor(a){super(),We(this,a,Se,Ee,Ge,{})}}export{Qe as component};
