Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Project: inspect pallet damage from 3D point scans

Last updated: 7 Oct 20265 min read
project
AdvancedBy AITrove Editorial

Build a scan-level defect detector with a declared coordinate frame, scan-group evaluation and a review path for missing or low-density depth.

Build the scan ledger

Collect raw depth scans with pallet ID, scanner site, acquisition session, units, sensor pose and calibration revision. Record reviewed defect types, location and severity, plus whether depth returns are missing near the suspected defect. Split by pallet before creating training crops or resampled point sets. Keep a reserved scanner and time period for the final transfer check. The geometry lesson defines the transformations to version.

Set a transparent baseline

Compare a simple geometric threshold on height or missing volume with a point-set classifier. A neural score is only useful if it finds defects the baseline misses without overwhelming inspectors with false flags. Record defect prevalence, manual review capacity and the cost of a missed structural flaw. Include clean pallets with reflective wrap, partial occlusion and irregular loading so the detector sees operational negatives rather than only tidy scans.

Verify the model path

The code executes one synthetic class update for a shared point encoder with max pooling. It checks tensor axes and finite loss; it does not train on pallet scans or prove that max pooling captures a small break. Compare a mean-pooling ablation and a physical-geometry baseline under the same pallet-level holdout. The set lesson separates order invariance from physical invariance.

Score operational slices

Report pallet-level recall for severe defects, false flags per inspected pallet, abstention rate for poor scans and review time. Slice by point density, defect size, scanner site, pallet material and reflective packaging. Examine missed defects in raw coordinate space; if the sampled cloud discarded the flaw, changing classifier depth alone cannot fix the problem. Freeze the score threshold before the final scanner-site evaluation.

Release with a review route

Package unit conversion, calibration version, crop and sampling rules, model weights, threshold and minimum usable point count. Route sparse or malformed scans to rescan or manual review; do not label them clean. Measure p95 scan-to-decision time including decode and sampling. Keep the threshold baseline available as a rollback while collecting reviewed failures and per-site drift evidence.

Implementation

python
import torch
from torch import nn
from torch.nn import functional as functional

torch.manual_seed(47)
pallet_scans = torch.rand(4, 32, 3)
reviewed_damage = torch.tensor([0, 1, 0, 1])
point_encoder = nn.Sequential(nn.Linear(3, 16), nn.ReLU(), nn.Linear(16, 8), nn.ReLU())
inspection_head = nn.Linear(8, 2)
optimizer = torch.optim.AdamW(list(point_encoder.parameters()) +
                              list(inspection_head.parameters()), lr=0.0007)
encoded_points = point_encoder(pallet_scans)
scan_features = encoded_points.amax(dim=1)
damage_logits = inspection_head(scan_features)
assert damage_logits.shape == (4, 2)
loss = functional.cross_entropy(damage_logits, reviewed_damage)
optimizer.zero_grad(set_to_none=True)
loss.backward()
optimizer.step()
assert torch.isfinite(loss)

Performance and operating cost

For B scans and N retained points, point encoding and activation memory grow approximately linearly with BN at fixed layer widths. Raw scanner data, crop construction and repeated sampling can dominate end-to-end cost. Increasing N may preserve smaller defects but reduces throughput; select it from measured recall-versus-latency curves. The example is a single synthetic optimizer step, not a validated detector, and its random points have no physical meaning.

Common Mistakes

  • Do not claim scan-level random-crop accuracy as pallet-level generalization.
  • Do not classify a scan with too few valid returns as clean.
  • Do not ship a class score without a reviewed threshold and a rescan route.

Read next

ai-data
deep-learning
Storage details