Skip to content
All notes

Notes · 2026-10-27 · 28 min

From a scan to a floor plan, start to finish

Every step with its command: the free local pipeline that turns a point cloud into an A3 drawing, then the rented GPU session that tests a pretrained model against it.

Scan to planPoint cloudsVectorisationPTv3Runpod

This is the complete runbook for the two-room plan: the free part that runs on your laptop, the paid part that runs on a rented GPU, and every command in between. Nothing is summarised away — if a step exists, it is here with the code that performs it.

The shape of the job. A handheld scanner gives you a cloud of XYZ points. A floor plan is a handful of lines. Getting from one to the other is ten small steps, each of which fixes one specific kind of mess. The AI part is optional and comes last.

What you need before you start

1

A Mac or PC with Python 3.9 or newer, and a terminal you are not afraid of.

2

The scan itself, as a .las file. Twenty million points for two rooms is normal.

3

About US$10 of credit on a cloud GPU service (only if you want the AI section).

4

Forty minutes, most of which is waiting.

Install the libraries the local half needs. This is the only setup on your own machine:

python3 -m pip install laspy numpy scipy scikit-image shapely pillow

If any of that fails, run python3 -m pip install --user ... with the same list. Nothing here needs a GPU, a cloud account or a licence.

Part 1 — Turn the scan into a drawing (free, on your Mac)

1

Look at the file before touching it. Point counts and extents tell you whether the file is what you think it is, and give you the numbers every later step relies on.

import laspy, numpy as np
las = laspy.read("3D/TwoRooms.las")
xyz = np.vstack([las.x, las.y, las.z]).T
print(len(xyz), "points")
print("bounds", xyz.min(0).round(2), xyz.max(0).round(2))

What you should see: 2,453,988 points and something like 11.6 x 5.1 x 3.3 m. If the extents are kilometres wide, the file is in a projected coordinate system and needs centring first.

2

Reduce to 2 cm. Keep one point per 2 cm cube. This is the single biggest speed win and it costs nothing in accuracy, because the lines you are about to draw are measured in centimetres.

voxel = 0.02
key = np.floor(xyz / voxel).astype(np.int64)
_, keep = np.unique(key, axis=0, return_index=True)
xyz = xyz[keep]
print(len(xyz), "points after voxel")
3

Delete the floating points. For every point, look at its 24 nearest neighbours; if the average distance is far outside the norm, the point is a stray from glass or metal and goes.

from scipy.spatial import cKDTree
tree = cKDTree(xyz)
d, _ = tree.query(xyz, k=25, workers=-1)
mean_d = d[:, 1:].mean(axis=1)
keep = mean_d < mean_d.mean() + 1.8 * mean_d.std()
xyz = xyz[keep]
print(f"{len(xyz):,} kept · {100*keep.mean():.1f}% of the cloud")

Expect to lose two to three per cent. If you lose twenty per cent, the threshold is too aggressive and you are deleting real wall points.

4

Find the floors. Sort every point by height and look for the spikes. A floor is a huge flat surface, so an enormous number of points share almost the same Z.

z = xyz[:, 2]
hist, edges = np.histogram(z, bins=200)
mids = (edges[:-1] + edges[1:]) / 2
peaks = mids[hist > 0.15 * hist.max()]
print("floor candidates:", peaks.round(2))

Two clusters of peaks means two storeys. Process each one separately, or both plans will be printed on top of each other.

5

Slice at wall height. Keep only what sits between 0.85 m and 1.75 m above the floor: above the desks, below the door heads.

fz = float(np.percentile(z, 2))          # floor height
band = xyz[(z > fz + 0.85) & (z < fz + 1.75)]
print(len(band), "points in the wall band")

This one line is why the drawing stops looking like a smear. Slice at 1.4 m and you catch every desk edge and monitor arm; slice here and you catch mostly wall.

6

Rasterise it. Project the slice onto the ground on a 3 cm grid. A cell with a point becomes a wall cell.

CELL = 0.03
lo = xyz[:, :2].min(0); hi = xyz[:, :2].max(0)
nx = int((hi[0]-lo[0])/CELL)+2; ny = int((hi[1]-lo[1])/CELL)+2
ix = ((band[:,0]-lo[0])/CELL).astype(int)
iy = ((band[:,1]-lo[1])/CELL).astype(int)
grid = np.zeros((ny, nx), bool)
ok = (ix>=0)&(ix<nx)&(iy>=0)&(iy<ny)
grid[iy[ok], ix[ok]] = True
7

Close the sampling holes. Grow the shapes and shrink them back. Gaps smaller than about 15 cm disappear; real 90 cm doorways survive. Keep the window well under a door width or you will wall yourself in.

from scipy import ndimage
grid = ndimage.binary_closing(grid, np.ones((5, 5)))   # ~15 cm
grid = ndimage.binary_opening(grid, np.ones((3, 3)))   # drop specks
8

Trace the outline and straighten it. The boundary of each wall band becomes a polygon, the polygon is simplified, and edges within eight degrees of horizontal or vertical are snapped flat.

from skimage import measure
from shapely.geometry import Polygon
rings = []
for c in measure.find_contours(grid.astype(float), 0.5):
    xy = [(lo[0] + col*CELL, lo[1] + row*CELL) for row, col in c]
    poly = Polygon(xy).buffer(0).simplify(0.03)
    if poly.area > 0.3:
        rings.append(poly)
print(len(rings), "wall polygons")

The simplification tolerance is the difference between a hand-drawn look and a wobbly outline. Three centimetres is a good starting point for a handheld scan.

9

Measure, do not guess. Wall thickness comes from a distance transform — the maximum distance from a wall cell to its own edge is half the thickness. Glazing is decided by density per side, because glass returns almost nothing.

dist = ndimage.distance_transform_edt(grid)
thick = np.median(dist[dist > dist.max()*0.5]) * 2 * CELL
print(f"wall thickness {thick*1000:.0f} mm")

m = 0.45
for name, sel in [("N", band[:,1] > hi[1]-m), ("S", band[:,1] < lo[1]+m),
                  ("W", band[:,0] < lo[0]+m), ("E", band[:,0] > hi[0]-m)]:
    print(name, round(len(band[sel]) / (0.45 * max(nx, ny) * CELL), 0), "pts/m2")

The side whose density falls to roughly a quarter of the others is the glazed façade. That is not a heuristic guess — glass physically reflects the beam away, so the return count collapses.

10

Write the sheet. Everything measured above goes onto an A3 page: hatched walls, glazing with mullion ticks, room labels with areas, dimension line, scale bar, north arrow. Write SVG first, print PDF second, so line weights stay crisp.

# the geometry above, written as an SVG with millimetre units
# then: node scripts/render-sheet.mjs plan.svg plan   -> plan.pdf + plan.png

If you only want the drawing and not the AI, you are finished here. Everything after this point is an experiment about how far a pretrained model gets on a building it has never seen.

Part 2 — Rent the GPU (only for the AI section)

1

Go to runpod.io and sign in. Add US$10 of credit under Billing. Ten dollars is four or five sessions; you will spend about one.

2

Click Deploy. You are renting a machine by the hour, not subscribing to anything.

3

Choose GPU RTX 4090 (24 GB). A 3090 or A5000 also works and costs less; the model does not need speed, it needs memory.

4

Choose template PyTorch 2.8 / CUDA 12.8. This matters — the CUDA version on the box has to match the spconv wheel you install later.

5

Container disk 30 GB, volume 0 GB, no ports. You do not need a persistent disk for a two-hour job.

6

Click Deploy On-Demand. Wait one to three minutes for the state to read Running.

7

Click Connect → Connect to Jupyter Lab. A browser tab opens on the pod's file system.

Confirm you actually got the GPU before installing anything. This is the thirty-second check that saves an hour of confusion:

nvidia-smi
python -c "import torch; print(torch.__version__, torch.cuda.is_available())" 

You want a table showing NVIDIA GeForce RTX 4090 and True. If CUDA says False, you picked a CPU template — terminate and redeploy.

8

Drag two files into /workspace in the Jupyter file list: the prepared .npz and the inference script. Then verify the sizes, because a silently truncated upload is the most common failure in this whole guide:

cd /workspace && ls -lh office-ptv3.npz ptv3-infer-old.py
# npz should be about 7.5 MB, the script about 3.5 KB

If the npz arrives at 1 MB instead of 7.5 MB, upload it again. If your file is larger than ~50 MB, split it on your Mac with split -b 4000000 file.npz part- and reassemble on the pod with cat part-* > file.npz.

Part 3 — Install the environment (one block, twelve minutes)

Paste this whole block into the pod terminal. It clones Pointcept, pins it to the commit that matches the published weights, installs the CUDA extensions, and compiles the custom operators.

cd /workspace
git clone --recursive https://github.com/Pointcept/Pointcept.git
cd Pointcept && git checkout ad653ee && git submodule update --init --recursive
pip install -q spconv-cu126
pip install -q torch-scatter torch-cluster -f https://data.pyg.org/whl/torch-2.8.0+cu128.html
pip install -q addict einops plyfile termcolor timm ftfy regex tqdm h5py pyyaml \
  tensorboard tensorboardx wandb yapf scipy matplotlib torch-geometric peft
pip install -q --ignore-installed blinker open3d
apt-get update -qq && apt-get install -y -qq libsparsehash-dev ninja-build libegl1 libgl1 libglib2.0-0
cd libs/pointops && python setup.py install && cd ../..
python -c "import torch, spconv, pointops; print('ENV OK', torch.__version__)" 

You want ENV OK 2.8.0+cu128. Two warnings are normal: a FutureWarning from timm, and [PointROPE] CUDA implementation unavailable — both are cosmetic.

The pin to ad653ee is not housekeeping. The published S3DIS weights are a 2024 build; the current code changed how points are serialised, and loading old weights into new code produces a cls_mode error and, if you get past it, an eleven-terabyte memory request. Pinning is faster than patching forward.

Part 4 — Download the weights (1 GB, two minutes)

The checkpoint lives on HuggingFace. This downloads only the S3DIS folder:

pip install -q huggingface_hub
python - <<'PY'
from huggingface_hub import snapshot_download
p = snapshot_download("Pointcept/PointTransformerV3",
                      allow_patterns=["s3dis-semseg-pt-v3m1-0-rpe/**"])
print("WEIGHTS:", p)
PY

Copy the path it prints. That path plus /model/model_best.pth is the file you feed to the next step.

Part 5 — Run the inference (three minutes)

One command. The script loads the cloud in 4 m tiles so the attention never asks for more memory than a 24 GB card has.

cd /workspace/Pointcept
cp /workspace/ptv3-infer-old.py .
W=/workspace/.cache/huggingface/hub/models--Pointcept--PointTransformerV3/snapshots/5e25cfaf759289b03db1f90f143b3dc5172929d3/s3dis-semseg-pt-v3m1-0-rpe
python ptv3-infer-old.py \
  --config configs/s3dis/semseg-pt-v3m1-1-rpe.py \
  --weights $W/model/model_best.pth \
  --input /workspace/office-ptv3.npz \
  --out /workspace/tworoom-labels.npy

Expected output, in order: loaded 695,629 points, weights loaded · missing=0 unexpected=0, running 6 tiles of 4.0 m, wrote /workspace/tworoom-labels.npy, then a table of thirteen class counts. If missing is not zero, the weights and the config disagree — check the commit pin.

Part 6 — Bring the labels back, then stop the meter

1

In Jupyter, right-click tworoom-labels.npy and choose Download. It is about 700 KB — one byte per point.

2

Move it next to your working folder on the Mac.

3

Terminate the pod from the RunPod dashboard. Closing the browser tab does not stop billing; only Stop or Terminate does.

mv ~/Downloads/tworoom-labels.npy ~/projects/gis-portfolio/.cache/

Part 7 — Read what the model actually said

Never trust a segmentation result you have not counted. This is the whole inspection, five lines:

import numpy as np
lab = np.load(".cache/tworoom-labels.npy")
names = ["ceiling","floor","wall","beam","column","window","door",
         "table","chair","sofa","bookcase","board","clutter"]
counts = np.bincount(lab, minlength=13)
for i, n in enumerate(counts):
    print(f"{names[i]:10s} {n:8d}  {100*n/len(lab):5.1f}%")

What came back for the two rooms:

•

wall 55.2%, bookcase 29.6%, clutter 7.0% — the model spent its confidence on walls and things it could not name.

•

table 3.8%, chair 1.5% — the classes we wanted, present but scattered into dozens of fragments.

•

floor 1.4%, ceiling 0.0% — broken. When the floor is wrong, every height-relative judgement downstream is wrong too.

The geometric method on the same cloud found four desk tops and three chairs with clean outlines, free, in seconds. That is the comparison that decides which method owns which decision.

Part 8 — When it breaks (the errors you will actually hit)

•

unexpected keyword argument 'cls_mode' — code and weights are from different years. git checkout ad653ee and rerun.

•

No module named 'pointops' — the custom extension was never compiled: cd libs/pointops && python setup.py install.

•

No module named 'SharedArray' — the script used Pointcept's dataset layer. Use the version that builds grid_coord itself instead of importing it.

•

operator torchvision::nms does not exist — a pip install quietly upgraded torch. Reinstall the pair: pip install --force-reinstall --no-deps torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128.

•

bincount only supports 1-d — the batch tensor has the wrong shape. The model wants offset as a 1-D length and batch as 1-D indices.

•

Weights only load failed — PyTorch 2.6 and later refuse pickled checkpoints by default. Load with weights_only=False; the file came from HuggingFace, so it is trusted.

•

torch.OutOfMemoryError: Tried to allocate 11381 GiB — a shape bug, not a real memory shortage. Check the tensor shapes before you buy a bigger GPU.

•

Floor classified as table — the training set is American single-storey offices. This is a data problem, not a bug you can fix with parameters.

•

Upload arrived truncated — split the file, upload the parts, reassemble, and compare the size afterwards.

What it costs

The local half is free and runs in a few minutes. The GPU half costs about US$0.60–1.20 for a full session including setup, because the card is only needed for the install and the three-minute inference. Renting the cheapest 24 GB card instead of the fastest one saves a few cents and changes nothing else.

The one lesson worth keeping. Everything that made this drawing good happened before the first line of code ran: a clean extract, two rooms, full density. The algorithm decided how tidy the linework looked; the scan decided whether there was a building to draw at all.

  • Clean and crop the cloud before vectorising anything — it changes the result more than any algorithm setting.
  • Slice at wall height (0.85–1.75 m), not through the desks.
  • Snap to orthogonal only within about eight degrees, keep long angled walls as they are.
  • Measure wall thickness and room area from the data so the numbers match the drawing.
  • Detect glazing by point density per side; a glazed edge reads at about a quarter of a solid wall.
  • Count the classes before you trust them, and report agreement instead of a pretty picture.