Image Erase Node
It 'erases' pixels by shipping them to Baidu's cloud, not your GPU
- image
- IMAGE
The name makes it sound like a local eraser - paint a box, watch the pixels vanish on your own GPU. It isn't. Image Erase Node encodes your image, POSTs it to Baidu's cloud inpainting API, and pastes back whatever Baidu decided to fill the box with. No model download, no VRAM, no local diffusion. Just an HTTP call, a network connection, and an access token you have to go get.
That makes it the middle step of this pack's actual purpose: replacing text on an image. OCR Location Node finds where the words are, this node erases them, Chat Overlay Node draws the replacement. If you've got a photo of a sign, a screenshot, a product shot, or a comic page with text you want gone, this is the "gone" step.
How it works
You give it boxes as JSON arrays in [left, top, width, height] form - note that's x, y, width, height, not two corner points. A default of [[0, 0, 100, 100]] is just a placeholder box in the top-left corner; change it or you'll erase the wrong thing.
The node expands each box by your expand_pixels amount (clamped to the image bounds), then converts the tensor to a JPEG, base64-encodes it, and POSTs the whole thing to Baidu's image inpainting endpoint (aip.baidubce.com). Baidu does the actual inpainting server-side and returns a new image, which gets decoded back into a tensor. Clean.
The inputs that matter
- image - whatever you want scrubbed.
- rectangles - the boxes, as
[[left, top, width, height], ...]. This is the field you'll actually sweat over. - expand_pixels - 0 to 100; grows each box on all sides. Genuinely useful when your OCR box clips a letter.
- access_token - your Baidu AI platform token. The default is a Chinese placeholder (
请输入您的百度AI平台access token), which is not a token. You must replace it.
The single output is an IMAGE. On success you get the inpainted result; on failure you get the original image back with only a console message in Chinese. That silent fallback is the most common "why did nothing happen" moment - check the terminal, not just the preview.
Install
ComfyUI Manager: search ComfyUI-text-replace and hit Install, or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/banqingyuan/ComfyUI-text-replace
Then restart ComfyUI. Dependencies are light (opencv, numpy, Pillow, requests, torch) and most of them are already in any working ComfyUI install. pytesseract is listed in requirements.txt but no node actually uses it - ignore it, and don't bother installing the Tesseract binary. There are no model files to download, which is the one thing that makes this pack easy.
Common issues
- Expired token. Baidu access tokens last about 30 days (that's the
2592000in the token string - seconds in a month). The example tokens baked into the repo's test scripts are from October 2024 and have been dead for years. You get a fresh one from the Baidu AI open platform console. - Box format. OCRLocNode's
merged_rectanglesoutput is a list of dicts with anid- this node expects bare[x, y, w, h]arrays, so you can't wire them together directly. Type the boxes by hand or transform the JSON. - Quota. Baidu's inpainting API has a free tier and paid usage beyond it; when you exhaust the free calls, errors start and the node falls back to the un-erased image.
Honest take: by 2026, a one-shot instruction edit (Qwen-Image-Edit, Kontext) will wipe text for most people in a single prompt. This node's argument is determinism - it only touches the boxes you drew, leaving everything else bit-identical. If you need that, it's the right tool; if you don't, skip the whole pack.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| rectangles | STRING | [[0, 0, 100, 100]] | — |
| expand_pixels | INT | 00–100 | — |
| access_token | STRING | 请输入您的百度AI平台access token | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |