Files
huwenkai26-comfyui-remove-text/text_remove_node.py
T
2025-08-28 11:28:49 +08:00

46 lines
1.2 KiB
Python

import os
from PIL import Image
import numpy as np
from torchvision.transforms.functional import to_pil_image, to_tensor
from .dbnet.dbnet_infer import textRemove
class ImageRemoveTextNode:
"""
A simple node that retrieves basic information from an input image
"""
# Define node's basic information
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image": ("IMAGE",), # Input image
}
}
RETURN_TYPES = ("IMAGE",) # Output a string
FUNCTION = "remove_text" # Processing function name
CATEGORY = "image" # Node category
TITLE = "Image Info" # Node title
DESCRIPTION = "Get basic information from the input image" # Node description
def remove_text(self, image):
# Convert tensor to PIL Image
pil_image = to_pil_image(image[0])
# Get image information
removeImg = textRemove(pil_image)
return (removeImg,) # Return value must be a tuple
# This dictionary will be imported in __init__.py for node registration
NODE_CLASS_MAPPINGS = {
"ImageRemoveText": ImageRemoveTextNode
}
# Node display names
NODE_DISPLAY_NAME_MAPPINGS = {
"ImageRemoveText": "Image remove text"
}