A lightweight underwater target video detection method
By constructing a lightweight underwater target video detection network, using the anti-residual atrous convolution module and an improved loss function, we solve the problem of difficulty in balancing accuracy and speed in a single-stage target detection algorithm in an underwater environment, and achieve high efficiency, Accurate underwater target detection.
Patent Information
- Application Number
- CN202411020787.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-29
AI Technical Summary
The existing single-stage target detection algorithm is difficult to balance detection accuracy and detection speed in the underwater environment. Especially in complex backgrounds and target aggregation situations, the detection effect is poor.
A lightweight underwater target video detection method is used to construct a target detection network, including an image enhancement network, an anti-residual atrous convolution module and an SSH detector. The anti-residual atrous convolution module is used to reduce the amount of parameters and calculations, and use The improved Smooth L1-NWD loss function improves small target detection accuracy.
It achieves a good trade-off between underwater target detection speed and accuracy, improves real-time detection performance, can accurately detect small targets in complex underwater environments, and is suitable for resource-constrained scenarios.
Smart Images

Figure CN118552839B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to a lightweight underwater target video detection method. Background Art
[0002] With the rapid development of smart cars, wading vehicles will occupy a certain market in the future. In the future, vehicles equipped with various underwater target detection functions will become a competitive advantage. The combination of underwater target detection and automobiles will become an indispensable part of the future. Underwater target detection is easily affected by the absorption and scattering of light, and visibility is very poor. At the same time, due to the complex underwater environment, the detection background has blurred images, and there are many small and medium targets and target clustering in the detection target, which seriously affects the detection effect of the target detection algorithm. With the development of neural network technology, technicians introduced the neural network framework into the target detection algorithm to detect targets in complex underwater environments. In 2014, Girshick et al. proposed RCNN, which introduced the target detection task into the era of deep learning and opened up the great development of convolutional neural networks in the field of target detection. Subsequent target detection methods are divided into two categories according to whether the region proposal network (RPN) is used to obtain candidate regions. Therefore, the target detection algorithm using RPN becomes a two-stage detection method, and the target detection algorithm without RPN is called a single-stage detection method. For example:
[0003] 1. Underwater object detection based on improved SSD (Single Shot MultiBox Detector) convolutional block attention (Q. Li, MJ Er, L. Li, J. Chen and J. Wu, "Underwater Object Detection Based on Improved SSD with Convolutional Block Attention," 2022 5th International Conference on Intelligent Autonomous Systems (ICoIAS), Dalian, China, 2022, pp. 37-42.) proposed underwater object detection based on improved SSD and convolutional block attention. By using ResNet-50 instead of VGG-16 in the backbone network, the network can improve the specific information and location information of the target detection object. At the same time, the channel attention mechanism is added to the deep convolutional layer of SSD to increase the semantic information of the deep convolutional layer to ensure the accuracy of target detection.
[0004] 2. Underwater fish detection in sonar images based on improved Faster RCNN (D. Zhao, B. Yang, Y. Douand X. Guo, "Underwater fish detection in sonarimage based on an improvedFaster RCNN," 2022 9th International Forum on Electrical Engineering andAutomation (IFEEA), Zhuhai, China, 2022, pp.358-363.) proposed underwater fish detection in sonar images based on improved FasterRCNN, which uses feature pyramid FPN [ It is integrated into Faster RCNN to fuse multi-scale features, and Distance-Intersection-over-Union (DIoU) is used instead of Intersection-over-Union (IoU) to improve detection efficiency.
[0005] The above two methods show that the single-stage target detection algorithm has a great advantage in detection speed. Compared with the two-stage target detection algorithm, the single-stage target detection algorithm is more suitable for real-time detection of marine targets, but there is room for improvement in target detection accuracy. Summary of the invention
[0006] In order to solve the problem that the underwater target detection method based on the single-stage target detection algorithm in the prior art cannot take into account both detection accuracy and detection speed, the present invention provides a lightweight underwater target video detection method, which can achieve a good trade-off between underwater target detection speed and detection accuracy while realizing underwater target detection.
[0007] The technical solution of the present invention is as follows: a lightweight underwater target video detection method, which comprises the following steps:
[0008] S1: Build target detection network;
[0009] S2: Build training dataset;
[0010] S3: training the target detection network based on the training data set to obtain the trained target detection network;
[0011] S4: extracting the image to be identified from the target video and sending it to the trained target detection network to detect the underwater target;
[0012] Features:
[0013] The target detection network includes: an image enhancement network, a backbone feature extraction network, an SSH detector and an output module connected in sequence;
[0014] The backbone feature extraction network includes: an anti-residual dilated convolution module;
[0015] The anti-residual dilated convolution module is constructed based on the lightweight architecture Mobilenetv2; the types of the anti-residual dilated convolution module include: an anti-residual dilated convolution module with a stride of 1 and an anti-residual dilated convolution module with a stride of 2;
[0016] The anti-residual hole convolution module structurally includes: depth-wise convolution DWConv, point-wise convolution PWConv and depth-wise convolution DWConv connected in sequence; when the stride is 1, the output result after the input image is sequentially processed by depth-wise convolution DWConv and point-wise convolution PWConv is superimposed with the output directly mapped from the input image to obtain an output feature map; when the stride is 2, the input feature map is sequentially processed by point-wise convolution PWConv and depth-wise convolution DWConv to obtain an output feature map;
[0017] The depth-by-depth convolution DWConv extracts spatial features from the input feature map. The convolution kernel of the depth-by-depth convolution DWConv is in single-channel mode, and a convolution operation is performed on each channel of the feature map input into the neural network to ensure that the number of channels of the output feature map is consistent with that of the input feature map; the point-by-point convolution PWConv extracts channel features from the input feature map;
[0018] The image enhancement network performs enhancement processing on the input image to be identified, and sends the enhanced feature map to the backbone feature extraction network; the backbone feature extraction network performs initial feature extraction on the input feature map, uses the anti-residual hole convolution module to reconstruct the convolution structure, extracts feature maps of different scales to detect targets of different sizes, and then sends the features of different scales to the SSH detector for prediction; all the SSH detectors send the prediction results to the output module, and output the final detection results after merging.
[0019] It is further characterized by:
[0020] The backbone feature extraction network further includes: a standard convolution module, each of which includes: a standard convolution with a stride of 1 and a standard convolution with a stride of 2 connected in sequence;
[0021] The interlayer structure of the backbone feature extraction network includes: one layer of standard convolution, 10 layers of the anti-residual dilated convolution modules, one layer of the anti-residual dilated convolution module with a stride of 1, one layer of the anti-residual dilated convolution module with a stride of 2, one layer of the anti-residual dilated convolution module with a stride of 1, and four consecutive layers of the standard convolution modules connected in sequence;
[0022] The outputs of the 11th, 13th, 14th, 15th, 16th and 17th layers of the backbone feature extraction network are respectively fed into the SSH detector;
[0023] The corresponding strides of the 10 layers of anti-residual dilated convolution modules in the backbone feature extraction network are 2, 1, 2, 2, 2, 1, 2, 1, 1, 1 respectively;
[0024] The SSH detector comprises: a standard convolution, two parallel branches and a connection layer Concat connected in sequence;
[0025] The two branches include one standard convolution and two concatenated standard convolutions respectively;
[0026] The input feature map is sent to the first standard convolution to extract features, and then sent to two parallel branches at the same time; the outputs of the two parallel branches are sent to the connection layer Concat to merge;
[0027] When the backbone feature extraction network detects small targets and performs position regression, the anchor box position loss is calculated using the improved Smooth L1-NWD loss function L lco :
[0028] ;
[0029] Among them, l is the bounding box prediction value corresponding to the prior box, g is the position parameter of the real box, and N is the number of matching initial prediction boxes;
[0030] [cx,cy], w, h represent the center point coordinates, width and height of the bounding box BBox;
[0031] smooth L1 (.) is the Smooth l1 loss function;
[0032] x k ij Indicates whether the i-th predicted box matches the j-th real box for category k, the matching value is: 0, 1; l m i represents the prediction box, represents the real box, W 22(l,g) indicates the NWD distance calculation between the real box and the predicted box. α and β are hyperparameters representing the weights of the two. C indicates the category confidence prediction value.
[0033] The image enhancement network includes: a defogging operation, and the defogging operation includes: calculating a dark channel, estimating atmospheric light, estimating transmittance, and optimizing transmission in sequence.
[0034] The present application provides a lightweight underwater target video detection method, which uses an anti-residual dilated convolution module to build a lightweight feature extraction backbone network, which can reduce the number of parameters and the amount of calculation; while reducing the number of parameters and the amount of calculation, in order to increase the accuracy of target detection, after deep convolution learning features and classification and positioning regression of the convolution network, the SSH detection head is used to obtain multi-channel detection results for fusion detection, thereby improving the performance of real-time detection. Based on this method, when realizing underwater target detection, it can achieve a good trade-off between underwater target detection speed and detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a schematic diagram of the target detection network structure in this application;
[0036] Figure 2 Schematic diagram of depth-wise convolution operation;
[0037] Figure 3 Schematic diagram of point-by-point convolution operation;
[0038] Figure 4 This is a comparison of the receptive field of the dilated convolution with a dilation factor of 2 and the receptive field of the ordinary convolution;
[0039] Figure 5 The reverse residual dilated convolution modules are of different step lengths;
[0040] Figure 6 This is the structure diagram of the SSH detection header;
[0041] Figure 7 This is an example of training results for a small target position loss function improved using Smooth L1-NWD;
[0042] Figure 8 This is an example of the training results of the Smooth L1 position loss function;
[0043] Fig. 9 This is the detection result diagram of the lightweight target video detection algorithm based on Smooth L1-NWD and mobilenetv2;
[0044] Fig.10 Example of setting structure table for hyperparameters;
[0045] Fig.11 This is an example of comparing the parameters, computational complexity, and accuracy of different target detection networks. DETAILED DESCRIPTION
[0046] The present application includes a lightweight underwater target video detection method, which includes the following steps:
[0047] S1: Build target detection network;
[0048] S2: Build training dataset;
[0049] S3: Train the target detection network based on the training data set to obtain a trained target detection network;
[0050] S4: Extract the image to be identified from the target video and send it to the trained target detection network to detect underwater targets.
[0051] The specific method for constructing a training data set, the model training method, and the method for extracting images to be identified from a target video are all implemented based on existing technologies.
[0052] like Figure 1 As shown, the target detection network includes: an image enhancement network, a backbone feature extraction network, an SSH detector and an output module connected in sequence.
[0053] The image enhancement network enhances the input image to be identified and sends the enhanced feature map to the backbone feature extraction network; the backbone feature extraction network performs initial feature extraction on the input feature map, reconstructs the convolution structure using the anti-residual dilated convolution module, extracts feature maps of different scales to detect targets of different sizes, and then sends the features of different scales to the SSH detector for prediction; all SSH detectors send the prediction results to the output module, which are combined and output as the final detection results.
[0054] Among them, the image enhancement network (Dual reverse defogging module) performs an effect enhancement operation on the input image to be identified. The specific enhancement method can be implemented based on any enhancement algorithm in the prior art. The defogging operation in this embodiment includes: calculating dark channels in sequence, that is, calculating the darkest value of the RGB three channels, estimating the atmospheric light corresponding to the feature map (Estimation of atmospheric light), estimating the transmittance corresponding to the collected image (transmittance estimation), and after calculating the transmission optimization (transmission optimization), the feature map obtained is the enhanced image to be identified. In this application, the effect of the image to be identified is enhanced through the image enhancement network to improve the accuracy of subsequent recognition.
[0055] The backbone feature extraction network designed in it includes: anti-residual void convolution module and standard convolution module.
[0056] The anti-residual dilated convolution model is composed of a stack of depth-wise separable convolutions plus a normalization layer (BatchNormalization, BN layer) and an activation function layer (ReLU6). Figure 2 and Figure 3 As shown in the figure, the depthwise separable convolution can be divided into depthwise convolution (DWConv) and pointwise convolution (PWConv). The core idea of the depthwise separable convolution is to use depthwise convolution for spatial feature extraction and pointwise convolution for channel feature extraction. When extracting features, the depthwise separable convolution performs grouped convolution on the input feature map in the feature dimension, that is, a separate depthwise convolution is performed on each channel. And before output, a 1×1 pointwise convolution is performed on the feature maps on all feature dimensions to aggregate all feature dimensions, thereby reducing the amount of network parameter calculation and improving network calculation efficiency.
[0057] Standard convolution uses several multi-channel convolution kernels to perform convolution calculations on the input multi-channel feature map. The output feature map extracts both channel features and spatial features. However, the number of parameters and the amount of calculation of standard convolution are not suitable for lightweight neural networks. Specifically, assuming that the convolution kernel size is D k ×D k , the number of input channels is M, the number of output channels is N, and the output feature map size is D F ×D F , then the number of parameters of the standard convolution is D k×D k ×M×N, the computational complexity of the standard convolution is D k ×D k ×M×N×D F ×D F .
[0058] Figure 2 The M×Channel Input in the formula represents the number of M input data channels. Figure 3 In the above figure, M×Maps represents M feature maps. Filters represents convolution kernels.
[0059] The meaning of depth-wise convolution is that its convolution kernel is in single-channel mode, that is, convolution operation is performed on each channel of the feature map input to the neural network, so that the number of channels of the output feature map is consistent with that of the input feature map, that is, the number of input feature map channels is equal to the number of depth-wise convolution kernels and also equal to the number of output feature map channels. In terms of the amount of computation and parameter of the network layer convolution kernel, assuming that the size of the convolution kernel of the depth-wise convolution is D k ×D k , the number of convolution kernels is M, and the output feature map size is D F ×D F , then the number of parameters of depth-wise convolution can be expressed by the formula D k ×D k ×M, the computational complexity of depth-wise convolution can be expressed as D k ×D k ×M×D F ×D F .
[0060] like Figure 2 As shown in the figure, assuming that the input feature map is 64 pixels long and 64 pixels wide, and there is a color image with three RGB channels, the three single-channel convolution kernels of RGB perform convolution calculations respectively, and output three single-channel feature maps. Therefore, after a depth-wise convolution operation, a RGB three-channel image will generate three output feature maps. A filter contains only one convolution kernel of size 3×3, and the parameter quantity of the depth-wise convolution part is: Num depthwise =3×3×3=27.
[0061] Point-by-point convolution is essentially the use of a 1×1 convolution kernel to perform channel dimension increase. According to the characteristics of deep convolution, the number of input feature map channels is equal to the number of convolution kernels and also equal to the number of output feature maps. This will result in too few output feature maps, which essentially means that the number of output feature map channels is too small, with the output feature map number being 1 and the number of channels being 3. This may affect the validity of feature information, and in this case, point-by-point convolution is needed to increase or reduce the dimension of the feature map. In terms of the amount of computation and the amount of parameters of the network layer convolution kernel, assume that the convolution kernel size of the point-by-point convolution is 1×1×M, the number of convolution kernels is N, and the output feature map size is D. F ×D F , then the number of parameters of point-by-point convolution can be expressed as M×N, and the amount of calculation of point-by-point convolution can be expressed as M×N×D F ×D F .
[0062] like Figure 3 As shown in the figure, the three single-channel input feature maps obtained by depth-wise convolution are convolved with four 1×1×3 convolution kernels to output four feature maps. For point-by-point convolution, the number of output feature maps depends on the number of filters, so the parameter value of the point-by-point convolution layer is: Num pointwise = 1×1×3×4 = 12.
[0063] Dilated convolutions, also known as expanded convolutions, introduce a new parameter called the "dilation rate" to the convolution layer, which defines the spacing between values when the convolution kernel processes data. By adjusting this dilation rate, the receptive field can be regulated, so that the network can obtain a larger receptive field without introducing a pooling layer, thereby improving the feature extraction capability. Since the receptive field of the traditional convolution operation for the input feature map is limited, and the use of the pooling layer will cause the loss of feature information, the introduction of dilated convolution can effectively provide a larger receptive field without using a pooling layer and with a comparable amount of computation. Figure 4 As shown in group B. Figure 4 Group A in the figure is the normal convolution receptive field.
[0064] The anti-residual dilated convolution module in this application is as follows Figure 5 As shown in the figure, the anti-residual dilated convolution module is constructed based on the lightweight architecture Mobilenetv2; the types of anti-residual dilated convolution modules include: an anti-residual dilated convolution module with a stride of 1 and an anti-residual dilated convolution module with a stride of 2.
[0065] The anti-residual dilated convolution module structurally includes: sequentially connected depthwise convolution DWConv, pointwise convolution PWConv and depthwise convolution DWConv; the anti-residual module first uses 1×1 pointwise convolution for dimensionality reduction, then uses 3×3 depthwise convolution for feature extraction, and finally uses 1×1 pointwise dilated convolution for dimensionality increase. Since the stride is 1 or 2 when the anti-residual module is used in different network layers, when the stride is 1, the output result of the input image after the depthwise convolution DWConv and pointwise convolution PWConv operations are successively superimposed (marked as Add in the figure) with the output directly mapped from the input image (marked as shortcut in the figure) to obtain the output feature map; when the stride is 2, the input feature map is successively subjected to pointwise convolution PWConv and depthwise convolution DWConv operations to obtain the output feature map.
[0066] The depth-by-depth convolution DWConv extracts spatial features from the input feature map. The convolution kernel of the depth-by-depth convolution DWConv is in single-channel mode. It performs convolution operation on each channel of the feature map input into the neural network to ensure that the number of channels of the output feature map is consistent with that of the input feature map. The point-by-point convolution PWConv extracts channel features from the input feature map.
[0067] Figure 1 In the illustrated embodiment, each standard convolution module includes: a standard convolution with a stride of 1 and a standard convolution with a stride of 2 connected in sequence.
[0068] The interlayer structure of the backbone feature extraction network includes: 1 layer of standard convolution, 10 layers of anti-residual dilated convolution modules, one layer of anti-residual dilated convolution modules with a stride of 1, 1 layer of anti-residual dilated convolution modules with a stride of 2, one layer of anti-residual dilated convolution modules with a stride of 1 and four consecutive layers of standard convolution modules; the outputs of the 11th, 13th, 14th, 15th, 16th and 17th layers of the backbone feature extraction network are respectively sent to the SSH detector; the 10 layers of anti-residual dilated convolution modules in the backbone feature extraction network have corresponding strides of 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, respectively.
[0069] This application first uses the anti-residual hole convolution module to build a lightweight feature extraction backbone network, which reduces the number of parameters and the amount of calculation by 76% and 71% respectively. After the deep convolution learning features and classification and positioning regression of the convolutional network, the SSH detection head is used to obtain multi-channel detection results for fusion detection, thereby improving the performance of real-time detection. Experimental results show that the technical solution of this application can achieve good results in real-time detection of underwater fish video data, and can achieve a good balance between underwater target detection speed and detection accuracy.
[0070] The SSH detector includes: a standard convolution, two parallel branches and a connection layer Concat connected in sequence; the two parallel branches respectively include a standard convolution and two series-connected standard convolutions; the input feature map is sent to the first standard convolution to extract features, and then sent to the two parallel branches at the same time; the outputs of the two parallel branches are sent to the connection layer Concat for merging.
[0071] like Figure 6 The figure shows the structure of the SSH detection head. In common target detection networks, a single-stage detection and positioning method is usually used. The SSD and YOLO series target detection networks classify fixed boxes and regress them for target positioning, that is, they perform detection while classifying.
[0072] In order to reduce the inference time, reduce the memory usage and ensure the scale remains unchanged, the SSH detection head in this application directly classifies and locates the global information extracted by the convolution layer. Replacing the detector in the original SSD with the SSH detection head can speed up the operation. This reduces a lot of calculations and parameters caused by the use of fully connected layers. In addition, the SSH detection head module uses two branches with different receptive fields to fuse and then directly perform classification and regression, which greatly saves the efficiency of detection.
[0073] The loss function is an algorithm that measures the degree of fit between the network model and the data. The loss function describes the difference between the true value and the predicted value. The higher the value, the more the prediction deviates from the true value. On the contrary, the lower the value, the closer the predicted value is to the true value. In the field of deep learning, especially in the task of object detection, the design of the loss function is crucial. It directly affects the efficiency, stability and final performance of model training.
[0074] Traditional loss functions, such as Smooth L1 loss, although they perform well in many cases, still have some limitations when dealing with small objects. This is because small objects have relatively few features, and it is difficult for the model to extract effective information from them, resulting in a slow decrease in loss during training, or even overfitting, which affects the generalization ability of the model.
[0075] The target detection network in this application is a multi-scale feature fusion target detection network that uses an improved loss calculation function for small targets and improves the distance between the real box and the predicted box by introducing the NWD distance. NWD is a metric used to calculate the similarity between bounding boxes. It uses an innovative way to model the bounding box as a Gaussian distribution and uses the Wasserstein distance to measure the similarity between the two distributions to replace the traditional IoU method. Compared with the traditional IoU, NWD has the following benefits:
[0076] Even if two bounding boxes do not overlap at all or overlap very little, NWD can still accurately measure the similarity between them. This makes NWD more advantageous when dealing with very different or partially overlapping objects. (1) NWD is insensitive to the scale changes of the object and is therefore more stable when measuring the similarity between small objects. This is because NWD is based on a Gaussian distribution model, which has the property of scale invariance. (2) NWD can be applied to both single-stage and multi-stage anchor detectors and is suitable for a variety of object detection tasks. It can not only replace the application of IoU in label assignment, but also replace the application of IoU in non-maximum suppression (NMS) and regression loss functions. This makes NWD a general and flexible metric.
[0077] The calculation process of NWD involves modeling the bounding box as a two-dimensional Gaussian distribution and using the normalized Wasserstein distance to measure the similarity between the two Gaussian distributions. As a distance metric, Wasserstein distance has the advantage of being able to accurately measure the difference between different distributions, even if the two distributions have no overlap or the overlap is negligible. Therefore, NWD can provide more accurate and reliable results when measuring the similarity between boxes.
[0078] As a new measurement method based on Wasserstein distance, NWD has important application value in target detection tasks. This method adjusts the loss function by considering the target size, pays more attention to the position accuracy of small targets, and effectively improves the model's detection performance for small targets. Specifically, the improved loss function of NWD strengthens the model's sensitivity to small target features through normalization, so that the loss can drop faster in the early stages of training. This rapid loss drop not only accelerates the training process of the neural network, but also helps the model approach the optimal solution earlier, significantly improving the training efficiency. It solves the limitations of the IoU method when dealing with tiny objects, non-overlapping targets, and targets with varying scales by modeling it as a Gaussian distribution and using the Wasserstein distance. This makes NWD a more accurate, stable, and widely applicable measurement method.
[0079] The overall loss function of the SSD target detection network is:
[0080] ,
[0081] Among them, c is the category confidence prediction value, l is the bounding box prediction value corresponding to the prior box, and g is the position parameter of the real box; the total loss function is the weighted sum of classification and regression; α represents the weight of the two, and N represents the number of matches to the initial box.
[0082] The SSD position loss function (using Smooth l1 loss) is:
[0083] ,
[0084] Among them, x k ij Indicates whether the i-th predicted box matches the j-th real box for category k, and the matching value is: 0, 1; l m i represents the prediction box, Represents the true box.
[0085] Applying the NWD distance to calculate the Gaussian distribution of the distance between the predicted box and the true box can be explicitly expressed as:
[0086] ,
[0087] [cx,cy],w,h represent the center coordinates, width and height of BBOX.
[0088] The target detection network designed in this application is a lightweight small target detection network, and is also a target detection network based on an anchor frame. When the anchor frame is set in the convolution layer to perform a convolution operation on the input feature map to calculate the target position, the proportion of small targets is low and small targets are more easily confused with the background of the input image. Therefore, when calculating the loss of the anchor frame position, NWD distance and Smooth L1 are used to calculate the small target position loss, which is more helpful for small target detection.
[0089] This application uses an improved Smooth L1-NWD loss function to replace the original Smooth L1 positioning loss function in order to increase the accuracy of target detection while reducing the number of parameters and calculations in the anti-residual hole convolution module, thereby achieving rapid convergence of the model.
[0090] The backbone feature extraction network of this application detects small targets and performs position regression. The improved Smooth L1-NWD loss function L is used to calculate the anchor box position loss. lco :
[0091] ;
[0092] Among them, l is the bounding box prediction value corresponding to the prior box, g is the position parameter of the real box, N is the number of matching initial prediction boxes; x is the intersection-over-union calculation result, specifically, the value of x is: the intersection of i and j / the addition of i and j;
[0093] [cx,cy], w, h represent the center coordinates, width and height of the bounding box BBox; smooth L1 (.) is the Smoothl1 loss function; xk ij Indicates whether the i-th predicted box matches the j-th real box for category k, the matching value is: 0, 1; l m i represents the prediction box, represents the real box, W 2 2 (l, g) indicates the NWD distance calculation between the real box and the predicted box, α and β are hyperparameters representing the weights of the two; C represents the category confidence prediction value.
[0094] In order to achieve lightweight detection model, this application uses lightweight architecture Mobilenetv2 as the basic network to build a backbone feature extraction network, and uses it for initial feature extraction. In order to make the target detection network have less semantic information in small-size feature maps when detecting small targets, and to solve the problem of low anchor box confidence during position regression, an improved Smooth L1-NWD position loss function is used for position regression, and then 6 feature maps of different scales are extracted to detect targets of different sizes. In order to further reduce the number of model parameters and the amount of model calculation, the convolution structure is reconstructed using the anti-residual hole convolution module, and finally the features of the six scales are sent to the SSH detector for prediction. Experiments have shown that the lightweight underwater target detection network proposed in this chapter can meet the requirements of real-time underwater detection.
[0095] The experimental platform configuration is: Windows 11 operating system CUDA 10.1, CUDNN 7.6.5 Python 3.7 version, processor: AMD Ryzen 7 5800H with Radeon Graphics 3.20 GHz. The graphics card model is NVIDIA GeForce RTX 3060, and the Pytorch framework is used.
[0096] Integrate Smooth L1-NWD into the lightweight target detection network based on mobilenetv2 proposed in this application and adjust the hyperparameters α and β. Fig.10 It can be seen from the hyperparameter setting structure table that when the weight of the Smooth L1 loss function is smaller, the accuracy of the target detection model is lower, that is, the target detection network does not learn enough position feature information, resulting in insufficient accuracy. When the NWD weight decreases, it will also affect the target detection network's perception of the target position feature information. Therefore, after multiple sets of experimental comparisons, when α and β are set to 0.6 and 0.4 respectively, the target detection network can learn enough target position information to detect, thereby ensuring detection accuracy when locating the target.
[0097] With reference to the attached drawings Figure 7 and Figure 8, the vertical axis is the loss Loss, and the horizontal axis is the training cycle Epoch. Figure 7 The left side in the middle shows the small target position loss function result improved by Smooth L1-NWD. Figure 8 is the result of the Smooth L1 position loss function. From the comparison of the Smooth L1-NWD loss function and the Smooth L1 loss function in the two figures, it can be seen that the SmoothL1-NWD improved small target position loss function used in this application effectively solves the problems encountered by the traditional loss function in the small target detection task; it not only speeds up the loss reduction rate and improves the training efficiency, but also significantly improves the generalization ability and detection accuracy of the model by reducing overfitting and optimizing the feature extraction process. Figure 7 and Figure 8 The train loss in represents the training loss, the val loss represents the validation loss, the smooth train loss represents the smooth training loss, and the smooth val loss represents the smooth validation loss.
[0098] Based on the attached Fig.11 From the comparison table of different target detection network parameters, calculation amount, and accuracy, it can be seen that the target detection model (marked as OURS in the figure) implemented by the lightweight small target detection algorithm based on SmoothL1-NWD and mobilenetv2 designed in this application has several advantages. First, it is lightweight: the detection model designed in this application adopts a lightweight network model-mobilenetv2 as a feature extractor, which greatly reduces the number of parameters and calculations of the model. Compared with other models, the parameter amount of the model implemented by the lightweight small target detection algorithm based on Smooth L1-NWD and mobilenetv2 in this application is 6M, and the calculation amount is 1.78G, which can achieve small target detection tasks in scenarios with limited computing resources. Secondly, it is efficient: due to the use of mobilenetv2 as a feature extractor, the model performs well in terms of computing speed, can process video streams in real time, and meet application scenarios with high real-time requirements. Compared with traditional target detection methods, the lightweight small target detection algorithm in this application can greatly improve the calculation speed while ensuring accuracy, so it is more suitable for scenarios with high real-time requirements. Finally, accuracy: Although the object detection model in this application is relatively small, it performs well in small object detection tasks with an accuracy of 93.77%. Compared with other object detection network models, this model has a higher accuracy.
[0099] Fig. 9The 8 pictures in the figure show the detection result diagram obtained after the model constructed by the lightweight target video detection algorithm based on Smooth L1-NWD and mobilenetv2 in this application detects a real underwater fish video and extracts the detection results every three frames and saves them. It can be seen from the figure that the lightweight target video detection model in this application can detect targets in the case of complex underwater backgrounds and clustered target detection objects. From the detection results, the target detection model of this application also basically meets the requirements for underwater small target detection results in the case of multiple targets.
[0100] Based on the above experimental results, it can be concluded that the lightweight target video detection model constructed in this application can meet the requirements of underwater target detection. First of all, the model has the advantage of being lightweight, and uses mobilenetv2 as the feature extraction backbone network, which greatly reduces the number of parameters and the amount of calculation of the model. Compared with other models, the number of parameters of the lightweight target detection algorithm based on Smooth L1-NWD and mobilenetv2 is only 6M, and the amount of calculation is 1.784G, which makes the algorithm suitable for resource-constrained scenarios, such as mobile devices, embedded devices, etc., and can still achieve efficient target detection tasks with limited computing resources. Secondly, this model performs well in terms of computing speed, can process video streams in real time, and meet application scenarios with high real-time requirements. Using the improved Smooth L1-NWD as the loss function, it can guarantee the accuracy of real-time target detection to a certain extent while ensuring real-time performance, and provides an effective solution for real-time small target detection. Experiments have shown that the use of mobilenetv2 backbone extraction network, Smooth L1-NWD loss function and SSH detection head in this method makes the accuracy of the target detection model reach 93.77%. Compared with other models, it has higher detection performance and better real-time performance.
Claims
1. A lightweight underwater target video detection method, comprising the following steps: S1: Build target detection network; S2: Build training dataset; S3: training the target detection network based on the training data set to obtain the trained target detection network; S4: extracting the image to be identified from the target video and sending it to the trained target detection network to detect the underwater target; Features: The target detection network includes: an image enhancement network, a backbone feature extraction network, an SSH detector and an output module connected in sequence; The backbone feature extraction network includes: an anti-residual dilated convolution module; The anti-residual dilated convolution module is constructed based on the lightweight architecture Mobilenetv2; the types of the anti-residual dilated convolution module include: an anti-residual dilated convolution module with a stride of 1 and an anti-residual dilated convolution module with a stride of 2; The anti-residual hole convolution module structurally includes: a depth-wise convolution DWConv module, a point-wise convolution PWConv module and a depth-wise convolution DWConv module connected in sequence; when the stride is 1, the output result after the input image is sequentially processed by the depth-wise convolution DWConv and the point-wise convolution PWConv is superimposed with the output directly mapped from the input image to obtain an output feature map; when the stride is 2, the input feature map is sequentially processed by the point-wise convolution PWConv and the depth-wise convolution DWConv to obtain an output feature map; The depth-by-depth convolution DWConv extracts spatial features from the input feature map. The convolution kernel of the depth-by-depth convolution DWConv is in single-channel mode, and a convolution operation is performed on each channel of the feature map input into the neural network to ensure that the number of channels of the output feature map is consistent with that of the input feature map; the point-by-point convolution PWConv extracts channel features from the input feature map; The image enhancement network performs enhancement processing on the input image to be identified, and sends the enhanced feature map to the backbone feature extraction network; the backbone feature extraction network performs initial feature extraction on the input feature map, uses the anti-residual hole convolution module to reconstruct the convolution structure, extracts feature maps of different scales to detect targets of different sizes, and then sends the features of different scales to the SSH detector for prediction; all the SSH detectors send the prediction results to the output module, and output the final detection results after merging.
2. A lightweight underwater target video detection method according to claim 1, characterized in that: The backbone feature extraction network further includes: a standard convolution module, each of which includes: a standard convolution module with a stride of 1 and a standard convolution module with a stride of 2 connected in sequence; The interlayer structure of the backbone feature extraction network includes: 1 layer of standard convolution modules, 10 layers of anti-residual dilated convolution modules, one layer of anti-residual dilated convolution modules with a stride of 1, 1 layer of anti-residual dilated convolution modules with a stride of 2, one layer of anti-residual dilated convolution modules with a stride of 1, and four consecutive layers of standard convolution modules.
3. A lightweight underwater target video detection method according to claim 2, characterized in that: The outputs of the 11th, 13th, 14th, 15th, 16th and 17th layers of the backbone feature extraction network are respectively fed into the SSH detector.
4. A lightweight underwater target video detection method according to claim 2, characterized in that: The corresponding strides of the 10 layers of anti-residual hole convolution modules in the backbone feature extraction network are 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, respectively.
5. The lightweight underwater target video detection method according to claim 1, characterized in that: The SSH detector comprises: a standard convolution module, two parallel branches and a connection layer Concat connected in sequence; Among the two branches, one branch includes a standard convolution module, and the other branch includes two standard convolution modules connected in series; The input feature map is sent to the first standard convolution to extract features, and then sent to two parallel branches at the same time; the outputs of the two parallel branches are sent to the connection layer Concat to be merged.
6. The lightweight underwater target video detection method according to claim 1, characterized in that: When the backbone feature extraction network detects small targets and performs position regression, the anchor box position loss is calculated using the improved Smooth L1-NWD loss function L lco : ; Among them, l is the bounding box prediction value corresponding to the prior box, g is the position parameter of the real box, and N is the number of matching initial prediction boxes; [cx,cy], w, h represent the center point coordinates, width and height of the bounding box BBox; smooth L1 (.) is the Smooth l1 loss function; x k ij Indicates whether the i-th predicted box matches the j-th real box for category k, the matching value is: 0, 1; l m i represents the prediction box, represents the real box, W 2 2(l,g) indicates the NWD distance calculation between the real box and the predicted box, α and β are hyperparameters representing the weights of the two; C represents the category confidence prediction value.
7. The lightweight underwater target video detection method according to claim 1, characterized in that: The image enhancement network includes: a defogging operation, and the defogging operation includes: calculating a dark channel, estimating atmospheric light, estimating transmittance, and optimizing transmission in sequence.
