How zmoka-zht/cdmamba works
Main Components
• Data Management Layer – Represented by the “data” directory, this module deals with dataset handling, preprocessing, list generation (e.g., generate_list.py), and utility functions.
• Core Functionalities – Found in the “core” directory, which includes basic utilities such as logging (logger.py) and metrics (metrics.py) essential for monitoring training and inference.
• Model Architectures – The “models” directory houses numerous deep neural network implementations (e.g., CDMamba, ChangeFormer, FC-EF, SNUNet, etc.). Note the subdirectories (like “backbone”, “changemamba_cd_help”, “darnet_help”, etc.) that indicate modular designs and possible reuse of components.
• Configuration Management – “config” holds different JSON configurations for various experimental settings (for example, levir_cdmamba.json, levir_test_cdmamba.json). These files define hyperparameters, dataset paths, and other runtime options.
• Miscellaneous Utilities – The “misc” folder contains additional scripts for tasks such as metric computation and auxiliary PyTorch utilities.
• Training & Testing Pipeline – Scripts like train_cd.py and test_cd.py serve as entry points for training and evaluating the models, tying the above components together.
Relationships and Data Flow
• Preprocessing and Utility Functions: Indicate that the “data/util.py” and “data/colormap.py” assist in handling and preparing data before it is fed to the models.
• Core Processing: Show that after a model processes the data, the “core” components (logging and metrics) capture outputs, errors, performance data, and other signals during training and testing.
• Kernel / Low-level Operations: Within the “models/changemamba_cd_help/kernels” sub-tree, there is a specialized sub-system (written in C/C++ for CUDA kernels) to optimize selective scanning operations. Represent these as a “CUDA Kernel Module” linked to the main model execution allowing for GPU-accelerated operations.
• External Libraries: Mark dependencies like PyTorch, CUDA, and potential external libraries (mamba-ssm and causal-conv1d as hinted in the README) to give context on the runtime environment.
Architectural Patterns and Design Principles
• Integration of Optimized Low-level Routines: The use of custom CUDA kernels for selective scan operations (in “changemamba_cd_help/kernels/selective_scan”) indicates optimized performance paths for critical operations.