How fpthink/spnet works
Project type and purpose
• This is a research-oriented deep learning framework (SPNet) for point-cloud over-segmentation.
• It comprises a PyTorch-based training/inference pipeline, C/C++ CUDA custom operators, configuration management, dataset handling, and experiment logging.
File structure
Top-level directories and their roles:
• config: YAML configuration files (model settings, paths)
• dataset: raw point-cloud data folders (S3DIS, ScanNet, vKITTI)
• exp: output folder for experiments (checkpoints, logs)
• lib:
– ply_c: C++ library for PLY file I/O and graph extraction
– pointops: custom CUDA kernels for point operations (knn, grouping, sampling)
– sync_bn: synchronized batchnorm utilities for multi-GPU
• model: Python modules defining network architecture and modules
• tool: shell & Python scripts to launch training and testing
• util: Python utilities for data loading, graph computation (compute_spg), metrics, transforms
Extract additional insights from README
• Requires manual CMake build of ply_c and Python install of pointops.
• Training/testing invoked via tool/sh_train.sh and tool/sh_test.sh, passing dataset key, experiment ID, and config file.
Out main components and interactions
a. Components:
1) Configuration Loader (config/spnet.yaml → util/config.py)
2) Data Ingestion & Preprocessing
– Dataset modules (util/S3DIS_dataset.py, SCANNET_dataset.py, etc.)
– compute_spg graph generator (util/compute_spg)
– transform and provider utilities (util/transform.py, util/provider.py)
3) Custom Operator Libraries
– ply_c (lib/ply_c → CMake/C++ layer)
– pointops (lib/pointops → CUDA kernels exposed via Python)
– sync_bn (lib/sync_bn for multi-GPU batchnorm)
4) Model Core
– network.py (defines SPNet architecture)
– modules.py (building blocks: graph convolution, pooling)
5) Training & Evaluation Scripts
– tool/train.py, tool/test.py orchestrate data loader → model → optimizer → loss → metrics
– shell wrappers (tool/sh_train.sh, tool/sh_test.sh) inject parameters and launch processes
6) Experiment Management & Artifacts
– exp/… directory stores checkpoints (saved_model/*.pth), logs, and evaluation outputs
b. Relationships & Data Flow
– Config Loader → Training Script & Data Ingestion
– Data Ingestion → compute_spg (calls ply_c to read PLY and build superpoint graph)
– Data → pointops custom CUDA kernels for neighborhood queries, grouping, sampling
– Preprocessed batches → Model Core → Forward Pass → Loss & Metric computation
– Backward pass → Custom ops + PyTorch → Parameter updates
– Checkpoint saving → exp directory
c. Architectural patterns & design principles
– Layered separation: Python orchestration (top) vs. high-performance C/CUDA kernels (bottom)
– Modular design: clear boundaries between data loader, custom ops, model definitions, and training loops
– Configuration-driven: YAML files control all hyperparameters and paths
– Experiment reproducibility: all artifacts stored under exp/<dataset>/<exp_id>
d. Key technologies, frameworks, libraries
– Python 3.6.6, PyTorch 1.4.0, CUDA 10.1
– CMake, Boost, Eigen3 (for lib/ply_c)
– Custom CUDA kernels (lib/pointops)
– YAML for configuration
Diagramming recommendations
– Config file → Config Loader → Scripts
– Dataset storage → Data loader → compute_spg → pointops → Model
– Model → exp (checkpoint/storage)
Detailed element checklist
• Custom-op layer showing submodules (knnquery, grouping, sampling)
• Build-time steps (cmake & make for ply_c; python setup.py install for pointops)
• Experiment directory structure and checkpoint saving
Top layer: Config & Orchestration
Middle layer: Data ingestion & Preprocessing → Custom Ops → Model Core
Bottom layer: C/C++/CUDA libraries and GPU resources
This will capture the essential architectural elements without over-splitting, giving a clear, accurate view of SPNet’s system design.