Files
fastai/docs/transforms.adoc
2018-04-02 16:27:01 -07:00

51 lines
1.8 KiB
Plaintext

= fastai.transforms
Jeremy Howard and contributors
:toc:
== 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 : ...
[[Transform]]
== Class Transform [.small]#(tfm_y=TfmType.NO)#
.Abstract parent for all transforms.
Override do_transform to implement transformation of a single object.
=== Arguments
tfm_y (type TfmType, default TfmType.NO)::
Type of transform. For details, see xref:TfmType[TfmType]
=== Methods
set_state::
A transform may include a random component. If it does, it will often need to transform `y` using the same random values as `x` (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 `Transform` class provide a thread local `store` attribute for you to use. See {{xref RandomFlip}} for an example of how to use random state safely in `Transform` subclasses.
[[TfmType]]
== Class TfmType:IntEnum
.Type of transformation.
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)