CCTech MLSD Lines Preprocessor ⚡
M-LSD straight lines — the preprocessor for architecture, interiors, and vanishing points
- image
- IMAGE
Most edge preprocessors trace every contour they can find. MLSD does something narrower and more useful for a specific job: it detects only straight line segments - the wall edges, window frames, table corners, and perspective lines of a scene - and draws them as clean lines on a black canvas. If your subject is a building, a room, or anything with strong geometric structure, this is the condition that holds it together. It's how you keep an interior render's vanishing points honest.
It's also one of the conditions the newer union ControlNets actually kept: both Alibaba PAI's Z-Image and Flux 2 unions include MLSD as a mode, so on those bases you're not stuck dragging it into an SDXL workflow. On the older SD 1.5/SDXL world, an MLSD ControlNet is a classic, well-documented option.
How it works
M-LSD (Mobile Line Segment Detection) is built on a MobileNetV2 backbone - small, fast, designed to run on-device - plus a line-segment head that outputs segments rather than pixel edges. This node is a from-scratch port of the architecture from comfyui_controlnet_aux (Apache-2.0), real model code rather than a wrapper. The checkpoint auto-downloads from HuggingFace on first use into ComfyUI/models/mlsd/, and the detector renders its findings onto a black canvas.
Inputs and outputs that matter
image- a photo or render with linear geometry. Indoor shots and architecture are the sweet spot; a portrait will produce almost nothing.resolution(default 512, 64–2048) - internal detection resolution.score_threshold(default 0.1, 0.01–2.0) - how confident a segment must be to survive. Raise it to strip out faint junk lines.dist_threshold(default 0.1, 0.01–20.0) - the distance tolerance when merging segments. The one you'll fiddle with when lines come out fragmented into dashes instead of continuous strokes.
The output is one IMAGE - white straight lines on black. Wire it into an MLSD ControlNet's control_image, or into the MLSD mode of a union. Because the output is so geometric, it's also a great candidate to eyeball in a PreviewImage before committing.
Installing it
Part of ChrisColeTech/ComfyUI-ControlNet-Nodes, the eleven-preprocessor pack under 🤖 CCTech/Preprocessors. Install via ComfyUI Manager (search "ComfyUI-ControlNet-Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ChrisColeTech/ComfyUI-ControlNet-Nodes
Restart ComfyUI. No dependencies beyond the pack's requirements.txt (huggingface_hub, opencv-python).
Common issues
The first run downloads the checkpoint - expect a pause. The classic MLSD complaint is fragmented lines: a wall edge that should be one stroke comes out as several short dashes. That's what dist_threshold is for; raise it a little to encourage the detector to join segments. Opposite problem - too much junk, specks and stray marks - is score_threshold's job. And remember the scope: this detector is only looking for straight lines. Feed it a curved organic subject and you'll get an almost-empty map, which isn't a bug.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| resolution | INT | 51264–2048 | — |
| score_threshold | FLOAT | 0.100.01–2 | — |
| dist_threshold | FLOAT | 0.100.01–20 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |