ComfyUI > Nodes > comfyui_LLM_Polymath > Generate mask from text

ComfyUI Node: Generate mask from text

Class Name

polymath_text_mask

Category
Masquerade/Masking
Author
lum3on (Account age: 105days)
Extension
comfyui_LLM_Polymath
Latest Updated
2025-05-18
Github Stars
0.06K

How to Install comfyui_LLM_Polymath

Install this extension via the ComfyUI Manager by searching for comfyui_LLM_Polymath
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter comfyui_LLM_Polymath in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Generate mask from text Description

Generate text masks from images using OCR and adaptive thresholding for isolating text regions, ideal for AI artists.

Generate mask from text:

The polymath_text_mask node is designed to generate a mask from text within an image using Optical Character Recognition (OCR) and adaptive thresholding techniques. This node is particularly useful for AI artists who need to isolate text regions in images for further processing or analysis. By leveraging EasyOCR, the node can detect text in various languages, making it versatile for international applications. The adaptive thresholding method ensures that the mask accurately represents the text areas by adjusting to the image's lighting conditions. This node is essential for tasks that require precise text extraction, such as creating text overlays, enhancing text visibility, or preparing images for text-based machine learning models.

Generate mask from text Input Parameters:

image

The image parameter is the input image from which the text mask will be generated. It should be provided in a tensor format that the node can process. The image is converted to grayscale for further processing, ensuring that the text detection is not affected by color variations.

language_name

The language_name parameter specifies the language of the text to be detected in the image. This is crucial for the OCR process, as it determines the language model used by EasyOCR. If the language is not specified, the default is English ('en').

ocr_confidence_threshold

The ocr_confidence_threshold parameter sets the minimum confidence level for text detection by the OCR. Text regions with a confidence score below this threshold will be ignored, ensuring that only reliable text detections are included in the mask. This parameter helps in reducing false positives and can be adjusted based on the quality of the input image.

use_gpu

The use_gpu parameter indicates whether to utilize GPU acceleration for the OCR process. Enabling this option can significantly speed up text detection, especially for large images or when processing multiple images. However, it requires a compatible GPU and the necessary software setup.

threshold_block_size

The threshold_block_size parameter defines the size of the neighborhood area used for adaptive thresholding. It must be an odd number, and if an even number is provided, it will be incremented by one. This parameter affects the sensitivity of the thresholding process, with larger values leading to smoother masks.

threshold_c

The threshold_c parameter is a constant subtracted from the mean or weighted mean in the adaptive thresholding process. It fine-tunes the thresholding sensitivity, allowing for better control over the mask's accuracy in different lighting conditions.

Generate mask from text Output Parameters:

output_mask

The output_mask is the resulting mask generated from the input image, highlighting the detected text regions. This mask is returned as a tensor, which can be used for further processing or analysis in various applications. The mask provides a binary representation of the text areas, making it easy to integrate with other image processing workflows.

Generate mask from text Usage Tips:

  • Ensure that the input image is clear and has a good contrast between text and background to improve OCR accuracy.
  • Adjust the ocr_confidence_threshold to filter out unreliable text detections, especially in noisy images.
  • Use the language_name parameter to specify the correct language for OCR, as this can significantly impact detection accuracy.
  • Enable use_gpu if you have a compatible GPU to speed up the OCR process, especially for batch processing.

Generate mask from text Common Errors and Solutions:

"Failed to initialize EasyOCR Reader."

  • Explanation: This error occurs when the EasyOCR library is not installed or there is an issue initializing the OCR reader.
  • Solution: Ensure that EasyOCR is installed by running pip install easyocr. Check your system's GPU compatibility if you are attempting to use GPU acceleration.

"Input image is invalid."

  • Explanation: The input image provided is either empty or not in a supported format.
  • Solution: Verify that the image is correctly loaded and in a compatible format (e.g., RGB or RGBA). Ensure the image tensor is not empty.

"Unsupported image format for grayscale conversion."

  • Explanation: The input image has an unsupported number of channels for conversion to grayscale.
  • Solution: Ensure the image is in a standard format with either 3 (RGB) or 4 (RGBA) channels, or already in grayscale.

Generate mask from text Related Nodes

Go back to the extension to check out more related nodes.
comfyui_LLM_Polymath
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.