These are
converted redistributions of the original checkpoints published at
cherubicxn/scalelsd. No retraining or
fine-tuning was performed — the numerical content of the network is unchanged.
1import MLXScaleLSD
2
3// Downloads from this repo on first use, then caches locally.
4let directory = try await ModelStore.download(.v2)
5let session = try ScaleLSDSession.load(directory: directory)
6
7let image = try ScaleLSDSession.loadImage(at: imageURL)
8let result = try session.detect(image)
9for segment in result.segments(minimumScore: 10) {
10 print(segment.x1, segment.y1, segment.x2, segment.y2, segment.score)
11}
The original checkpoints are PyTorch pickles, which MLX cannot read. Scripts/convert.py in
the Swift repo performs a format conversion plus several inference-only graph simplifications,
each of which is numerically equivalent (verified to ~2e-6 relative against the PyTorch
reference):
Verified stage by stage against the PyTorch reference. The final 9-channel HAT field matches to
1.1e-05 (v1) / 1.4e-05 (v2) maximum relative error. End-to-end on assets/indoor.jpg:
Detections are not bit-exact by construction: the 512-junction cap and the nearest-junction
assignment are discrete choices that a sub-noise perturbation can flip. See
docs/PARITY.md.
Apache-2.0, inherited from the original checkpoints at
cherubicxn/scalelsd. The upstream ScaleLSD source
is MIT (Copyright © 2023 Nan Xue). Original work and all model credit belong to the ScaleLSD
authors; this repository contributes only a format conversion.
1@inproceedings{ScaleLSD,
2 title = {ScaleLSD: Scalable Deep Line Segment Detection Streamlined},
3 author = {Zeran Ke and Bin Tan and Xianwei Zheng and Yujun Shen and Tianfu Wu and Nan Xue},
4 booktitle = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
5 year = {2025},
6}