How whjdark/aagnet works
Main Components to Identify
a. Input/Data Processing:
• Dataset Creation and Conversion: The “dataset” directory includes modules (e.g., AAGExtractor, Features, OCCUtils, and Utils) which are responsible for extracting and managing geometric, topological, and extended attributes from STEP/B-Rep files.
• Data Loading: The “dataloader” folder provides multiple variants (e.g., mfcad, mfinstseg) for reading and preprocessing the raw data.
• Dataset Partitions: “MFInstseg_partition” houses text files that likely serve as train/validation/test splits.
b. Model:
• Neural Network Components: The “models” directory includes definitions for encoders, decoders, segmentation heads, and the network’s auxiliary layers (activations, loss functions, etc.). This is where the main AAGNet architecture is defined.
• Additional Modeling Utilities: The “ASIN_for_MFInstSeg” sub-module contains additional model scripts likely tailored to working with the MFInstSeg dataset.
c. Training & Inference Engine:
• The “engine” folder holds trainer and tester scripts (e.g., seg_trainer.py, inst_trainer.py, inst_test.py, inst_test_per_feature_metric.py) which drive the training and evaluation pipelines.
d. Visualization and Evaluation:
• “utils” contains various utility scripts for post-processing and visualization (e.g., qt5_visualization, step2stl, visualize_uv), and additional performance testing (e.g., infer_speed_test).
e. Supporting Components:
• “environment.yml” provides the computational environment information, demonstrating dependencies on PyTorch, DGL, pythonocc-core, and other libraries.
Relationships and Interactions
• Data flows from raw STEP/B-Rep files through the dataset extraction pipelines (in “dataset” and “dataloader” modules) to produce the gAAG inputs.
• These inputs are fed into the model, which is comprised of distinct stages: an “input encoder” (extracting basic features), a “graph encoder” (leveraging GNNs to capture spatial and topological relationships), and a “multi-task head” that produces segmentation outputs.
• Training and evaluation are performed via scripts in the “engine” directory, where configuration and dataset paths are defined.
• There is a clear separation between training, testing, and inference components with dedicated utilities making the system modular and testable.
Architectural Patterns and Key Design Principles
• Modular Organization: The separation into dataset handling, modeling, training, and testing modules illustrates a clean modular design.
• Multi-task Learning: The network is designed to support simultaneous tasks, as evident in the multi-task head architecture.
• Graph Neural Network (GNN) Concepts: The central idea is processing graph-based representations (gAAG) that maintain geometric, topological, and attribute information.
• Data Pipelines: There’s a well-demarcated pipeline from raw data through conversion to training-ready formats (gAAG), giving room to easily swap datasets (MFCAD, MFCAD++, MFInstSeg) via configuration changes.
Relevant Technologies & Libraries
• PyTorch is used as the primary deep learning framework.
• DGL (Deep Graph Library) indicates that the models make use of graph processing capabilities.
• pythonocc-core and occt are crucial for CAD model manipulation and geometric processing.
• Numba for potential acceleration of numerical/geometric computations.
• Supporting libraries like scikit-learn, timm, wandb, and torchmetrics for evaluation, model checkpointing and experiment tracking.