# Improvement of Damage Segmentation Based on Pixel-Level Data Balance Using VGG-Unet
## 4 Building Data Set and Choosing Configurations
### Evaluation Method for Accuracy  
To evaluate accuracy of the outcome, Confusing Matrix is widely used in Deep Learning, especially for classification. However, segmentation calculate accuracy through the number of pixels of each class in one image instead of the quantity of images of each class from all images in the data set. In this research, all VGG-Unet models are trained for two classes segmentation. Thus, the pixels predicted as damages or rubber bearings are counted as Positive, while others are Negative. And if the class of predicted pixels is same as the class in annotation, these pixels are predicted as True while others are False. The name of pixels in Confusing Matrix of Damage Segmentation for two classes is shown as Figure 9.  
Many criteria for accessing accuracy of semantic segmentation have been proposed and widely used. Here are 4 popular metrics to evaluate the prediction ability of VGG-Unet model at the level of pixel. Most traditional method is called pixel accuracy (PA), which means calculate the accuracy pixel by pixel and defined as (1). Compared with PA, mean pixel accuracy (MPA) takes quantities of pixels from different classes into account, and it would calculate the average of accuracy of all classes. The (2) shows how to calculate MPA, and here k means the number of true classes in one image. Mean intersection over union (MIoU) and frequency weighted intersection over union (FWIoU) [39], combine the pixels of one class together as one union, shown as (3) and (4). FWIoU also considers the proportion of all classes and select the weight for each class. \[\text{PA}=\frac{\text{TP+TN}}{\text{TP+FP+FN+TN}} \tag{1}\]  
\[\text{MPA}=\frac{1}{\text{k}}\left(\frac{\text{TP}}{\text{FN+TP}}+\frac{\text {TN}}{\text{FP+TN}}\right) \tag{2}\]  
\[\text{MIoU}=\frac{1}{\text{k}}\left(\frac{\text{TP}}{\text{FP+TP+FN}}+\frac{ \text{TN}}{\text{FP+TN+FN}}\right) \tag{3}\]  
\[\text{FWIoU}=\frac{1}{\text{TP+TN+FN+FP}}\left(\frac{\text{TP(TP+FN)}}{\text{ FN+TP+FN}}+\frac{\text{TN(TN+FP)}}{\text{FP+TN+FN}}\right) \tag{4}\]  
However, PA and FWIoU don't enlarge the weight of damages and just calculate from percentage of damage pixels. These two methods are suitable for large area object segmentation such as corrosion or structure, but unreasonable for small damages like cracks, since the undamaged size (TN) of images occupies too many pixels. On the contrary,  
Figure 9: Confusing Matrix of detection. MPA and MIoU, magnified the weight of damages as same as the weight of other parts. These methods are good for segmentation evaluation for small damages, which just occupy a small proportion of pixels in the images. Thus, these two methods are widely adopted for the data set with carefully selected and processed damage images to judge the capabilities of FCN models on detecting the severity of the minor damages. However, it is not all time that we want to excessively increase the weight of damages, especially for real-word damage inspection. One reason is that most images in the process of inspection do not include damages, while the damage pixels only account a small part in the whole data set. Another reason is humans judge damage from images through the characteristics of continuous pixels rather than a small number of independent pixels. Thus, some independent pixels which are not precisely predicted cannot influence people's understanding of labeled images, however, it greatly affects the accuracy value. What's more, using these two methods make the evaluation result fluctuate greatly when the damage occupies different areas in the images. These are caused by excessively increasing the weight of minor damages. To make a balance between no increase damage weight and overly increase damage weight, a method could control the weight of objects is defined.