-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some docs and improve docstrings
- Loading branch information
Showing
23 changed files
with
463 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
🚧 Under construction 🚧 | ||
# Callbacks | ||
|
||
Callbacks in Lighter allow you to customize and extend the training process. You can define custom actions to be executed at various stages of the training loop. | ||
|
||
## Freezer Callback | ||
The `LighterFreezer` callback allows you to freeze certain layers of the model during training. This can be useful for transfer learning or fine-tuning. | ||
|
||
## Writer Callbacks | ||
Lighter provides writer callbacks to save predictions in different formats. The `LighterFileWriter` and `LighterTableWriter` are examples of such callbacks. | ||
|
||
- **LighterFileWriter**: Writes predictions to files, supporting formats like images, videos, and ITK images. | ||
- **LighterTableWriter**: Saves predictions in a table format, such as CSV. | ||
|
||
For more details on how to implement and use callbacks, refer to the [PyTorch Lightning Callback documentation](https://pytorch-lightning.readthedocs.io/en/stable/extensions/callbacks.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
🚧 Under construction 🚧 | ||
# Inferer | ||
|
||
The inferer in Lighter is used for making predictions on data. It is typically used in validation, testing, and prediction workflows. | ||
|
||
## Using Inferers | ||
Inferers must be classes with a `__call__` method that accepts two arguments: the input to infer over and the model itself. They are used to handle complex inference scenarios, such as patch-based or sliding window inference. | ||
|
||
## MONAI Inferers | ||
Lighter integrates with MONAI inferers, which cover most common inference scenarios. You can use MONAI's sliding window or patch-based inferers directly in your Lighter configuration. | ||
|
||
For more information on MONAI inferers, visit the [MONAI documentation](https://docs.monai.io/en/stable/inferers.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
🚧 Under construction 🚧 | ||
# Postprocessing | ||
|
||
Postprocessing in Lighter allows you to apply custom transformations to data at various stages of the workflow. This can include modifying inputs, targets, predictions, or entire batches. | ||
|
||
## Defining Postprocessing Functions | ||
Postprocessing functions can be defined in the configuration file under the `postprocessing` key. They can be applied to: | ||
- **Batch**: Modify the entire batch before it is passed to the model. | ||
- **Criterion**: Modify inputs, targets, or predictions before loss calculation. | ||
- **Metrics**: Modify inputs, targets, or predictions before metric calculation. | ||
- **Logging**: Modify inputs, targets, or predictions before logging. | ||
|
||
## Example | ||
```yaml | ||
postprocessing: | ||
batch: | ||
train: '$lambda x: {"input": x[0], "target": x[1]}' | ||
criterion: | ||
input: '$lambda x: x / 255.0' | ||
metrics: | ||
pred: '$lambda x: x.argmax(dim=1)' | ||
logging: | ||
target: '$lambda x: x.cpu().numpy()' | ||
``` | ||
For more information on how to use postprocessing in Lighter, refer to the [Lighter documentation](./config.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ | |
|
||
Lighter is a configuration-centric framework where the config. is used for setting up the machine learning workflow from model architecture selection, loss function, optimizer, dataset preparation and running the training/evaluation/inference process. | ||
|
||
Our configuration system is heavily based on MONAI bundle parser but with a standardized structure. For every configuration, we expect several items to be mandatorily defined. | ||
Our configuration system is heavily based on the MONAI bundle parser but with a standardized structure. For every configuration, we expect several items to be mandatorily defined. | ||
|
||
The configuration is divided into two main components: | ||
- **Trainer**: Handles the training process, including epochs, devices, etc. | ||
- **LighterSystem**: Encapsulates the model, optimizer, datasets, and other components. | ||
|
||
Let us take a simple example config to dig deeper into the configuration system of Lighter. You can go through the config and click on the + for more information about specific concepts. | ||
|
||
|
@@ -49,7 +53,9 @@ system: | |
1. `_target_` is a special reserved keyword that initializes a python object from the provided text. In this case, a `Trainer` object from the `pytorch_lightning` library is initialized | ||
2. `max_epochs` is an argument of the `Trainer` class which is passed through this format. Any argument for the class can be passed similarly. | ||
3. `$@` is a combination of `$` which evaluates a python expression and `@` which references a python object. In this case we first reference the model with `@model` which is the `torchvision.models.resnet18` defined earlier and then access its parameters using `[email protected]()` | ||
4. YAML allows passing a list in the format below where each `_target_` specifices a transform that is added to the list of transforms in `Compose`. The `torchvision.datasets.CIFAR10` accepts these with a `transform` argument and applies them to each item. | ||
4. YAML allows passing a list in the format below where each `_target_` specifies a transform that is added to the list of transforms in `Compose`. The `torchvision.datasets.CIFAR10` accepts these with a `transform` argument and applies them to each item. | ||
|
||
5. Datasets are defined for different modes: train, val, test, and predict. Each dataset can have its own transforms and configurations. | ||
|
||
## Configuration Concepts | ||
As seen in the [Quickstart](./quickstart.md), Lighter has two main components: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.