Underwater image target detection method and system
By improving the YOLOv7-tiny model, combined with adaptive color balance and SPD-Conv modules, the CBAM attention mechanism is improved, which solves the problem of insufficient detection accuracy and efficiency in complex underwater environments, and improves small target detection performance and model efficiency.
Patent Information
- Application Number
- CN202410865806.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-10
AI Technical Summary
Existing underwater target detection algorithms have insufficient detection accuracy and efficiency in complex underwater environments, especially poor detection performance for small targets, and the model scale is large and cannot meet real-time requirements.
Using the improved YOLOv7-tiny model, through adaptive color balance algorithm and background light estimation, combined with SPD-Conv and improved CBAM attention mechanism, image preprocessing and feature extraction are performed to improve image clarity and detection accuracy.
It significantly improves the detection accuracy of small underwater targets, reduces the amount of model parameters and calculations, enhances the adaptability to complex underwater environments, and achieves higher detection efficiency and accuracy.
Smart Images

Figure CN118628900A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of underwater image target detection, and specifically relates to an underwater image target detection method and system based on improved YOLOv7-tiny. Background Art
[0002] The ocean is the largest resource on Earth. However, due to the scattering and absorption of light in the underwater environment, as well as the scattering of light by plankton and suspended particles in the water, the detection and identification of underwater targets has become extremely complex. Especially in complex underwater environments, targets are often similar to the surrounding environment, which greatly reduces the accuracy of target detection.
[0003] To solve this problem, computer vision technology based on deep learning is widely used in underwater target detection. It can extract richer information and provide more features for subsequent processing, thereby improving detection accuracy. Target detection methods based on deep learning can usually be divided into two-stage algorithms and single-stage algorithms.
[0004] The two-stage target detection algorithms mainly include RCNN (Regions with CNN features), FastRCNN, and FasterRCNN, which can improve the detection accuracy, but they are highly complex and cannot perform real-time detection.
[0005] In contrast, the single-stage target detection algorithm completes the target detection task in a single stage, which can better meet the real-time requirements. Typical representatives of this type of algorithm include SSD (Single Shot MultiBox Detector) and YOLO (You Only Look Once). In addition, according to whether it is necessary to explicitly define a priori anchor boxes, single-stage algorithms can be further divided into anchor box-based and anchor box-free methods. Anchor box-free methods such as FCOS have better versatility.
[0006] However, although these algorithms have achieved certain success in underwater target detection, corresponding problems have also emerged. The combination of YOLOv5 (the V5 version of the YOLO series target detection algorithm) and SwinTransformer can improve the detection accuracy, but it will greatly increase the model size. Although SWIPNet can improve the detection accuracy, it still needs to be improved in underwater feature extraction. The combination of YOLOV4 (the V4 version of the YOLO series target detection algorithm) and the CBAM attention mechanism can achieve better detection results, but further exploration is still needed. The latest lightweight model YOLOv7-MA improves the target detection accuracy, but the response strategy for complex underwater environments needs further research. The same problem also exists for the S-FPN feature pyramid method with shortcut connections that add residual learning.
[0007] Since underwater target detection needs to meet real-time conditions, most single-stage algorithms are used in detection tasks. However, according to actual research, no matter which algorithm is used, there are problems and limitations. In this context, this study aims to further improve the accuracy and efficiency of underwater target detection, especially in complex underwater environments. Summary of the invention
[0008] In view of the above problems, the purpose of the present invention is to provide an underwater image target detection method and system based on improved YOLOv7-tiny, which is used to improve the accuracy and efficiency of underwater target detection.
[0009] To achieve the above objectives, the technical solution adopted by the present invention is: an underwater image target detection method based on improved YOLOv7-tiny, comprising:
[0010] Step 1: Image preprocessing: The input underwater image is preprocessed using an adaptive color equalization algorithm to enhance the details of dark areas and improve the image color cast;
[0011] Step 2: Background light estimation, including:
[0012] Get the blurriest 0.1% pixels in the image as the first background light estimate;
[0013] The image is pre-processed with adaptive color equalization, and then blurred. After gamma correction and image sharpening, the texture detail information is enhanced, and the second background light estimation value is obtained through quadtree decomposition.
[0014] Perform grayscale transformation on the original image to obtain a grayscale image, and obtain the third background light estimation value through quadtree decomposition;
[0015] According to the three background light estimation values, a final background light estimation value is obtained by using a final background light calculation formula;
[0016] Step 3: Scene depth estimation: Extract the distribution characteristics of the RGB channels of the image to obtain a preliminary scene depth estimation value, and obtain the final scene depth estimation value based on the final background light estimation value and the preliminary scene depth estimation value.
[0017] Step 4: Transmission coefficient estimation: The transmission coefficient mapping estimation is obtained through the transmission coefficient calculation formula;
[0018] Step 5: Scene brightness restoration: Feature fusion is performed using the scene brightness restoration formula, and a histogram equalization algorithm is used to obtain a high-quality underwater enhanced image;
[0019] Step 6: Target detection: Use the improved YOLOv7-tiny model to perform target detection on the enhanced image to obtain underwater target information.
[0020] In a possible embodiment, the improved YOLOv7-tiny model includes:
[0021] Using SPD-Conv to replace the MP module in the YOLOv7-tiny includes the following steps:
[0022] Replace the first and second layer CBL modules of the YOLOv7-tiny backbone network with the ELAN-C module that improves the CBAM attention mechanism;
[0023] Replace the MP module in the YOLOv7-tiny backbone network with the SPD-Conv module.
[0024] In a possible embodiment, the SPD-Conv includes a space-to-depth layer and a non-strided convolution layer, and the sampling method is to convert the spatial dimension of the input feature map into the depth dimension through the space-to-depth layer, and then perform a convolution operation through the non-strided convolution layer to achieve downsampling of the feature map, including:
[0025] Take an intermediate feature map X of arbitrary size S×S×C1 and slice the sequence of sub-feature maps into:
[0026] f 0,0 =X[0:S:scale,0:S:scale],
[0027] f 1,0 =X[1:S:scale,0:S:scale],···,
[0028] f scale-1,0 =X[scale-1:S:scale,0:S:scale];
[0029] f 0,1 =X[0:S:scale,1:S:scale],f 1,1 ···,
[0030] f scale-1,1 =X[scale-1:S:scale,1:S:scale];
[0031] f 0,scale-1 =X[0:S:scale,scale-1:S:scale],f 1,scale-1 ···,
[0032] f scale-1,scale-1=X[scale-1:S:scale,scale-1:S:scale].
[0033] Each sub-feature map is downsampled by slicing; where a sub-feature map f x,y It consists of all X(i,j) such that i+x and j+y can divide the slice;
[0034] Finally, each sub-feature map is connected along the channel dimension to obtain the intermediate feature map X'.
[0035] In a possible embodiment, the improved CBAM attention mechanism includes a CLS module, and the CLS module includes:
[0036] Perform maximum pooling and average pooling on each column in a single channel to extract feature information within the channel;
[0037] Concatenate the feature information of each column that has been subjected to maximum pooling with the feature information of each column that has been subjected to average pooling;
[0038] The concatenated feature information is convolved and the result is fed into the sigmoid function to generate a channel attention feature map;
[0039] The information of each column in the channel is combined with the information of each row in the channel to form a new channel attention mechanism.
[0040] In a possible embodiment, the formula of the sigmoid function is as follows:
[0041]
[0042] Here, e is the base of natural logarithms.
[0043] The present invention also provides an underwater image target detection system based on improved YOLOv7-tiny, comprising:
[0044] a memory for storing instructions executable by a processor;
[0045] The processor is used to execute instructions to implement the underwater image target detection method based on the improved YOLOv7-tiny.
[0046] The beneficial effects of the present invention are as follows: the fusion image enhancement algorithm effectively enhances the clarity and color of the underwater data set; in order to address the problem that the model performance drops rapidly when the underwater image resolution is low and the object is small, the present invention replaces the maximum pooling module in YOLOv7-tiny with the SPD convolution module, thereby reducing the number of parameters and the amount of calculation of the feature extraction network while improving the accuracy of underwater small target detection; in order to address the problem of feature information loss caused by feature fusion of the CBAM attention mechanism, the channel attention mechanism is improved and the intrinsic connection of the single channel is added to improve the target detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 This is a flow chart of the image enhancement algorithm of the present invention.
[0048] Figure 2 It is the YOLOv7-tiny network structure.
[0049] Figure 3 This is the SPD-Conv network structure diagram of the present invention.
[0050] Figure 4 Improved CLS module diagram for the channel of the present invention.
[0051] Figure 5 ELAN-C module and SCLS-YOLO network structure of the present invention.
[0052] Figure 6 This is a heat map visualization comparison of the present invention, where (a) the original image; (b) the YOLOv7-tiny processed image;
[0053] (c) SCLS-YOLO processing image. DETAILED DESCRIPTION
[0054] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings. The description in this part is only exemplary and explanatory and should not have any limiting effect on the protection scope of the present invention.
[0055] like Figure 1 As shown, the present invention provides an underwater image target detection method based on improved YOLOv7-tiny, comprising the following steps:
[0056] S100: Pre-process the input underwater images with an adaptive color balancing algorithm to enhance details in dark areas and improve image color cast.
[0057] Among them, the adaptive color equalization algorithm is used to improve the quality of underwater images. The algorithm adjusts the light and color distribution in the image, so that the details of the darker areas in the image are enhanced and the color distortion is reduced. This process helps to improve the overall clarity and color accuracy of the image, providing a better foundation for subsequent image analysis and processing.
[0058] In some possible embodiments, the adaptive color balancing algorithm may adopt an improved algorithm based on histogram equalization.
[0059] S200: Background light estimation, including:
[0060] Get the blurriest 0.1% pixels in the image as the first background light estimate;
[0061] The image is pre-processed with adaptive color equalization, and then blurred. After gamma correction and image sharpening, the texture detail information is enhanced, and the second background light estimation value is obtained through quadtree decomposition.
[0062] Perform grayscale transformation on the original image to obtain a grayscale image, and obtain the third background light estimation value through quadtree decomposition;
[0063] According to the three background light estimation values, a final background light estimation value is obtained by using a final background light calculation formula.
[0064] Among them, quadtree decomposition can subdivide the image into small blocks that are easier to process and analyze, so as to facilitate more efficient analysis and processing.
[0065] In one possible implementation, a possible method for calculating the final background light estimation value is as follows: First, a weight is set according to the reliability or confidence of each estimation value. For example, if the first estimation value based on the most blurred pixel is considered to be the most reliable, it can be given the largest weight. Then, the three estimation values are multiplied by the corresponding weights respectively, and the results are added to obtain the final background light estimation value.
[0066] S300: extracting features of the RGB channel distribution characteristics of the image to obtain a preliminary scene depth estimation value, and obtaining a final scene depth estimation value based on the final background light estimation value and the preliminary scene depth estimation value.
[0067] A possible formula for calculating the initial scene depth estimate is as follows:
[0068] R / B ratio = R channel pixel value / B channel pixel value;
[0069] (RB) / (R+G+B) ratio = (R channel pixel value - B channel pixel value) / (R channel pixel value + G channel pixel value + B channel pixel value);
[0070] A possible calculation formula for the final scene depth estimation is as follows:
[0071] Final depth = g(preliminary depth, background light estimation, other features);
[0072] Here, g can be a linear function, a polynomial function, a neural network or other models.
[0073] S400: Obtain a transmission coefficient mapping estimate using a transmission coefficient calculation formula.
[0074] A possible formula for calculating the transmission coefficient is as follows:
[0075] T(x,y)=exp(-β×d(x,y))
[0076] T(x,y) represents the transmission coefficient at pixel (x,y);
[0077] β represents the water attenuation coefficient, which is related to the turbidity of the water;
[0078] d(x,y) represents the scene depth at pixel (x,y).
[0079] S500: Scene brightness restoration: Feature fusion is performed using the scene brightness restoration formula, and a histogram equalization algorithm is used to obtain a high-quality underwater enhanced image.
[0080] A possible scene brightness restoration formula is a scene brightness restoration formula based on dark channel prior, as follows:
[0081]
[0082] Where L(x,y) represents the restored scene brightness at pixel (x,y), I(x,y) represents the input image brightness at pixel (x,y), A represents the global background light estimation value, and T(x,y) represents the transmission coefficient at pixel (x,y).
[0083] Principle: The dark channel prior assumes that in a haze-free image, the pixel value of at least one color channel is very small, close to 0. By solving the dark channel, the global background light can be estimated, and the scene brightness can be restored using the transfer coefficient.
[0084] S600: Target detection: Use the improved YOLOv7-tiny model to perform target detection on the enhanced image to obtain underwater target information.
[0085] The YOLOv7-tiny network structure is as follows Figure 2As shown in Figure 1, YOLOv7-tiny is a lightweight version of the YOLO (YouOnlyLookOnce) series of target detection models. Figure 1 It adopts an improved network structure and optimized training strategy, aiming to reduce the computational workload and memory usage of the model while maintaining high accuracy.
[0086] The network structure of YOLOv7-tiny includes the backbone network, feature pyramid network, output layer and loss function. The backbone network usually uses the backbone network to extract image features. The feature pyramid network is used to process feature maps of different scales to detect objects of different sizes. The output layer is responsible for generating target detection results, including information such as target category, location and confidence. The loss function is used to optimize the model parameters so that the model can predict the target more accurately.
[0087] Compared with the full version of YOLOv7, YOLOv7-tiny has streamlined and optimized the network structure, removed some redundant modules and layers, and adopted a lightweight convolution kernel and network structure design, thereby reducing the number of model parameters and the amount of computation while maintaining high accuracy, making the model more suitable for resource-constrained environments or mobile devices.
[0088] This example uses the improved YOLOv7-tiny model to perform target detection on the enhanced image, including
[0089] Use SPD-Conv to replace the MP module in the YOLOv7-tiny. Replacing the module includes the following steps:
[0090] Replace the first and second layer CBL modules of the YOLOv7-tiny backbone network with the ELAN-C module that improves the CBAM attention mechanism;
[0091] Replace the MP module in the YOLOv7-tiny backbone network with the SPD-Conv module.
[0092] The SPD-Conv module includes a space-to-depth layer and a non-strided convolution layer. The sampling method is to convert the spatial dimension of the input feature map into the depth dimension through the space-to-depth layer, and then perform a convolution operation through the non-strided convolution layer to achieve downsampling of the feature map, including:
[0093] Take an intermediate feature map X of arbitrary size S×S×C1 and slice the sequence of sub-feature maps into:
[0094] f 0,0 =X[0:S:scale,0:S:scale],
[0095] f 1,0 =X[1:S:scale,0:S:scale],···,
[0096] f scale-1,0 =X[scale-1:S:scale,0:S:scale];
[0097] f 0,1 =X[0:S:scale,1:S:scale],f 1,1 ···,
[0098] f scale-1,1 =X[scale-1:S:scale,1:S:scale];
[0099] f 0,scale-1 =X[0:S:scale,scale-1:S:scale],f 1,scale-1 ···,
[0100] f scale-1,scale-1 =X[scale-1:S:scale,scale-1:S:scale].
[0101] Each sub-feature map is downsampled by slicing; where a sub-feature map f x,y It consists of all X(i,j) such that i+x and j+y can divide the slice;
[0102] Finally, each sub-feature map is connected along the channel dimension to obtain the intermediate feature map X'.
[0103] refer to Figure 3 , when scale = 2, four sub-graphs f are obtained 0,0 ,f 0,1 ,f 1,0 ,f 1,1 The shape of each subgraph is Downsample X by a factor of 2. Finally, connect these sub-feature maps along the channel dimension to obtain the feature map X', which is reduced by 2 times in the spatial dimension and increased by 4 times in the channel dimension. That is, SPD converts the feature map X(W,H,C) into an intermediate feature map
[0104] Replace the MP module in the backbone network with the SPD-Conv module to improve the detection accuracy of images with low resolution or small objects. The overall SCLS-YOLO flow chart is as follows: Figure 5As shown in the figure, the CBAM attention mechanism starts from the two scopes of channel and spatial, introduces two analysis dimensions of spatial attention and channel attention, and realizes the sequential attention structure from channel to space.
[0105] However, in the channel attention module, the CBAM attention mechanism only considers the relationship between channels, but does not consider the intrinsic connection between channels, which causes some significant features in the channel to disappear. This embodiment improves the channel attention mechanism and proposes a CLS module.
[0106] refer to Figure 4 In a possible embodiment, the CLS module includes:
[0107] Perform maximum pooling and average pooling on each column in a single channel to extract feature information within the channel;
[0108] Concatenate the feature information of each column that has been subjected to maximum pooling with the feature information of each column that has been subjected to average pooling;
[0109] The concatenated feature information is convolved and the result is fed into the sigmoid function to generate a channel attention feature map;
[0110] The information of each column in the channel is combined with the information of each row in the channel to form a new channel attention mechanism.
[0111] The Sigmoid function is a commonly used activation function. It is used in neural networks to introduce nonlinear transformations and compress input values between 0 and 1. The formula of the Sigmoid function is as follows:
[0112]
[0113] In this embodiment, 5000 underwater images are selected for target detection, including 3500 training set images, 500 validation set images and 1000 test set images, covering a total of 4 categories: sea cucumber, sea urchin, scallop and starfish. In the model training, the input image size is 640×640, and the model training uses the stochastic gradient descent (SGD) optimizer. The initial learning rate is set to 0.01, the momentum coefficient is 0.937, and the number of image samples in each batch of training is 16, and the number of training rounds is 300.
[0114] In order to accurately evaluate the performance of the improved model on underwater images, this embodiment adopts performance evaluation indicators commonly used in the field of target detection, mainly including precision, recall rate and average precision mean.
[0115] Precision refers to the ratio of the number of targets correctly detected by the model to the number of all detected targets. The calculation formula is as follows:
[0116]
[0117] Among them, TP represents the positive examples of correct predictions, and FP represents the positive examples of incorrect predictions.
[0118] Recall is the ratio of the number of targets successfully detected by the model to the number of actual targets. The calculation formula is as follows:
[0119]
[0120] Among them, TP represents the correctly predicted positive example; FN represents the incorrectly predicted negative example.
[0121] The average precision mean (AveragePrecisionMean) model's average precision level on targets of different categories better reflects the detection performance of the model on each category. Its calculation formula is as follows:
[0122]
[0123] Among them, AP i represents the average precision of category i; K is the total number of categories.
[0124] In order to verify the effectiveness of the SCLS-YOLO algorithm, mAP@0.5 is used as the evaluation index. Using YOLOv7-tiny as the baseline model, different improvement strategies are gradually introduced while keeping the experimental environment and training parameters consistent, and ablation experiments are performed on a test set containing 5,000 underwater data from Zhanjiang in 2022. The purpose is to verify the impact of each improvement method on the performance of the final model. The results of the model on the test set are shown in Table 1.
[0125] As can be seen from Table 1, by comparing the enhanced image with the original image, some texture details have been significantly restored and the image clarity has also been significantly improved. Using the same YOLOv7-tiny model, after adding the enhancement module ACB-IBLA to the image dataset, the detection accuracy increased by 1%. On the basis of adding the ACB-IBLA model, the MP module was replaced with the SPD-Conv module. Although the number of model parameters increased slightly, the detection accuracy increased by 1.4%. On this basis, after adding the improved CLS attention mechanism module in this chapter, the model accuracy was further improved to 83.5%, which is 3.2 percentage points higher than the original YOLOv7-tiny model and 2.4% higher than the CBAM attention mechanism. The improvement is quite obvious.
[0126] In order to comprehensively evaluate the performance of the SCLS-YOLO algorithm in detecting small and medium-sized underwater targets, this chapter conducted an experimental comparative analysis under the same experimental environment and training parameters. This chapter uses mAP@0.5 as an evaluation indicator of the performance of different algorithms to verify the effectiveness of the SCLS-YOLO algorithm model. Table 2 below shows the mAP@0.5 results of each target detection algorithm in the 2022 Zhanjiang 1000 test dataset, where the bold part represents the optimal value of this category among all compared algorithms.
[0127] According to the data in Table 2, it can be concluded that the SCLS-YOLO algorithm has the best single-category accuracy and average accuracy among all the compared algorithms, and its mAP@0.5 reaches 83.5%, which is significantly higher than other network models. Compared with the existing target detection algorithm YOLOv7-tiny, the mAP@0.5 of SCLS-YOLO is improved by 3.2%, which fully verifies that the target detection algorithm proposed in this chapter has a higher accuracy rate for detecting small and micro targets in underwater images and is more suitable for the detection of small targets.
[0128] Table 1 Detection results of various improvement strategies on the test set
[0129] Model Learnable parameters Hashrate(G) mAP@0.5% YOLOv7-tiny 6023106 13.2 80.3 YOLOv7-tiny+A 6023106 13.2 81.3 YOLOv7-tiny+A+CBAM 6016648 13.1 81.1 YOLOv7-tiny+A+B 6539202 14.2 82.7 SCLS-YOLOours 6539600 14.2 83.5
[0130] Among them, module A is the ACB-IBLA image enhancement algorithm module, module B is the SPD-Conv module, module C is the ELAN-C module, and the SCLS-YOLO model is a model that includes the A, B, and C module models.
[0131] Table 2 Detection results of various improvement strategies on the test set
[0132] Model Sea Cucumber sea urchin scallop starfish mAP@0.5% YOLOv7-tiny 70.5 89.1 74.1 87.6 80.3 YOLOv7-tiny+A 73.7 89.4 74.4 87.6 81.3 YOLOv7-tiny+A+CBAM 73.4 89.7 73.8 87.4 81.1 YOLOv7-tiny+A+B 75.0 90.7 76.2 88.8 82.7 SCLS-YOLOours 76.6 90.7 77.8 89.1 83.5
[0133] In order to more intuitively reflect the superior performance of the model in this chapter, this example visualizes the feature maps of YOLOv7-tiny and the prediction results at three different stages, and gives a more intuitive explanation of the attention mechanism, such as Figure 6 shown. Figure 6 (b) is the heat map visualization result of YOLOv7-tiny. Figure 6 (c) is the heat map visualization result of the model in this chapter. Figure 6 (b) Compared with the above, the model in this embodiment pays more attention to the target area in the input image and responds more evenly to the target feature area of small targets in the underwater image.
[0134] In another embodiment, the present invention further provides an underwater image target detection system based on improved YOLOv7-tiny, comprising:
[0135] a memory for storing instructions executable by a processor;
[0136] A processor is used to execute instructions to implement the underwater image target detection method based on improved YOLOv7-tiny in the above embodiment.
[0137] It should be noted that, in this article, the terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus.
[0138] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only used to help understand the method and core ideas of the present invention. The above is only a preferred implementation of the present invention. It should be pointed out that due to the limitations of textual expression and the objective existence of infinite specific structures, ordinary technicians in this technical field can make several improvements, modifications or changes without departing from the principles of the present invention, and can also combine the above technical features in an appropriate manner; these improvements, modifications, changes or combinations, or the direct application of the inventive concept and technical solution to other occasions without improvement, should be regarded as the protection scope of the present invention.
Claims
1. A method for underwater image target detection, characterized in that: include: Step 1: Image preprocessing: The input underwater image is preprocessed using an adaptive color equalization algorithm to enhance the details of dark areas and improve the image color cast; Step 2: Background light estimation, including: Get the blurriest 0.1% pixels in the image as the first background light estimate; The image is pre-processed with adaptive color equalization, and then blurred. After gamma correction and image sharpening, the texture detail information is enhanced, and the second background light estimation value is obtained through quadtree decomposition. Perform grayscale transformation on the original image to obtain a grayscale image, and obtain the third background light estimation value through quadtree decomposition; According to the three background light estimation values, a final background light estimation value is obtained by using a final background light calculation formula; Step 3: Scene depth estimation: Extract the distribution characteristics of the RGB channels of the image to obtain a preliminary scene depth estimation value, and obtain the final scene depth estimation value based on the final background light estimation value and the preliminary scene depth estimation value. Step 4: Transmission coefficient estimation: The transmission coefficient mapping estimation is obtained through the transmission coefficient calculation formula; Step 5: Scene brightness restoration: Feature fusion is performed using the scene brightness restoration formula, and a histogram equalization algorithm is used to obtain a high-quality underwater enhanced image; Step 6: Target detection: Use the improved YOLOv7-tiny model to detect targets on the enhanced image and obtain underwater target information; Wherein, the improved YOLOv7-tiny model includes: Using SPD-Conv to replace the MP module in the YOLOv7-tiny includes the following steps: Replace the first and second layer CBL modules of the YOLOv7-tiny backbone network with the ELAN-C module that improves the CBAM attention mechanism; Replace the MP module in the YOLOv7-tiny backbone network with the SPD-Conv module.
2. The underwater image target detection method according to claim 1, characterized in that: The SPD-Conv module includes a space-to-depth layer and a non-strided convolution layer. The sampling method is to convert the spatial dimension of the input feature map into the depth dimension through the space-to-depth layer, and then perform a convolution operation through the non-strided convolution layer to achieve downsampling of the feature map, including: Take an intermediate feature map X of arbitrary size S×S×C1 and slice the sequence of sub-feature maps into: f 0,0 =X[0:S:scale,0:S:scale], f 1,0 =X[1:S:scale,0:S:scale],···, f scale-1,0 =X[scale-1:S:scale,0:S:scale]; f 0,1 =X[0:S:scale,1:S:scale],f 1,1 ···, f scale-1,1 =X[scale-1:S:scale,1:S:scale]; f 0,scale-1 =X[0:S:scale,scale-1:S:scale],f 1,scale-1 ···, f scale-1,scale-1 =X[scale-1:S:scale,scale-1:S:scale]. Each sub-feature map is downsampled by slicing; where a sub-feature map f x,y It consists of all X(i,j) such that i+x and j+y can divide the slice; Finally, each sub-feature map is fused along the channel dimension to obtain the intermediate feature map X'.
3. The underwater image target detection method according to claim 1, characterized in that: The improved CBAM attention mechanism includes a CLS module, and the CLS module includes: Perform maximum pooling and average pooling on each column in a single channel to extract feature information within the channel; Concatenate the feature information of each column that has been subjected to maximum pooling with the feature information of each column that has been subjected to average pooling; The concatenated feature information is convolved and the result is fed into the sigmoid function to generate a channel attention feature map; Combine each column of information in the channel with each row of information in the channel to form new feature information.
4. The underwater image target detection method according to claim 3, characterized in that: The formula of the sigmoid function is as follows: Here, e is the base of natural logarithms.
5. An underwater image target detection system, characterized in that: include: a memory for storing instructions executable by a processor; A processor, configured to execute instructions to implement the underwater image target detection method as described in any one of claims 1 to 4.
