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