A ship lightweight target detection method
By employing data augmentation and network improvement methods, a lightweight target detection model was constructed, which solved the detection problem in complex environments of unmanned surface vessels (USVs), improved the accuracy and speed of ship target detection, and is suitable for target recognition tasks on USVs.
Patent Information
- Application Number
- CN202310787800.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-06-29
AI Technical Summary
Existing target detection methods based on water surface optical images are limited by complex environments and computing power when deployed on unmanned surface vessels, resulting in poor detection performance. In particular, false detections and missed detections occur frequently under conditions such as backlight, rain, and fog. Furthermore, the diversity of ship target sizes affects detection accuracy.
We constructed a ship dataset using data augmentation techniques, improved the YOLOv7-tiny network through adaptive anchor frame strategy and cluster analysis, designed the FasterNeXt module using partially convolutional PConv and SiLU activation functions, introduced the SENet channel attention mechanism, and added skip connections to the path aggregation network to form a lightweight target detection model.
It improves the accuracy and speed of ship target detection, reduces false detections and missed detections in complex environments, enhances the real-time performance and robustness of the model, and facilitates deployment in unmanned surface vessels.
Smart Images

Figure CN116912682B_ABST
Abstract
Description
Technical Field
[0001] This application relates to a method for detecting lightweight targets on ships, belonging to the field of intelligent unmanned smart ships. Background Technology
[0002] In recent years, unmanned surface vessels (USVs) technology has developed rapidly. Target detection methods based on water surface optical images have been widely applied in the field of USV perception, and optical image processing technology has become increasingly mature. Water surface optical images are rich in imaging information, but current mainstream target detection methods based on water surface optical images face challenges when deployed on USVs. These challenges arise because the working environment of USVs is complex and variable, including backlighting, rain, and fog. Furthermore, the detection models deployed on USVs are limited by computing power, and the scale of ship targets varies greatly. All these factors affect the detection performance of target detection methods. Summary of the Invention
[0003] The purpose of this application is to provide a method for detecting lightweight targets on ships, which can effectively improve the accuracy of ship target detection, reduce false detections and missed detections in complex environments, increase detection speed, and has the characteristics of real-time performance, robustness, and easy deployment.
[0004] To achieve the above objectives, the first aspect of this application provides a method for detecting lightweight targets in ships, comprising:
[0005] The ship data is acquired, data augmentation is performed on the ship data to obtain a ship dataset, wherein the ship data includes images of ship targets in several complex environmental scenarios;
[0006] Based on the ship dataset, target anchor frames for ships are constructed using an adaptive anchor frame strategy and cluster analysis is performed to obtain prior frames that conform to ship scale.
[0007] Based on the ship dataset and the prior boxes, a YOLOv7-tiny network is constructed. A FasterNeXt module is designed using partial convolutional PConv and SiLU activation functions. The FasterNeXt module is used to replace the multi-branch splicing layer in the backbone and path aggregation network of the YOLOv7-tiny network to obtain the first detection model.
[0008] The FasterAttention module is designed using the SENet channel attention mechanism. The FasterAttention module is then used to replace part of the FasterNeXt module in the first detection model to obtain the second detection model.
[0009] Skip connections are added to the path aggregation network in the second detection model to obtain a lightweight ship target detection model, and target detection is performed through the lightweight ship target detection model.
[0010] In one implementation, the data augmentation of the ship data includes:
[0011] Based on the ship data, random noise was generated and stretched to simulate the ship target's condition in rainy weather.
[0012] The image brightness and saturation were randomly varied to simulate the situation of ship targets under different lighting conditions;
[0013] The method of randomly introducing Gaussian blur and changing image contrast is used to simulate the situation of ship targets in foggy weather;
[0014] We simulated poor image quality by randomly adding Gaussian noise and salt-and-pepper noise.
[0015] In one implementation, the design of the FasterNeXt module using partially convolutional PConv and SiLU activation functions includes:
[0016] The FasterNet Block module is constructed using the partially convolutional PConv and SiLU activation functions, wherein the FasterNet Block module includes a first FB branch and a second FB branch;
[0017] The FasterNeXt module is designed based on the FasterNet Block module, wherein the FasterNeXt module includes a first FN branch and a second FN branch.
[0018] In one implementation, constructing the FasterNetBlock module using the partially convolutional PConv and SiLU activation functions includes:
[0019] A feature map of size W×H×C is obtained from the ship dataset. The feature map is then input into the first FB branch, and the output of the first FB branch is the feature map.
[0020] The feature map is input to the second FB branch, and the output of the second FB branch is obtained through a 3×3 partial convolutional PConv unit and two CBS units set sequentially in the second FB branch. The CBS unit includes a pointwise convolution with a 1×1 kernel, a BN layer and a SiLU activation function.
[0021] The output of the first FB branch is added to the output of the second FB branch to obtain the FasterNetBlock module.
[0022] In one implementation, designing the FasterNeXt module based on the FasterNet Block module includes:
[0023] The feature map is input to the first FN branch, and the output of the first FN branch is obtained through the CBS unit in the first FN branch;
[0024] The feature map is input to the second FN branch, and the output of the second FN branch is obtained through the CBS unit and the FasterNet Block module set sequentially in the second FN branch.
[0025] The outputs of the first FN branch and the second FN branch are concatenated and then passed through the CBS unit once to obtain the FasterNeXt module.
[0026] In one implementation, the design of the FasterAttention module using the SENet channel attention mechanism includes:
[0027] Based on the FasterNeXt module, the CBS unit part in the FasterNet Block module of the second FN branch is replaced by the SENet channel attention mechanism to obtain the FasterAttention module.
[0028] In one implementation, adding skip connections to the path aggregation network in the second detection model to obtain a ship lightweighting target detection model includes:
[0029] In the path aggregation network of the second detection model, a path is established from the original feature output to directly connect the last feature output node in the feature map at the same network level, thus obtaining the ship lightweight target detection model.
[0030] The second aspect of this application provides a target detection device for lightweight ships, comprising:
[0031] The acquisition module is used to acquire ship data, perform data augmentation on the ship data, and obtain a ship dataset, wherein the ship data includes images of ship targets in several complex environmental scenarios;
[0032] The clustering module is used to construct target anchor frames for ships based on the ship dataset using an adaptive anchor frame strategy and perform cluster analysis to obtain prior frames that conform to ship scale.
[0033] The first improvement module is used to construct a YOLOv7-tiny network based on the ship dataset and the prior box, design a FasterNeXt module through partial convolutional PConv and SiLU activation functions, and use the FasterNeXt module to replace the backbone and multi-branch splicing layer in the path aggregation network of the YOLOv7-tiny network to obtain the first detection model.
[0034] The second improvement module is used to design a FasterAttention module through the SENet channel attention mechanism, and use the FasterAttention module to replace part of the FasterNeXt module in the first detection model to obtain the second detection model.
[0035] The third improvement module is used to add jump connections to the path aggregation network in the second detection model to obtain a ship lightweight target detection model, and to perform target detection through the ship lightweight target detection model.
[0036] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the first aspect or any embodiment of the first aspect.
[0037] The fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the first aspect or any embodiment of the first aspect.
[0038] As shown above, this application provides a lightweight ship target detection method. It improves the YOLOv7-tiny network by designing a FasterNeXt module using partially convolutional PConv and SiLU activation functions, reducing the number of model parameters and computational complexity. Then, it designs a FasterAttention module using the SENet channel attention mechanism, enabling the model to learn more key features of the target while significantly reducing the number of parameters and computational cost, thus improving the accuracy of ship target detection in complex water surface scenarios and achieving better detection results. Finally, it adds skip connections to the path aggregation network of the model to enhance feature fusion of effective features. The lightweight ship target detection method provided in this application improves the YOLOv7-tiny network by combining data augmentation, lightweight convolution, and enhanced feature fusion. This strengthens feature extraction, reduces model size, and makes the final lightweight ship target detection model more suitable for the specific scenarios of water surface target recognition tasks. The processing results are faster and more accurate, reducing false positives and false negatives in complex environments, improving detection speed, and possessing the characteristics of real-time performance, robustness, and ease of deployment. It solves the problems of deploying detection models in unmanned surface vessels and the issues of multi-scale and large intra-class differences in ship targets. It is suitable for application scenarios that require accuracy and speed in the identification of mobile back-end targets such as surface unmanned surface vessels. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 A flowchart illustrating a method for detecting lightweight targets in ships, provided as an embodiment of this application;
[0041] Figure 2 A YOLOv7-tiny network structure diagram provided for embodiments of this application;
[0042] Figure 3 A FasterNet Block network structure diagram provided for embodiments of this application;
[0043] Figure 4 A FasterNeXt network structure diagram provided for embodiments of this application;
[0044] Figure 5 A SENet network structure diagram provided in this application embodiment;
[0045] Figure 6 A FasterAttention network structure diagram provided for embodiments of this application;
[0046] Figure 7 A network structure diagram of a target detection model for lightweight ships provided in this application embodiment;
[0047] Figure 8 This is a comparison diagram of the detection effects of the original model (left) and the improved model (right) provided in an embodiment of this application. Detailed Implementation
[0048] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of this application with unnecessary detail.
[0049] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0050] It should also be understood that the terminology used in this application specification is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this application specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0052] Many specific details are set forth in the following description in order to provide a full understanding of this application. However, this application may also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.
[0053] Example 1
[0054] This application provides a method for detecting lightweight targets in ships, such as... Figure 1 As shown, the method includes:
[0055] S100 acquires ship data, performs data augmentation on the ship data, and obtains a ship dataset, wherein the ship data includes images of ship targets in several complex environmental scenarios;
[0056] Optionally, acquiring ship data includes:
[0057] We acquired publicly available datasets (Seaship7000), Water Surface Object Detection Dataset (WSODD), Singapore Maritime Dataset (SMD), and data collected by unmanned surface vessels, and created our own dataset after extensive frame extraction and deduplication. The collected data covers a variety of complex scenarios, including backlighting, fog, waves, and target clustering, aiming to improve the model's generalization ability.
[0058] Optionally, the data enhancement of the ship data includes:
[0059] On a self-made dataset, based on the ship data, the following methods were used to simulate ship targets in rainy weather: generating and stretching random noise; randomly changing image brightness and saturation to simulate ship targets under different lighting conditions; randomly introducing Gaussian blur and changing image contrast to simulate ship targets in foggy weather; and randomly adding Gaussian noise and salt-and-pepper noise to simulate poor image quality. Based on these simulations, corresponding data were obtained, and a ship dataset was derived.
[0060] Based on the ship dataset, S200 constructs the target anchor frame of the ship through an adaptive anchor frame strategy and performs cluster analysis to obtain a prior frame that conforms to the ship scale.
[0061] Optionally, considering the diversity of domestically built surface vessels and the large length and width of some, the prior boxes using COCO data cannot accurately represent the sample scale. Therefore, this embodiment of the application employs an adaptive anchor box strategy to perform cluster analysis on the target anchor boxes of domestically built vessels, obtaining prior boxes that better match the vessel scale.
[0062] S300 constructs a YOLOv7-tiny network based on the ship dataset and the prior boxes, designs a FasterNeXt (FN) module using partial convolution PConv (Partial Convolution) and SiLU activation function, and uses the FasterNeXt module to replace the backbone and multi-branch concatenation layer (MultiConcatBlock, MCB) in the path aggregation network (PaNet) of the YOLOv7-tiny network to obtain the first detection model;
[0063] Optionally, the YOLOv7-tiny network is an object detection network, and its network structure diagram is as follows. Figure 2 As shown, the network includes a backbone for extracting feature information from the feature map, a neck for adjusting the dimension of the feature map and connecting the backbone and the head, and a head for network output. The path aggregation network uses branch networks to downsample the input image to different degrees to obtain feature maps of different resolutions, and then stitches these feature maps together to further extract high-level features. The embodiments of this application mainly replace the MCB in the backbone and path aggregation network to reduce the number of model parameters and the number of floating-point operations per billion (GFLOPS).
[0064] Optionally, the design of the FasterNeXt module using the partially convolutional PConv and SiLU activation functions includes: constructing a FasterNet Block (FB) module using the partially convolutional PConv and SiLU activation functions, wherein the FasterNetBlock module includes a first FB branch and a second FB branch;
[0065] The FasterNeXt module is designed based on the FasterNet Block module, wherein the FasterNeXt module includes a first FN branch and a second FN branch.
[0066] Optional, such as Figure 3 As shown, the construction of the FasterNetBlock module using the partially convolutional PConv and SiLU activation functions includes:
[0067] Based on the ship dataset, a feature map with size W×H×C (height×width×channels, i.e., length×width×number of channels) is obtained. The feature map is then input into the first FB branch, and the output of the first FB branch is the feature map.
[0068] The feature map is input to the second FB branch. Feature information in different spatial dimensions is extracted by the partial convolution PConv unit with a kernel size of 3×3 set in the second FB branch. Then, the information fusion between channels is enhanced by two CBS units while keeping the number of channels unchanged, and the output of the second FB branch is obtained. The CBS unit includes a pointwise convolution with a kernel size of 1×1, a BN layer and a SiLU activation function.
[0069] The output of the first FB branch is added to the output of the second FB branch to obtain the FasterNetBlock module.
[0070] Optional, such as Figure 4 As shown, designing the FasterNeXt module based on the FasterNet Block module includes:
[0071] The feature map is input to the first FN branch, and the number of channels is reduced by C / 2 through the CBS unit in the first FN branch to obtain the output of the first FN branch;
[0072] The feature map is input to the second FN branch. After the number of channels is reduced by C / 2 by the CBS unit set in the second FN branch, the output of the second FN branch is obtained through the FB module.
[0073] After concatenating the outputs of the first FN branch and the second FN branch to restore the original number of channels C, the FasterNeXt module is obtained by passing it through a CBS unit.
[0074] In this embodiment, the FasterNeXt module is used to replace the MCB in the backbone and path aggregation network of the original model (YOLOv7-tiny), reducing the number of model parameters and the amount of floating-point operations per billion operations.
[0075] S400 designs a FasterAttention (FA) module using the SENet channel attention mechanism, and uses the FasterAttention module to replace part of the FasterNeXt module in the first detection model to obtain a second detection model;
[0076] Optional, such as Figure 5As shown, the design of the FasterAttention module using the SENet channel attention mechanism includes: based on the FasterNeXt module, replacing the CBS unit portion of the FasterNet Block module in the second FN branch with the SENet channel attention mechanism to obtain the FasterAttention module. In one embodiment, firstly, the CBS unit portion of the FB module is replaced using the SENet channel attention mechanism, that is, some CBS units in the FB module are replaced with SE units to obtain the FB-A module. Then, the FB module in the second FN branch of the FN module is replaced with the FB-A module to obtain the FA module.
[0077] Optional, such as Figure 6 As shown, the SENet channel attention mechanism includes three steps: compression (Squeeze), excitation (Excitation), and scaling.
[0078] Specifically, the first step is to perform a Squeeze operation, using global average pooling to transform the input W×H×C into a 1×1×C feature map, where C represents the input channel. This achieves compression in spatial dimensions, as shown in the formula:
[0079]
[0080] The second step involves excitation to generate weights for all feature channels. This step mainly consists of two fully connected layers. The first layer introduces a parameter *r* to further compress the number of channels in the input feature map, resulting in an output of 1×1×C / r. The second fully connected layer then performs dimensionality upscaling, restoring the feature map to 1×1×C. Finally, the sigmoid function is used to limit the obtained weight values to between 0 and 1.
[0081] The third step is to perform a scaling operation. This step multiplies the channel weight values obtained in the second step with the original input feature map, that is, to weight the original feature map by channels, so that the model pays more attention to the channels of interest and extracts features better. The specific formula is as follows:
[0082]
[0083] Since SENet is a plug-and-play network module that can be used anywhere in the network, it has a significant improvement effect on image classification tasks. Therefore, in this embodiment, the SENet channel attention mechanism is introduced to replace the CBS unit in FasterNetBlock, and a FasterAttention module is constructed. The FasterAttention module is then used to replace part of the FasterNeXt module in the model, reducing the number of parameters while enabling the model to learn more of the key features of the target, thereby improving the model accuracy and achieving better detection results.
[0084] S500 adds skip connections to the path aggregation network in the second detection model to obtain a lightweight ship target detection model, and performs target detection through the lightweight ship target detection model.
[0085] Optionally, adding skip connections to the path aggregation network in the second detection model to obtain the ship lightweight target detection model includes:
[0086] In the path aggregation network of the second detection model, a path is established from the original feature output to directly connect the last feature output node in the feature map at the same network level, resulting in a lightweight improved model YOLOv7-FA, which is the ship lightweight target detection model.
[0087] In one implementation, the network structure of the improved ship lightweight target detection model is as follows: Figure 7 As shown. In feature maps at the same network level, a path is established from the original feature output directly to the final feature output node to better fuse the output features of different feature layers. When performing feature fusion at different scales, the path aggregation network adjusts to the same feature size through sampling interpolation before performing simple channel concatenation. The drawback of this approach is that it treats all input features equally and cannot automatically distinguish the importance of different feature outputs. Considering this problem, this embodiment sets corresponding weights based on the different contributions of feature maps of different sizes to the feature fusion effect. The weights are automatically adjusted according to the contribution of feature maps at different levels during actual training, thereby obtaining better feature fusion results and achieving better detection accuracy. The obtained weights are normalized using softmax. A larger weight value indicates a greater contribution and greater importance to the Neck network. The calculation method is shown in the formula:
[0088]
[0089] In the formula, This represents the output feature map after feature fusion. Represents the weights that can be adaptively learned. This represents the original input feature map. The value 0.0001 represents a minimum value set to prevent data computational instability. First, the Concat module in the original network is replaced. A gradient parameter is defined in the input feature map of each different network layer. Adaptive learning is performed during training, and after normalization, the gradient is multiplied by its respective input feature map to obtain the result. Finally, the feature maps of each network layer are summed to obtain the final output. After a second downsampling in the backbone, a 40×40×256 feature map is output through FasterAttention. An additional backbone network feature output path is concatenated with the medium-scale prediction branch. Because the self-made ship dataset contains mostly large and medium-sized features, medium-scale feature fusion is added. Skip connections are used to increase the number of parameters by a small amount to improve accuracy.
[0090] As can be seen from the above, this application provides a method for detecting lightweight targets on ships. It improves the YOLOv7-tiny network by designing a FasterNeXt module using partially convolutional PConv and SiLU activation functions, reducing the number of model parameters and computational complexity. Then, it designs a FasterAttention module using the SENet channel attention mechanism, enabling the model to learn more key features of the target while significantly reducing the number of parameters and computational cost, thus improving the accuracy of ship target detection in complex water surface scenarios and achieving better detection results. Finally, it adds skip connections to the path aggregation network of the model to enhance the feature fusion of effective features. This method is suitable for application scenarios where accuracy and speed are required in the identification of mobile back-end targets such as unmanned surface vessels.
[0091] Example 2
[0092] This application demonstrates the effectiveness of the ship lightweight target detection method provided in Embodiment 1 through experiments. The specific experimental environment is as follows:
[0093] During network training, the initial learning rate was set to 0.01, and stochastic gradient descent (SGD) was used for optimization. The momentum coefficient was set to 0.937, and the learning rate adjustment strategy was set to cosine annealing. The number of training epochs was set to 300, the batch size was set to 32, and the data augmentation method was used with mosaic. The input image size was 640×640. The experimental environment and platform are as follows:
[0094] Table 1 Experimental Environment Setup
[0095]
[0096] The specific experimental results are as follows:
[0097] The experimental metrics are shown in Table 2. The YOLOv7-FA in this embodiment and the original model (YOLOv7-tiny) were tested on an RTX2080. The comparison shows that, in terms of surface vessel target detection, YOLOv7-FA in this embodiment shows improvements in all metrics except for a slightly lower accuracy compared to YOLOv7-tiny. The number of parameters is reduced by 40%, GFLOPs by 41.67%, mAP@.5 is increased by 2.4%, and the detection speed is slightly higher than the original model by 1.37 fps. Therefore, it is a more suitable lightweight detection method for surface vessel target detection.
[0098] Table 2 Experimental Indicators
[0099]
[0100] Detection results are as follows Figure 8 As shown in the figure, the first column is the detection effect of the original model (YOLOv7-tiny), and the second column is the detection effect of the improved YOLOv7-FA in the embodiment of this application. It can be seen that compared with YOLOv7-tiny, YOLOv7-FA has lower false negatives and lower false positives in complex scenarios such as fog, low light and multi-scale target aggregation, and performs better in the detection of ship targets on the water surface.
[0101] Example 3
[0102] This application provides a ship lightweight target detection device, which includes: an acquisition module, a clustering module, a first improved module, a second improved module, and a third improved module;
[0103] The acquisition module is used to acquire ship data, perform data augmentation on the ship data, and obtain a ship dataset. The ship data includes images of ship targets in several complex environmental scenarios.
[0104] The clustering module is used to construct target anchor frames for ships based on the ship dataset using an adaptive anchor frame strategy and perform cluster analysis to obtain prior frames that conform to ship scale.
[0105] The first improvement module is used to construct a YOLOv7-tiny network based on the ship dataset and the prior box, design a FasterNeXt module through partial convolution PConv and SiLU activation functions, and use the FasterNeXt module to replace the backbone and multi-branch splicing layer in the path aggregation network of the YOLOv7-tiny network to obtain the first detection model.
[0106] The second improvement module is used to design a FasterAttention module through the SENet channel attention mechanism, and to replace part of the FasterNeXt module in the first detection model with the FasterAttention module to obtain the second detection model.
[0107] The third improvement module is used to add jump connections to the path aggregation network in the second detection model to obtain a ship lightweight target detection model, and to perform target detection through the ship lightweight target detection model.
[0108] As can be seen from the above, this application provides a lightweight ship target detection device. It improves the YOLOv7-tiny network by designing a FasterNeXt module using partially convolutional PConv and SiLU activation functions, reducing the number of model parameters and computational complexity. Then, it designs a FasterAttention module using the SENet channel attention mechanism, enabling the model to learn more key features of the target while significantly reducing the number of parameters and computational cost, thus improving the accuracy of ship target detection in complex water surface scenarios and achieving better detection results. Finally, it adds skip connections to the path aggregation network of the model to enhance the feature fusion of effective features. This device is suitable for applications requiring both accuracy and speed in the identification of mobile backend targets such as unmanned surface vessels.
[0109] Example 4
[0110] This application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor. The memory stores software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory and processor are connected via a bus. Specifically, the processor implements any of the steps in Embodiment 1 by running the computer program stored in the memory.
[0111] It should be understood that, in the embodiments of this application, the processor may be a Central Processing Unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0112] Memory may include read-only memory, flash memory, and random access memory, and provides instructions and data to the processor. Some or all of the memory may also include non-volatile random access memory.
[0113] As can be seen from the above, the electronic device provided in this application implements a lightweight ship target detection method as provided in Embodiment 1 by running a computer program. It improves the YOLOv7-tiny network by designing a FasterNeXt module using partially convolutional PConv and SiLU activation functions, reducing the number of model parameters and computational complexity. Then, it designs a FasterAttention module using the SENet channel attention mechanism, enabling the model to learn more key features of the target while significantly reducing the number of parameters and computational cost, thus improving the accuracy of ship target detection in complex water surface scenarios and achieving better detection results. Finally, it adds skip connections to the path aggregation network of the model to strengthen the feature fusion of effective features. This method is suitable for application scenarios where accuracy and speed are required in the identification of mobile backend targets such as unmanned surface vessels.
[0114] It should be understood that if the integrated modules / units described above are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0115] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0116] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the above device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0117] It should be noted that the methods and detailed examples provided in the above embodiments can be incorporated into the apparatus and devices provided in the embodiments, and can be referred to each other, without further elaboration.
[0118] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0119] In the embodiments provided in this application, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / device embodiments described above are merely illustrative. For instance, the division of the modules or units described above is merely a logical functional division, and in actual implementation, it can be divided in other ways. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0120] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for detecting lightweight targets in ships, characterized in that, include: The ship data is acquired, data augmentation is performed on the ship data to obtain a ship dataset, wherein the ship data includes images of ship targets in several complex environmental scenarios; Based on the ship dataset, target anchor frames for ships are constructed using an adaptive anchor frame strategy and cluster analysis is performed to obtain prior frames that conform to ship scale. Based on the ship dataset and the prior boxes, a YOLOv7-tiny network is constructed. A FasterNeXt module is designed using partial convolutional PConv and SiLU activation functions. The FasterNeXt module is used to replace the multi-branch splicing layer in the backbone and path aggregation network of the YOLOv7-tiny network to obtain the first detection model. The FasterAttention module is designed using the SENet channel attention mechanism. The FasterAttention module is then used to replace part of the FasterNeXt module in the first detection model to obtain the second detection model. Skip connections are added to the path aggregation network in the second detection model to obtain a lightweight ship target detection model, and target detection is performed through the lightweight ship target detection model.
2. The method for detecting lightweight targets in ships as described in claim 1, characterized in that, The data augmentation of the ship data includes: Based on the ship data, random noise was generated and stretched to simulate the ship target's condition in rainy weather. The image brightness and saturation were randomly varied to simulate the situation of ship targets under different lighting conditions; The method of randomly introducing Gaussian blur and changing image contrast is used to simulate the situation of ship targets in foggy weather; We simulated poor image quality by randomly adding Gaussian noise and salt-and-pepper noise.
3. The method for detecting lightweight targets in ships as described in claim 1, characterized in that, The design of the FasterNeXt module using partially convolutional PConv and SiLU activation functions includes: The FasterNetBlock module is constructed using the partially convolutional PConv and SiLU activation functions, wherein the FasterNetBlock module includes a first FB branch and a second FB branch; The FasterNeXt module is designed based on the FasterNetBlock module, wherein the FasterNeXt module includes a first FN branch and a second FN branch.
4. The method for detecting lightweight targets in ships as described in claim 3, characterized in that, The construction of the FasterNetBlock module using the partially convolutional PConv and SiLU activation functions includes: A feature map of size W×H×C is obtained from the ship dataset. The feature map is then input into the first FB branch, and the output of the first FB branch is the feature map. The feature map is input to the second FB branch, and the output of the second FB branch is obtained through a 3×3 partial convolutional PConv unit and two CBS units set sequentially in the second FB branch. The CBS unit includes a pointwise convolution with a 1×1 kernel, a BN layer and a SiLU activation function. The output of the first FB branch is added to the output of the second FB branch to obtain the FasterNetBlock module.
5. The method for detecting lightweight targets in ships as described in claim 4, characterized in that, The step of designing the FasterNeXt module based on the FasterNetBlock module includes: The feature map is input to the first FN branch, and the output of the first FN branch is obtained through the CBS unit in the first FN branch; The feature map is input to the second FN branch, and the output of the second FN branch is obtained through the CBS unit and the FasterNetBlock module set sequentially in the second FN branch. The outputs of the first FN branch and the second FN branch are concatenated and then passed through the CBS unit once to obtain the FasterNeXt module.
6. The method for detecting lightweight targets in ships as described in claim 5, characterized in that, The FasterAttention module designed using the SENet channel attention mechanism includes: Based on the FasterNeXt module, the CBS unit part in the FasterNetBlock module of the second FN branch is replaced by the SENet channel attention mechanism to obtain the FasterAttention module.
7. The method for detecting lightweight targets in ships as described in any one of claims 1-6, characterized in that, The step of adding skip connections to the path aggregation network in the second detection model to obtain the ship lightweight target detection model includes: In the path aggregation network of the second detection model, a path is established from the original feature output to directly connect to the last feature output node in the feature map at the same network level, thus obtaining the ship lightweight target detection model.
8. A target detection device for lightweight ships, characterized in that, include: The acquisition module is used to acquire ship data, perform data augmentation on the ship data, and obtain a ship dataset, wherein the ship data includes images of ship targets in several complex environmental scenarios; The clustering module is used to construct target anchor frames for ships based on the ship dataset using an adaptive anchor frame strategy and perform cluster analysis to obtain prior frames that conform to ship scale. The first improvement module is used to construct a YOLOv7-tiny network based on the ship dataset and the prior box, design a FasterNeXt module through partial convolutional PConv and SiLU activation functions, and use the FasterNeXt module to replace the backbone and multi-branch splicing layer in the path aggregation network of the YOLOv7-tiny network to obtain the first detection model. The second improvement module is used to design a FasterAttention module through the SENet channel attention mechanism, and use the FasterAttention module to replace part of the FasterNeXt module in the first detection model to obtain the second detection model. The third improvement module is used to add jump connections to the path aggregation network in the second detection model to obtain a ship lightweight target detection model, and to perform target detection through the ship lightweight target detection model.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the steps of the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.