Data¶
Lightnet Data Module
This module contains everything related to pre- and post-processing of your data.
It also has functionality to create datasets from images and annotations that are parseable with brambox.
Check out the tutorial to learn how to use these operators.
Preprocessing¶
All pre-processing operators can work with PIL/Pillow images, OpenCV Numpy arrays or PyTorch Tensors (should be normalized float tensors between 0-1). The pre-processing that works with annotations, expects brambox dataframes.
In order to simplify the process of adding new transformation, a few base classes have been created. Each pre-processing function in lightnet is a subclass of one of these 3 classes:
Base transform class for the pre-processing on images. |
|
Base transform class that for the joint pre-processing of images and annotations. |
|
Base transform class for the pre-processing on annotations. |
Fit¶
These transformation modify the image and annotation data to fit a certain input dimension and as such are all ImageAnnoTransform
.
You can pass the required dimensions directly to these classes, or you can pass a dataset object which will be used to get the dimensions from.
The latter only works with Dataset
and allows to change the required dimensions per batch.
Rescale and crop images/annotations to the right network dimensions. |
|
Rescale images/annotations and add top/bottom borders to get to the right network dimensions. |
|
Pad images/annotations to a certain dimension. |
|
Rescale images/annotations to the right network dimensions. |
|
Crop and filter annotations to fit inside of the image boundaries. |
Augmentation¶
These transformations allow you to augment your data, allowing you to train on more varied data without needing to fetch more. Some of these transformations only modify the image data (usually color modifiers), others also need to modify the annotations and are thus multi-transforms.
Randomly flip image. |
|
Perform random HSV shift on the RGB data. |
|
Add random jitter to an image, by randomly cropping (or adding borders) to each side. |
|
Randomly rotate the image/annotations. |
Postprocessing¶
GetBoxes¶
These operators allow you to convert various network output to one of the common bounding box tensor formats:
Convert the output from corner detection networks to an HBB tensor. |
|
Convert the output from anchor detection networks to an HBB tensor. |
|
Convert the output from multiscale anchor detection networks to an HBB tensor. |
|
Convert the output from oriented anchor detection networks to an OBB tensor. |
|
Convert the output from multiscale anchor detection networks to an OBB tensor. |
|
Convert the output from masked anchor detection networks to an HBB tensor with mask coefficients. |
|
Convert the output from multiscale anchor detection networks to an HBB tensor with mask. |
|
Compute masks from prototype masks and coefficients. |
Filtering¶
The following classes allow you to filter output bounding boxes based on some criteria.
They can work on the lightnet common bounding box tensor format or on a brambox dataframe.
Performs non-maximal suppression on the bounding boxes, filtering boxes with a high overlap. |
|
Performs soft NMS with exponential decaying on the bounding boxes, as explained in [1]. |
|
Faster version of SoftNMS which filters boxes with a high overlap, using exponential decay. |
Reverse Fit¶
These operations cancel the fit pre-processing operators and can only work on brambox dataframes.
Performs a reverse |
|
Performs a reverse |
|
Performs a reverse |
|
Performs a reverse |
Brambox¶
Brambox related post-processing operators.
Converts a tensor to a list of brambox objects. |
|
Transforms pizelwise segmentation masks to PyGEOS polygons. |
Others¶
Some random classes and functions that are used in the data subpackage.
This is lightnet's own version of |
|
This class is a subclass of the base |
|
Lightnet dataloader that enables on the fly resizing of the images. |
|
Function that collates dataframes by concatenating them. |