How darylfung96/self-supervised-ct-segmentation works
Main Components
• Data Layer:
• Input Datasets: Several dataset sources (e.g., medseg, deepglobe, spacenet) as seen in the “datasets” folder and the instructions on preparing the InfNet datasets.
• Data Preprocessing: Scripts and utilities such as “combine_dataset.py”, dataloader scripts (e.g., dataloader_LungInf.py, dataloader_MulClsLungInf_UNet.py), and additional preprocessing utilities in the “utils” folder.
• Model Architecture:
• Core Segmentation Models: Under the “InfNet/Code/model_lung_infection” directory we have multiple network implementations (e.g., InfNet_ResNet.py, InfNet_Res2Net.py, InfNet_UNet.py, InfNet_VGGNet.py) along with a “backbone” directory and “module” folder for attention and UNet parts.
• Self-Supervised Component: The training scripts (e.g., main_inf-net.py, main_multi-inf-net.py) also load pre-trained self-supervised weights (via load_net_path arguments) to fine-tune the segmentation models.
• Training Pipeline:
• Training Scripts: Multiple training scripts for both baseline and self-supervised versions (e.g., MyTrain_LungInf.py, MyTrain_MulClsLungInf_UNet.py).
• Hyperparameters and Data Augmentation: Command-line arguments manage aspects such as random cutout, focal loss, lookahead optimization, and cross-validation folds.
• External Tools: TensorBoard logs (with graphs being saved under a “graphs” directory) and checkpoint handling (saving weights and logging metrics).
• Evaluation & Results Generation:
• Evaluation Modules: Python evaluation scripts (e.g., rocs_generation.py, MyTest_LungInf.py, MyTest_MulClsLungInf_UNet.py) and MATLAB scripts in “InfNet/EvaluationTool” to compute measures like dice, jaccard, ROC curves, etc.
• Results Organization: Output directories (e.g., “InfNet/Results” subfolders) to store segmentation results by model type.
Relationships and Data Flow
• From the training pipelines, outputs (i.e., model checkpoints, training logs) are generated, which then serve as input for the evaluation modules.
• Evaluation outputs (e.g., segmentation masks, ROC curves, metric logs) are directed to dedicated “Results” folders and also visualized via TensorBoard and MATLAB-based tools.
• A block representing model comparison functionality (as seen with load_net_path_2) that takes outputs from different training experiments and compares evaluation metrics statistically.
Architectural Patterns and Design Principles
• Modularity: The clear separation between model definition (in the “Code” directory), data utilities, and training/evaluation scripts indicates a modular design.
• Reusability & Extensibility: The use of common utility modules and the separation of backbone and module components enable easy modification or addition of new network architectures.
• Experimentation and Cross-Validation: Support for cross-validation and different training regimes (baseline vs. self-supervised) suggests that the system is designed for empirical performance improvement.
Technologies and Libraries
• Deep Learning Libraries: Likely PyTorch or a similar deep learning framework given the structure of model scripts (e.g., “.py” files and checkpoint-based model saving).
• Data Visualization: TensorBoard for monitoring training graphs.
• Evaluation Tools: MATLAB scripts for evaluation measures and ROC generation.
• Utility Scripts: Python scripts for data format conversion, dataset splitting, and network evaluation.