Extensions/NH-Nodes
ComfyUI Extension

NH-Nodes

ComfyUI custom nodes for image workflows, tiling, masks, smart resize, logic routing, prompt and text tools, batch automation, SAM 3 object segmentation from mask formulas (Vietnamese words too), instance selection, close-up garment/portrait parsing, body-part masks by name (Sapiens2), and VTON preprocessing.

By jetthuangai·Created 7 months ago·Updated 7 days ago· 7
jetthuangai/NH-Nodes
Nodes76
On cloudLocal install
CategoryNH-Nodes/Image, NH-Nodes/Batch
Stars7
Updated7 days ago

Nodes (76)

NH Agnostic Image Generator

Garment erased, model fooled

NH-Nodes/Image
Any List Split (NH)

Your list is one socket away from ten named outputs

NH-Nodes/Batch
Any Branch Switch (NH)

One input, five output branches, and only the branch you picked runs

NH-Nodes/Logic
Any Switch (NH)

The Any Switch (NH) that isn't the fallback you were promised

NH-Nodes/Logic
Batch Index (NH)

Grab one frame out of a batch without touching the rest

NH-Nodes/Batch
Batch Merge (NH)

Stack three image batches into one, and it fixes the sizes for you

NH-Nodes/Batch
Body Segment (NH)

Type 'clothes - shoes' and get the mask

NH-Nodes/Vision
Boolean Switch (NH)

A plain on/off switch, because your graph needed one

NH-Nodes/Utils
Load Clip Index (NH)

Load one of 64 CLIPs by number, and stop dragging dropdowns

NH-Nodes/Loaders
Compare (NH)

Turn any two values into a true/false for the rest of your graph

NH-Nodes/Logic
Counter (NH)

A counter that remembers between queue runs, so your loop knows where it is

NH-Nodes/Batch
Load Diffusion Model Index (NH)

Pick a diffusion model by index — or hand the choice to a boolean

NH-Nodes/Loaders
Garment Segment (NH)

Cut the shirt out with a SegFormer mask, no hand-painting

NH-Nodes/Vision
Gate Switch (NH)

A valve that blocks the branch behind it, not just the data

NH-Nodes/Logic
If/Else (NH)

Your graph's if/else, with both sides always wired

NH-Nodes/Logic
Image Compare (NH)

Put two images in one frame so you can actually see the difference

NH-Nodes/Image
Image Grid Composite (NH)

A contact sheet in one node, with gaps and padding

NH-Nodes/Image
Image Label (NH)

Stamp a header or footer caption onto a batch of images

NH-Nodes/Image
Image Resize Unit (NH)

Millimetres, DPI and all

NH-Nodes/Image
Image Tile (NH)

Cut a huge image into overlapping tiles your VRAM can handle

NH-Nodes/Image
Image Untile (NH)

Sew the tiles back together, even if you upscaled them first

NH-Nodes/Image
NH Large Image Compare

A/B your 4K renders without melting the browser

NH-Nodes/Image
NH Large Image Preview

Zoom into an 8K render in your browser without freezing the canvas

NH-Nodes/Image
NH Large Preview Cache Manager

Your big previews are stacking up in temp. Here's the broom.

NH-Nodes/Image
Layer Layout Composite (NH)

Turn a batch of images into a print-ready contact sheet

NH-Nodes/Image
Layer Stack Composite (NH)

Drop layers onto a canvas with exact coordinates

NH-Nodes/Image
List Create (NH)

Make a list ComfyUI can actually index into

NH-Nodes/Batch
List Filter (NH)

Filter your list by contains, regex, or length

NH-Nodes/Batch
List Index (NH)

Grab the Nth item out of a list, cleanly

NH-Nodes/Batch
Load Image Info (NH)

Load an image and get its filename and path out the other side

NH-Nodes/Image
Load Images Folder (NH)

Load a folder of images by index, step, and seed mode

NH-Nodes/Image
Load images matching

Load the images that match — a folder-aware matching loader

NH-Nodes/Image
Logic Gate (NH)

The boolean brain your workflow keeps not having

NH-Nodes/Logic
Load LoRA Clip Index (NH)

One index to switch which LoRA hits the CLIP

NH-Nodes/Loaders
Load LoRA Model Index (NH)

Index into a wall of LoRAs without a wall of nodes

NH-Nodes/Loaders
Mask Morphology (NH)

Expand masks by X and Y separately, fill holes, blur the edges

NH-Nodes/Mask
NH Mask Aspect Ratio Match

Make one mask's aspect ratio match another's

NH-Nodes/Mask
Mask Properties (NH)

Width, height, and bbox of a mask in one pull

NH-Nodes/Mask
NH Mask-Aware Resize

Resize an image and never lose the mask's subject

NH-Nodes/Image
NH Create Box Mask

Turn any mask into a clean rectangle

NH-Nodes/Mask
Math Eval (NH)

Do real math in the graph, not node spaghetti

NH-Nodes/Logic
Multi-Slider (FLOAT)

Multi-Slider (FLOAT) is the decluttering move

NH-Nodes/Utils
Multi-Slider (INT)

Five integer dials that cut your canvas clutter in half

NH-Nodes/Utils
Pack Universal (NH)

Collapsing a dozen wires into one tidy pipe

NH-Nodes/Utils/Pipe
Portrait Segment (NH)

A checklist of face parts instead of one blunt mask

NH-Nodes/Vision
Prompt Join (NH)

Building prompts from fragments without the comma soup

NH-Nodes/Text
Prompt Scheduler (NH)

Rotate prompts per step for animation and mid-run swaps

NH-Nodes/Text
Prompt Template (NH)

Fill {placeholders} from real inputs instead of editing text

NH-Nodes/Text
Random Choice (NH)

Weighted randomness for prompts, LoRAs, and branch picking

NH-Nodes/Logic
NH Ratio Preset Image Resize

When you want to say 'make it 2:3' and mean it

NH-Nodes/Resolution
Regex Extract (NH)

Pull, replace, or split text without leaving ComfyUI

NH-Nodes/Text
NH Remove Resize Padding

Undo the letterbox bars your resize added

NH-Nodes/Resolution
NH Restore Image Geometry

Get back the edges your model cropped away

NH-Nodes/Resolution
SAM3 Segment (NH)

Name a thing, get every one of them

NH-Nodes/Vision
Save Image Path (NH)

Dump images into a folder you choose, and get the paths back

NH-Nodes/Image
NH Save Large Image

Save the full-res file without making your canvas choke

NH-Nodes/Image
Segs Compose (NH)

Build one mask out of labels, not brushes

NH-Nodes/Vision
Segs Preview (NH)

See every instance drawn on your own photo

NH-Nodes/Vision
Segs Select (NH)

Pick the second person from the left, not all of them

NH-Nodes/Vision
Segs To Impact SEGS (NH)

Feed SAM 3's finds to Impact Pack's detailers

NH-Nodes/Vision
Segs To Masks (NH)

One MASK per instance, and the labels to prove it

NH-Nodes/Vision
NH Simple Face Paste

Drop a face onto a new body with mask-guided blending

NH-Nodes/Image
NH Smart Ratio Image Resize

Let the model's preset table pick your crop for you

NH-Nodes/Resolution
NH Smart Resolution Picker

The txt2img resolution node that already did the math

NH-Nodes/Resolution
String Operations (NH)

Ten string helpers hiding in one dropdown

NH-Nodes/Text
Switch N (NH)

Pick one of ten inputs by index, with a safe fallback

NH-Nodes/Logic
Text Concatenate (NH)

Up to 64 strings joined on one delimiter, without the mess

NH-Nodes/Text
Text Index (NH)

Pick the Nth prompt out of a stack, and stop when there's nothing to pick

NH-Nodes/Text
Text Random Line (NH)

Let this node roll the dice for you

NH-Nodes/Text
Text Split (NH)

Text Split (NH) does the parsing for you

NH-Nodes/Text
Text Split Lines (NH)

The ComfyUI text superpower

NH-Nodes/Text
Universal Slider Builder (NH)

Build your own parameter node from a text config — no Python required

NH-Nodes/Utils
Unpack Universal (NH)

Unpacking the Universal Pipe

NH-Nodes/Utils/Pipe
Load VAE Index (NH)

One loader, up to 64 VAEs, picked by a single number

NH-Nodes/Loaders
Value Match Index (NH)

The lookup node your switches are missing

NH-Nodes/Logic
VTON Ultimate Processor (NH)

The preprocessing half of virtual try-on, all in one node

NH-Nodes/VTON
Readme
<p align="center"><img src="docs/assets/banner.jpg" alt="NH-Nodes — image, mask, resolution and workflow nodes for ComfyUI" width="100%"></p> <p align="center"> <a href="https://registry.comfy.org/nodes/nh-nodes"><img src="https://img.shields.io/badge/ComfyUI_Registry-nh--nodes-2563eb" alt="ComfyUI Registry"></a> <a href="https://github.com/jetthuangai/NH-Nodes/actions/workflows/tests.yml"><img src="https://github.com/jetthuangai/NH-Nodes/actions/workflows/tests.yml/badge.svg" alt="Tests"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT_(see_notices)-16a34a" alt="License"></a> <a href="docs/en/README.md"><img src="https://img.shields.io/badge/Docs-EN_%7C_VI-0f766e" alt="Documentation"></a> </p> <p align="center"><b>English</b> · <a href="docs/vi/README.md">Tiếng Việt</a></p>

NH-Nodes for ComfyUI

76 production-focused nodes for ComfyUI: load and save image sets with their metadata, tile and composite large images, pick the right resolution for current models and put results back into the original frame, refine masks, segment garments and faces (also in half-body and group photos), mask the skin, hair, lips, teeth and clothes of people by typing their names, get the mask of anything you name with SAM 3 from a short formula such as person - bag or background, build VTON masks, route workflows with lazy switches, generate prompts, and test many LoRAs or models from one node.

Every node is documented with a visual card, its inputs and outputs, and examples — in English and Vietnamese.

Highlights

<table> <tr> <td width="50%"><a href="docs/en/resolution.md"><img src="docs/assets/examples/resize-modes.jpg" alt="Resize modes"></a><br> <b>Resolution done right</b> — presets for FLUX.2, Qwen-Image and Z-Image, cover / contain / stretch resizing, and an exact round trip back to the original frame.</td> <td width="50%"><a href="docs/en/image-compose.md"><img src="docs/assets/examples/tile-untile.jpg" alt="Tile and untile"></a><br> <b>Large images</b> — split into overlapping tiles, process them, and blend them back seamlessly; deep-zoom preview for images too big for the canvas.</td> </tr> <tr> <td><a href="docs/en/vision.md"><img src="docs/assets/examples/garment-segment.jpg" alt="Garment segmentation"></a><br> <b>Segmentation</b> — name what you want (people, windows, the sky) or write a formula such as <code>person - bag</code> or <code>background</code>, and SAM 3 returns the mask, with crisp edges on small and medium objects even in 4K–8K photos, and shows it on the node; type <code>skin</code>, <code>hair, face</code> or <code>clothes - shoes</code> and Body Segment masks those parts of every person; garment and face-part masks from models that parse faces and people close up; VTON garment masks with pose and parsing.</td> <td><a href="docs/en/mask.md"><img src="docs/assets/examples/mask-morphology.jpg" alt="Mask morphology"></a><br> <b>Mask tools</b> — fast grow / shrink on the CPU or the GPU, hole filling, soft edges, bounding boxes and aspect-ratio matching.</td> </tr> <tr> <td><a href="docs/en/image-compose.md"><img src="docs/assets/examples/layer-layout.jpg" alt="Layer layout"></a><br> <b>Compositing</b> — layouts, layer stacks with alpha, labelled grids and side-by-side comparisons.</td> <td><a href="docs/en/logic.md"><img src="docs/assets/examples/grid-composite.jpg" alt="Grid composite"></a><br> <b>Workflow logic</b> — lazy If/Else and switches that run only the chosen branch, safe math, counters, lists and prompt tools.</td> </tr> </table>

Installation

ComfyUI Manager — search for NH-Nodes, install, restart ComfyUI.

Comfy CLI

comfy node install nh-nodes

Manual

cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
python -m pip install -r requirements.txt

Restart ComfyUI afterwards. Requirements: a recent ComfyUI (tested with 0.41) and Python 3.10+. SAM3 Segment and Body Segment have more requirements, listed below.

Optional: VTON and segmentation models

  • VTON Ultimate Processor needs ONNX Runtime, which is not installed automatically (the CPU wheel would overwrite an existing GPU build). Install one of them into ComfyUI's Python: python -m pip install onnxruntime-gpu (NVIDIA) or python -m pip install onnxruntime (CPU).

  • Garment Segment, Portrait Segment, Body Segment and VTON download their models from Hugging Face on first use (pinned revisions, only the needed files): about 256 MB for Garment Segment, and 1.6 GB for Body Segment (3.3 GB and 5.9 GB for its larger sizes). Garment Segment, Portrait Segment and Body Segment also fetch YuNet, a 230 KB face detector (MIT) that runs on the CPU. Body Segment needs PyTorch 2.4 or newer. To keep models elsewhere, add these keys to extra_model_paths.yaml:

    my_models:
        base_path: D:/ai-models/
        nh_nodes: NH-Nodes/            # garment, face and body-part models, and the YuNet face detector
        vton_mask: ComfyUI-Vton-Mask/  # VTON pose + parsing ONNX models
        sam3: sam3/                    # SAM 3 checkpoint (you download sam3.pt yourself)
    
  • Requirements for SAM 3 (SAM3 Segment only): an NVIDIA GPU with CUDA, Meta's sam3 package and the sam3.pt checkpoint. NH-Nodes installs and downloads none of them: you install the package yourself and request the weights from Meta. The steps, and what to do if another SAM 3 pack is already installed, are in Before you start with SAM 3.

Quick start

| Goal | Chain | Guide | |---|---|---| | Upscale or refine a huge image piece by piece | Load Image → Image Tile → your sampler/upscaler per tile → Image Untile | image-compose | | Generate at the model's native size, then restore the original framing | Load Image → NH Smart Ratio Image Resize → edit → NH Restore Image Geometry | resolution | | Inpaint only the clothes | Load Image → Garment Segment → Mask Morphology (grow) → inpaint | vision | | Mask the skin, hair, lips, teeth or clothes of the people in a photo by name | Load Image → Body Segment (regions: skin, hair, face or clothes - shoes; Vietnamese works: da, tóc, môi) → mask → retouch or inpaint | vision | | Mask every person, window or the sky in a large photo, or everything except the person | Load Image → SAM3 Segment (concepts: window, person - bag or background) → mask → edit or inpaint; add Segs Select to pick single instances | vision | | Compare many LoRAs, one per queue | Counter → Load LoRA Model Index (index) → sampler → Image Label (prints the LoRA name) → Save Image | loaders | | Run one of two branches without executing the other | condition → If/Else (lazy) → … | logic |

Node catalog

| Group | Nodes | Guide | |---|---|---| | Image — load & save | Load Image Info, Load Images Folder, Load images matching, Save Image Path, NH Save Large Image | EN · VI | | Image — compose | Image Tile, Image Untile, Image Grid Composite, Layer Layout Composite, Layer Stack Composite, Image Compare, Image Label, Image Resize Unit | EN · VI | | Image — large preview | NH Large Image Preview, NH Large Image Compare, NH Large Preview Cache Manager | EN · VI | | Image — mask-based retouch | NH Mask-Aware Resize, NH Agnostic Image Generator, NH Simple Face Paste | EN · VI | | Resolution | NH Smart Resolution Picker, NH Smart Ratio Image Resize, NH Ratio Preset Image Resize, NH Remove Resize Padding, NH Restore Image Geometry | EN · VI | | Mask | Mask Morphology, Mask Properties, NH Create Box Mask, NH Mask Aspect Ratio Match | EN · VI | | Vision | Garment Segment, Portrait Segment, Body Segment, SAM3 Segment, Segs Select, Segs Compose, Segs To Masks, Segs To Impact SEGS, Segs Preview | EN · VI | | VTON | VTON Ultimate Processor | EN · VI | | Logic | Compare, Logic Gate, If/Else, Switch N, Any Switch, Any Branch Switch, Gate Switch, Value Match Index, Math Eval, Random Choice | EN · VI | | Text | Prompt Template, Prompt Scheduler, String Operations, Prompt Join, Text Split, Regex Extract, Text Index, Text Concatenate, Text Split Lines, Text Random Line | EN · VI | | Batch & lists | Batch Index, Batch Merge, Counter, List Create, List Index, List Filter, Any List Split | EN · VI | | Loaders | Load LoRA Model Index, Load LoRA Clip Index, Load Diffusion Model Index, Load VAE Index, Load Clip Index | EN · VI | | Utils | Multi-Slider (FLOAT/INT), Boolean Switch, Pack Universal, Unpack Universal, Universal Slider Builder (deprecated) | EN · VI |

All nodes live under NH-Nodes in the node menu; search by name or by node id (for example NH_ImageTile).

Documentation

License

NH-Nodes' own code is MIT. Some features rely on third-party code or models with other terms — see THIRD_PARTY_NOTICES.md:

  • VTON Ultimate Processor and Portrait Segment are for non-commercial use only (CC BY-NC-SA 4.0 code and parsing models; non-commercial face-parsing model).
  • Garment Segment is for non-commercial use only, and NVIDIA's licence defines that as research or evaluation purposes only: its default model (FASHN Human Parser) is under the NVIDIA Source Code License for SegFormer. The other model, fashionpedia, declares no licence but is fine-tuned from NVIDIA's mit-b3, so treat it the same way.
  • Body Segment uses Meta's Sapiens2 under the Sapiens2 License: royalty-free, with no non-commercial clause, but it prohibits surveillance, biometric processing, identifying people, deepfakes and other uses, requires you to follow privacy, biometric and trade-control laws, and lets Meta audit your use, end the licence and change its terms. The model code is included with its licence; the weights are downloaded from Meta's Hugging Face repositories.
  • SAM3 Segment uses Meta's SAM 3 under the SAM License: royalty-free, with no non-commercial clause, but it bars military or warfare, nuclear, espionage, and gun or illegal-weapon uses. The weights and the sam3 package are not included; you get them from Meta.

Development

  • Layout: core/ holds shared helpers and model backends (no nodes); nodes/<category>/ mirrors the menu, and every module there that defines NODE_CLASS_MAPPINGS is registered automatically; web/ holds the frontend extensions.

  • Tests and lint (run from the ComfyUI root / the pack folder):

    python -m pytest custom_nodes/NH-Nodes/tests -q
    ruff check .
    
  • Docs assets are generated from the live code: docs/_tools/build_node_cards.py (node cards) and docs/_tools/build_examples.py (example images), both run from the ComfyUI root.

Author

jetthuang.com · Hugging Face · Support via PayPal. If NH-Nodes helps your work, a ⭐ on GitHub is appreciated.