Template Class PreProcessor¶
Defined in File preprocessor.hpp
Class Documentation¶
-
template<typename DatasetX = arma::mat, typename DatasetY = arma::mat>
class mlpack::models::PreProcessor¶ Contains standatd pre-process functions for popular datasets.
- tparam DatasetX
Datatype for loading input features.
- tparam DatasetY
Datatype for prediction features.
Public Static Functions
-
static inline void ChannelFirstImages(DatasetX &trainFeatures, const size_t imageWidth, const size_t imageHeight, const size_t imageDepth, bool normalize = true)¶
Converts image to channel first format used in PyTorch. Performs the same function as torch.transforms.ToTensor().
- Parameters
trainFeatures – Input features that will be converted into channel first format.
imageWidth – Width of the image in dataset.
imageHeight – Height of the image in dataset.
imageDepth – Depth / Number of channels of the image in dataset.
-
template<typename eT>
static inline void YOLOPreProcessor(const DatasetY &annotations, arma::Mat<eT> &output, const size_t version = 1, const size_t imageWidth = 224, const size_t imageHeight = 224, const size_t gridWidth = 7, const size_t gridHeight = 7, const size_t numBoxes = 2, const size_t numClasses = 20, const bool normalize = true)¶ PreProcessor for YOLO model. Converts arma::field type annotations to arma::mat type for training YOLO model. Each column in target matrix has the size : gridWidth * gridHeight * (5 * numBoxes + classes).
Note : This function must be called manually before model is used.
- Parameters
annotations – Field object created using model’s dataloader containing annotation for images.
output – Output matrix where output will be stored.
imageWidth – Width of image used for training YOLO model.
imageHeight – Height of image used for training YOLO model.
gridWidth – Width of output feature map of YOLO model.
gridHeight – Height of output feature map of YOLO model.
numBoxes – Number of bounding boxes per grid.
numClasses – Number of classes in training set.
normalize – Boolean to determine whether coordinates are to to be normalized or not. Defaults to true.