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 l,b as n,f as fe,g as f,j as m,k as r,l as xe,m as s,n as g,t as b,o as d,p as h}from"../chunks/index.9b1f405b.js";import{C as Re,H as Xe,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.5bcbaa63.js";import{C as H}from"../chunks/CodeBlock.e82446dd.js";import{D as Se}from"../chunks/DocNotebookDropdown.68a629d2.js";function Ee(ge){let c,N,S,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> 토큰을 붙여야 합니다) 파이프라인을 실행합니다:",le,B,se,J,we='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ghibli-castles.png"/>',ie,C,Ze="다른 스케줄러로 실험하여 출력에 어떤 영향을 미치는지 확인할 수도 있습니다:",ne,x,ae,T,$e='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/lms-ghibli.png"/>',pe,R,je="아래 공백을 확인하고 <code>strength</code> 값을 다르게 설정하여 이미지를 생성해 보세요. <code>strength</code>를 낮게 설정하면 원본 이미지와 더 유사한 이미지가 생성되는 것을 확인할 수 있습니다.",me,X,Ge="자유롭게 스케줄러를 <code>LMSDiscreteScheduler</code>로 전환하여 출력에 어떤 영향을 미치는지 확인해 보세요.",oe,o,ve,re,F,ce,E,ue;return w=new Re({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),Z=new Se({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;",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"}]}}),$=new Xe({props:{title:"텍스트 기반 image-to-image 생성",local:"텍스트-기반-image-to-image-생성",headingTag:"h1"}}),v=new H({props:{code:"IXBpcCUyMGluc3RhbGwlMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBmdGZ5JTIwYWNjZWxlcmF0ZQ==",highlighted:"!pip install diffusers transformers ftfy accelerate",wrap:!1}}),I=new H({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 H({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 H({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 H({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"),N=i(),S=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,le=i(),u(B.$$.fragment),se=i(),J=a("div"),J.innerHTML=we,ie=i(),C=a("p"),C.textContent=Ze,ne=i(),u(x.$$.fragment),ae=i(),T=a("div"),T.innerHTML=$e,pe=i(),R=a("p"),R.innerHTML=je,me=i(),X=a("p"),X.innerHTML=Ge,oe=i(),o=a("iframe"),re=i(),u(F.$$.fragment),ce=i(),E=a("p"),this.h()},l(e){const t=Ce("svelte-u9bgzb",document.head);c=p(t,"META",{name:!0,content:!0}),t.forEach(l),N=n(e),S=p(e,"P",{}),fe(S).forEach(l),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),le=n(e),f(B.$$.fragment,e),se=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(x.$$.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),R=p(e,"P",{"data-svelte-h":!0}),m(R)!=="svelte-19pmm5g"&&(R.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(l),re=n(e),f(F.$$.fragment,e),ce=n(e),E=p(e,"P",{}),fe(E).forEach(l),this.h()},h(){r(c,"name","hf:doc:metadata"),r(c,"content",He),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){xe(document.head,c),s(e,N,t),s(e,S,t),s(e,L,t),g(w,e,t),s(e,V,t),g(Z,e,t),s(e,Y,t),g($,e,t),s(e,z,t),s(e,j,t),s(e,Q,t),s(e,G,t),s(e,D,t),g(v,e,t),s(e,P,t),s(e,k,t),s(e,q,t),g(I,e,t),s(e,A,t),s(e,W,t),s(e,K,t),g(_,e,t),s(e,O,t),s(e,M,t),s(e,ee,t),s(e,y,t),s(e,te,t),s(e,U,t),s(e,le,t),g(B,e,t),s(e,se,t),s(e,J,t),s(e,ie,t),s(e,C,t),s(e,ne,t),g(x,e,t),s(e,ae,t),s(e,T,t),s(e,pe,t),s(e,R,t),s(e,me,t),s(e,X,t),s(e,oe,t),s(e,o,t),s(e,re,t),g(F,e,t),s(e,ce,t),s(e,E,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(x.$$.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(x.$$.fragment,e),d(F.$$.fragment,e),ue=!1},d(e){e&&(l(N),l(S),l(L),l(V),l(Y),l(z),l(j),l(Q),l(G),l(D),l(P),l(k),l(q),l(A),l(W),l(K),l(O),l(M),l(ee),l(y),l(te),l(U),l(le),l(se),l(J),l(ie),l(C),l(ne),l(ae),l(T),l(pe),l(R),l(me),l(X),l(oe),l(o),l(re),l(ce),l(E)),l(c),h(w,e),h(Z,e),h($,e),h(v,e),h(I,e),h(_,e),h(B,e),h(x,e),h(F,e)}}}const He='{"title":"텍스트 기반 image-to-image 생성","local":"텍스트-기반-image-to-image-생성","sections":[],"depth":1}';function Ne(ge){return _e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class De extends Ue{constructor(c){super(),Be(this,c,Ne,Ee,ke,{})}}export{De as component};
