Buckets:
| <meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{"local":"stable-diffusion-2","sections":[{"local":"tips","sections":[{"local":"available-checkpoints","title":"Available checkpoints:"},{"local":"how-to-load-and-use-different-schedulers","title":"How to load and use different schedulers."}],"title":"Tips"}],"title":"Stable diffusion 2"}" data-svelte="svelte-1phssyn"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/assets/pages/__layout.svelte-hf-doc-builder.css"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/start-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/chunks/vendor-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/chunks/paths-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/pages/__layout.svelte-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/pages/api/pipelines/stable_diffusion_2.mdx-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/chunks/IconCopyLink-hf-doc-builder.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/v0.9.0/en/_app/chunks/CodeBlock-hf-doc-builder.js"> | |
| <h1 class="relative group"><a id="stable-diffusion-2" 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="#stable-diffusion-2"><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>Stable diffusion 2 | |
| </span></h1> | |
| <p>Stable Diffusion 2 is a text-to-image <em>latent diffusion</em> model built upon the work of <a href="https://stability.ai/blog/stable-diffusion-public-release" rel="nofollow">Stable Diffusion 1</a>. | |
| The project to train Stable Diffusion 2 was led by Robin Rombach and Katherine Crowson from <a href="https://stability.ai/" rel="nofollow">Stability AI</a> and <a href="https://laion.ai/" rel="nofollow">LAION</a>.</p> | |
| <p><em>The Stable Diffusion 2.0 release includes robust text-to-image models trained using a brand new text encoder (OpenCLIP), developed by LAION with support from Stability AI, which greatly improves the quality of the generated images compared to earlier V1 releases. The text-to-image models in this release can generate images with default resolutions of both 512x512 pixels and 768x768 pixels. | |
| These models are trained on an aesthetic subset of the <a href="https://laion.ai/blog/laion-5b/" rel="nofollow">LAION-5B dataset</a> created by the DeepFloyd team at Stability AI, which is then further filtered to remove adult content using <a href="https://openreview.net/forum?id=M3Y74vmsMcY" rel="nofollow">LAION’s NSFW filter</a>.</em></p> | |
| <p>For more details about how Stable Diffusion 2 works and how it differs from Stable Diffusion 1, please refer to the official <a href="https://stability.ai/blog/stable-diffusion-v2-release" rel="nofollow">launch announcement post</a>.</p> | |
| <h2 class="relative group"><a id="tips" 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="#tips"><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>Tips | |
| </span></h2> | |
| <h3 class="relative group"><a id="available-checkpoints" 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="#available-checkpoints"><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>Available checkpoints: | |
| </span></h3> | |
| <p>Note that the architecture is more or less identical to <a href="./api/pipelines/stable_diffusion">Stable Diffusion 1</a> so please refer to <a href="./api/pipelines/stable_diffusion">this page</a> for API documentation.</p> | |
| <ul><li><em>Text-to-Image (512x512 resolution)</em>: <a href="https://huggingface.co/stabilityai/stable-diffusion-2-base" rel="nofollow">stabilityai/stable-diffusion-2-base</a> with <a href="/docs/diffusers/v0.9.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a></li> | |
| <li><em>Text-to-Image (768x768 resolution)</em>: <a href="https://huggingface.co/stabilityai/stable-diffusion-2" rel="nofollow">stabilityai/stable-diffusion-2</a> with <a href="/docs/diffusers/v0.9.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a></li> | |
| <li><em>Image Inpainting (512x512 resolution)</em>: <a href="https://huggingface.co/stabilityai/stable-diffusion-2-inpainting" rel="nofollow">stabilityai/stable-diffusion-2-inpainting</a> with <a href="/docs/diffusers/v0.9.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionInpaintPipeline">StableDiffusionInpaintPipeline</a></li> | |
| <li><em>Image Upscaling (x4 resolution resolution)</em>: <a href="https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler" rel="nofollow">stable-diffusion-x4-upscaler</a> <a href="/docs/diffusers/v0.9.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionUpscalePipeline">StableDiffusionUpscalePipeline</a></li></ul> | |
| <p>We recommend using the <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.DPMSolverMultistepScheduler">DPMSolverMultistepScheduler</a> as it’s currently the fastest scheduler there is.</p> | |
| <ul><li><em>Text-to-Image (512x512 resolution)</em>:</li></ul> | |
| <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> DiffusionPipeline, DPMSolverMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| repo_id = <span class="hljs-string">"stabilityai/stable-diffusion-2-base"</span> | |
| pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, revision=<span class="hljs-string">"fp16"</span>) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"High quality photo of an astronaut riding a horse in space"</span> | |
| image = pipe(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"astronaut.png"</span>)<!-- HTML_TAG_END --></pre></div> | |
| <ul><li><em>Text-to-Image (768x768 resolution)</em>:</li></ul> | |
| <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> DiffusionPipeline, DPMSolverMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| repo_id = <span class="hljs-string">"stabilityai/stable-diffusion-2"</span> | |
| pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, revision=<span class="hljs-string">"fp16"</span>) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"High quality photo of an astronaut riding a horse in space"</span> | |
| image = pipe(prompt, guidance_scale=<span class="hljs-number">9</span>, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"astronaut.png"</span>)<!-- HTML_TAG_END --></pre></div> | |
| <ul><li><em>Image Inpainting (512x512 resolution)</em>:</li></ul> | |
| <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> PIL | |
| <span class="hljs-keyword">import</span> requests | |
| <span class="hljs-keyword">import</span> torch | |
| <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> DiffusionPipeline, DPMSolverMultistepScheduler | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>): | |
| response = requests.get(url) | |
| <span class="hljs-keyword">return</span> PIL.Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">"RGB"</span>) | |
| img_url = <span class="hljs-string">"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"</span> | |
| mask_url = <span class="hljs-string">"https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"</span> | |
| init_image = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)) | |
| mask_image = download_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)) | |
| repo_id = <span class="hljs-string">"stabilityai/stable-diffusion-2-inpainting"</span> | |
| pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, revision=<span class="hljs-string">"fp16"</span>) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"Face of a yellow cat, high resolution, sitting on a park bench"</span> | |
| image = pipe(prompt=prompt, image=init_image, mask_image=mask_image, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"yellow_cat.png"</span>)<!-- HTML_TAG_END --></pre></div> | |
| <ul><li><em>Image Upscaling (x4 resolution resolution)</em>: <a href="https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler" rel="nofollow">stable-diffusion-x4-upscaler</a> <a href="/docs/diffusers/v0.9.0/en/api/pipelines/stable_diffusion#diffusers.StableDiffusionUpscalePipeline">StableDiffusionUpscalePipeline</a></li></ul> | |
| <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> 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> StableDiffusionUpscalePipeline | |
| <span class="hljs-keyword">import</span> torch | |
| <span class="hljs-comment"># load model and scheduler</span> | |
| model_id = <span class="hljs-string">"stabilityai/stable-diffusion-x4-upscaler"</span> | |
| pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id, revision=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16) | |
| pipeline = pipeline.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-comment"># let's download an image</span> | |
| url = <span class="hljs-string">"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png"</span> | |
| response = requests.get(url) | |
| low_res_img = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">"RGB"</span>) | |
| low_res_img = low_res_img.resize((<span class="hljs-number">128</span>, <span class="hljs-number">128</span>)) | |
| prompt = <span class="hljs-string">"a white cat"</span> | |
| upscaled_image = pipeline(prompt=prompt, image=low_res_img).images[<span class="hljs-number">0</span>] | |
| upscaled_image.save(<span class="hljs-string">"upsampled_cat.png"</span>)<!-- HTML_TAG_END --></pre></div> | |
| <h3 class="relative group"><a id="how-to-load-and-use-different-schedulers" 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="#how-to-load-and-use-different-schedulers"><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>How to load and use different schedulers. | |
| </span></h3> | |
| <p>The stable diffusion pipeline uses <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.DDIMScheduler">DDIMScheduler</a> scheduler by default. But <code>diffusers</code> provides many other schedulers that can be used with the stable diffusion pipeline such as <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.PNDMScheduler">PNDMScheduler</a>, <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a>, <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.EulerAncestralDiscreteScheduler">EulerAncestralDiscreteScheduler</a> etc. | |
| To use a different scheduler, you can either change it via the <a href="/docs/diffusers/v0.9.0/en/using-diffusers/configuration#diffusers.ConfigMixin.from_config">ConfigMixin.from_config()</a> method or pass the <code>scheduler</code> argument to the <code>from_pretrained</code> method of the pipeline. For example, to use the <a href="/docs/diffusers/v0.9.0/en/api/schedulers#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a>, you can do the following:</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-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, EulerDiscreteScheduler | |
| <span class="hljs-meta">>>> </span>pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">"stabilityai/stable-diffusion-2"</span>) | |
| <span class="hljs-meta">>>> </span>pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># or</span> | |
| <span class="hljs-meta">>>> </span>euler_scheduler = EulerDiscreteScheduler.from_pretrained(<span class="hljs-string">"stabilityai/stable-diffusion-2"</span>, subfolder=<span class="hljs-string">"scheduler"</span>) | |
| <span class="hljs-meta">>>> </span>pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">"stabilityai/stable-diffusion-2"</span>, scheduler=euler_scheduler)<!-- HTML_TAG_END --></pre></div> | |
| <script type="module" data-hydrate="si6dzx"> | |
| import { start } from "/docs/diffusers/v0.9.0/en/_app/start-hf-doc-builder.js"; | |
| start({ | |
| target: document.querySelector('[data-hydrate="si6dzx"]').parentNode, | |
| paths: {"base":"/docs/diffusers/v0.9.0/en","assets":"/docs/diffusers/v0.9.0/en"}, | |
| session: {}, | |
| route: false, | |
| spa: false, | |
| trailing_slash: "never", | |
| hydrate: { | |
| status: 200, | |
| error: null, | |
| nodes: [ | |
| import("/docs/diffusers/v0.9.0/en/_app/pages/__layout.svelte-hf-doc-builder.js"), | |
| import("/docs/diffusers/v0.9.0/en/_app/pages/api/pipelines/stable_diffusion_2.mdx-hf-doc-builder.js") | |
| ], | |
| params: {} | |
| } | |
| }); | |
| </script> | |
Xet Storage Details
- Size:
- 23.9 kB
- Xet hash:
- 53900b86eef838caee43ae411b27047e150a4460a793f4e16b63bd9c430e7ced
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.