Skip to content

Commit 4d92a40

Browse files
committed
Update README
1 parent 3a80fb0 commit 4d92a40

1 file changed

Lines changed: 40 additions & 52 deletions

File tree

README.md

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Asparagus
22

3+
Welcome to Asparagus.
4+
5+
Asparagus is a modular machine learning framework designed for medical imaging applications. The codebase is built on PyTorch, Lightning and Hydra and handles model training, experiment management, and evaluation with prepared data. To prepare your data see [Preprocessing](#1-preprocessing). The functional and modules directories follow the structure of torch.nn.functional and torch.nn with the former being stateless functions and the latter being classes that combine and build upon these with the logic and conventions adopted by Asparagus from PyTorch, Lightning, and Hydra.
6+
37
# Table of Contents
48
- [Resources](#resources)
59
- [Getting Started](#getting-started)
610
- [0. Setup](#0-setup)
711
- [1. Preprocessing](#1-preprocessing)
8-
- [2. Data Splitting](#2-trainvaltest-splitting)
9-
- [3. Training](#3-training)
10-
- [4. Testing](#4-testing)
12+
- [2. Training](#3-training)
13+
- [3. Testing](#4-testing)
14+
- [Contributing](#contributing)
1115

1216
# Resources
1317
- [Common Issues](./docs/common_issues.md)
@@ -22,87 +26,64 @@
2226

2327
## 0. Setup
2428

25-
### Regular installation
26-
To install the package see: [Installation](./docs/installation.md)
27-
To set up required and optional environment variables see: [Environment Variables](./docs/environment_variables.md)
29+
### Package installation
30+
For a standard local editable installation:
31+
```git clone https://github.com/Sllambias/asparagus
32+
cd asparagus
33+
pip install -e .
34+
```
2835

29-
### DCAI/Gefion installation
3036
To install Asparagus on Gefion, please refer to [Installing Asparagus environment on Gefion](./docs/environment_on_gefion.md).
3137

38+
### Environment variables
39+
To set up required and optional environment variables see: [Environment Variables](./docs/environment_variables.md)
3240

3341
## 1. Preprocessing
34-
3542
See the [asparagus_preprocessing](https://github.com/Sllambias/asparagus_preprocessing) repository.
3643

3744
## 2. Training
38-
Asparagus uses hydra configs (see [Hydra](https://hydra.cc/docs/intro/)) to set up all training runs. To use the default setup 3 args are required.
45+
Asparagus uses hydra configs (see [Hydra](https://hydra.cc/docs/intro/)) to configure training runs. To use the default setup 3 args are required.
3946
- The Task to train on
4047
- The model architecture to use
4148
- The data split to use
4249

43-
These can be given either by creating a config that specifies them see [Example Config 1](./docs/configs.md#example-config-1), or at runtime using the command line as illustrated below.
44-
45-
46-
### 3.1 Run ids
50+
These can be given either by creating a config that specifies them see [Example Config 1](./docs/configs.md#example-config-1-the-complete-config), or at runtime using the command line as illustrated below.
4751

48-
When starting a new training run, Asparagus will assign the run a ´run_id´ which can be used to
52+
When starting a new training run, Asparagus will assign the run a unique ´run_id´ which can be used to:
4953
1. restart a failed run
5054
2. start a training from a pretrained model (however a checkpoint can also be loaded from a path)
5155

52-
### 3.2 Pretraining
53-
- Training with the default pretraining config
56+
### 2.1 Pretraining
57+
- Pretraining with the default pretraining config
5458

5559
```asp_pretrain task=Task998_LauritSyn +model=unet_b_lw_dec data.train_split=split_75_15_10```
5660

57-
### 3.3 Training (from scratch)
58-
- Training a *segmentation* model with the default training config
59-
60-
```asp_train_seg task=Task997_LauritSynSeg +model=unet_tiny data.train_split=split_75_15_10```
61-
62-
- Training a *segmentation* model with a pre-defined config
61+
### 2.2 Training from scratch
62+
- Training a classification/regression/segmentation model with the default training config
6363

64-
```asp_train_seg --config-name seg_lauritsynseg_tiny```
64+
```asp_train_[cls,reg,seg] task=Data004_Parrots +model=unet_tiny data.train_split=split_75_15_10```
6565

66-
- Training a *classification* model with a pre-defined config
66+
- Training a classification/regression/segmentation model with a pre-defined config
6767

68-
```asp_train_cls --config-name cls_lauritsyncls_tiny```
69-
70-
- Training a *regression* model with a pre-defined config
71-
72-
```asp_train_reg --config-name reg_lauritsynreg_tiny```
68+
```asp_train_[cls,reg,seg] --config-name my_dummy_config```
7369

7470
- Restarting a failed run
7571

76-
Simply add `run_id=123` where `123` is your run id to the command used to start the job. For instance to restart the segmentation job with the pre-defined config from above, just do
77-
```asp_train_seg --config-name seg_lauritsynseg_tiny run_id=123```
78-
79-
### 3.4 Finetuning
72+
To restart a job find the ```run_id``` of the job you want to restart. It will be present in the path and in the hydra output files. Then, rerun the job with the exact same command and configs and add `run_id=123` (where `123` is your run id). Asparagus will detect the existing model folder and load the most recent weights to continue from these.
8073

81-
There are two ways of loading
74+
### 2.3 Finetuning
8275

83-
Asparagus will create a "derived_models.log" in the folder of the pretrained model so you can always track which finetuned models and run_id's are its _children_.
76+
Finetuning largely follows the same structure as training except
8477

85-
- Finetuning a segmentation model using the default finetuning config
78+
- Finetuning a classification/regression/segmentation model using the default finetuning config from a checkpoint with a run_id
8679

87-
from a checkpoint with a run_id (typically trained on the same machine)
88-
89-
```asp_finetune_seg task=Task997_LauritSynSeg checkpoint_run_id=435850 load_checkpoint_name=last.ckpt```
80+
```asp_finetune_[cls,reg,seg] task=Data004_Parrots checkpoint_run_id=435850 load_checkpoint_name=last.ckpt```
9081

9182
or from a checkpoint given by a path
9283

93-
```asp_finetune_seg task=Task997_LauritSynSeg checkpoint_path=/path/to/model.ckpt```
94-
84+
```asp_finetune_[cls,reg,seg] task=Data004_Parrots checkpoint_path=/path/to/model.ckpt```
9585

96-
- Finetuning a classification model from a versioned checkpoint using a pre-defined config
97-
98-
```asp_finetune_cls --config-name checkpoint_run_id=435850 ft_cls_lauritsyncls_tiny```
99-
or
100-
```asp_finetune_cls --config-name checkpoint_path=/path/to/run.ckpt ft_cls_lauritsyncls_tiny```
101-
102-
103-
- Finetuning a regression model is currently not implemented.
104-
105-
## 4. Running a segmentation model on the test set
86+
## 3. Testing
10687

10788
## Testing with hydra config
10889

@@ -117,4 +98,11 @@ checkpoint_run_id: 532
11798
load_checkpoint_name: epoch=4-step=25.ckpt
11899
```
119100

120-
101+
# Contributing
102+
Contributing to the main branch of asparagus follows regular pull request standards.
103+
- Open pull request.
104+
- Pass linting, formatting and testing checks. Asparagus repositories use [ruff](https://docs.astral.sh/ruff/) for formatting and linting. To lint locally intall ruff and run ```ruff check --fix``` in the Asparagus directory (omitting --fix for a dry run) and to format locally run ```ruff format``` in the Asparagus directory. Running tests locally can be achieved with pytest. After checks
105+
- Request review from relevant moderators. If you're in doubt ask the repository owner.
106+
- (if relevant) apply requested changes
107+
- Acquire approval
108+
- Merge

0 commit comments

Comments
 (0)