A method and system for detecting marine animals
Patent Information
- Application Number
- CN202311749140.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2026-10-16
AI Technical Summary
然而,这些算法仍然存在一些局限性,如检测速度慢、检测精度低、检测成本高等问题
[0042] As can be seen from the above technical solutions, compared with the prior art, this invention provides a marine animal detection method and system. It improves upon YOLOv8 by introducing DCNv2 into the YOLOv8 backbone network, enhancing the model's ability to model target shape and spatial variations, enabling it to better adapt to complex geometric transformations and spatial structures. Simultaneously, it integrates the CoTAttention contextual attention mechanism module into the C2f block, preserving richer gradient flow information while enabling the C2f_CoT module to have long-range interaction capabilities, thereby improving visual information extraction capabilities. The improved spatial pyramid pooling SPPFCSPC reduces the computational load of pooling layers with smaller kernels by connecting three independent pooling operations, while obtaining pooling layer results with larger kernels, achieving acceleration while maintaining the same perception range. To further improve the detection effect of small-sized targets, this invention introduces a P2 branch detection head based on the three-scale detection of YOLOv8 and uses a larger 160×160 detection layer specifically for processing the detection of smaller targets, effectively locating the position of small targets and thus enabling better detection of small targets.
Smart Images

Figure CN122929602A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of marine animal species detection technology, and more specifically to a method and system for marine animal detection. Background Technology
[0002] Marine target detection refers to the technology of accurately locating and identifying specific targets in marine environments. This technology is widely used in underwater cable laying, oil exploration, salvage and rescue, marine fish detection, seabed aquaculture, underwater navigation, smart aquaculture, and underwater target engagement. Currently, marine target detection methods often employ improved Faster-RCNN algorithms to obtain fish school target location information, utilize UWGAN networks for underwater raw image restoration, or use RNNs and CNNs for marine data prediction. However, these algorithms still have limitations, such as slow detection speed, low detection accuracy, and high detection cost. Especially in the marine environment, the image samples acquired by underwater cameras are generally small and of low quality, and large models have slow inference speeds and large scales, making direct application to underwater scenarios inefficient. Furthermore, the limited storage and computing power of underwater embedded devices makes the deployment of large networks in marine environments difficult. Therefore, solving the problem of further lightweighting marine fish school detection algorithms to facilitate industrial deployment and improving detection speed and accuracy has become a challenge that urgently needs to be addressed by those skilled in the art. Summary of the Invention
[0003] In view of this, the present invention provides a marine animal detection method and system that can automatically learn and identify marine animal characteristics using a large amount of marine animal image data, thereby achieving efficient, accurate and low-cost marine animal species detection.
[0004] To achieve the above objectives, the present invention adopts the following technical solution:
[0005] A method for detecting marine animals includes the following steps:
[0006] Obtain a dataset of marine animals;
[0007] The marine animal dataset is input into the improved YOLOv8 model for training to obtain a marine animal detection model;
[0008] The image of the marine animal to be identified is input into the marine animal detection model to obtain the detection result of the marine animal species to be identified.
[0009] Optionally, the acquired marine animal dataset may also be augmented and preprocessed, specifically by rotating, mosaic-enhancing, and Gaussian blurring the images in the marine animal dataset.
[0010] Optional, the improved YOLOv8 model is improved as follows:
[0011] A position offset is introduced at each sampling point of the convolution kernel, and a modulation mechanism is used to adjust the sampling position of the convolution module to form a deformable convolution DCNV2 module. DCNV2 is used for feature extraction in the backbone network of the traditional YOLOv8 model.
[0012] The C2F_CoT module combines a Transformer-style context attention mechanism with a C2F block.
[0013] Replace the traditional YOLOv8 spatial pyramid pooling SPPF with spatial pyramid pooling SPPFCSPC.
[0014] Based on the traditional YOLOv8 three-scale receptive field detection, a 160*160 P2 small target detection head is added.
[0015] Optionally, a position offset is introduced at each sampling point. The specific steps are as follows: The offset in a 3×3 deformable convolutional network is obtained through traditional convolutional layers; simultaneously, traditional and deformable convolutions that generate the offset are trained, and the gradient is backpropagated using bilinear interpolation to learn the offset; wherein, the offset matrix obtained by the deformable convolution kernel is:
[0016] p k ∈{(-1,-1),(-1,-1),...,(-1,-1)};
[0017]
[0018] p k Δp represents the pre-specified offset at the k-th position. k and w k These represent the learnable offset and the weight of the sampling point k, respectively.
[0019] Optionally, in the modulation mechanism, the modulated scalar obtained by applying separate convolutions to the same input feature map x is incorporated into the deformable convolution as follows:
[0020]
[0021] w k Δp k and Δm k These are the weight at sampling point k, the learnable position offset, and the modulation scalar, respectively.
[0022] Optionally, the specific steps of the context attention mechanism Transformer block are as follows:
[0023] The CoT module learns context keys by performing k×k grouped convolutions on the neighbor keys within all k×k grids in spatial geometry.
[0024] The context key and query Q are concatenated, and the attention matrix is obtained through two consecutive 1×1 convolutions. The query operation is as follows:
[0025] A = [K] 1 ,Q]W θ W δ
[0026] in, The key represents the input 2D feature map, W θ W represents the weight matrix with a ReLU activation function. δ Let Q represent the weight matrix without an activation function, and let Q represent the query matrix.
[0027] Then, based on the contextual attention matrix A, all values are aggregated to calculate the participating feature map K. 2 The aggregation method is as follows:
[0028]
[0029] Among them, K 2 A represents the dynamic context of the input, A is the context attention matrix, and V represents the definition of the values.
[0030] The final output of CoT incorporates static context through an attention mechanism.
[0031] Optionally, spatial pyramid pooling (SPPFCSPC) is achieved by concatenating three independent pooling operations, as shown in the following expression:
[0032]
[0033]
[0034]
[0035]
[0036] Where R represents the output result. This represents tensor concatenation, where F represents the input feature map. R1 indicates that the max pooling layer is filled with 2, and the kernel size is 3×3; R1 represents the output after the first pooling operation, whose gradient flows to the second pooling layer to obtain R2, and similarly to obtain R3; R4 represents the result obtained by concatenating the tensors of R1, R2, and R3.
[0037] Optionally, a 160*160 P2 small target detection head can be added. The specific steps are as follows: Based on the three-scale detection of YOLOv8, a P2 branch detection head is introduced, and a 160×160 detection layer is used to process target detection.
[0038] A marine animal detection system based on an improved YOLOv8, comprising:
[0039] Data acquisition module: used to acquire marine animal datasets;
[0040] Marine animal monitoring model training module: used to input the marine animal dataset into the improved YOLOv8 model for training, and obtain the marine animal detection model;
[0041] Detection Result Module: This module is used to input images of marine animals to be identified into the marine animal detection model to obtain the detection results of the marine animal species to be identified.
[0042] As can be seen from the above technical solutions, compared with the prior art, this invention provides a marine animal detection method and system. It improves upon YOLOv8 by introducing DCNv2 into the YOLOv8 backbone network, enhancing the model's ability to model target shape and spatial variations, enabling it to better adapt to complex geometric transformations and spatial structures. Simultaneously, it integrates the CoTAttention contextual attention mechanism module into the C2f block, preserving richer gradient flow information while enabling the C2f_CoT module to have long-range interaction capabilities, thereby improving visual information extraction capabilities. The improved spatial pyramid pooling SPPFCSPC reduces the computational load of pooling layers with smaller kernels by connecting three independent pooling operations, while obtaining pooling layer results with larger kernels, achieving acceleration while maintaining the same perception range. To further improve the detection effect of small-sized targets, this invention introduces a P2 branch detection head based on the three-scale detection of YOLOv8 and uses a larger 160×160 detection layer specifically for processing the detection of smaller targets, effectively locating the position of small targets and thus enabling better detection of small targets.
[0043] This invention improves upon YOLOv8 for marine animal category detection, increasing detection speed and accuracy while reducing costs. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, 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 embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0045] Figure 1 This is a schematic diagram of the method steps of the present invention;
[0046] Figure 2(a) is a schematic diagram of the structure of the traditional YOLOv8 model;
[0047] Figure 2(b) is a schematic diagram of the structure of the improved YOLOv8 model (DPSC-YOLO) of the present invention, wherein the components are put together to indicate that the two components are in a data flow relationship.
[0048] Figure 3 This is a schematic diagram of the deformable convolutional network in this invention;
[0049] Figure 4 This is a schematic diagram of the deformable convolutional combination module structure of the present invention.
[0050] Figure 5 This is a schematic diagram of the CoTAttention contextual attention mechanism in this invention.
[0051] Figure 6 This is a schematic diagram of the C2f_CoT composite module structure;
[0052] Figure 7 Schematic diagram of SPPCSPC structure and SPPFCSPC structure module;
[0053] Figure 8 This is a schematic diagram of the model training process in Example 2;
[0054] Figure 9 This is an example diagram of the detection results of the DPSC-YOLO of the present invention;
[0055] Figure 10(a) is a heatmap showing the visualization of the backbone network during training of the DPSC-YOLO and YOLOv8 models in Example 2.
[0056] Figure 10(b) is a visualization heatmap comparing the spatial pyramid pooling of the DPSC-YOLO and YOLOv8 models during training in Example 2.
[0057] Figure 10(c) is a visual heatmap comparison of the detection head during the training of the DPSC-YOLO and YOLOv8 models in Example 2. Detailed Implementation
[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0059] As a leading single-stage detection algorithm, the YOLO series boasts high accuracy and fast detection speed, making it widely applicable to various target detection tasks. This algorithm is optimized based on the latest YOLOv8 model. YOLOv8 is the latest version of the YOLO (You Only Look Once) series algorithm, offering higher accuracy and faster inference speed compared to previous generations. Furthermore, the research approaches from previous generations are also applicable to YOLOv8. Compared to previous generations, the improvements are as follows: (1) CSPlayer has undergone some changes. The C2f module, referencing the ELAH structure in YOLOv7, has been designed. This module has a cross-stage bottleneck in two convolutions, improving accuracy by combining high-level features with contextual information; (2) YOLOv8, referencing YOLOx, uses an anchorless model with a decoupled head to independently handle object, classification, and regression tasks. This design allows each branch to focus on its task and improves the overall accuracy of the model; (3) BCE loss is used as the classification loss in YOLOv8, and the regression loss is in the form of Ciou loss plus DFL (Distribution Focal Loss). The model can quickly focus on the distribution of objects' locations. In summary, YOLOv8 is an efficient and accurate object detection algorithm, suitable for the marine animal detection task in this invention.
[0060] Traditional convolution has an inherent limitation: it can only sample at fixed locations in the input feature map. However, deformable convolution learns the ability to deform spatial geometry by introducing a positional offset at each sampling point of the convolution kernel. This offset allows the kernel to sample randomly in the vicinity of its current position, breaking the limitation of sampling at regular grid points in traditional convolution. Through this deformation operation, deformable convolution can better perceive and capture local details in the input feature map. This capability improves the model's ability to model geometric changes.
[0061] This invention employs the C2f_CoT module, which retains the advantages of the C2f module, ensures lightweight design, and obtains richer gradient flow information. Simultaneously, the Contextual Transformer (CoT) is introduced, enabling the C2f_CoT module to possess long-range interaction capabilities. Traditional self-attention effectively triggers feature interactions at different spatial locations, depending on the input itself. However, in traditional self-attention mechanisms, all paired query key relationships are learned independently on isolated query key pairs without exploring the rich intermediate context. This severely limits the ability of self-attention learning to perform visual representation learning on 2D feature maps. The Contextual Transformer (CoT) block, on the other hand, integrates contextual information mining and self-attention learning into a unified architecture, fully utilizing the contextual information between adjacent keys to effectively promote self-attention learning and enhance the representativeness of the output aggregated feature map.
[0062] Spatial pyramid pooling is a more efficient method than simple max pooling, expanding the receptive field of the backbone and significantly distinguishing the most important contextual features. After multi-scale feature extraction, this structure outputs a fixed-size feature vector to increase the network's receptive range. Compared to SPPCSPC, SPPFCSPC reduces the computational cost of pooling layers with smaller kernels by concatenating three independent pooling operations, while obtaining pooling layer results with larger kernels, thus achieving speedup while maintaining the same receptive range.
[0063] YOLOv8 employs a well-designed feature layer architecture with varying scales, enabling the model to capture features from targets of different sizes more comprehensively. Specifically, a 20×20 feature layer is used to detect large targets. To handle medium-sized targets, the 20×20 feature layer is upsampled by 2x and fused with a 40×40 feature layer. Similarly, the 40×40 feature layer is also upsampled by 2x and fused with an 80×80 feature layer for detecting small targets. To further improve the detection performance of small targets, this invention introduces a P2 branch detection head based on YOLOv8's three-scale detection, and uses a larger 160×160 detection layer specifically for detecting even smaller targets. The newly added P2 branch receives input primarily from shallow convolutional layers, containing a wealth of information on shape, position, and size, effectively locating small targets and thus enabling better detection.
[0064] Example 1
[0065] This embodiment discloses a method for detecting marine animals. See [link to relevant documentation]. Figure 1 This includes the following steps:
[0066] Step 1: Obtain the marine animal dataset.
[0067] The marine animal dataset includes several images of marine animals and the corresponding marine animal species category for each image.
[0068] The real marine environment is far more complex than the environment in which the data was collected. To increase data diversity and improve the model's generalization ability, it is necessary to enhance the model's robustness to different image variations and noise. Therefore, this invention employs a series of data augmentation techniques. First, the existing image is horizontally flipped and rotated 60° counterclockwise to help the model learn the swimming postures of marine animals from different perspectives. Second, a mosaic effect is introduced, dividing the image into 8x8 blocks and blurring them to simulate low-resolution images, thereby increasing the model's robustness to blurred images. Furthermore, Gaussian blur is introduced, replacing pixels in the image with the weighted average of surrounding pixels to smooth the image and reduce noise, allowing the model to focus more on the overall features of the image.
[0069] After image rotation, mosaic enhancement, and Gaussian blurring, a total of 9340 enhanced images were obtained. The dataset was divided into training, validation, and test sets according to an 80%:10%:10% ratio, with the training set containing 7472 images, the validation set containing 934 images, and the test set containing 934 images.
[0070] By applying these data augmentation techniques, we obtained a more diverse and robust marine animal dataset, providing a better foundation for model training and analysis.
[0071] Step 2: Based on the marine animal dataset, using marine animal images as input and the corresponding species categories of the marine animal images as output, train the improved YOLOv8 model to obtain the marine animal detection model.
[0072] The improved YOLOv8 model is based on the traditional YOLOv8 model (see Figure 2(a)) and the following four improvements are made to obtain the DPSC-YOLO model (see Figure 2(b)):
[0073] (1) Introduce a position offset for each sampling point of the convolution kernel in traditional convolution, and use a modulation mechanism to adjust the sampling position of the convolution module to form a deformable convolution DCNV2 module. Use DCNV2 for feature extraction in the backbone network of the traditional YOLOv8 model.
[0074] Deformable convolutional networks (see) Figure 3 See also the specific modules integrated in YOLOv8. Figure 4 DCNv2 includes:
[0075] 1) Introducing Position Offsets: First, offsets are obtained in a 3×3 deformable convolutional network using traditional convolutional layers. Then, both traditional and deformable convolutions are trained simultaneously to generate the offsets, and bilinear interpolation is used to backpropagate the gradients to learn the offsets. The offset matrix obtained from the deformable convolution kernel is:
[0076] p k ∈{(-1,-1),(-1,-1),...,(-1,-1)}
[0077]
[0078] p k Δp represents the pre-specified offset at the k-th position. k and w k These represent the learnable offset and the weights at sampling point k, respectively. Bilinear interpolation is used in the calculation. Δp k It is obtained by applying a separate convolution to the same input feature map x.
[0079] 2) Modulation Mechanism: The deformable convolution with the modulation mechanism added is obtained by applying a modulation scalar to the same input feature map x.
[0080]
[0081] w k Δp k and Δm k These are the weights at sampling point k, the learnable position offset, and the modulation scalar, respectively. The modulation scalar lies in the range [0,1] and is a real number with an unconstrained range. Bilinear interpolation is used in the calculation. Δp k and Δm k It is obtained by applying a separate convolution to the same input feature map x.
[0082] (2) See CoTAttention contextual Transformer attention mechanism. Figure 5 The CoT module first performs k×k grouped convolutions on all neighbor keys within a k×k grid in space to obtain the context for each key. In this way, the learned context keys... It can naturally reflect the static context information between adjacent keys.
[0083] Following this, the context key and query Q are concatenated, and the attention matrix is obtained through two consecutive 1×1 convolutions. Then, based on the context attention matrix A, all values are aggregated to calculate the participating feature map K. 2 .
[0084] A = [K] 1 ,Q]Wθ W δ
[0085]
[0086] Among them, K 2 Given a dynamic context representation as input, the final output of CoT incorporates the static context K through an attention mechanism. 1 and K 2 They merged together.
[0087] See C2f_CoT. Figure 6 The module first undergoes a convolutional layer, followed by a splitting operation, with the split portion being subjected to gradient splitting. The original C2f module uses a single convolutional block for splitting before concatenation, while C2f_CoT uses a CoT module for splitting. C2f_CoT fully utilizes the contextual information between adjacent keys in the splitting part, effectively promoting self-attention learning and enhancing the representational power of the output aggregated feature map.
[0088] The design of C2f_CoT can enhance the semantic distribution of features learned by convolutional neural networks, so that correct semantic regions can be highlighted, while irrelevant semantic regions tend to zero.
[0089] (3) Replace the original spatial pyramid pooling SPPF in YOLOv8 with SPPFCSPC. SPPFCSPC is an improvement on SPPCSPC in YOLOv7. Figure 7 .
[0090] Spatial pyramid pooling SPPFCSPC is:
[0091]
[0092]
[0093]
[0094]
[0095] Where R represents the output result, represents tensor concatenation, and F represents the input feature map.
[0096] Spatial Pyramid Pooling (SPPFCSPC) reduces the computation of pooling layers with smaller pooling kernels by connecting three independent pooling operations, while obtaining pooling layer results with larger pooling kernels, thus achieving acceleration while maintaining the same sensing range.
[0097] (4) Add the P2 small target detection head (see the red box in Figure 2(b)). The specific operation is as follows:
[0098] Traditional YOLOv8 uses feature layers of three scales: 20×20, 40×40, and 80×80. Building upon YOLOv8's three-scale detection, a P2 branch detection head is introduced, employing a larger 160×160 detection layer specifically for detecting smaller targets.
[0099] In this embodiment, YOLOv8 is an open-source, single-stage object detection algorithm developed by Ultralytics.
[0100] Step 3: Input the image of the marine animal to be identified into the marine animal detection model to obtain the species detection result of the marine animal image.
[0101] Example 2
[0102] This embodiment demonstrates the beneficial effects of the method of the present invention by performing target detection on images of marine animals to be identified through specific experiments.
[0103] Experimental Platform: This experiment was conducted on a Windows 10 operating system, equipped with an Intel(R) Core(TM) i5-10400F@2.9GHz processor and 32GB of RAM, and an Nvidia GeForce RTX 2080Ti graphics card with 22GB of video memory. The development language was Python 3.9, the deep learning framework used was PyTorch-GPU 2.0.1, the CUDA version was 11.8, and cuDNN version v8.9.2.26 was used for GPU acceleration.
[0104] The Marine dataset consists of two parts. One part comes from the Roboflow dataset website, the official dataset management platform recommended by YOLOv8, which provides many free datasets. Developers can easily obtain datasets in the required formats without manual conversion. The other part consists of self-made marine animal images collected online and through visits to aquariums. The dataset is categorized into the following seven groups: puffin, jellyfish, shark, penguin, stingray, starfish, and fish.
[0105] Experimental setup: The experimental training process is as follows Figure 8 As shown in Table 1. In the experiment, the parameters were set as follows: a total of 300 epochs of training, a batch size of 64, an initial learning rate of 0.01, an SGD optimizer, and a weight decay of 0.0005. Specific parameter settings are shown in Table 1. Parameters not mentioned in this invention used the official default parameters from YOLOv8.
[0106] Table 1 Experimental parameter settings
[0107] Dataset Marine animal dataset Maximum number of training epochs 300 Learning rate (starting) 0.01 Batchsize 64 Weight decay 0.0005 Optimizer SGD
[0108] Evaluation Metrics: In the experiments, multiple comprehensive evaluation methods, such as precision and mean precision (mAP), were applied to evaluate the detection performance of DPSC-YOLO on the ocean dataset. Precision measures the accuracy of target recognition for each type, while recall shows the model's ability to detect targets. mAP is the average precision across all classes, used to compare performance differences between different models or parameter configurations. The evaluation formula is:
[0109]
[0110]
[0111]
[0112]
[0113] TP represents the number of correctly predicted positive samples, FN represents the number of incorrectly predicted negative samples, and FP represents the number of incorrectly predicted positive samples. Additionally, Params is introduced to represent the number of model parameters, i.e., the number of parameters that the model needs to learn.
[0114] Experimental Results: To investigate the effectiveness of the improved method proposed in this invention, ablation experiments and comparative experiments were conducted step-by-step to verify the effectiveness of the improved algorithm. The comparison revealed that the DPSC-YOLO proposed in this invention has significant advantages over other models. Compared with the baseline model YOLOv8n, DPSC-YOLO improves mAP@.5 by 1.1% and mAP@0.5-0.95 by 4.8%, while only slightly improving the number of parameters and GFLOPs. This further demonstrates that this invention achieves a balance between lightweight design and detection performance, and achieves optimal performance. The final detection results are shown below. Figure 9 .
[0115] Table 2 Comparison of DPSC-YOLO with various detector versions
[0116] Model mAP@.5 / % mAP@0.5-0.95 / % Params / M FLOPs / G Epochs YOLOv5n 97.4 71.7 2.5 7.2 300 YOLOv6n 96.1 77.6 7 9.4 300 YOLOv7-tiny 96.6 70.9 6.0 13.2 300 YOLOv8n 97.6 80.9 3.0 8.2 300 YOLOv8n+Dyhead 98.0 83.4 3.5 9.7 300 YOLOv8n+Timm 98.7 88.1 13.3 35.1 300 YOLOv8s 98.7 86.7 11.1 28.5 300 DPSC-YOLOn(ours) 98.7 85.7 4.8 13.6 300
[0117] Meanwhile, ablation experiments were conducted on the YOLOv8 detector for each of the four improvements in this embodiment. YOLOv8 was used as the baseline model in this experiment, and the results are shown in Table 3. Based on the combined experimental results, the algorithm achieved optimal performance after 300 rounds of iterative training using the DCNv2 module, SPPFCSPC module, P2 detector head, and C2f_CoT module, demonstrating the effectiveness of this invention in marine animal detection. A detailed model structure heatmap is shown in Figure 10, where the left side represents YOLOv8 and the right side represents DPSC-YOLO. The P4 part of the backbone network effectively suppresses irrelevant features at the bottom of the image, allowing the model to focus more on the target object of interest. Through spatial pyramid pooling visualization, this invention better perceives and captures local details of small fish schools in the right half of the image. Furthermore, the added P2 detector head, compared to the P3 detector head, shows higher attention to densely packed small fish schools. Therefore, this invention demonstrates superior results in small target detection. These improvements make the model more accurate and robust when handling small targets and complex scenes.
[0118] Table 3 DPSC-YOLO Ablation Experiment
[0119]
[0120]
[0121] Another embodiment of the present invention discloses a marine animal detection system based on an improved YOLOv8, comprising:
[0122] Data acquisition module: used to acquire marine animal datasets;
[0123] Marine animal monitoring model training module: used to input the marine animal dataset into the improved YOLOv8 model for training, and obtain the marine animal detection model;
[0124] Detection Result Module: This module is used to input images of marine animals to be identified into the marine animal detection model to obtain the detection results of the marine animal species to be identified.
[0125] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0126] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. 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 the invention. Therefore, the invention 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.
Claims
1. A method for detecting marine animals, characterized in that, Includes the following steps: Obtain a dataset of marine animals; The marine animal dataset is input into the improved YOLOv8 model for training to obtain a marine animal detection model; The image of the marine animal to be identified is input into the marine animal detection model to obtain the detection result of the marine animal species to be identified.
2. The method for detecting marine animals according to claim 1, characterized in that, It also includes data augmentation and preprocessing of the acquired marine animal dataset, specifically: rotating, mosaic enhancement, and Gaussian blurring of the images in the marine animal dataset.
3. The method for detecting marine animals according to claim 1, characterized in that, The specific improvements to the YOLOv8 model are as follows: A position offset is introduced at each sampling point of the convolution kernel, and a modulation mechanism is used to adjust the sampling position of the convolution module to form a deformable convolution DCNV2 module. DCNV2 is used for feature extraction in the backbone network of the traditional YOLOv8 model. The C2F_CoT module combines a Transformer-style context attention mechanism with a C2F block. Replace the traditional YOLOv8 spatial pyramid pooling SPPF with spatial pyramid pooling SPPFCSPC. Based on the traditional YOLOv8 three-scale receptive field detection, a 160*160 P2 small target detection head is added.
4. The method for detecting marine animals according to claim 3, characterized in that, A positional offset is introduced at each sampling point. The specific steps are as follows: The offset in a 3×3 deformable convolutional network is obtained through traditional convolutional layers; simultaneously, both traditional and deformable convolutions that generate the offset are trained, and the gradient is backpropagated using bilinear interpolation to learn the offset; the offset matrix obtained from the deformable convolution kernel is: p k ∈{(-1,-1),(-1,-1),...,(-1,-1)}; p k Δp represents the pre-specified offset at the k-th position. k and w k These represent the learnable offset and the weight of the sampling point k, respectively.
5. The method for detecting marine animals according to claim 4, characterized in that, In the modulation mechanism, the modulation scalar obtained by applying individual convolutions to the same input feature map x is incorporated into the deformable convolution as follows: w k Δp k and Δm k These are the weight at sampling point k, the learnable position offset, and the modulation scalar, respectively.
6. The method for detecting marine animals according to claim 3, characterized in that, The specific steps of the context attention mechanism in the Transformer block are as follows: The CoT module learns context keys by performing k×k grouped convolutions on the neighbor keys within all k×k grids in spatial geometry. The context key and query Q are concatenated, and the attention matrix is obtained through two consecutive 1×1 convolutions. The query operation is as follows: A=[K 1 ,Q]W θ W δ W θ W represents the weight matrix with a ReLU activation function. δ This represents the weight matrix without an activation function. The key represents the input 2D feature map, and Q represents the query matrix; Based on the context attention matrix A, all values are aggregated to compute the participating feature map K. 2 The aggregation method is as follows: Among them, K 2 A represents the dynamic context of the input, A is the context attention matrix, and V represents the definition of the values; The final output of the CoT module combines the static context with the input through an attention mechanism.
7. The method for detecting marine animals according to claim 3, characterized in that, Spatial pyramid pooling (SPPFCSPC) works by concatenating three independent pooling operations, as shown in the following expression: Where R represents the output result. This represents tensor concatenation, where F represents the input feature map. R1 indicates that the max pooling layer is filled with 2, and the kernel size is 3×3; R1 represents the output after the first pooling operation, whose gradient flows to the second pooling layer to obtain R2, and similarly to obtain R3; R4 represents the result obtained by concatenating the tensors of R1, R2, and R3.
8. The method for detecting marine animals according to claim 3, characterized in that, A 160*160 P2 small target detection head was added. The specific steps were as follows: Based on the three-scale detection of YOLOv8, a P2 branch detection head was introduced, and a 160×160 detection layer was used to process target detection.
9. A marine animal detection system based on an improved YOLOv8, characterized in that, include: Data acquisition module: used to acquire marine animal datasets; Marine animal monitoring model training module: used to input the marine animal dataset into the improved YOLOv8 model for training, and obtain the marine animal detection model; Detection Result Module: This module is used to input images of marine animals to be identified into the marine animal detection model to obtain the detection results of the marine animal species to be identified.