Files
sum-parts-test/scripts/poc_infer.sh
T
nbrightandClaude Opus 5 f39b093106 Record results so far and fix the memory blowup in the palette decode
Adds STATUS.md as the handoff document: benchmark numbers, the bare-earth
metrics that actually matter for this project, the Korean-data domain gap that
retraining will not fix, and what to do on the 24 GB machine.

The memory problem was in how a prediction's colours were turned back into
class indices. Every consumer built an (N, 13, 3) float64 temporary:

    d = ((rgb[:, None, :] - COLOR_MAP[None, :, :]) ** 2).sum(axis=2)

That is ~250 MB of intermediates per 800k-point tile, several live at once, and
a full 4.7M-point block pushes it into gigabytes. main.py writes exact palette
entries, so an exact hash lookup resolves nearly every point with no large
temporary; only leftovers fall back to a chunked distance search. Peak RSS on a
470k-point tile drops to 61 MB. Extracted to sumparts_palette.py and shared by
coarse_eval.py and split_by_class.py.

Also from this round:

- patch_cm_mutation.sh: ConfusionMatrix.update() rewrote the caller's pred
  tensor in place, folding every ignore_index point into class num_classes-1.
  test() saves its visualization from that same tensor afterwards, so an
  unlabelled tile came out 100% wall and the model looked degenerate when it
  was not.
- patch_class_mask.sh: SUMPARTS_MASK_CLASSES drops known-absent classes from
  the argmax. Measured on Seosan and it does not help - the runner-up for
  "water" is "wall", not "terrain" - but the experiment is worth keeping.
- split_by_class.py now writes .ply alongside .obj. A vertex-only OBJ has zero
  faces and most viewers render nothing, which is why the first export looked
  broken.
- verify_outputs.sh reads exported files back with a parser, so "here are your
  files" can be checked rather than asserted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 09:07:31 +09:00

59 lines
1.9 KiB
Bash

#!/usr/bin/env bash
# SUM Parts - run inference on the converted Korean tile
#
# This answers one question: does a SUM Parts model accept our data and emit
# per-point predictions? It does NOT measure anything. The checkpoint is the
# 1-epoch smoke-test model and the tile carries label=0 everywhere, so the
# reported mIoU/OA are meaningless by construction. Look at whether it runs and
# what the predicted class histogram looks like, nothing else.
set -euo pipefail
CONDA_ROOT="$HOME/miniconda3"
ENV_NAME="sumparts"
REPO="$HOME/sum-parts/semantic_segmentation/PointNeXt_bundle"
SEG="$REPO/examples/segmentation"
TILE="$HOME/sum-parts/data/korea_poc/seosan_BlockYBA_tile0.ply"
TRACK="$HOME/sum-parts/data/korea_poc_track"
LOG="${LOG:-/tmp/sumparts_poc_infer.log}"
source "$CONDA_ROOT/etc/profile.d/conda.sh"
conda activate "$ENV_NAME"
export WANDB_MODE=disabled WANDB_SILENT=true
export CUDA_HOME="$CONDA_PREFIX"
[ -f "$TILE" ] || { echo "error: $TILE missing -- run poc_korea.sh first" >&2; exit 1; }
# The dataset class globs {train,val,test}/*.ply and errors on a missing split,
# so all three have to exist even for a test-only run.
for split in train val test; do
mkdir -p "$TRACK/$split"
ln -f "$TILE" "$TRACK/$split/$(basename "$TILE")"
done
rm -rf "$TRACK/processed"
# The cfg has to match the architecture that wrote the checkpoint; hardcoding
# one here loads the weights into the wrong model and torch raises on the
# state_dict.
source "/mnt/d/MYCLAUDE_PROJECT/sum-parts-test/scripts/resolve_ckpt.sh"
cd "$SEG"
set +e
python -u main.py \
--cfg "../../cfgs/sumv2_triangle/${CKPT_CFG}.yaml" \
mode=test \
--pretrained_path "$CKPT" \
dataset.common.data_root="$TRACK" \
wandb.use_wandb=False \
batch_size=2 \
val_batch_size=1 \
> "$LOG" 2>&1
rc=$?
set -e
echo "=== exit=$rc | last 25 lines ==="
tail -25 "$LOG"
[ "$rc" -eq 0 ] && echo "POC INFER DONE" || echo "POC INFER FAILED (rc=$rc)"
exit "$rc"