How to Remove any Background in Stable Diffusion

Updated
How to Remove any Background in Stable Diffusion
Master the ultimate technique: Effortlessly remove backgrounds using stable diffusion for flawless edits. Elevate your image enhancement starting today.

1. Introduction

Step into the world of image editing excellence with the transformative power of stable diffusion. This guide unlocks the effortless art of background removal, enabling you to achieve flawlessness in every edit. Join us as we explore how this groundbreaking technique can elevate your image enhancement endeavors and bring your creative vision to life.

2. Install Remove Background Extension

To facilitate background removal using stable diffusion, it's necessary to acquire and install a dedicated extension. For this you can follow the following steps:

  • Open your Stable Diffusion Web UI.
  • Navigate to the Extensions tab within Stable Diffusion.
  • Go to the Install from URL subsection.
  • Paste the following URL: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg
  • Click on the Install button to download the extension

how-to-remove-any-background-in-stable-diffusion-download-extension.webp

Once you've installed it, head over to the Installed tab, and give a click on Apply and restart UI. This will ensure the successful installation of the extension. After you've successfully installed it, you can spot the downloaded extension in the "\stable-diffusion-webui\extensions" folder:

how-to-remove-any-background-in-stable-diffusion-download-extension-folder-remove-background.webp

Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds
20% bonus on first deposit

3. Craft an Initial Image (with background)

Before diving into background removal, let's first craft an image to work on. We'll accomplish this using our own prompt generator extension to generate a portrait of a woman. To learn more and see how to install this extension you can have a look here:

Dive into Creativity: Stable Diffusion New Prompt Extension

Certainly, feel welcome to devise your own prompt. However, I believe this extension could offer you swift idea inspiration.

The image provided below has been created through the use of the extension in the txt2img tab:

how-to-remove-any-background-in-stable-diffusion-download-extension-example-with-background.webp

  • Positive Prompt: ((Captivating)), ((Exquisite)), ((Masterpiece)), ((Impressive)), ((Intricate)), ((Mind-blowing)), women, Mexican woman, Mexican, Mexicana Woman, raw photo, Unedited photo, Original photo, Unprocessed photo, Atmospheric illumination, Light scattering, Hazy lighting, Wide aperture, Zoom lens, Shallow depth of field, beach background
  • Negative Prompt: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark
  • Sampling Steps: 30
  • Sampler: DDIM
  • CFG scale: 7
  • Size: 704x392 (16:9)
  • Model: cyberrealistic

Now, let's witness the remove background extension in action. We'll delve into the process of removing the background from the image we just generated.

4. Use Remove Background Extension

Having recently created an image through the txt2img tab, you'll notice a set of buttons located beneath the image. Our next step involves clicking the Send to extras button, which will ensure the image is properly placed for the eventual background removal process.

how-to-remove-any-background-in-stable-diffusion-send-to-extras-next-diffusion.webp

After you've clicked the Send to extras button and the extension has been installed successfully, you'll notice a Remove background section located at the lower left corner:

how-to-remove-any-background-in-stable-diffusion-remove-background-section-extras-next-diffusion.webp

Now there are several remove background methods to choose from:

  • u2net
  • u2netp
  • u2net_human_seg
  • u2net_cloth_seg
  • silueta
  • isnet-general-use
  • isnet-anime

I've observed that the u2net background removal method exhibits the highest consistency across various image types. Therefore, let's opt for that. Additionally, remember that there's a Resize option; I'll set this to 1 to maintain the image's original size. Here are the settings I'll be using before proceeding to generate and remove the background:

how-to-remove-any-background-in-stable-diffusion-final-settings-remove-background-extension-next-dif.webp

Now, go ahead and click the Generate button to witness the enchantment of the background removal extension in action:

how_to_remove_any_background_in_stable_diffusion_no-background-example-transformed.webp

The newly generated image will have a transparent background and will be saved in the outputs folder

Ouputs folder

All the images from which the background has been removed will be stored in the "outputs\extras-images" folder:

how-to-remove-any-background-in-stable-diffusion-outputs-folder-nextdiffusion.webp

Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

5. Extras Tab Stable Diffusion

If you already possess a previously generated image, you can immediately navigate to the Extras section located within Stable Diffusion. Within this section, you have the option to either Drag and Drop or Upload an image onto the image canvas:

how_to_remove_any_background_in_stable_diffusion_example_1_nextdiffusion.webp

Ensure that you choose the u2net technique for background removal and select a Resize value of 1 if you wish to maintain the original size of the initial image without any changes. Go ahead and hit that Generate button, and watch as the background disappears like it's pulling a disappearing act that would make even a magician jealous!

how_to_remove_any_background_in_stable_diffusion_example_1_nextdiffusion-no_bg.webp

6. Batch Background Removal (Multiple Images)

You also have the capability to eliminate backgrounds from numerous images simultaneously. Navigate to the Extras section and access the Batch from Directory subtab. Here, you can define the Input directory, which designates the pathway to the images you intend to have their backgrounds removed.

Should you prefer to maintain a streamlined approach, leaving the Output Directory field unfilled will result in the storage of background-removed images within the default output folder ("outputs\extras-images" folder). Below an example of how it should look when you fill in the Input Directory:

how_to_remove_any_background_in_stable_diffusion_batch_remove_backgrounds.webp

After choosing the u2net background removal method, clicking the Generate button will trigger the removal of backgrounds from all images within your Input Directory.

Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

7. Conclusion

As we arrive at the conclusion, we've truly embraced the art of background removal, harnessed the impressive capabilities of "u2net" and unveiled the secret to efficiently whisking away a bunch of backgrounds all at the same time—because who said editing can't be a bit like magic, where the more you make vanish, the merrier the result!

Frequently Asked Questions

To initiate background removal, begin by installing the dedicated extension associated with stable diffusion. Once installed, this extension is your key to unlocking the potential of stable diffusion for seamless background removal.

Among the available options, the u2net background removal method has shown the highest consistency across different types of images. This method is a reliable choice to achieve dependable results. Keep in mind that you also have the option to use the Resize setting to maintain an image's original size during the removal process.

character creation tool card

AI Image Generation Tool

Create Your AI Images in Seconds!

News & Updates