Skip to content

Product Background Removal and Replacement: BiRefNet Local, Qwen-2.1 Transparent Background, Bria Cloud ​

💡 One-sentence summary: Use ComfyUI to build a product background removal and replacement pipeline — BiRefNet for local background removal, Qwen-2.1 for direct transparent-background output, Bria for cloud batching.

When making e-commerce images, you most often run into three things: listings need white or transparent backgrounds, detail pages need scene replacement, and batches of images need uniform processing. This page gives you three ComfyUI background removal routes—pick one based on your device and purpose and see it through.

What You'll Be Able to Do After This Lesson ​

  • Cut out a transparent-background product PNG with clean edges: BiRefNet runs locally, free and offline.
  • Get a reusable workflow with dual outputs of "mask + RGBA transparent background"—just swap in another image and run it again.
  • Generate a new product image with a built-in transparent background from a single sentence (the Qwen-2.1 route, ideal for items not yet photographed).
  • Build a decision framework for choosing a route by device: pick one of local-free, generate-direct, or cloud-batch.

Why Use ComfyUI Instead of Online Background Removal Tools? ​

CapabilityOnline Background Removal ToolsComfyUI
Original image privacy❌ Images must be uploaded to their servers✅ BiRefNet runs locally; original images never leave your computer
Batch processing❌ Free tiers usually limit the number of images, requiring one-by-one uploads✅ Workflows run queues—load a batch and go
Downstream processing❌ Download the cutout first, then upload it to another tool✅ The transparent background connects directly to upscaling, compositing, and video nodes
Algorithm choice❌ You're stuck with their one and only model✅ Switch between BiRefNet, Qwen-2.1, and Bria per image
Long-term cost❌ Pay per image once the free quota runs out✅ Local models are free; cloud nodes have clearly priced credits

Your Current Pain Points ​

  • Platform listings require white or transparent backgrounds, but your photos come back with everyday scene backgrounds—retouching them one by one is enough to make your eyes blur.
  • You want to swap scene backgrounds on detail pages, but the online tool's free quota is used up, and paying only solves the background removal step.
  • A batch of new product images needs uniform processing—upload one by one, download one by one, and resizing means doing it all over again.
  • The new product hasn't been scheduled for photography yet, but the listing needs images first—where do the images come from?

When to Use This Technique ​

  • You already have real product photos and just need to cut out the subject and output a transparent-background PNG: go with the BiRefNet local solution—free and offline.
  • The product image hasn't been shot yet, or you want to combine "generate + background removal" into one step: go with Qwen-Image-2.1, which supports alpha transparent-background output.
  • No local GPU, or you need cloud batch processing: go with the Bria background removal API.

🎒 Preparation Before Starting ​

  1. Update ComfyUI to a fairly recent version (BiRefNet is a newly natively supported feature that older versions lack), then go through the Model × Task Overview to confirm your VRAM and use case match.
  2. BiRefNet route: download birefnet.safetensors, place it in the models/background_removal/ directory, and restart ComfyUI.
  3. Qwen-2.1 route: prepare the model files following the Qwen-Image-2.1 model page.
  4. Bria route: log in to your ComfyUI account and have credits ready—Bria is a cloud Partner node that deducts credits per use, with no local model download.

Follow Along ​

Step 1: Download the BiRefNet model into the background_removal directory ​

First, prepare the model locally: BiRefNet is a background removal model natively supported by ComfyUI, free to run locally with no original images uploaded.

Download birefnet.safetensors from Comfy-Org's BiRefNet model repository and place it in the location below (note: not the checkpoints folder):

ComfyUI/
└── models/
    └── background_removal/
        └── birefnet.safetensors

Restart ComfyUI after placing it—it only scans the model directory at startup.

You should see: after the restart, the bg_removal_name parameter of the Remove Background (BiRefNet) subgraph in the template offers birefnet as an option.

Step 2: Run the BiRefNet template to complete your first ComfyUI background removal ​

The template already has all the wiring done, so you don't need to build a workflow from scratch.

Top menu Workflow → Browse Templates; find "BiRefNet: Remove Background" under the Utility category and load it (you can also search for this name directly in the template library). Upload a product image in the LoadImage node and click Queue to run it once.

You should see: results in two preview windows—PreviewImage shows the cut-out transparent-background image (RGBA), and MaskPreview shows the black-and-white mask, where white is the product and black is the background.

💡 This is the unique value of ComfyUI

BiRefNet runs on your own computer: no internet, no fees, no original images uploaded. The cut-out transparent background doesn't need to be downloaded and re-uploaded—it connects directly to upscaling, compositing, and video nodes, so one workflow runs end to end.

Step 3: Inspect the mask edges to decide whether manual touch-up is needed ​

Mask quality directly determines how natural the result looks after the background replacement; checking before compositing saves rework.

Zoom in on the MaskPreview and focus on the product edges, cut-outs, straps, handles, and similar areas.

You should see: if the edges are clean and the cut-outs are clear, you can go straight to background replacement; if there's residual color or breaks along the edges, fix the mask manually before moving on.

Step 4: Use Qwen-2.1 to produce a transparent background directly from one sentence ​

When a new product hasn't been photographed yet, or you don't need to keep real-shot details, combine "generate product image" and "background removal" into a single step. The VAE of Qwen-Image-2.1 natively decodes 4 channels—the transparent background is generated directly into the alpha channel, not cut out afterwards.

Search the template library for "Remove Background: Qwen Image 2.1" to load it (it reuses the Image Edit (Qwen Image 2.1) subgraph), put the image to process into LoadImage, keep the prompt as Remove the background, and output a PNG image, and run the queue.

You should see: a PNG with a transparent channel is output, and you can compare the result with the original in ImageCompare.

Step 5: Batch background removal with Bria cloud ​

When you have no local GPU, or a batch of images needs uniform processing, the cloud node works once you log in—no model download required.

Search the template library for "Bria: Remove Image Background" and load it with one click, log in to your ComfyUI account (the Partner node requires an account), upload the product image to LoadImage, and run the queue.

You should see: the image is uploaded to the Bria cloud for processing and a transparent-background result is returned; each run deducts 3.8 credits.

📋 Magic Prompts ​

Two of the three routes are prompt-driven—copy the following lines directly.

🎯 One-sentence background removal ​

Expected result: a real photo goes in, a transparent-background PNG comes out, no manual mask editing needed.

text
Remove the background, and output a PNG image
  • Use in: the prompt input of the "Remove Background: Qwen Image 2.1" template; the template already includes this line, just leave it unchanged.
  • ✅ Save the result as PNG; saving as JPG will lose the alpha channel.
  • ✅ Set the resolution parameter to 0 to follow the input image's own dimensions.
  • ❌ Don't append background descriptions after this instruction—it only does background removal.

📝 Generate a transparent-background product image directly ​

Expected result: for new products that haven't been photographed yet, generate a product image with a built-in transparent background in one sentence.

text
This is an RGBA format image with transparency. 【你的商品描述,如 a glass perfume bottle】. The image has an alpha channel and a transparent background.
  • Use in: the prompt of the Qwen Image 2.1 text-to-image template; the first and last sentences are format notes from the template's tips, don't delete them.
  • ✅ Save as PNG to preserve the alpha channel.
  • ✅ Keep cfg at 1; this is the official path for Qwen-2.1.
  • ❌ Don't omit the first and last format-note sentences—they tell the model to output an alpha channel.

🔧 Extract only a specified subject from a cluttered scene ​

Expected result: for a scene with multiple people and objects, extract only the subject named in the prompt, keeping the original pixels at full resolution with a new alpha channel.

text
only the shoes
  • Use in: the prompt of the "Bria: Guided Background Removal" template; write the subject you want to keep, such as the man in the blue shirt or only the shoes.
  • ✅ Name the subject specifically in the prompt; the more explicit, the less likely the extraction goes wrong.
  • ❌ When the prompt doesn't match anything, the returned image is entirely transparent.

Checkpoints ✅ ​

  • Edges: zoom into MaskPreview and check whether product edges, cutouts, straps, and similar spots have leftover colors or breaks.
  • Format: transparent backgrounds can only be saved as PNG, not JPG, otherwise the alpha channel will be lost.
  • Background replacement: composite the transparent-background image from the IMAGE output directly with the background image; unify the dimensions of both images before compositing.

Pitfall warnings ​

  • Model placed in the wrong directory: birefnet.safetensors must be placed in models/background_removal/; putting it in checkpoints won't be recognized; restart ComfyUI after placing it for it to take effect.
  • When BiRefNet encounters an extremely cluttered background, or a subject that blends into the background (such as glass or sheer semi-transparent products), the mask can easily be inaccurate and needs manual touch-ups.
  • Qwen-2.1 is a generative route and will rewrite product details, so it's not suitable for images that require photographic fidelity.
  • Qwen-2.1's output has 4 channels; feeding it into nodes that only accept three channels will cause errors, and the error appears on downstream nodes, not on the Qwen node: insert a SplitImageWithAlpha after decoding and feed those nodes with its RGB output.
  • Bria runs in the cloud and original images get uploaded; evaluate first when unpublished products are involved.

Advanced tips (optional) ​

  • Masks aren't just for background replacement: BiRefNet's MASK output can be connected directly to other nodes for inpainting, color adjustment, or saving for later use.
  • Product videos also need background handling: Bria's video nodes support background removal, green screen, and background replacement; input videos must be within 60 seconds.
  • Don't want to manually composite a new background: use Qwen-Image-Edit instruction-based editing to replace the background or change text in one sentence.

Lesson summary ​

On this page you built your own ComfyUI background-removal pipeline, with three routes to switch between depending on the situation:

SituationRouteOutput
Real photos already takenBiRefNet localMask + RGBA transparent background, free and offline
New products not yet photographedQwen-2.1 generationTransparent-background PNG generated directly in one sentence
No local GPU / batch processing neededBria cloudTransparent-background result, 3.8 credits per run

Once the background-removal step is done in ComfyUI, replacing the background comes down to two approaches: compositing the transparent-background image with a new background, or having Qwen-Image-Edit replace it directly with one sentence.

Next lesson preview ​

Cutout transparent-background image not high-resolution enough? The next page, Product image upscaling, covers conservative upscaling and Z-Image-Turbo 2K. To replace backgrounds or change text in one sentence, see Qwen-Image-Edit instruction-based editing.

gaodong.aiAboutPrivacyContact

Independent tutorials, not affiliated with any product mentioned. Product names and trademarks belong to their owners. Check official pages for prices and policies.