# Research on Automated Fiber Placement Surface Defect Detection Based on Improved YOLOv7
## 4 Experimental Setup and Result Analysis
### Evaluation Indicators  
The confusion matrix is a common evaluation method used in object detection tasks to help illustrate the performance of a model. \"TN\" stands for true negative, which shows the number of negative examples classified accurately. Similarly, \"TP\" stands for true positive, which indicates the number of positive examples classified accurately. The term \"FP\" shows the false positive value, i.e., the number of actual negative examples incorrectly classified as positive; and \"FN\" means the false negative value, which is the number of actual positive examples incorrectly classified as negative [46].  
In object detection tasks, the following commonly used performance metrics are as shown in Table 1.  
Precision is calculated among the positive results correctly detected [47]. The calculation formula is as follows:  
\[Precision=\frac{TP}{TP+FP} \tag{15}\]  
Recall is calculated among the boxes that should be detected (ground truth) and the true positives [47]. The calculation formula is as follows:  
\[Recall=\frac{TP}{TP+FN} \tag{16}\]  
AP: Average precision is the area-under-curve (AUC) region of the PR curve [47]. The average precision can comprehensively consider the performance of the detection algorithm at different confidence levels.  
mAP is the average of the AP for each category. For multi-class object detection tasks, the average precision for each category is typically calculated, and then, the mean average precision is obtained by averaging them. mAP can more comprehensively evaluate the performance of the entire object detection system.  
IoU measures the overlap between the detection box and the ground truth box. It is calculated by computing the ratio of the intersection area of the two boxes to the union area. Typically, if the IoU of two boxes is greater than a predefined threshold (e.g., 0.7), the detection is considered correct.  
The inference time can be simply understood as the time needed to obtain the output results from the input image through the model.  
FPS represents the number of images the model can process in a unit of time. Frames per second is a key metric for assessing the real-time performance of a detection system.  
The detection time for a single image refers to the time required to process one image. It is similar to inference time, but more specifically describes the time cost of processing a single image.  
Objectness loss (confidence loss) determines whether there are objects in the predicted bounding box. This loss function helps the model to distinguish the background and foreground areas.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Accuracy Evaluation Metrics** & **Speed Evaluation Metrics** \\ \hline Precision & Forward propagation time \\ Recall & Frames per second (FPS) \\ Average Precision (AP) & Floating point operations per second (FLOPs) \\ mean Average Precision (mAP) & Single-image detection time \\ Intersection over Union (IoU) & / \\ \hline \hline \end{tabular}
\end{table}
Table 1: Commonly used object detection evaluation metrics.  
Location loss (box regression loss) is applied only when the predicted bounding box contains an object. The loss function measures the errors between the predicted bounding box and the ground truth.  
Classification loss determines which category the object in the prediction box belongs to.