# Let’s learn Yolo from Xiaobai

Time：2020-9-8

Abstract:This article will take a detailed analysis of how to carry out yolov1 testing for beginners.

## YOLOv1 Testing

Entering the testing stage, we have got 98 bounding boxes, confidence and class probability maps. Next, we need some algorithms to filter bounding boxes. We start to introduce NMS (non Max suppression) non maximum suppression. ## Overview of NMS non maximum suppression

Non maximum suppression (NMS), as the name implies, is to suppress elements that are not maxima, which can be understood as local maximum search. This local represents a neighborhood. There are two parameters of the neighborhood, one is the dimension of the neighborhood, the other is the size of the neighborhood. This paper does not discuss the general NMS algorithm (refer to the NMS implementation of 1-D and 2-D data in efficient non maximum suppression), but is used to extract the window with the highest score in target detection. For example, in pedestrian detection, each window will get a score after feature extraction and classifier classification. However, sliding windows will cause many windows to contain or mostly cross with other windows. At this time, we need to use NMS to select those neighborhoods with the highest score (the probability of pedestrians is the highest), and suppress those windows with low scores.

NMS has very important applications in the field of computer vision, such as video target tracking, data mining, 3D reconstruction, target recognition and texture analysis.

## Testing process in yolov1

In the last blog, we have introduced the loss function, and given the formula for calculating the confidence level and the formula for the class probability (circled in the picture), which are known values. The right-hand result of the equation in the graph can be obtained by multiplying and simplifying the formula in the following formula. 1. Multiply the two to get 20 × 1 scores. For all 98 bounding boxes, 98 × 20 scores are obtained. 2. Get the first group of class of scores, which is assumed to be dog scores, as shown in box 1 in the figure.

3. Set score < 0.2 (probability is too low) to 0 through a thresh screening. As shown in box 2.

4. As noted in box 3.

5. Remove overlapped frames with NMS. As noted in box 4. ## Implementation of NMS in yolov1

As shown in the figure below, we assume that among the descending scores, the maximum score of bounding box 47 is 0.8, and the score of bounding box 20 is the second highest, which is 0.5. 1. Take the largest bounding box of score and keep it.

2. Find the non-zero box below him, that is, the bounding box with score of 0.5.

3. Calculate the intersection and union ratio of their two IOUs. If it is greater than 0.5, it indicates that their two coincidence degrees are very high. Set the value of bounding box with smaller score as 0

4. Take down a score in order and calculate the cross union ratio with the bounding box with score of 0.8. If the merge ratio is less than 0.5, this value is retained.

5. When the bounding box with score = 0.8 and other bounding boxes are calculated, take the largest score smaller than 0.8 in these scores, and then perform the above operation until the end condition is met.

6. Do the same for the second to twentieth classes.

7. Compare the size according to the score of each bounding box. Take out the largest value in the bounding box.

8. If there is a maximum score greater than 0, then draw the box corresponding to the score and regard it as the class. Until all the bounding boxes are traversed. 