Skip to content

Core & Constants

Shared constants, enums, and lightweight utilities that form the foundation of the pipeline. These modules have no heavy dependencies (no torch, spconv, pdal, numpy) and can be imported anywhere.

See also

Architecture: Classification Schema for the 4-class schema defined in constants.py


Constants

Constant Value / Type Description
NUM_CLASSES 4 Number of model output classes
CLASS_NAMES dict {0: "Background", 1: "Ground/Water", 2: "Bridge Deck", 3: "Obstacles"}
CLASS_COLORS dict Matplotlib colors per class (black, orange, blue, yellow)
CLASS_COLORS_HEX dict High-contrast hex palette for publication figures
BRIDGE_DECK_MODEL_CLASS 2 Model class for bridge deck
BRIDGE_DECK_ASPRS_CODE 17 ASPRS code for bridge deck
OBSTACLES_MODEL_CLASS 3 Model class for obstacles
OBSTACLES_ASPRS_CODE 18 ASPRS code for obstacles
VOXEL_SIZE 0.1 Default voxel size in meters
SPATIAL_SHAPE_PADDING 10 Padding added to voxel grid spatial shape
MIN_POINT_COUNT 100 Skip files with fewer points
BRIDGE_TIMEOUT 150 Default per-bridge timeout in seconds
AWS_MAX_RETRIES 3 Max S3 retry attempts (adaptive mode)

Class Mapping (ASPRS to Model)

Used at preprocessing/training time (LAS_TO_MODEL_MAP):

ASPRS Code ASPRS Name Model Class Model Name
2 Ground 1 Ground/Water
9 Water 1 Ground/Water
17 Bridge Deck 2 Bridge Deck
18 High Noise 3 Obstacles
all others - 0 Background

Used at inference time (MODEL_TO_LAS_MAP):

Model Class Model Name ASPRS Code ASPRS Name
0 Background 1 Unclassified
1 Ground/Water 2 Ground
2 Bridge Deck 17 Bridge Deck
3 Obstacles 18 High Noise

src.constants

Bridge Classification - shared constants and lightweight utilities.

This module has NO heavy dependencies (no torch, spconv, pdal, numpy) so it can be safely imported anywhere, including environments without a GPU.

InferenceResult

Bases: Enum

Outcome of a single bridge inference call.

InferenceMode

Bases: Enum

Output mode for bridge classification inference.

BridgeTimeout

Bases: BaseException

Raised when a single bridge exceeds the per-bridge wall-clock timeout.

bridge_timeout_guard

bridge_timeout_guard(seconds: float) -> Iterator[None]

SIGALRM-based wall-clock timeout. Raises BridgeTimeout after seconds.

Note: SIGALRM is delivered but the Python handler only fires when the bytecode eval loop runs. This CANNOT interrupt blocking C extensions (e.g. PDAL network reads). For C-blocking code, use subprocess-based timeout with Process.terminate() instead - see _run_bridge_in_subprocess in download_and_weak_supervise_hucs.py.

Parameters:

Name Type Description Default
seconds float

Wall-clock timeout in seconds. If <= 0, the guard is a no-op.

required

Raises:

Type Description
BridgeTimeout

If the guarded block exceeds the timeout.

Example
try:
    with bridge_timeout_guard(300):
        result = long_running_operation()
except BridgeTimeout:
    handle_timeout()

src.logging_utils

Shared logging configuration for long-running data scripts.

Provides a file + console logging setup used by download_bridge_lidar and download_and_weak_supervise_hucs (and any future data pipelines).

setup_logging

setup_logging(name: str, log_dir: str = './logs') -> Logger

Set up logging to both file and console.

Creates a timestamped log file under log_dir and returns a logger that writes INFO+ to the file and WARNING+ to stderr.

Parameters:

Name Type Description Default
name str

Logger name and log-file prefix (e.g. 'bridge_processing').

required
log_dir str

Directory to store log files.

'./logs'

Returns:

Type Description
Logger

Configured logger instance.