Nodes/ComfyUI-productfix/Get text mask OCR (middlek)
ComfyUI Node

Get text mask OCR (middlek)

The node that turns OCR text into a mask, so your labels survive regeneration

By MiddleKD·Created 2 years ago·Updated about a year ago· 21
Get text mask OCR (middlek)
  • image
  • MASK
languagesnot use
codesen,ko

Product photos live or die on their text. A shampoo bottle with legible Korean labels, a logo, a model number - regenerate that bottle with Stable Diffusion and the words come back as mush. That's the whole problem this pack exists to solve, and GetTextMask is where it starts: it reads the text on your input image with OCR and hands you a mask that says "protect exactly these pixels."

What it does

GetTextMask runs EasyOCR over your image, takes every detected text bounding box, and fills it white in a mask tensor. Everything that isn't text stays black. The author explicitly recommends this over the existing EasyOCR node because "PIL usage is not stable" there - this one keeps everything in tensor land.

The mask isn't for display. In the pack's text-transfer workflow it feeds the mask input of DetailTransferAdd, so fine detail (read: letters) from the original photo gets transplanted onto the regenerated image only where the text lives. Or it goes through an invert into ApplyLatentInjection's inject_mask so the product region stays pinned. Either way, the OCR mask is what tells the rest of the pipeline where the words are.

Inputs you actually set

  • image - your product photo (the source of truth you want the text preserved from).
  • languages - a dropdown of EasyOCR languages, default "not use". Leave it alone and use codes instead.
  • codes - a comma-separated list of EasyOCR language codes, default en,ko. This is the field that actually does the work when languages is "not use". Add ch_sim if your product is Chinese-market, ja for Japanese packaging, and so on.

One gotcha: the two language controls are mutually exclusive. Pick a value in languages and it wins; leave it on "not use" and codes is used directly.

The output

A single MASK tensor, batch-aligned with your input. Wire it into DetailTransferAdd's optional mask (image domain) or into ApplyLatentInjection. If the mask edges feel tight, most people run it through a grow/dilate node before it hits the detail transfer - Impact Pack's mask blur or essentials' mask operations both work.

Install

Same as the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/MiddleKD/ComfyUI-productfix
pip install -r requirements.txt

Restart ComfyUI after. The pack's requirements.txt is just diffusers and easyocr; easyocr is the heavyweight one here and it drags in torchvision and opencv (already present in most ComfyUI installs). EasyOCR also downloads its detection and recognition models on first run - the node creates ComfyUI/models/EasyOCR/ and stores them there, so the first read is slow, the rest are fast.

Common issues

  • First run hangs or downloads for ages - that's EasyOCR pulling models. Let it finish once.
  • Decorative or tiny text gets missed - OCR is good, not magic. Small-print or stylized logos often don't get boxes. If the label detail is falling through, that's where the DetailTransferAdd mask comes up short and you either accept it or mask the region by hand.
  • Wrong-language garbage boxes - check your codes. EasyOCR returns whatever language you ask for, so a Korean label scanned as English produces worse masks, not better.

It's a niche pack with a tiny community footprint - don't expect a pile of forum threads when something misbehaves. But this node is the unglamorous heart of the whole productfix approach, and once it clicks, the text-preservation pipeline makes sense.

Categoryproductfix

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
languagesCOMBOnot use45 options: English/en, 简体中文/ch_sim, 繁體中文/ch_tra, العربية/ar, Azərbaycan/az, Euskal/eu, +39
codesSTRINGen,ko

Outputs (1)

NameTypeDescription
MASKMASK