In ModelPack Training Guide | Detection, we have explained how to train the model from the basic command line options. Embedded trainer also includes additional parameters to control two different aspects from the training process: augmentation techniques and loss weighting. In this tutorial we are going to explain how to properly set these parameters from the command line option. Even when default parameters are those that have shown the best performance over different dataset we benchmarked, ModelPack also exposes these parameters for expert mode.
ModelPack Training Parameters
This section describes how to properly set the advanced parameters exposed by ModelPack.
Augmentation techniques are used for ModelPack in order to reduce overfitting during training. By using these techniques, our dataset iterators (based on tf.data.Datasets objects) randomly apply geometric and color transformations to the training images while building batches. Internally, ModelPack uses Albumentations library. In order to simplify the list of parameters, we configured the augmentation techniques with more frequently used values and expose their probabilities of occurrence to the user. In other words, users will be able to control how frequently each augmentation technique is applied.
- --Flip: Performs an horizontal flip. By default uses a 0.5 probability since the output does not provide too much variation. See documentation at HorizontalFlip
- --RandomBrightnessContrast: This techniques applies a color transformation that modifies the contrast and brightness of the image at the same time. See more documentation at RandomBrightnessContrast. By default its value is 0.2
- --ToGray: This techniques transform the image into gray scale with a probability of 0.2
- --ChannelShuffle: This technique interchange the channels of the image with a probability of 0.01. The idea of this technique is to handle the channel order limitation. Some recording devices are RGB or BGR. By using this technique we can make our model performs well in both channel orders given the color is not as important as the shape of the objects.
- --RandomFog: This technique makes the image a bit foggy or unfocused. For real live deployments, rain and dust causes accuracy drops when present. By using this technique we can make our model more robust to these unexpected situations. By default the value is 0.01
- --ShiftScaleRotate: This is a very good technique that deals with position and size of the objects. By default this technique has assigned 0.3 since it causes the biggest changes on the input image.
When training an object detection model it is very common to integrate multiple loss functions. To weight them could be really helpful in some cases. Imagine our model is having a high rate of detections but lower rate of classification. This means our model is having issues to distinguish between objects of different classes. For these cases the optimizer became eager, due to it is easy to optimize the localization loss instead of classification loss. To mitigate this issue we can use a larger value to penalize the localization loss, causing the model to pay more attention in classification part.
ModelPack exposes three different loss functions.
- localization loss: Computes how far our boxes are from Ground Truth boxes. The main goal of this loss is to reduce localization errors, in other words, to reduce the number of False Negatives.
- classification loss: Computes how well the match is between classes, predicted and GT. This loss is also based on the reduction of False Negatives, but this time related to classification.
- objectness loss: This is an auxiliary loss function that helps to balance the prediction rate. It acts as a correctness coefficient to reduce the number of False Positives.
By default all these loss weights are conservative and are set to 1.0 (no weight). If the user wants to modify them it should use the following parameters:
- --weighted-localization: Sets a value to localization loss
- --weighted-classification: Sets a value to classification loss
- --weighted-objectness: Sets a value to objectness loss
The total loss used to update the optimization process is based on the following formula
total-loss = weighted-localization * loc-loss + \
weighted-classification * clf-loss + \
weighted-objectness * obj-loss
If the user wants to remove one of the loss function then it should set the weight to 0. For example, for a single class problem, classification loss is not needed and classification-loss can be suppressed by setting --weighted-classification=0.
In this article we have described how to go deeper into ModelPack. To change dataset augmentation techniques could lead us to reduce overfitting. On the other hand, by weighting the loss functions, we can make our model pay more attention to specific information it is missing.
|Previous Step||Home||Next Step|
|ModelPack Logging System||ModelPack Overview||DeepView Validation Tool|