ComfyUI-LexTools is a Python-based image processing and analysis toolkit that uses machine learning models for semantic image segmentation, image scoring, and image captioning.
ComfyUI-LexTools is a Python-based image processing and analysis toolkit that uses machine learning models for semantic image segmentation, image scoring, and image captioning. The toolkit includes three primary components:
ImageProcessingNode.py - Implements various image processing nodes such as:
ImageAspectPadNode
: Expands the image to meet a specific aspect ratio. This node is useful for maintaining the aspect ratio when processing images.
image
(IMAGE), aspect_ratio
(RATIO), invert_ratio
(BOOLEAN), feathering
(INT), left_padding
(INT), right_padding
(INT), top_padding
(INT), bottom_padding
(INT)show_on_node
(INT)ImageScaleToMin
: Calculates the value needed to rescale an image's smallest dimension to 512. This node is useful for scaling images down to 512 or up to 512 for faster processing. It ensures that at least one dimension (width or height) is 512 pixels.
image
(IMAGE)ImageRankingNode
: Ranks the images based on specific criteria.
score
(INT), prompt
(STRING), image_path
(STRING), json_file_path
(STRING)ImageFilterByIntScoreNode
and ImageFilterByFloatScoreNode
: Filter images based on a threshold score. Currently, these nodes may throw errors if the following node in the sequence does not handle blank outputs.
score
(INT for ImageFilterByIntScoreNode
and FLOAT for ImageFilterByFloatScoreNode
), threshold
(FLOAT), image
(IMAGE)ImageQualityScoreNode
: Calculates a quality score for the image.
aesthetic_score
(INT), image_score_good
(INT), image_score_bad
(INT), ai_score_artificial
(INT), ai_score_human
(INT), weight_good_score
(INT), weight_aesthetic_score
(INT), weight_bad_score
(INT), weight_AIDetection
(INT), MultiplyScoreBy
(INT), show_on_node
(INT), weight_HumanDetection
(INT)ScoreConverterNode
: Converts the score to different data types.
score
(SCORE)Additional nodes from GitHub Pages - These have been modified to improve performance and add an option to store the model in RAM, which significantly reduces generation time:
CalculateAestheticScore
: An optimized version of the original, with an option to keep the model loaded in RAM.AestheticScoreSorter
: Sorts the images by score.AestheticModel
: Loads the aesthetic model.ImageCaptioningNode.py - Implements nodes for image captioning and classification:
ImageCaptioningNode
: Provides a caption for the image using BLIP model.
image
(IMAGE)FoodCategoryClassifierNode
: Classifies food categories in images.
image
(IMAGE)AgeClassifierNode
: Classifies the age range in images.
image
(IMAGE)ArtOrHumanClassifierNode
: Detects if an image is AI-generated or human-made.
image
(IMAGE), show_on_node
(BOOL)DocumentClassificationNode
: Classifies document types.
image
(IMAGE)NSFWClassifierNode
: Classifies content safety levels.
image
(IMAGE), show_on_node
(BOOL), threshold
(FLOAT)WatermarkDetectionNode
: Detects watermarks in images using EfficientNet.
image
(IMAGE), show_on_node
(BOOL), threshold
(FLOAT)SegformerNode.py - Handles semantic segmentation of images:
SegformerNode
: Performs semantic segmentation with multiple model options.
image
(IMAGE), model_name
(STRING), normalize_mask
(BOOL), binary_mask
(BOOL), resize_mode
(STRING), invert_mask
(BOOL), show_preview
(BOOL), return_individual_masks
(BOOL), post_process
(STRING), post_process_radius
(INT), segment_groups
(STRING)SegformerNodeMasks
: Creates individual segment masks.
image
(IMAGE), segments_to_merge
(STRING), model_name
(STRING)SegformerNodeMergeSegments
: Merges and processes segments with advanced options.
image
(IMAGE), segments_to_merge_str
(STRING), model_name
(STRING), normalize_mask
(BOOL), binary_mask
(BOOL), resize_mode
(STRING), invert_mask
(BOOL), show_preview
(BOOL), blur_radius
(INT), dilation_radius
(INT), intensity
(FLOAT), ceiling
(FLOAT)SeedIncrementerNode
: Manages seed incrementation for workflows.
seed
(INT), IncrementAt
(INT)StepCfgIncrementNode
: Handles step and configuration increments.
seed
(INT), cfg_start
(INT), steps_start
(INT), image_steps
(INT), max_steps
(INT)The project requires the following Python libraries:
pip install torch transformers pillow matplotlib numpy scipy huggingface_hub torchvision
cd ComfyUI/custom_nodes
git clone https://github.com/YourUsername/ComfyUI-LexTools.git
The nodes will appear in the ComfyUI interface under the "LexTools" category, organized into subcategories:
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.