Introduction and overview
The fastai transforms pipeline for images is designed to convert your independent and dependent variables into a form ready to be batched by your DataLoader and passed to your model. It is most commonly used like this:
...example...
The most common types of transforms are predefined in …
The most likely customizations you might need to do are …
You can create custom transform pipelines using an approach like: …
If you want to create a custom transform, you will need to : …
Class Transform (tfm_y=TfmType.NO)
Override do_transform to implement transformation of a single object.
Arguments
- tfm_y (type TfmType, default TfmType.NO)
-
Type of transform. For details, see TfmType
Methods
- set_state
-
A transform may include a random component. If it does, it will often need to transform
yusing the same random values asx(e.g. a horizontal flip in segmentation must be applied to the mask as well). Therefore, this method is used to ensure all random state is calculated in one place.NB: Transformations are often run in multiple threads. Therefore any state must be stored in thread local storage. The
Transformclass provide a thread localstoreattribute for you to use. See {{xref RandomFlip}} for an example of how to use random state safely inTransformsubclasses.
Class TfmType:IntEnum
- NO
-
the default, y does not get transformed when x is transformed.
- PIXEL
-
x and y are images and should be transformed in the same way. E.g.: image segmentation.
- COORD
-
y are coordinates (i.e bounding boxes)
- CLASS
-
y are class labels (same behaviour as PIXEL, except no normalization)