Nodes/ComfyUI-Inference-Core-Nodes/[Inference.Core] M-LSD Lines
ComfyUI Node

[Inference.Core] M-LSD Lines

The ControlNet preprocessor for straight-edge architecture and interiors

By LykosAI·Created 2 years ago·Updated about a year ago· 33
[Inference.Core] M-LSD Lines
  • image
  • IMAGE
score_threshold0.10
dist_threshold0.10
resolution512

Most line-extraction preprocessors are built for organic, freehand-style lines - Lineart, Softedge, Scribble all lean toward soft, curvy, sketch-like output. M-LSD (Mobile Line Segment Detector) does the opposite on purpose: it's tuned specifically to find genuinely straight lines and ignore everything else. Reach for it on interiors, architecture, product photography - anywhere the actual geometry is rectilinear and you want the ControlNet condition to lock onto exactly those hard edges rather than picking up soft gradient noise from lighting or texture.

It's also not a fringe or aging model the way some preprocessors in this pack are. M-LSD is one of the twelve conditions on xinsir's SDXL union ControlNet - the single most capable general-purpose ControlNet artifact currently available - and it's one of the handful that survived into the newer union sets trained for Z-Image and Flux 2 as well. So unlike some of its neighbors here, M-LSD-conditioned checkpoints are still being trained for current-generation base models, not just inherited from the SD 1.5/SDXL era.

The two thresholds that actually matter

score_threshold (0.01–2, default 0.1) is the confidence cutoff for what counts as a detected line. Raise it to drop weak or uncertain detections and keep only the lines the model is confident about; lower it if a strongly geometric image is coming back with too few lines detected.

dist_threshold (0.01–20, default 0.1) controls how close two detected segments have to be before they get merged into a single line. Raise it if you're getting a cluttered mess of near-duplicate parallel lines where one clean line should be; lower it if genuinely separate lines are getting incorrectly fused together.

resolution (64–2048, default 512) is the standard preprocessor resize control shared across this pack.

The output is a single IMAGE - wire it into a Line- or MLSD-type ControlNet exactly as you would any other line preprocessor's output.

Installing it

Comes bundled 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 in [cuda12], [rocm], or [directml] for your hardware) and restart, rather than the plain pip install -e ., if you want ONNX-accelerated preprocessing instead of falling back to CPU.

Troubleshooting

The most common "is this broken" moment: run M-LSD on a portrait, a landscape, or anything organic and curvy, and you'll get little to nothing back. That's expected, not a bug - M-LSD is deliberately blind to anything that isn't a fairly straight edge, by design. If an architectural or interior shot is coming back with almost no detected lines, lower score_threshold before assuming something's wrong. If you're getting a chaotic tangle of near-duplicate lines, raise dist_threshold to merge them.

If you find yourself wanting soft, forgiving edges on an organic subject instead, this is the wrong preprocessor entirely - reach for Softedge, PiDiNet, or Lineart instead, which this pack also ships.

CategoryControlNet Preprocessors/Line Extractors

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
score_thresholdoptFLOAT0.100.01–2
dist_thresholdoptFLOAT0.100.01–20
resolutionoptINT51264–2048

Outputs (1)

NameTypeDescription
IMAGEIMAGE