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.
Nodes (76)
Garment erased, model fooled
Your list is one socket away from ten named outputs
One input, five output branches, and only the branch you picked runs
The Any Switch (NH) that isn't the fallback you were promised
Grab one frame out of a batch without touching the rest
Stack three image batches into one, and it fixes the sizes for you
Type 'clothes - shoes' and get the mask
A plain on/off switch, because your graph needed one
Load one of 64 CLIPs by number, and stop dragging dropdowns
Turn any two values into a true/false for the rest of your graph
A counter that remembers between queue runs, so your loop knows where it is
Pick a diffusion model by index — or hand the choice to a boolean
Cut the shirt out with a SegFormer mask, no hand-painting
A valve that blocks the branch behind it, not just the data
Your graph's if/else, with both sides always wired
Put two images in one frame so you can actually see the difference
A contact sheet in one node, with gaps and padding
Stamp a header or footer caption onto a batch of images
Millimetres, DPI and all
Cut a huge image into overlapping tiles your VRAM can handle
Sew the tiles back together, even if you upscaled them first
A/B your 4K renders without melting the browser
Zoom into an 8K render in your browser without freezing the canvas
Your big previews are stacking up in temp. Here's the broom.
Turn a batch of images into a print-ready contact sheet
Drop layers onto a canvas with exact coordinates
Make a list ComfyUI can actually index into
Filter your list by contains, regex, or length
Grab the Nth item out of a list, cleanly
Load an image and get its filename and path out the other side
Load a folder of images by index, step, and seed mode
Load the images that match — a folder-aware matching loader
The boolean brain your workflow keeps not having
One index to switch which LoRA hits the CLIP
Index into a wall of LoRAs without a wall of nodes
Expand masks by X and Y separately, fill holes, blur the edges
Make one mask's aspect ratio match another's
Width, height, and bbox of a mask in one pull
Resize an image and never lose the mask's subject
Turn any mask into a clean rectangle
Do real math in the graph, not node spaghetti
Multi-Slider (FLOAT) is the decluttering move
Five integer dials that cut your canvas clutter in half
Collapsing a dozen wires into one tidy pipe
A checklist of face parts instead of one blunt mask
Building prompts from fragments without the comma soup
Rotate prompts per step for animation and mid-run swaps
Fill {placeholders} from real inputs instead of editing text
Weighted randomness for prompts, LoRAs, and branch picking
When you want to say 'make it 2:3' and mean it
Pull, replace, or split text without leaving ComfyUI
Undo the letterbox bars your resize added
Get back the edges your model cropped away
Name a thing, get every one of them
Dump images into a folder you choose, and get the paths back
Save the full-res file without making your canvas choke
Build one mask out of labels, not brushes
See every instance drawn on your own photo
Pick the second person from the left, not all of them
Feed SAM 3's finds to Impact Pack's detailers
One MASK per instance, and the labels to prove it
Drop a face onto a new body with mask-guided blending
Let the model's preset table pick your crop for you
The txt2img resolution node that already did the math
Ten string helpers hiding in one dropdown
Pick one of ten inputs by index, with a safe fallback
Up to 64 strings joined on one delimiter, without the mess
Pick the Nth prompt out of a stack, and stop when there's nothing to pick
Let this node roll the dice for you
Text Split (NH) does the parsing for you
The ComfyUI text superpower
Build your own parameter node from a text config — no Python required
Unpacking the Universal Pipe
One loader, up to 64 VAEs, picked by a single number
The lookup node your switches are missing
The preprocessing half of virtual try-on, all in one node
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) orpython -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
sam3package and thesam3.ptcheckpoint. 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
- Guide: English · Tiếng Việt
- PDF guides: English · Tiếng Việt
- Changelog: docs/CHANGELOG.md — read it when updating: some fixes change outputs on purpose.
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'smit-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
sam3package 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 definesNODE_CLASS_MAPPINGSis 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) anddocs/_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.