Buckets:
| <meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{"local":"","sections":[{"local":"","sections":[{"local":"cpu","title":"CPU"},{"local":"gpu","title":"GPU"}],"title":"무μμμ± μ μ΄νκΈ°"},{"local":"","title":"κ²°μ λ‘ μ μκ³ λ¦¬μ¦"}],"title":"μ¬ν κ°λ₯ν νμ΄νλΌμΈ μμ±νκΈ°"}" data-svelte="svelte-1phssyn"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/assets/pages/__layout.svelte-hf-doc-builder.css"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/start-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/vendor-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/paths-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/pages/__layout.svelte-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/pages/using-diffusers/reproducibility.mdx-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/Tip-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/IconCopyLink-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/CodeBlock-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.21.0/ko/_app/chunks/DocNotebookDropdown-hf-doc-builder.js"> | |
| <h1 id="">μ¬ν κ°λ₯ν νμ΄νλΌμΈ μμ±νκΈ°</h1> | |
| <div class="flex space-x-1 absolute z-10 right-0 top-0"> | |
| <div class="relative colab-dropdown "> | |
| <button class=" " type="button"> | |
| <img alt="Open In Colab" class="!m-0" src="https://colab.research.google.com/assets/colab-badge.svg"> | |
| </button> | |
| </div> | |
| <div class="relative colab-dropdown "> | |
| <button class=" " type="button"> | |
| <img alt="Open In Studio Lab" class="!m-0" src="https://studiolab.sagemaker.aws/studiolab.svg"> | |
| </button> | |
| </div></div> | |
| <p>μ¬νμ±μ ν μ€νΈ, κ²°κ³Ό μ¬ν, κ·Έλ¦¬κ³ <a href="resuing_seeds">μ΄λ―Έμ§ νλ¦¬ν° λμ΄κΈ°</a>μμ μ€μν©λλ€. | |
| κ·Έλ¬λ diffusion λͺ¨λΈμ 무μμμ±μ λ§€λ² λͺ¨λΈμ΄ λμκ° λλ§λ€ νμ΄νλΌμΈμ΄ λ€λ₯Έ μ΄λ―Έμ§λ₯Ό μμ±ν μ μλλ‘ νλ μ΄μ λ‘ νμν©λλ€. | |
| νλ«νΌ κ°μ μ ννκ² λμΌν κ²°κ³Όλ₯Ό μ»μ μλ μμ§λ§, νΉμ νμ© λ²μ λ΄μμ λ¦΄λ¦¬μ€ λ° νλ«νΌ κ°μ κ²°κ³Όλ₯Ό μ¬νν μλ μμ΅λλ€. | |
| κ·ΈλΌμλ diffusion νμ΄νλΌμΈκ³Ό 체ν¬ν¬μΈνΈμ λ°λΌ νμ© μ€μ°¨κ° λ¬λΌμ§λλ€.</p> | |
| <p>diffusion λͺ¨λΈμμ 무μμμ±μ μμ²μ μ μ΄νκ±°λ κ²°μ λ‘ μ μκ³ λ¦¬μ¦μ μ¬μ©νλ λ°©λ²μ μ΄ν΄νλ κ²μ΄ μ€μν μ΄μ μ λλ€.</p> | |
| <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400"><p>π‘ Pytorchμ <a href="https://pytorch.org/docs/stable/notes/randomness.html" rel="nofollow">μ¬νμ±μ λν μ μΈ</a>λ₯Ό κΌ μ½μ΄λ³΄κΈΈ μΆμ²ν©λλ€:</p> | |
| <blockquote><p>μμ νκ² μ¬νκ°λ₯ν κ²°κ³Όλ Pytorch λ°°ν¬, κ°λ³μ μΈ μ»€λ°, νΉμ λ€λ₯Έ νλ«νΌλ€μμ 보μ₯λμ§ μμ΅λλ€. | |
| λν, κ²°κ³Όλ CPUμ GPU μ€νκ°μ μ¬μ§μ΄ κ°μ seedλ₯Ό μ¬μ©ν λλ μ¬ν κ°λ₯νμ§ μμ μ μμ΅λλ€.</p></blockquote></div> | |
| <h2 id="">무μμμ± μ μ΄νκΈ°</h2> | |
| <p>μΆλ‘ μμ, νμ΄νλΌμΈμ λ Έμ΄μ¦λ₯Ό μ€μ΄κΈ° μν΄ κ°μ°μμ λ Έμ΄μ¦λ₯Ό μμ±νκ±°λ μ€μΌμ€λ§ λ¨κ³μ λ Έμ΄μ¦λ₯Ό λνλ λ±μ λλ€ μνλ§ μ€νμ ν¬κ² μμ‘΄ν©λλ€,</p> | |
| <p><a href="https://huggingface.co/docs/diffusers/v0.18.0/en/api/pipelines/ddim#diffusers.DDIMPipeline" rel="nofollow">DDIMPipeline</a>μμ λ μΆλ‘ λ¨κ³ μ΄νμ ν μ κ°μ μ΄ν΄λ³΄μΈμ:</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMPipeline | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| model_id = <span class="hljs-string">"google/ddpm-cifar10-32"</span> | |
| <span class="hljs-comment"># λͺ¨λΈκ³Ό μ€μΌμ€λ¬λ₯Ό λΆλ¬μ€κΈ°</span> | |
| ddim = DDIMPipeline.from_pretrained(model_id) | |
| <span class="hljs-comment"># λ κ°μ λ¨κ³μ λν΄μ νμ΄νλΌμΈμ μ€ννκ³ numpy tensorλ‘ κ°μ λ°ννκΈ°</span> | |
| image = ddim(num_inference_steps=<span class="hljs-number">2</span>, output_type=<span class="hljs-string">"np"</span>).images | |
| <span class="hljs-built_in">print</span>(np.<span class="hljs-built_in">abs</span>(image).<span class="hljs-built_in">sum</span>())<!-- HTML_TAG_END --></pre></div> | |
| <p>μμ μ½λλ₯Ό μ€ννλ©΄ νλμ κ°μ΄ λμ€μ§λ§, λ€μ μ€ννλ©΄ λ€λ₯Έ κ°μ΄ λμ΅λλ€. λ¬΄μ¨ μΌμ΄ μΌμ΄λκ³ μλ κ±ΈκΉμ?</p> | |
| <p>νμ΄νλΌμΈμ΄ μ€νλ λλ§λ€, <a href="https://pytorch.org/docs/stable/generated/torch.randn.html" rel="nofollow">torch.randn</a>μ | |
| λ¨κ³μ μΌλ‘ λ Έμ΄μ¦ μ κ±°λλ κ°μ°μμ λ Έμ΄μ¦κ° μμ±νκΈ° μν λ€λ₯Έ λλ€ seedλ₯Ό μ¬μ©ν©λλ€.</p> | |
| <p>κ·Έλ¬λ λμΌν μ΄λ―Έμ§λ₯Ό μμ μ μΌλ‘ μμ±ν΄μΌ νλ κ²½μ°μλ CPUμμ νμ΄νλΌμΈμ μ€ννλμ§ GPUμμ μ€ννλμ§μ λ°λΌ λ¬λΌμ§λλ€.</p> | |
| <h3 class="relative group"><a id="cpu" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cpu"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> | |
| <span>CPU | |
| </span></h3> | |
| <p>CPUμμ μ¬ν κ°λ₯ν κ²°κ³Όλ₯Ό μμ±νλ €λ©΄, PyTorch <a href="https://pytorch.org/docs/stable/generated/torch.randn.html" rel="nofollow">Generator</a>λ‘ seedλ₯Ό κ³ μ ν©λλ€:</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMPipeline | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| model_id = <span class="hljs-string">"google/ddpm-cifar10-32"</span> | |
| <span class="hljs-comment"># λͺ¨λΈκ³Ό μ€μΌμ€λ¬ λΆλ¬μ€κΈ°</span> | |
| ddim = DDIMPipeline.from_pretrained(model_id) | |
| <span class="hljs-comment"># μ¬νμ±μ μν΄ generator λ§λ€κΈ°</span> | |
| generator = torch.Generator(device=<span class="hljs-string">"cpu"</span>).manual_seed(<span class="hljs-number">0</span>) | |
| <span class="hljs-comment"># λ κ°μ λ¨κ³μ λν΄μ νμ΄νλΌμΈμ μ€ννκ³ numpy tensorλ‘ κ°μ λ°ννκΈ°</span> | |
| image = ddim(num_inference_steps=<span class="hljs-number">2</span>, output_type=<span class="hljs-string">"np"</span>, generator=generator).images | |
| <span class="hljs-built_in">print</span>(np.<span class="hljs-built_in">abs</span>(image).<span class="hljs-built_in">sum</span>())<!-- HTML_TAG_END --></pre></div> | |
| <p>μ΄μ μμ μ½λλ₯Ό μ€ννλ©΄ seedλ₯Ό κ°μ§ <code>Generator</code> κ°μ²΄κ° νμ΄νλΌμΈμ λͺ¨λ λλ€ ν¨μμ μ λ¬λλ―λ‘ νμ <code>1491.1711</code> κ°μ΄ μΆλ ₯λ©λλ€.</p> | |
| <p>νΉμ νλμ¨μ΄ λ° PyTorch λ²μ μμ μ΄ μ½λ μμ λ₯Ό μ€ννλ©΄ λμΌνμ§λ μλλΌλ μ μ¬ν κ²°κ³Όλ₯Ό μ»μ μ μμ΅λλ€.</p> | |
| <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400"><p>π‘ μ²μμλ μλλ₯Ό λνλ΄λ μ μκ° λμ μ <code>Generator</code> κ°μ²΄λ₯Ό νμ΄νλΌμΈμ μ λ¬νλ κ²μ΄ μ½κ° λΉμ§κ΄μ μΌ μ μμ§λ§, | |
| <code>Generator</code>λ μμ°¨μ μΌλ‘ μ¬λ¬ νμ΄νλΌμΈμ μ λ¬λ μ μλ \λλ€μν\μ΄κΈ° λλ¬Έμ PyTorchμμ νλ₯ λ‘ μ λͺ¨λΈμ λ€λ£° λ κΆμ₯λλ μ€κ³μ λλ€.</p></div> | |
| <h3 class="relative group"><a id="gpu" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#gpu"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> | |
| <span>GPU | |
| </span></h3> | |
| <p>μλ₯Ό λ€λ©΄, GPU μμμ κ°μ μ½λ μμλ₯Ό μ€ννλ©΄:</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMPipeline | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| model_id = <span class="hljs-string">"google/ddpm-cifar10-32"</span> | |
| <span class="hljs-comment"># λͺ¨λΈκ³Ό μ€μΌμ€λ¬ λΆλ¬μ€κΈ°</span> | |
| ddim = DDIMPipeline.from_pretrained(model_id) | |
| ddim.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-comment"># μ¬νμ±μ μν generator λ§λ€κΈ°</span> | |
| generator = torch.Generator(device=<span class="hljs-string">"cuda"</span>).manual_seed(<span class="hljs-number">0</span>) | |
| <span class="hljs-comment"># λ κ°μ λ¨κ³μ λν΄μ νμ΄νλΌμΈμ μ€ννκ³ numpy tensorλ‘ κ°μ λ°ννκΈ°</span> | |
| image = ddim(num_inference_steps=<span class="hljs-number">2</span>, output_type=<span class="hljs-string">"np"</span>, generator=generator).images | |
| <span class="hljs-built_in">print</span>(np.<span class="hljs-built_in">abs</span>(image).<span class="hljs-built_in">sum</span>())<!-- HTML_TAG_END --></pre></div> | |
| <p>GPUκ° CPUμ λ€λ₯Έ λμ μμ±κΈ°λ₯Ό μ¬μ©νκΈ° λλ¬Έμ λμΌν μλλ₯Ό μ¬μ©νλλΌλ κ²°κ³Όκ° κ°μ§ μμ΅λλ€.</p> | |
| <p>μ΄ λ¬Έμ λ₯Ό νΌνκΈ° μν΄ π§¨ Diffusersλ CPUμ μμμ λ Έμ΄μ¦λ₯Ό μμ±ν λ€μ νμμ λ°λΌ ν μλ₯Ό GPUλ‘ μ΄λμν€λ | |
| <a href="https://huggingface.co/docs/diffusers/v0.18.0/en/api/utilities#diffusers.utils.randn_tensor" rel="nofollow">randn_tensor()</a>κΈ°λ₯μ κ°μ§κ³ μμ΅λλ€. | |
| <code>randn_tensor</code> κΈ°λ₯μ νμ΄νλΌμΈ λ΄λΆ μ΄λμμλ μ¬μ©λλ―λ‘ νμ΄νλΌμΈμ΄ GPUμμ μ€νλλλΌλ <strong>νμ</strong> CPU <code>Generator</code>λ₯Ό ν΅κ³Όν μ μμ΅λλ€.</p> | |
| <p>μ΄μ κ²°κ³Όμ ν¨μ¬ λ λ€κ°μμ΅λλ€!</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMPipeline | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| model_id = <span class="hljs-string">"google/ddpm-cifar10-32"</span> | |
| <span class="hljs-comment"># λͺ¨λΈκ³Ό μ€μΌμ€λ¬ λΆλ¬μ€κΈ°</span> | |
| ddim = DDIMPipeline.from_pretrained(model_id) | |
| ddim.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-comment">#μ¬νμ±μ μν generator λ§λ€κΈ° (GPUμ μ¬λ¦¬μ§ μλλ‘ μ‘°μ¬νλ€!)</span> | |
| generator = torch.manual_seed(<span class="hljs-number">0</span>) | |
| <span class="hljs-comment"># λ κ°μ λ¨κ³μ λν΄μ νμ΄νλΌμΈμ μ€ννκ³ numpy tensorλ‘ κ°μ λ°ννκΈ°</span> | |
| image = ddim(num_inference_steps=<span class="hljs-number">2</span>, output_type=<span class="hljs-string">"np"</span>, generator=generator).images | |
| <span class="hljs-built_in">print</span>(np.<span class="hljs-built_in">abs</span>(image).<span class="hljs-built_in">sum</span>())<!-- HTML_TAG_END --></pre></div> | |
| <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400"><p>π‘ μ¬νμ±μ΄ μ€μν κ²½μ°μλ νμ CPU generatorλ₯Ό μ λ¬νλ κ²μ΄ μ’μ΅λλ€. | |
| μ±λ₯ μμ€μ 무μν μ μλ κ²½μ°κ° λ§μΌλ©° νμ΄νλΌμΈμ΄ GPUμμ μ€νλμμ λλ³΄λ€ ν¨μ¬ λ λΉμ·ν κ°μ μμ±ν μ μμ΅λλ€.</p></div> | |
| <p>λ§μ§λ§μΌλ‘ <a href="https://huggingface.co/docs/diffusers/v0.18.0/en/api/pipelines/unclip#diffusers.UnCLIPPipeline" rel="nofollow">UnCLIPPipeline</a>κ³Ό κ°μ | |
| λ 볡μ‘ν νμ΄νλΌμΈμ κ²½μ°, μ΄λ€μ μ’ μ’ μ λ° μ€μ°¨ μ νμ κ·Ήλλ‘ μ·¨μ½ν©λλ€. | |
| λ€λ₯Έ GPU νλμ¨μ΄ λλ PyTorch λ²μ μμ μ μ¬ν κ²°κ³Όλ₯Ό κΈ°λνμ§ λ§μΈμ. | |
| μ΄ κ²½μ° μμ ν μ¬νμ±μ μν΄ μμ ν λμΌν νλμ¨μ΄ λ° PyTorch λ²μ μ μ€νν΄μΌ ν©λλ€.</p> | |
| <h2 id="">κ²°μ λ‘ μ μκ³ λ¦¬μ¦</h2> | |
| <p>κ²°μ λ‘ μ μκ³ λ¦¬μ¦μ μ¬μ©νμ¬ μ¬ν κ°λ₯ν νμ΄νλΌμΈμ μμ±νλλ‘ PyTorchλ₯Ό ꡬμ±ν μλ μμ΅λλ€. | |
| κ·Έλ¬λ κ²°μ λ‘ μ μκ³ λ¦¬μ¦μ λΉκ²°μ λ‘ μ μκ³ λ¦¬μ¦λ³΄λ€ λλ¦¬κ³ μ±λ₯μ΄ μ νλ μ μμ΅λλ€. | |
| νμ§λ§ μ¬νμ±μ΄ μ€μνλ€λ©΄, μ΄κ²μ΄ μ΅μ μ λ°©λ²μ λλ€!</p> | |
| <p>λ μ΄μμ CUDA μ€νΈλ¦Όμμ μμ μ΄ μμλ λ λΉκ²°μ λ‘ μ λμμ΄ λ°μν©λλ€. | |
| μ΄ λ¬Έμ λ₯Ό λ°©μ§νλ €λ©΄ νκ²½ λ³μ <a href="https://docs.nvidia.com/cuda/cublas/index.html#results-reproducibility" rel="nofollow">CUBLAS_WORKSPACE_CONFIG</a>λ₯Ό <code>:16:8</code>λ‘ μ€μ ν΄μ | |
| λ°νμ μ€μ μ€μ§ νλμ λ²νΌ ν¬λ¦¬λ§ μ¬μ©νλλ‘ μ€μ ν©λλ€.</p> | |
| <p>PyTorchλ μΌλ°μ μΌλ‘ κ°μ₯ λΉ λ₯Έ μκ³ λ¦¬μ¦μ μ ννκΈ° μν΄ μ¬λ¬ μκ³ λ¦¬μ¦μ λ²€μΉλ§νΉν©λλ€. | |
| νμ§λ§ μ¬νμ±μ μνλ κ²½μ°, λ²€μΉλ§ν¬κ° λ§€ μκ° λ€λ₯Έ μκ³ λ¦¬μ¦μ μ νν μ μκΈ° λλ¬Έμ μ΄ κΈ°λ₯μ μ¬μ©νμ§ μλλ‘ μ€μ ν΄μΌ ν©λλ€. | |
| λ§μ§λ§μΌλ‘, <a href="https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html" rel="nofollow">torch.use_deterministic_algorithms</a>μ | |
| <code>True</code>λ₯Ό ν΅κ³ΌμμΌ κ²°μ λ‘ μ μκ³ λ¦¬μ¦μ΄ νμ±ν λλλ‘ ν©λλ€.</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> os | |
| os.environ[<span class="hljs-string">"CUBLAS_WORKSPACE_CONFIG"</span>] = <span class="hljs-string">":16:8"</span> | |
| torch.backends.cudnn.benchmark = <span class="hljs-literal">False</span> | |
| torch.use_deterministic_algorithms(<span class="hljs-literal">True</span>)<!-- HTML_TAG_END --></pre></div> | |
| <p>μ΄μ λμΌν νμ΄νλΌμΈμ λλ² μ€ννλ©΄ λμΌν κ²°κ³Όλ₯Ό μ»μ μ μμ΅λλ€.</p> | |
| <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> | |
| <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> | |
| Copied</div></button></div> | |
| <pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMScheduler, StableDiffusionPipeline | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| model_id = <span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span> | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id).to(<span class="hljs-string">"cuda"</span>) | |
| pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config) | |
| g = torch.Generator(device=<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"A bear is playing a guitar on Times Square"</span> | |
| g.manual_seed(<span class="hljs-number">0</span>) | |
| result1 = pipe(prompt=prompt, num_inference_steps=<span class="hljs-number">50</span>, generator=g, output_type=<span class="hljs-string">"latent"</span>).images | |
| g.manual_seed(<span class="hljs-number">0</span>) | |
| result2 = pipe(prompt=prompt, num_inference_steps=<span class="hljs-number">50</span>, generator=g, output_type=<span class="hljs-string">"latent"</span>).images | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"L_inf dist = "</span>, <span class="hljs-built_in">abs</span>(result1 - result2).<span class="hljs-built_in">max</span>()) | |
| <span class="hljs-string">"L_inf dist = tensor(0., device='cuda:0')"</span><!-- HTML_TAG_END --></pre></div> | |
| <script type="module" data-hydrate="kk57mo"> | |
| import { start } from "/docs/diffusers/v0.21.0/ko/_app/start-hf-doc-builder.js"; | |
| start({ | |
| target: document.querySelector('[data-hydrate="kk57mo"]').parentNode, | |
| paths: {"base":"/docs/diffusers/v0.21.0/ko","assets":"/docs/diffusers/v0.21.0/ko"}, | |
| session: {}, | |
| route: false, | |
| spa: false, | |
| trailing_slash: "never", | |
| hydrate: { | |
| status: 200, | |
| error: null, | |
| nodes: [ | |
| import("/docs/diffusers/v0.21.0/ko/_app/pages/__layout.svelte-hf-doc-builder.js"), | |
| import("/docs/diffusers/v0.21.0/ko/_app/pages/using-diffusers/reproducibility.mdx-hf-doc-builder.js") | |
| ], | |
| params: {} | |
| } | |
| }); | |
| </script> | |
Xet Storage Details
- Size:
- 25.3 kB
- Xet hash:
- 9881fb8ce36b511bb518ff8089cdb478dd842e4add44b0e5047e07ec5c5c3140
Β·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.