A target detection method based on NAM and YOLOv3

By embedding the attention mechanism (NAM) into the YOLOv3 model, the problems of low accuracy and slow speed of traditional object detection techniques are solved, and more efficient object detection results are achieved.

CN115861651BActive Publication Date: 2025-12-16HUNAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211670444.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-25
Publication Date
2025-12-16
Estimated Expiration
2042-12-25

AI Technical Summary

Technical Problem

Traditional object detection techniques cannot meet the needs of modern applications, and deep learning-based object detection methods suffer from low detection accuracy and slow speed.

Method used

By embedding the attention mechanism (NAM) into the YOLOv3 model, the feature extraction capability is improved and the detection performance is enhanced by combining channel and spatial attention mechanisms.

Benefits of technology

Without increasing computational cost, the YOLOv3 model improved detection accuracy by 0.56%, enabling it to better handle targets that are similar in class, numerous, and overlapping, thus improving recall and average precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115861651B_ABST
    Figure CN115861651B_ABST
Patent Text Reader

Abstract

The application provides a target detection method based on NAM and YOLOv3, so that the average detection accuracy is improved. The YOLOv3 model based on the attention mechanism focuses on enhancing the key space and channel in the image and suppressing the insignificant features in the space or channel, so that the network learning performance is ensured. Firstly, a PASCALVOC dataset in the target detection field is selected; secondly, a YOLOv3 model is constructed, the dataset is transmitted into the model for training, an Adam algorithm and a StepLR learning rate adjustment strategy are used, and the model performance is evaluated; thirdly, the YOLOv3 model embedded with the NAM attention mechanism is trained, and the performance evaluation is completed; finally, the test results are compared with those of the classic YOLOv3 model. The application provides the target detection method based on NAM and YOLOv3, compared with the YOLOv3 model, the average detection accuracy is improved on the general dataset, and the method is more suitable for the case that multiple objects are not all detected. In addition, the embedded module can also be integrated into other models for comparative experiments, and has good applicability and robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image recognition and relates to a target detection method based on NAM and YOLOv3. This method has good detection performance on the publicly available PASCALVOC dataset in the field of target detection. Background Technology

[0002] Object detection mainly involves traditional object detection techniques and deep learning-based object detection techniques. With the rapid development of science and technology and the widespread application of machine intelligence, traditional object detection techniques can no longer meet the actual needs of applications. Due to the rapid development of deep learning theory and technology, convolutional neural networks are performing better and better in feature extraction. Therefore, deep learning-based object detection techniques have emerged and have now become the mainstream method in the field of object detection.

[0003] Deep learning-based object detection techniques can be broadly categorized into two types: region-based and regression-based. Region-based methods, also known as two-stage methods, divide the detection task into two steps: 1. Generating several candidate regions in the image; 2. Classifying and locating objects within these candidate regions using a convolutional neural network. Key methods include R-CNN, Fast R-CNN, and Faster R-CNN. These methods offer high accuracy but are slow. Regression-based methods, also known as one-stage methods, utilize the convolutional features of convolutional neural networks to directly regress the object's class probability and location coordinates. Key methods include SSD and the YOLO series.

[0004] Visual attention, or attention mechanism, is a resource allocation method that filters useful information from a large amount of data. It focuses on the necessary information, allocating more attention to these areas to obtain detailed information about the target while ignoring unimportant regions. In computer vision, attention mechanisms learn a weight distribution and apply it to the original features to acquire more detailed information about the target while suppressing other useless information. Attention mechanisms can be divided into three categories: channel attention, spatial attention, and hybrid attention. This paper embeds the NAM attention mechanism into the classic YOLOv3 method to test its performance. Compared with the original model, the improved model achieves a 0.56% improvement in accuracy. Furthermore, this module enables the network to automatically learn cross-dimensional interactions with almost no added parameters, improving the effective feature channel weights and allowing the network to focus on important feature channels, thus enhancing feature extraction capabilities. Compared with the original model, the improved model achieves improved accuracy, and this module can also be embedded into other classic models for comparative experiments. Summary of the Invention

[0005] This invention proposes a target detection method based on NAM and YOLOv3. By embedding the NAM attention mechanism, the detection performance of the YOLOv3 model is improved to a certain extent.

[0006] Step 1: Download the publicly available PASCALVOC dataset for object detection, and extract it to a directory named VOCdevkit. Ensure that it is consistent with the general dataset in this field to achieve a comparison effect and test the performance of the method of this invention. The download address is: http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCtrainval_06-Nov-2007.tar;

[0007] http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCtest_06-Nov-2007.tar;

[0008] http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCdevkit_08-Jun-2007.tar;

[0009] The VOC dataset provides 20 object categories. In the dataset used in this invention, the images are labeled with the object's classification information pName, the center coordinates (x, y) of the object, and the object's width w and height h, and are visualized using rectangular boxes.

[0010] Step 2: Construct a YOLOv3 network model. Input the dataset from Step 1 into the model, train the YOLOv3 network to obtain the weight file W1, evaluate the model performance, and prepare comparative reference materials.

[0011] First, randomly initialize the initial weights of the network so that the initial values ​​conform to a Gaussian normal distribution. The input is an image x with pixels of (416×416×3).

[0012] The input matrix is ​​then processed through the main network structure of the YOLOv3 model, consisting of 52 convolutional layers and three feature extraction stages, resulting in three output feature matrices. The dimensions of these three feature matrices are (52×52×75), (26×26×75), and (13×13×75), respectively. The (52×52×75) feature matrix has the smallest receptive field, suitable for detecting small objects in images. The (26×26×75) feature matrix has a centered receptive field, suitable for detecting medium-sized objects. The (13×13×75) feature matrix has a large output receptive field, suitable for detecting large objects.

[0013] The first convolutional layer has a 3×3 kernel, a stride of 2, and 32 kernels, outputting a (208×208×32) feature map. The second convolutional layer also has a 3×3 kernel, a stride of 1, and 32 kernels, outputting another (208×208×32) feature map, and so on. Based on the different convolutional kernels in each feature layer, the model enters three stages, successively obtaining (52×52×256), (26×26×512), and (13×13×1024) feature maps. Then, the model enters feature interaction layers 1, 2, and 3 for further feature convolution operations, as follows:

[0014] Feature interaction layer 1 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (52×52×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (52×52×75) feature map is obtained. Figure 1 .

[0015] Feature interaction layer 2 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (26×26×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (26×26×75) feature map is obtained. Figure 2 .

[0016] Feature interaction layer 3 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (13×13×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (13×13×75) feature map is obtained. Figure 3 .

[0017] With 13×13×75 features Figure 3 For example: The first dimension, 13, represents the number of horizontal pixels in the image; the second dimension, 13, represents the number of vertical pixels in the image; the third dimension, 75, represents the number of features of the target of interest, containing information at three scales. Each scale contains 25 information points: the center coordinates (x, y) of the target of interest, the target width w and height h, the category information pName, and the confidence score c. The category information pName = 20. Therefore, 3 × (1 + 1 + 1 + 1 + 20 + 1) = 75. Figure 2 and characteristics Figure 3 Meaning and characteristics of each dimension Figure 1 same.

[0018] Step 3: Based on the NAM attention mechanism, reconstruct the YOLOv3 network architecture, input the PASCALVOC dataset into the reconstructed model to complete the training, and test its performance.

[0019] NAM, as an efficient and lightweight attention mechanism, combines channel and spatial attention mechanisms, enabling it to focus on important features. Embedding the NAM module into the YOLOv3 backbone network DarkNet-53, the NAM module utilizes the contribution factors of weights to improve the attention mechanism, avoiding the addition of fully connected and convolutional layers. This allows the network to automatically learn cross-dimensional interactions with almost no added parameters, enhancing the weights of the key feature channels and strengthening feature extraction capabilities.

[0020] Regarding the placement and number of NAM modules, excessive depth will reduce the network's computation speed, while insufficient shallow feature extraction will prevent the network from effectively inferring the regions and channels of interest. Therefore, this invention only adds NAM modules after each detection scale of YOLOv3, i.e., after DarkNet-53.

[0021] Channel attention uses the scaling factor of Batch Normalization to represent the importance of the weights, i.e.

[0022] Where μ B and σ B γ and β are the mean and standard deviation of the mini-batch, respectively, and γ and β are trainable affine transformation parameters.

[0023] Applying the scaling factor described above to each pixel in the channel yields the channel attention weights. The channel normalization formula is as follows: M c =sigmoid(W γ (BN(F1)))

[0024] Where M c For the output features, γ is the scaling factor for each channel, and the weight is W. γ =γ i / ∑ j=0 γ j .

[0025] If the same normalization method is applied to each pixel in the space, the weights of the spatial attention can be obtained. The pixel normalization formula is as follows: M s =sigmoid(W λ (BN s (F2)))

[0026] Where M s For the output features, λ is the scaling factor for each space, and the weight is W. λ =λ i / Σ j=0 λ j .

[0027] To suppress unimportant features, a regularization term is added to the loss function: Loss = ∑ (x,y) l(f(x,W),y)+p∑g(γ)+p∑g(λ).

[0028] x represents the input, y is the output, W represents the network weights, l(·) is the loss function, g(·) is the l1 norm penalty function, and p is the penalty that balances g(γ) and g(λ).

[0029] The YOLOv3 model with embedded NAM attention mechanism was trained on the PASCALVOC dataset. The training process was consistent with the training process in step 2. The weight file W2 was output, and the training results were detected.

[0030] Step 4: Compare the test results with the classic YOLOv3 model;

[0031] During the testing process, the detection accuracy at IoU=0.5 was used as a metric for model performance. If the intersection-union ratio (IoU) of the model's predicted bounding box and the actual bounding box of the image is greater than 0.5, the image detection is considered successful. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of this specification, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a flowchart of the method of the present invention;

[0034] Figure 2 This is a diagram of the YOLOv3 network model structure;

[0035] Figure 3 This is a schematic diagram of the network training process;

[0036] Figure 4 This is a diagram of the network model structure after embedding NAM attention;

[0037] Figure 5 This is a diagram of the channel attention structure of the NAM attention mechanism;

[0038] Figure 6 This is a spatial attention structure diagram of the NAM attention mechanism;

[0039] Figure 7 This is a partial detection result image of the original YOLOv3 model;

[0040] Figure 8 This is a comparison chart of the detection results of the original YOLOv3 and the model of this invention;

[0041] Figure 9 This represents the overall performance of the original YOLOv3 and the model of this invention on the validation dataset; Detailed Implementation

[0042] To make the above and other objects, features and advantages of the present invention more apparent, the present invention will be described in detail below with reference to experiments and illustrations. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention.

[0043] Reference Figure 1 The implementation steps of this invention are as follows:

[0044] Step 1: Download the publicly available PASCALVOC dataset for object detection, and extract it to a directory named VOCdevkit. Ensure consistency with this common dataset in the field to achieve a comparative effect and test the performance of the method presented in this invention. Download addresses are: http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCtrainval_06-Nov-2007.tar; http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCtest_06-Nov-2007.tar; http: / / host.robots.ox.ac.uk / pascal / VOC / voc2007 / VOCdevkit_08-Jun-2007.tar;

[0045] The VOC dataset provides 20 object categories. In the dataset used in this invention, the images are labeled with the object's classification information pName, the center coordinates (x, y) of the object, and the object's width w and height h, and are visualized using rectangular boxes.

[0046] Step 2: Construct a YOLOv3 network model. Input the dataset from Step 1 into the model, train the YOLOv3 network to obtain the weight file W1, evaluate the model performance, and prepare comparative reference materials.

[0047] First, randomly initialize the initial weights of the network so that the initial values ​​conform to a Gaussian normal distribution. The input is an image x with pixels of (416×416×3).

[0048] Then, as Figure 2 The input matrix is ​​processed through the main network structure of the YOLOv3 model, which consists of 52 convolutional layers and three feature extraction stages, resulting in three output feature matrices. The dimensions of these three feature matrices are (52×52×75), (26×26×75), and (13×13×75), respectively. The (52×52×75) feature matrix has the smallest receptive field, suitable for detecting small objects in images. The (26×26×75) feature matrix has a centered receptive field, suitable for detecting medium-sized objects. The (13×13×75) feature matrix has a large output receptive field, suitable for detecting large objects.

[0049] The first convolutional layer has a 3×3 kernel, a stride of 2, and 32 kernels, outputting a (208×208×32) feature map. The second convolutional layer also has a 3×3 kernel, a stride of 1, and 32 kernels, outputting another (208×208×32) feature map, and so on. Based on the different convolutional kernels in each feature layer, the model enters three stages, successively obtaining (52×52×256), (26×26×512), and (13×13×1024) feature maps. Then, the model enters feature interaction layers 1, 2, and 3 for further feature convolution operations, as follows:

[0050] Feature interaction layer 1 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (52×52×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (52×52×75) feature map is obtained. Figure 1 .

[0051] Feature interaction layer 2 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (26×26×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (26×26×75) feature map is obtained. Figure 2 .

[0052] Feature interaction layer 3 is a convolutional module with 5 convolutional operations. The kernel sizes and numbers are (1×1×128), (3×3×256), (1×1×128), (3×3×256), and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (13×13×128) feature map. Then, through (3×3×75) and (1×1×75) convolutional operations, a (13×13×75) feature map is obtained. Figure 3 .

[0053] With 13×13×75 features Figure 3 For example: The first dimension, 13, represents the number of horizontal pixels in the image; the second dimension, 13, represents the number of vertical pixels in the image; the third dimension, 75, represents the number of features of the target of interest, containing information at three scales. Each scale contains 25 information points: the center coordinates (x, y) of the target of interest, the target width w and height h, the category information pName, and the confidence score c. The category information pName = 20. Therefore, 3 × (1 + 1 + 1 + 1 + 20 + 1) = 75. Figure 2 and characteristics Figure 3 Meaning and characteristics of each dimension Figure 1 same.

[0054] In summary, as Figure 3 The specific training process can be simplified and summarized as follows:

[0055] (1) Randomly initialize the initial weights of the network so that the initial values ​​conform to a Gaussian normal distribution;

[0056] (2) The input image is propagated forward through the network structure in step two of this invention to obtain the output value as a feature. Figure 1 ,feature Figure 2 and characteristics Figure 3 And use the feature map information to obtain the information of the predicted bounding box;

[0057] (3) Match the ground truth boxes labeled in the dataset with the anchor boxes obtained by clustering: calculate the center point of the ground truth box, filter out the anchor boxes corresponding to this center point, select the anchor box with the largest IoU value with the ground truth box as the target box, and assign the coordinate value information of the ground truth box to the target box to obtain the coordinate value of the target box.

[0058] (4) Use the loss function to calculate the error loss between the network's predicted bounding box output value and the target box value:

[0059] (5) When the number of iterations is less than epoch=100, the Adam optimization algorithm and StepLR with fixed step size decay are used to update the weights until the number of iterations is greater than epoch, at which point the training is terminated, the weight file is output, and the training results are evaluated. The main test metric of the method of this invention is mAP (mean Average Precision), which represents the average precision. First, the average precision AP (Average Precision) is calculated within a class, and then the average precision mAP (mean Average Precision) is calculated for all classes.

[0060] Step 3: Based on the NAM attention mechanism, reconstruct the YOLOv3 network architecture, input the PASCAL VOC dataset into the reconstructed model to complete the training, and test its performance;

[0061] NAM, as an efficient and lightweight attention mechanism, combines channel and spatial attention mechanisms, enabling it to focus on important features. Embedding the NAM module into the YOLOv3 backbone network DarkNet-53, the NAM module utilizes the contribution factors of weights to improve the attention mechanism, avoiding the addition of fully connected and convolutional layers. This allows the network to automatically learn cross-dimensional interactions with almost no added parameters, enhancing the weights of the key feature channels and strengthening feature extraction capabilities.

[0062] Regarding the placement and number of NAM modules, excessive depth reduces the network's computational speed, while insufficient shallow feature extraction prevents the network from effectively inferring the regions and channels of interest. Therefore, this invention adds NAM modules only after each detection scale of YOLOv3, i.e., after DarkNet-53, as shown below. Figure 4 .

[0063] Channel attention (e.g.) Figure 5 The scaling factor of Batch Normalization is used to represent the importance of the weights, i.e.

[0064] Where μ B and σB γ and β are the mean and standard deviation of the mini-batch, respectively, and γ and β are trainable affine transformation parameters.

[0065] Applying the scaling factor described above to each pixel in the channel yields the channel attention weights. The channel normalization formula is as follows: M c =sigmoid(W γ (BN(F1)))

[0066] Where M c For the output features, γ is the scaling factor for each channel, and the weight is W. γ =γ i / ∑ j=0 γ j

[0067] If for space (e.g.) Figure 6 By applying the same normalization method to each pixel in the matrix, the spatial attention weights can be obtained. The pixel normalization formula is as follows: M s =sigmoid(W λ (BN s (F2)))

[0068] Where M s For the output features, λ is the scaling factor for each space, and W is the weight. λ =λ i / ∑ j=0 λ j

[0069] To suppress unimportant features, a regularization term is added to the loss function: Loss = ∑ (x,y) l(f(x,W),y)+p∑g(γ)+p∑g(λ)

[0070] x represents the input, y is the output, W represents the network weights, l(·) is the loss function, g(·) is the l1 norm penalty function, and p is the penalty that balances g(γ) and g(λ).

[0071] On the PASCALVOC dataset, a YOLOv3 model with embedded NAM attention mechanism was trained. The training process was consistent with the training process in step two. The weight file W2 was output, and the training results were detected.

[0072] Step 4: Compare the test results with the classic YOLOv3 model;

[0073] The invention will be further described below with reference to simulation examples.

[0074] Simulation example:

[0075] This invention uses the original YOLOv3 model as a comparison model, and the PASCALVOC dataset as the training and testing sets, and provides some detection results.

[0076] Figure 7 These are partial detection results from the original YOLOv3 model. Images with different backgrounds, categories, and sizes were selected. Based on the detection results of the basic categories of objects in the images, the results were found to be good.

[0077] Figure 8 This is a comparison chart of the detection results of the original YOLOv3 model and the model of this invention. The left side shows the detection effect of the original YOLOv3 model, and the right side shows the detection effect of the model of this invention.

[0078] For the left side, the original YOLOv3 model performs poorly when the target categories are similar, the targets overlap, or the targets are densely distributed in the image. Figure 8 In some cases, when there are multiple sheep, multiple cows, and multiple people, some may not be detected; when there are people, dogs, and boats, only people and dogs are detected, but boats are not detected.

[0079] Compared to the left side, the improved method of this invention successfully detects more sheep, cattle and people when the categories are similar, numerous and partially overlapping; it can also provide more accurate detection for categories missed by target detection, thus ensuring recall.

[0080] Figure 9 The figures represent the overall performance of the original YOLOv3 model and the model of this invention on the validation dataset. AP is the average accuracy for each class, and mAP is the average accuracy for all classes. It can be seen that the model of this invention has a higher average accuracy mAP on the validation set than the original YOLOv3 model.

[0081] In summary, the simulation experiments show that the improved model of this invention has superior detection accuracy compared with YOLOv3. The improved model in this paper improves the accuracy by nearly 0.56%. In addition, this module does not introduce additional computational load, and the real-time performance is not affected compared with the original model. This embedded module can also be integrated into other models for comparative experiments, and has good applicability and robustness.

Claims

1. A target detection method based on NAM and YOLOv3, the actual steps of which are as follows: Step 1: Download the publicly available PASCALVOC dataset for object detection, ensuring it is consistent with common datasets in this field, to achieve a comparison effect and test the performance of the method; Step 2: Construct a YOLOv3 network model. Input the dataset from Step 1 into the model, train the YOLOv3 network to obtain the weight file W, evaluate the model performance, and make comparisons with relevant reference materials. Step 3: Based on the NAM (Normalization-based Attention Module) attention mechanism, reconstruct the YOLOv3 network architecture. Input the dataset from Step 1 into the reconstructed model to complete training and test performance. The method adds a NAM module after each detection scale of YOLOv3, that is, adds a NAM module after DarkNet-53; Channel attention uses a scaling factor from Batch Normalization to represent the importance of the weights, i.e. Where μ B and σ B γ and β are the mean and standard deviation of the mini-batch, respectively, and γ and β are trainable affine transformation parameters. Applying the scaling factor described above to each pixel in the channel yields the channel attention weights, i.e., the channel normalization formula: M c =sigmoid(W γ (BN(F1))), where M c For the output features, γ is the scaling factor for each channel, and the weight is W. γ =γ i / ∑ j=0 γ j ; If the same normalization method is applied to each pixel in the space, the weights of the spatial attention can be obtained, i.e., the formula for pixel normalization: M s =sigmoid(W λ (BN s (F2))), where M s For the output features, λ is the scaling factor for each space, and the weight is W. λ =λ i / ∑ j=0 λ j ; To suppress unimportant features, a regularization term is added to the loss function: Loss = ∑ (x,y) l(f(x,W),y)+p∑g(γ)+p∑g(λ), where x represents the input, y is the output, W represents the network weights, l(·) is the loss function, g(·) is the l1 norm penalty function, and p is the penalty that balances g(γ) and g(λ); Train the YOLOv3 model with embedded NAM attention mechanism on the PASCALVOC dataset. The training process is consistent with the training process in step 2. Output the weight file W2 and detect the training results. Step 4: Compare the test results with the classic YOLOv3 model.

2. According to claim 1, the object detection method based on NAM and YOLOv3, step one: download the publicly available PASCALVOC dataset in the field of object detection. This dataset originates from a world-class computer vision challenge used to build and evaluate methods for image classification, object detection, and segmentation. The VOC dataset provides 20 object categories. In the images of the dataset used by the method, the object's classification information pName, the center coordinates (x, y) of the object, and the width w and height h of the object are labeled, and the object is visualized using a rectangular box.

3. According to claim 1, the object detection method based on NAM and YOLOv3, step two: constructing a YOLOv3 network system, inputting the dataset from step one into the model for training, obtaining the weight file W1, evaluating its performance, and preparing comparative reference materials; the network model and training process are as follows: The main network structure of the YOLOv3 model is Darknet53, which consists of 52 convolutional layers and three feature extraction stages, outputting three feature matrices with dimensions of (52×52×75), (26×26×75), and (13×13×75). The (52×52×75) feature matrix has the smallest receptive field, suitable for detecting small objects in images; the (26×26×75) feature matrix has a centered receptive field, suitable for detecting medium-sized objects; and the (13×13×75) feature matrix has a large output receptive field, suitable for detecting large objects. First, the initial weights of the network are randomly initialized to conform to a Gaussian normal distribution. An input image x with pixels of (416×416×3) is passed through the first convolutional layer with a 3×3 kernel, a stride of 2, and 32 kernels, outputting a (208×208×32) feature map. The second convolutional layer also uses a 3×3 kernel with a stride of 1 and 32 kernels, outputting another (208×208×32) feature map, and so on. Based on the different convolutional kernels in each feature layer, the network enters three stages, successively obtaining a (52×52×256) feature map, a (26×26×512) feature map, and a (13×13×1024) feature map. Then, the feature convolution operation continues in feature interaction layers 1, 2, and 3, as follows: Feature interaction layer 1 is a convolutional module with 5 convolutional operations. The kernel size and number are (1×1×128), (3×3×256), (1×1×128), (3×3×256) and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a feature map of (52×52×128). Then, through convolutional operations of (3×3×75) and (1×1×75), feature map 1 of (52×52×75) is obtained. Feature interaction layer 2 is a convolutional module with 5 convolutional operations. The kernel size and number are (1×1×128), (3×3×256), (1×1×128), (3×3×256) and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (26×26×128) feature map. Then, through convolutional operations of (3×3×75) and (1×1×75), a (26×26×75) feature map 2 is obtained. Feature interaction layer 3 is a convolutional module with 5 convolutional operations. The kernel size and number are (1×1×128), (3×3×256), (1×1×128), (3×3×256) and (1×1×128) respectively, with a stride of 1 for each kernel, resulting in a (13×13×128) feature map. Then, through convolutional operations of (3×3×75) and (1×1×75), a (13×13×75) feature map 3 is obtained. In feature map 3: the first dimension 13 represents the number of horizontal pixels in the image, the second dimension 13 represents the number of vertical pixels in the image, and the third dimension 75 represents the number of features of the target of interest, containing information at three scales. Each scale contains 25 information points, which are: the center coordinates (x, y) of the target of interest, the target width w and height h, the category information pName and the confidence level c, where the category information pName = 20; therefore, 3 × (1 + 1 + 1 + 1 + 20 + 1) = 75; the meaning of each dimension in feature map 2 and feature map 3 is the same as that in feature map 1; In summary, the specific training process can be simplified as follows: (1) Randomly initialize the initial weights of the network so that the initial values ​​conform to a Gaussian normal distribution; (2) The input image is propagated forward through the network structure in step two of the method to obtain the output values ​​of feature map 1, feature map 2, and feature map 3, and the information of the feature map is used to obtain the information of the predicted bounding box; (3) Match the ground truth boxes labeled in the dataset with the anchor boxes obtained by clustering: calculate the center point of the ground truth box, filter out the anchor boxes corresponding to this center point, select the anchor box with the largest IoU value with the ground truth box as the target box, and assign the coordinate value information of the ground truth box to the target box to obtain the coordinate value of the target box. (4) Use the loss function to calculate the error loss between the network's predicted bounding box output value and the target box value; (5) When the number of iterations is less than epoch=100, the Adam optimization algorithm and StepLR fixed step size decay update weights until the number of iterations is greater than epoch, then terminate training, output weight file, and evaluate the training results; the main test index of the method is mAP (meanAverage Precision), which represents the average precision. First, the average precision AP (Average Precision) is calculated within a class, and then the average precision of all classes is averaged again to calculate mAP (meanAverage Precision).

4. The target detection method based on NAM and YOLOv3 according to claim 1, step four: compare with the classic YOLOv3 model and analyze the test results.

Citation Information

Patent Citations

  • Small target detection method based on attention mechanism

    CN114202672A

  • Pedestrian detection method, apparatus and device, and storage medium

    CN115131819A