ComfyUI Node Runs on cloud

M-LSD Lines

The straight-line preprocessor for architecture and interiors

By Fannovel16·Created 3 years ago·Updated 4 months ago· 4,136
M-LSD Lines
  • image
  • IMAGE
score_threshold0.10
dist_threshold0.10
resolution512

If you're generating rooms, buildings, or anything with hard geometry, M-LSD is the edge detector you actually want. It only cares about straight line segments - walls, door frames, window mullions, table edges - and it throws away the organic clutter. Canny will happily trace every wrinkle in a bedsheet; M-LSD gives you the architecture and nothing else. That focus is the whole point. For a scene where the composition is defined by straight lines and vanishing points, it produces a cleaner, more followable control map than a general edge detector.

How it works

M-LSD (Mobile Line Segment Detection) is a lightweight model that finds straight line segments in an image and returns them as a clean wireframe. It's not tracing outlines pixel by pixel like Canny - it's detecting line segments geometrically, which is why the output looks like an architect's sketch instead of a busy edge map. You feed that wireframe into an M-LSD ControlNet (control_v11p_sd15_mlsd on SD 1.5), and the model builds a new image that respects those structural lines while inventing everything else from your prompt. It's the go-to for interior redesign - same room layout, completely different furniture and style.

Worth saying up front, because it trips people up: the preprocessor only makes the hint image. It does nothing to your generation on its own. You still need the matching M-LSD ControlNet model loaded, and that lives in the SD 1.5 / SDXL world - the newer Flux and Z-Image unions include MLSD as one of their conditions too, so it carries forward better than most.

The inputs that matter

The node takes an image and gives you back an IMAGE - the line wireframe - that wires straight into your ControlNet Apply node. Two thresholds control how aggressive the detection is:

  • score_threshold (default 0.1) - the confidence cutoff. Raise it to keep only strong, obvious lines; lower it to catch faint ones. If your map is a mess of stray segments, nudge this up.
  • dist_threshold (default 0.1) - the minimum line length / distance filter. Raise it to drop short, fragmented segments and keep only the long structural lines.

resolution (default 512) sets the working size; match it to your render. The defaults are sane for most interior shots - reach for the thresholds only when the map is too noisy or too sparse.

Installing it

Install through ComfyUI Manager (search ComfyUI's ControlNet Auxiliary Preprocessors, install, restart), or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Fannovel16/comfyui_controlnet_aux
pip install -r requirements.txt

Restart ComfyUI. The M-LSD weights (mlsd_large_512_fp32.pth) download from HuggingFace on the first run - it's a small model, so this is quick and painless.

Where people get burned

The most common mistake is reaching for M-LSD on the wrong subject. It's built for straight lines, so on a portrait, a landscape, or anything curvy it'll return almost nothing usable - that's not a bug, it's the tool telling you to use Canny or softedge instead. Second, if your control map comes out too sparse, your thresholds are too strict; too busy, and they're too loose. Tune score_threshold first. And the constant across this whole pack: a preprocessor with no matching ControlNet loaded is just making pretty wireframes that never touch your output - make sure the MLSD ControlNet is actually in your graph and set to a strength that bites.

CategoryControlNet Preprocessors/Line Extractors

Inputs (4)

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

Outputs (1)

NameTypeDescription
IMAGEIMAGE