Remove and Combine Backgrounds with AI
Howto & Style
Step 1: Article in Markdown Syntax
Introduction
Welcome, my friends! Today, I want to show you how to remove backgrounds using the Automatic 1111 and how to leverage it inside ComfyUI, where it's a lot more powerful. My Patreon supporters get this workflow and many other workflows and videos as rewards. Thanks for your support!
Removing Backgrounds in Automatic 1111
The process of removing backgrounds in Automatic 1111 is straightforward. There is an extension called stable-diffusion-webui-RMG
which you need to install. Here’s how to set it up:
Navigate to Extensions:
- Go to the Extensions tab in Automatic 1111.
Install the Extension:
- Click on 'Available' and then 'Load from'.
- Search for
stable-diffusion-webui-RMG
or browse the list to find it. - Click 'Install' on the right-hand side.
Apply and Restart:
- After installation, go to 'Installed' and click on 'Apply and Restart UI'.
Unfortunately, this extension does not work directly in the Text to Image tab. You need to create the image first and then send it to the 'Extras' tab.
- Send to Extras:
- Scroll down to the 'Remove Background' section.
- Check this option to open it up.
Here, you have multiple methods for background removal such as U-2-Net
, U-2-NetP
, U-2-Net Clothes
, etc. Choose the one that fits your need. When ready, click 'Generate'. This will produce a PNG download with a transparent background.
Fine-tuning the Background Removal
Inspect the Image:
- Click on the image to see if the background has been removed satisfactorily.
- Check for small gaps and edges.
Adjust Settings:
- Use 'Alpha Matting' settings to adjust the foreground and background thresholds.
- You can also tweak the 'Erode Size' for more refined results.
Choosing a Gray Studio Background
For characters, it's beneficial to use a gray studio background. Gray doesn’t interfere with most colors and doesn’t leave unwanted color spills around the edges.
Using ComfyUI for Enhanced Background Removal
ComfyUI offers more powerful and flexible options for background removal. Here’s how to set it up:
Render Your Character:
- Use prompts for creating a character, for example, a character in a studio on a gray background.
Render the Background:
- Create separate renders for the background; for instance, a teal and orange room.
Combine Foreground and Background:
- Use nodes to combine the character image with the background.
ComfyUI is versatile because it allows a range of options for editing the images, be it using masks or direct combination methods.
Example Workflows
Layer Style Pack:
- This method creates a mask for you.
- Combine using Layer Mask Generation and Pixel Spread.
VAS Pack:
- Directly removes the background to create a PNG with a transparent background.
- Combine foreground and background directly.
MixLab Pack:
- Offers different background removal methods similar to Automatic 1111.
- Outputs a mask and combines it with a composite node.
Finally, a denoise filter with a slight setting (e.g., 0.37) can help blend the character and background better.
Conclusion
ComfyUI is a powerful tool compared to Automatic 1111, offering more flexibility and advanced options for image processing. Let me know your thoughts in the comments. Thanks for watching and see you soon!
Keywords
- Background Removal
- Automatic 1111
- ComfyUI
- Stable Diffusion
- Layer Style Pack
- VAS Pack
- MixLab Pack
- PNG Download
- Alpha Matting
- Erode Size
- Gray Studio Background
FAQ
Q: What is the benefit of using a gray studio background?
A: Gray doesn’t interfere with most colors, doesn’t remove the colors out of the image, and doesn’t leave unwanted color spills.
Q: Which extension do I need for background removal in Automatic 1111?
A: You need the stable-diffusion-webui-RMG
extension.
Q: Can I use the background removal extension directly in the Text to Image tab of Automatic 1111?
A: No, you must first create the image and then use the background removal feature in the 'Extras' tab.
Q: What should I check after removing the background?
A: Inspect the edges and small gaps, such as between arms and torso, or fingers and background.
Q: What makes ComfyUI more powerful than Automatic 1111 for background removal?
A: ComfyUI offers more options for editing and combining images, and more settings for fine-tuning background removal.
Q: How do I combine foreground and background images in ComfyUI?
A: Use various nodes and packs such as Layer Style, VAS, and MixLab to combine images seamlessly.