[Inference.Core] PiDiNet Soft-Edge Lines
A faster alternative to HED for ControlNet
- image
- IMAGE
PiDiNet (Pixel Difference Network) fills the same slot in a ControlNet workflow as HED/Softedge: it produces gradient edges with varying thickness rather than Canny's hard binary lines, which makes it more forgiving on organic subjects - you don't need a perfect, clean edge for the model to make good use of it. PiDiNet is generally the community's go-to alternative to the older HED model for that same soft-edge conditioning slot: lighter, faster to run, and producing that same forgiving gradient-edge character rather than Canny's precision.
That "forgiving" part is the actual selling point over Canny, and it's worth internalizing before you pick a line extractor: Canny needs genuinely clean edges to look good and can leave gaps on a messy or low-contrast photo, where a softedge model like PiDiNet still returns something usable. Reach for it on faces, hair, fabric, foliage - anywhere a hard binary edge map would either miss real detail or draw a jagged line where a soft gradient belongs.
The one real setting
safe (enable/disable, default enable) runs a post-processing pass that suppresses noisy or spurious edge detections, giving you a cleaner map at a small cost to fine detail. Leave it on for most images - it's the default for a reason, and it's what keeps PiDiNet's output usably clean. Turn it off specifically when you're working with a very textured or detailed source image and safe mode is throwing away real detail you actually wanted to keep in the edge map.
resolution (64–2048, default 512) is the standard preprocessor input-resize control shared across this whole pack.
Output is a single IMAGE - wire it into a Softedge-type ControlNet exactly as you would HED's output; they're conditioning on the same kind of edge information.
Installing it
Comes with the LykosAI Inference Core Nodes pack. Via ComfyUI Manager, search "ComfyUI-Inference-Core-Nodes". Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/LykosAI/ComfyUI-Inference-Core-Nodes
then install.py, or pip install -e .[cuda] (swap for [cuda12], [rocm], or [directml] to match your hardware) and restart. Use the accelerated extra rather than plain pip install -e . if you want this preprocessor running on your GPU instead of falling back to CPU.
Troubleshooting
If edges are coming back too clean and thin for what you wanted - you were hoping for a bit more texture and detail in the map - try disabling safe mode before assuming you need a different preprocessor entirely; that one toggle accounts for a lot of the variation in PiDiNet's output character. If you're getting noisy, cluttered edge maps even with safe enabled, the source image itself may just be too busy for softedge conditioning to help - that's a case where switching to Canny (cleaner, harder lines) or M-LSD (if the noise is really just non-straight clutter you don't need) is more likely to fix things than tweaking PiDiNet's one toggle further.
One more thing worth knowing if you're deciding between preprocessors: this pack also ships its own M-LSD line extractor for the straight-edge case, so if PiDiNet's output isn't what a given image needs, swap in a different node from the same pack, keep everything else in the graph identical, and compare the actual difference before committing to one.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| safeopt | COMBO | enable | 2 options: enable, disable |
| resolutionopt | INT | 51264–2048 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |