ComfyUI workflow


AI
Last updated on

Background

My spouse works for a small online store selling spare parts globally. They take many product photos and update them regularly on product description pages. Previously, this image processing was time-consuming. Because the photos are taken with a phone, the process involved removing the background or extracting the items, composing the items against a pure white background, or replicating items multiple times in a single image to show stacks, adding text labels, and finally resizing the images.

Last year, I used BRIA-RMBG-2.0 with RMBG-2-Studio to help remove the background and compose the object with a white background, but there was still much work to do. Until recently, I found that BRIA-RMBG-2.0 has a ComfyUI node. I am planning to use this node along with other nodes to fully streamline the whole process.

Setup Proceedure

  • install ComfyUI, follow the guides on the page to install it on our home Linux workstaion with nvidia 1070Ti GPU
    • the Linux box is running debian 12 with cuda 12.4
    • clone the repository
    • create python virtual environment python3.11 -m venv venv
    • activate the virtual environment source venv/bin/activate
    • install pytorch packages pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
    • install other requirments pip install -r requirements.txt
  • install ComfyUI Manager to manage the ComfyUI
  • using ComfyUI Manager to install custom nodes
    • ComfyUI-RMBG, various nodes inlcuding
      • Remove Background (RMBG): used to remove the background
      • BiRefNet Remove Background (RMBG): also used to remove the background
      • Segmentation (RMBG): extract the object if the origianl image has more than one objects
      • Image Preview (RMBG) 🖼️
      • Image Stitch (RMBG) 🖼️: arranges the items and output as an images
      • Image Combiner (RMBG) 🖼️: used to combine the image object with pure white background image
      • Crop To Object (RMBG) 🖼️🎭: used to crop the image to its object size, same as comfy-node-crop-image-by-mask
    • comfy-node-crop-image-by-mask: crop the image to its object size
    • TextOverlay Node for ComfyUI: add text on the images, support alignments
    • ComfyUI_LayerStyle: it has node Brightness & Contrast node as BrightnessContrastV2 to change the image Brightness and contrast
    • ComfyUI_rotate_image: rotate image
    • KayTool: has node 𝙆 Image Resizer to resize image with ratio
  • launched with python main.py --listen

Workflows

There are two scenarios: one object in a picture, and a stack of items in a picture. Therefore, I created two workflows.

  • rmbg-multi-add-text

optional

optional

optional

optional

Load Image

Remove Background (RMBG)

Crop Image By Mask

Rotate Image

LayerColor: Brightness Contrast V2

RepeatImageBatch

Image Stitch (RMBG)

𝙆 Image Resizer

Image Combiner (RMBG)

Load Image(background)

𝙆 Image Resizer

Text Overlay

Save Image

BiRefNet Remove Background (RMBG)

Segmentation (RMBG)

  • rmbg-single-add-text

optional

optional

optional

optional

Load Image

Remove Background (RMBG)

Crop Image By Mask

Rotate Image

LayerColor: Brightness Contrast V2

𝙆 Image Resizer

Image Combiner (RMBG)

Load Image(background)

𝙆 Image Resizer

Text Overlay

Save Image

BiRefNet Remove Background (RMBG)

Segmentation (RMBG)

Problems

  • I’ve introduced the “Image Crop” node to tailor the image containing only the object to its actual size. I haven’t yet found a better way to determine the object’s size automatically. I already created a github issue to ask if they can implement this feature. This is done by comfy-node-crop-image-by-mask
© 2025 Jennings Liu. All rights reserved.