S100 OpenExplorer

# #Data Normalization Parameter Configuration

## #Parameters

Parameter: mean_value

This parameter means the average value subtracted from the image of specified preprocessing method.

- Parameter descriptions:

  - When there is only one input node, only one value needs to be configured, which indicates that all channels need to subtract this mean value.

  - When there are multiple nodes, provide values consistent with the number of channels (these values are separated by spaces), indicating that each channel is subtracted by a different mean value.

Attention

If there exists a node that does not require `mean` processing, configure `'None'` for that node.

Parameter: scale_value

This parameter indicates the numerical scale coefficient for the specified preprocessing method.

- Parameter descriptions:

  - When there is only one input node, only one value needs to be configured, indicating that all channels are multiplied by this coefficient.

  - When there are multiple nodes, provide values consistent with the number of channels (these values are separated by spaces), indicating that each channel is multiplied by a different coefficient.

Attention

If there exists a node that does not require `scale` processing, configure `'None'` for that node.

Parameter: std_value

This parameter indicates the numerical std coefficient for the specified preprocessing method.

- Parameter descriptions:

  - When there is only one input node, only one value needs to be configured, indicating that all channels are divided by this coefficient.

  - When there are multiple nodes, provide values consistent with the number of channels (these values are separated by spaces), indicating that each channel is divided by a different coefficient.

Attention

If there exists a node that does not require `std` processing, configure `'None'` for that node.

## #Formulas and Samples

The following combines the data normalization formulas for model training to provide you with an understanding of the process:

The `mean` and `scale` parameters in the YAML file need to be converted with the `mean` and `std` during training.

The calculation of the data normalization operation in the preprocess node is: n o r m_d a t a=(d a t a−m e a n)∗s c a l e norm\_data = ( data - mean ) * scale n or m_d a t a=(d a t a−m e an)∗sc a l e.

Taking YOLOv3 as an example, its preprocessing code during the training is as follows:

`def base_transform(image, size, mean, std): x = cv2.resize(image, (size, size).astype(np.float32)) x /= 255 x -= mean x /= std return x class BaseTransform: def __init__(self, size, mean=(0.406, 0.456, 0.485), std=(0.225, 0.224, 0.229)): self.size = size self.mean = np.array(mean, dtype=np.float32) self.std = np.array(std, dtype=np.float32)`

Then the calculation formula is n o r m_d a t a=(d a t a 255−m e a n)∗1 s t d norm\_data= (\frac{data}{255}-mean) * \frac{1}{std}n or m_d a t a=(255 d a t a​−m e an)∗s t d 1​.

Rewrite it to the computation for preprocessing nodes is: n o r m_d a t a=(d a t a 255−m e a n)∗1 s t d=(d a t a−255∗m e a n)∗1 255∗s t d norm\_data= (\frac{data}{255}-mean) * \frac{1}{std} =(data-255*mean) * \frac{1}{255*std}n or m_d a t a=(255 d a t a​−m e an)∗s t d 1​=(d a t a−255∗m e an)∗255∗s t d 1​.

Then m e a n_y a m l=255∗m e a n,s c a l e_y a m l=1 255∗s t d mean\_yaml = 255*mean, scale\_yaml= \frac{1}{255*std}m e an_y am l=255∗m e an,sc a l e_y am l=255∗s t d 1​.

On This Page