You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ROADMAP.md
+32-11Lines changed: 32 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,47 +4,68 @@ This document outlines the architectural upgrades and future development plans f
4
4
5
5
## Architectural Upgrades
6
6
7
-
### 1. Introduction of Registry Pattern
7
+
### 1. Introduction of Registry Pattern ✅ Done (PR #29)
8
8
**Objective**: Eliminate lengthy `if-elif` branches in downstream models like `ECG_CRNN` to enhance code maintainability and extensibility.
9
-
-**Current State**: Adding a new backbone currently requires modifying multiple files, including `models/ecg_crnn.py`.
9
+
-**Status**: Done. `MODELS`, `BACKBONES`, `ATTN_LAYERS` registries are implemented in `models/registry.py`; `OPTIMIZERS`, `SCHEDULERS`, `LOSSES` in `components/registry.py`; `PREPROCESSORS` in `preprocessors/registry.py`. All CNN backbones and downstream models use `@BACKBONES.register()` / `@MODELS.register()` decorators. `Registry.build(name, **kwargs)` is the unified construction interface. Adding a new backbone no longer requires modifying `models/ecg_crnn.py` or any other existing file.
10
10
-**Strategy**: Implement a registry mechanism similar to the one used in the `fl-sim` library. Establish `BACKBONES`, `MODELS`, and `SSL` registries.
11
11
- Use decorators like `@register_backbone("resnet")` to register modules.
12
12
- Use a unified `BACKBONES.build(name, **kwargs)` method for module instantiation.
13
13
-**Benefits**: Decouples model definition from construction logic, making it easier for both maintainers and users to inject custom backbones.
14
14
15
-
### 2. Standardized Backbone API
15
+
### 2. Standardized Backbone API ✅ Done (PR #30)
16
16
**Objective**: Provide a unified feature extraction interface for Self-Supervised Learning (SSL) and multi-task learning.
17
+
-**Status**: Done. All CNN backbones (`ResNet`, `VGG16`, `DenseNet`, `MobileNetV1/V2/V3`, `MultiScopicCNN`, `RegNet`, `Xception`) and the `Transformer` now implement `forward_features(x)` (returns feature maps before the classifier head) and `compute_features_output_shape(seq_len, batch_size)` for shape inference without running a forward pass.
17
18
-**Strategy**: Follow the convention used in the `timm` library by providing a `forward_features(x)` method for all CNN and Transformer backbones.
18
19
-**Features**:
19
20
- Unified return of feature maps instead of classification logits.
20
21
- Support for accessing intermediate activations for feature fusion or saliency analysis (e.g., Grad-CAM).
21
22
22
-
### 3. Leveraging Lazy Modules for Configuration Optimization
23
+
### 3. Leveraging Lazy Modules for Configuration Optimization ⬜ Not started
23
24
**Objective**: Reduce the burden of manually calculating and specifying `in_channels` in configuration files.
24
25
-**Strategy**: Introduce `nn.LazyLinear` or `nn.LazyConv1d` in complex SSL modules.
25
26
-**Benefits**: Simplifies `model_configs` by allowing the model to automatically infer input dimensions during the first forward pass, reducing boilerplate code.
26
27
27
-
### 4. Consolidation and Optimization of Preprocessors and Augmenters
28
+
### 4. Consolidation and Optimization of Preprocessors and Augmenters 🔄 In Progress
28
29
**Objective**: Eliminate redundancy between NumPy and PyTorch implementations and optimize performance by keeping computations on the GPU.
29
-
-**Pure PyTorch Filtering**: Implement `BandPass`and `BaselineRemove` using pure PyTorch (e.g., using `torchaudio.functional` or custom FFT-based filters) to avoid expensive CPU-GPU data transfers.
30
-
-**Unification of Managers**: Refactor `PreprocManager` and `AugmenterManager` to share a common base or registry, as their logic for managing sequences of transforms is very similar.
31
-
-**Dimension Agnostic Transforms**: Ensure all preprocessors and augmenters can handle arbitrary batch and lead dimensions (using `...` in slicing and einops where possible), reducing the need for functions like `preprocess_multi_lead_signal`.
32
-
-**Numpy Version Maintenance**: Keep `_preprocessors` (NumPy version) only for offline data preparation or deployment environments without PyTorch, while making the PyTorch `preprocessors` the primary choice for training pipelines.
30
+
-**Pure PyTorch Filtering** ✅: `BandPass`now uses a zero-phase FFT-based filter and `BaselineRemove` uses dual `avg_pool1d`, both implemented in `utils/utils_signal_t.py`. No more CPU-GPU data transfers.
31
+
-**Unification of Managers** ⬜: Refactor `PreprocManager` and `AugmenterManager` to share a common base or registry, as their logic for managing sequences of transforms is very similar.
32
+
-**Dimension Agnostic Transforms** ⬜ (augmenters pending): Preprocessors now handle arbitrary leading batch dimensions (`..., n_leads, siglen`). Augmenters still need to be updated.
33
+
-**Numpy Version Maintenance** ✅: `_preprocessors` (NumPy) is kept only for offline data preparation or deployment environments without PyTorch, while making the PyTorch `preprocessors` the primary choice for training pipelines.
33
34
34
-
### 5. Pandas 3.0 Migration and Dtype Consistency
35
+
### 5. Pandas 3.0 Migration and Dtype Consistency ⬜ Not started
35
36
**Objective**: Ensure compatibility with Pandas 3.0+, particularly concerning Arrow-backed strings and stricter type checking.
36
37
-**Explicit Object Dtypes**: Explicitly set `dtype=object` for DataFrame columns intended to hold list-like objects (e.g., diagnoses, available signals) to prevent errors when Arrow-backed strings are used.
37
38
-**Initialization Refactoring**: Replace patterns of initializing columns with `None` or `""` and then populating with lists via `.at[]` with more robust initializations like `[[] for _ in range(len(df))]` or using `.apply()`.
38
39
-**Vectorized Operations**: Prefer `.apply()` or other vectorized pandas operations over `iterrows()` loops for better performance and type consistency.
39
40
40
41
---
41
42
42
-
## Self-Supervised Learning (SSL) Roadmap
43
+
## Complete Incomplete Models ⬜
43
44
45
+
Several model files in `torch_ecg/models/` are currently stubs (`raise NotImplementedError` throughout). All stubs already inherit the correct mixins (`SizeMixin`, `CitationMixin`) and have backbone API signatures (`forward_features`, `compute_features_output_shape`) scaffolded. These should be completed before the SSL phase.
46
+
47
+
| File | Classes | Notes |
48
+
|---|---|---|
49
+
|`models/cnn/darknet.py`|`DarkNet`| Backbone for YOLO-style detection |
The `torch_ecg/ssl/` module is an empty shell. `ssl/README.md` contains a survey of target architectures (CLOCS, ST-MEM, MAE-ECG, SimCLR, TF-C, 3M-ECG, CMSC, ECG-BERT).
60
+
61
+
**Prerequisites**: Item 3 (Lazy Modules) and the model stubs above should be completed first.
62
+
63
+
-[ ] Define base classes: `BaseContrastiveLearner`, `BaseMaskedAutoencoder` (in `ssl/base.py`).
44
64
-[ ] Implement a base contrastive learning framework (supporting paradigms like SimCLR, MoCo).
0 commit comments