Lightweight fish detection method and system based on improved YOLOv8

By introducing FASTERBLOCK and CBAM in fish target detection algorithms, and using the WiOU loss function, the problem of accuracy and imbalance of the existing fish target detection algorithm and the imbalance of calculation quantity, realize the rapid and accurate fish density and distribution analysis analysis It improved the efficiency and accuracy of resource survey.

CN119380174APending Publication Date: 2025-01-28SHANDONG ACADEMY OF AGRICULTURAL SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411416745.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The existing fish object detection algorithm has problems of imbalance in accuracy and computational volume, which makes it impossible to be truly applied to real life.

Method used

Adopt a lightweight fish detection method and system based on the improvement of YOLOV8. By introducing FASTERBLOCK in FasterNet in the main network of YOLOV8 target detection algorithm to replace the Bottleneck module in the C2F to form the C2F-FASTER module, and embed the CBAM in the feature extraction layer, The replacement loss function CIOU is wiou.

Benefits of technology

Achieve rapid and accurately analyzing fish density and distribution, which greatly improves the efficiency and accuracy of resource survey.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380174A_ABST
    Figure CN119380174A_ABST
Patent Text Reader

Abstract

The invention provides a lightweight fish detection method and system based on improved YOLOv8. The method comprises the following steps: marking acquired historical fish detection images to obtain an image data set; a YOLOv8 target detection algorithm is established; training a target detection algorithm by using the fish detection image data set to obtain a trained target detection algorithm; wherein a Bottleneck module is replaced by Faster Block in a backbone network of the target detection algorithm; embedding CBAM in a feature extraction layer of a target detection algorithm; replacing a loss function CIoU with WIoU in a target detection algorithm; and inputting the current fish detection image into the trained target detection algorithm, and outputting a fish detection result. Based on the method, the invention further provides a lightweight fish detection system based on the improved YOLOv8, the fish density and distribution can be rapidly and accurately analyzed, and the efficiency and accuracy of resource investigation are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of fish detection, and in particular relates to a lightweight fish detection method and system based on improved YOLOv8. Background Art

[0002] With the continuous development of economy and the continuous increase of population, the demand for fish is also increasing. However, the traditional fish farming methods have the disadvantages of unreasonable resource utilization, serious environmental pollution and low production efficiency. These problems not only limit the sustainable development of fish farming, but also threaten the environment and human health. Therefore, transformation and upgrading and the adoption of precision farming models are imperative.

[0003] The application of fish target detection algorithms in aquaculture environments can help workers optimize the time and amount of feed delivery according to the number of fish, avoid waste, and improve feed utilization. At present, most fish target detection algorithms have the problem of imbalance between accuracy and computational complexity, which makes the algorithms unable to be truly applied in real life. Summary of the invention

[0004] In order to solve the above technical problems, the present invention proposes a lightweight fish detection method and system based on improved YOLOv8, which can quickly and accurately analyze fish density and distribution, greatly improving the efficiency and accuracy of resource surveys.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] A lightweight fish detection method based on improved YOLOv8, comprising the following steps:

[0007] Annotate the acquired historical fish detection images to obtain a fish detection image dataset;

[0008] A YOLOv8 target detection algorithm for fish detection is established; the YOLOv8 target detection algorithm is trained using a fish detection image dataset to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm.

[0009] Input the current fish detection image into the trained YOLOv8 target detection algorithm and output the fish detection result.

[0010] Furthermore, the process of labeling the acquired historical fish detection images includes:

[0011] The acquired historical fish detection images are annotated with tags to generate an XML file of the annotated form;

[0012] Then convert the xml type file into a txt type file.

[0013] Furthermore, the process of training the YOLOv8 target detection algorithm using the fish detection image dataset to obtain the trained YOLOv8 target detection algorithm includes:

[0014] The fish detection image dataset is divided into a training set, a validation set, and a test set according to a preset ratio;

[0015] The YOLOv8 target detection algorithm is trained using the training set; the output results of the YOLOv8 target detection algorithm after training are verified using the validation set; and the output results of the YOLOv8 target detection algorithm after training are tested using the test set.

[0016] Furthermore, the method also includes: the neck network of the YOLOv8 target detection algorithm adopts a PANet structure, removes the 1*1 downsampling layer, and finally sends the three output branches of PANet to the detection head for loss calculation or result solution through upsampling and channel fusion.

[0017] Furthermore, the method also includes that the YOLOv8 target detection algorithm adopts a decoupled head structure to separate the classification and detection heads.

[0018] Furthermore, the CBAM includes a channel attention module and a spatial attention module. The output feature map of the input feature map after passing through the channel attention module is then input into the spatial attention module to output the final feature map.

[0019] Furthermore, the feature map of the output of the channel attention module is expressed as:

[0020] M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F)));

[0021] Among them, AvgPool(F) is the average pooling feature; MaxPool(F) is the maximum pooling feature; σ is the sigmoid function; F is the input feature map; F'=M c (F).

[0022] Furthermore, the final feature map M output by the spatial attention module s (F') is expressed as:

[0023] M s (F') = σ(f7×7 ([AvgPool(F');MaxPool(F')]));

[0024] Among them, f 7×7 Represents a 7×7 convolutional layer.

[0025] Furthermore, the method further comprises: the YOLOv8 target detection algorithm adopts a bounding box regression loss function WIoU;

[0026] The calculation formula of WIoU is:

[0027] L Wlou =rR Wlou L Wlou ,R Wlou ∈[1,e),L lou ∈[0, 1];

[0028] Among them, R Wlou is the distance focusing mechanism; L lou is a common anchor frame; r is a non-monotonic focusing coefficient;

[0029] R Wlou L is used to enlarge the normal anchor box lou .

[0030] The present invention also proposes a lightweight fish detection system based on improved YOLOv8, including a preprocessing module, a building module and a detection module;

[0031] The preprocessing module is used to annotate the acquired historical fish detection images to obtain a fish detection image data set;

[0032] The establishment module is used to establish a YOLOv8 target detection algorithm for fish detection; the YOLOv8 target detection algorithm is trained using a fish detection image data set to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm.

[0033] The detection module is used to input the current fish detection image into the trained YOLOv8 target detection algorithm and output the fish detection result.

[0034] The effects provided in the content of the invention are only the effects of the embodiments, not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects:

[0035] The present invention proposes a lightweight fish detection method and system based on improved YOLOv8, the method comprising the following steps: annotating the acquired historical fish detection images to obtain a fish detection image data set; establishing a YOLOv8 target detection algorithm for fish detection; training the YOLOv8 target detection algorithm using the fish detection image data set to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; the loss function CIoU is replaced by WIoU in the target detection algorithm; the current fish detection image is input into the trained YOLOv8 target detection algorithm, and the fish detection result is output. Based on a lightweight fish detection method based on improved YOLOv8, a lightweight fish detection system based on improved YOLOv8 is also proposed, the present invention can quickly and accurately analyze fish density and distribution, greatly improving the efficiency and accuracy of resource surveys. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A flow chart of a lightweight fish detection method based on improved YOLOv8 proposed in Example 1 of the present invention;

[0037] Figure 2 A schematic diagram of the network structure of the improved YOLOv8 target detection algorithm proposed in Example 1 of the present invention;

[0038] Figure 3 A network diagram of the CBAM working process proposed in Example 1 of the present invention;

[0039] Figure 4 A network diagram of the working process of the channel attention module proposed in Example 1 of the present invention;

[0040] Figure 5 A network diagram of the working process of the spatial attention module proposed in Example 1 of the present invention;

[0041] Figure 6 This is a schematic diagram of the results of executing each loss function proposed in Example 1 of the present invention;

[0042] Figure 7 This is a schematic diagram of a lightweight fish detection system based on improved YOLOv8 proposed in Example 2 of the present invention. DETAILED DESCRIPTION

[0043] In order to clearly illustrate the technical features of the present solution, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings. The disclosure below provides many different embodiments or examples for realizing different structures of the present invention. In order to simplify the disclosure of the present invention, the components and settings of specific examples are described below. In addition, the present invention may repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed. It should be noted that the components illustrated in the accompanying drawings are not necessarily drawn to scale. The present invention omits the description of known components and processing techniques and processes to avoid unnecessary limitations on the present invention.

[0044] Example 1

[0045] Embodiment 1 of the present invention proposes a lightweight fish detection method based on improved YOLOv8, which is used to solve the technical problems existing in fish detection in the prior art. Figure 1 A flow chart of a lightweight fish detection method based on improved YOLOv8 proposed in Example 1 of the present invention;

[0046] In step S100, the acquired historical fish detection images are annotated to obtain a fish detection image dataset;

[0047] Data sets are collected through existing open source data sets and other resources on the Internet, and the data sets are cleaned and formatted in a unified manner.

[0048] Use software to annotate the objects in the image. Use Label Img software to annotate the fish image dataset with the label fish, generate an xml file with annotation format, and then convert it into a txt file. The following principles are followed when annotating the dataset: (1) The annotated box should fit the fish as closely as possible; (2) The fish that are occluded but less than two-thirds of the occlusion in the image should be annotated; (3) The fish that are more than two-thirds of the occlusion should not be annotated. After the annotation is completed, the dataset is divided into training set, validation set, and test set in a ratio of 8:1:1 for fish target detection.

[0049] In step S200, a YOLOv8 target detection algorithm for fish detection is established; the YOLOv8 target detection algorithm is trained using a fish detection image dataset to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm.

[0050] The YOLOv8 target detection algorithm is trained using the training set; the output results of the YOLOv8 target detection algorithm after training are verified using the validation set; and the output results of the YOLOv8 target detection algorithm after training are tested using the test set.

[0051] Figure 2 A schematic diagram of the network structure of the improved YOLOv8 target detection algorithm proposed in Example 1 of the present invention;

[0052] The YOLOv8 target detection algorithm established in this application consists of three parts: the backbone network, the neck network, and the head network, which work together to achieve efficient target detection capabilities.

[0053] In the backbone network, the YOLOv8 target detection algorithm replaces the C3 module in Yolov5 with the C2f module to achieve further lightweighting, while continuing to use the SPPF module in Yolov5. The C2f module significantly reduces the amount of calculation and improves the convergence speed and effect through more skip-layer connections and additional Split operations. At the same time, Darknet-53, as part of Backbone, draws on the idea of ​​ResNet and uses a large number of residual connections to alleviate the problem of gradient disappearance during training and make the model easy to converge.

[0054] The neck network part of the YOLOv8 target detection algorithm adopts the PANet structure, removes the 1*1 downsampling layer, and finally sends the three output branches of PANet to the Detect head for Loss calculation or result solution through upsampling and channel fusion.

[0055] The YOLOv8 target detection algorithm adopts the current mainstream decoupled head structure, separating the classification and detection heads, thereby improving performance. Compared with YOLOv5, the Yolov8 target detection algorithm has changed from Anchor-Based to Anchor-Free, reducing dependencies and enhancing flexibility.

[0056] The C2f module used in the YOLOv8 target detection algorithm contains a Bottleneck structure. Although the Bottleneck module can improve the network training speed and enhance the feature extraction capability. However, a large number of serially connected Bottleneck structures are used in YOLOv8, which brings a lot of computational overhead and also leads to excessive redundancy of channel information. To address this problem, FasterBlock in FasterNet is introduced to replace the Bottleneck module in C2f of YOLOv8 to form a C2f-Faster module to achieve lightweight network structure. The 2nd, 4th, 6th, 8th, 12th, 16th, 20th, and 24th layers of the improved YOLOv8 network structure are all C2f-Faster modules. The C2f-Faster module inherits the feature fusion capability of the C2f module and can effectively fuse low-level features with high-level features, thereby enhancing the model's utilization of detail information and semantic information. This multi-scale feature extraction enhances the model's perception of targets of different sizes. The C2f-Faster module shows significant advantages in improving the reasoning speed and accuracy of the YOLOv8 target detection model. Through partial convolution and efficient feature extraction, it not only optimizes the computing resource consumption, but also enhances the model's ability to detect objects of different scales.

[0057] The real fish breeding environment is complex. In order to suppress the interference of complex background features on detection and improve feature extraction capabilities, CBAM is embedded in the feature extraction layer of YOLOv8 to improve the detection accuracy of the model.

[0058] Figure 3 A network diagram of the CBAM working process proposed in Example 1 of the present invention;

[0059] CBAM includes a channel attention module and a spatial attention module. The output feature map of the input feature map after passing through the channel attention module is then input into the spatial attention module to output the final feature map.

[0060] Figure 4 A network diagram of the working process of the channel attention module proposed in Example 1 of the present invention;

[0061] The feature map output by the channel attention module is represented as:

[0062] M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F)));

[0063] Among them, AvgPool(F) is the average pooling feature; MaxPool(F) is the maximum pooling feature; σ is the sigmoid function; F is the input feature map; F'=M c (F).

[0064] The input feature map F (size is H×W×C) will be subjected to global maximum pooling and global average pooling respectively to obtain two 1×1×C feature maps. These two feature maps will be sent to a two-layer neural network (MLP) respectively, where the number of neurons in the first layer is C / r (r is the reduction rate, used to reduce the number of parameters), and the activation function is ReLU; the number of neurons in the second layer is C. This MLP is shared, that is, the two input feature maps share this path. The output feature map of the MLP will be added based on the element-wise operation, and then the channel attention feature map Mc will be generated through the Sigmoid activation function. Mc is element-wise multiplied with the input feature map F to obtain a new feature map F' for use by the spatial attention module.

[0065] Figure 5 A network diagram of the working process of the spatial attention module proposed in Example 1 of the present invention;

[0066] The final feature map M output by the spatial attention module s (F') is expressed as:

[0067] M s (F') = σ(f 7×7 ([AvgPool(F');MaxPool(F')]));

[0068] Among them, f 7×7 Represents a 7×7 convolutional layer.

[0069] The feature map F' output from the channel attention module is used as input, and global maximum pooling and global average pooling based on the channel are performed respectively to obtain two H×W×1 feature maps. The two feature maps are concat-operated based on the channel, and then reduced to a H×W×1 feature map through a 7×7 convolution layer. The convolution kernel size used here is 7×7 because the effect is better than 3×3. After the convolution operation, the spatial attention feature map M is generated through the Sigmoid activation function. s (F'). s (F') and F' are element-wise multiplied to obtain the final output feature map. AM significantly improves the performance of convolutional neural networks by combining channel attention and spatial attention mechanisms. This module not only focuses on important channel features, but also emphasizes key information in the spatial dimension, thus achieving excellent results in object detection.

[0070] Figure 6 This is a schematic diagram of the results of executing each loss function proposed in Example 1 of the present invention;

[0071] The YOLOv8 target detection algorithm comes with loss functions CIoU, DIoU, and EIoU, but the experimental results show that the effects of these three functions are not ideal. Later, WIoU was introduced as a loss function. The experimental results show that WIoU performs better than the first three functions. The loss function WIoU is a bounding box regression loss function that aims to optimize the accuracy and convergence speed of target detection through a dynamic non-monotonic mechanism. Compared with the traditional IoU loss, WIoU introduces a dynamic non-monotonic mechanism. By reasonably allocating gradient gains, it reduces large gradients or harmful gradients in extreme samples, thereby improving the generalization ability and overall performance of the network model. The core of the WIoU loss function lies in its dynamic non-monotonic focusing mechanism, which can dynamically adjust the focus of loss calculation according to the matching quality between the predicted box and the true box. This dynamic adjustment strategy enables WIoU to show better adaptability when processing samples of different qualities. In the calculation process, the WIoU loss function first constructs distance attention through distance metric to ensure that the loss calculation can fully consider the distance factor between the predicted box and the true box. This step is achieved through a two-layer attention mechanism. Then, the distance attention is weighted by the non-monotonic focusing coefficient to form the final WIoU loss value. This weighting method allows the loss function to pay more attention to samples of average quality, rather than just optimizing samples of extremely good or poor quality.

[0072] The calculation formula of WIoU is:

[0073] L Wlou =rR Wlou L Wlou ,R Wlou ∈[1,e),L lou ∈[0, 1];

[0074] Among them, R Wlou is the distance focusing mechanism; L Wlou is a common anchor frame; r is a non-monotonic focusing coefficient.

[0075] Distance Focus Mechanism R Wlou L is used to enlarge the normal anchor box lou , and R Wlou ∈[1, e) will significantly amplify L lou The non-monotonic focusing factor r is used to focus on anchor boxes of normal quality. The non-monotonic focusing factor is a factor used to adjust the degree of match between the predicted box and the true annotation box. Unlike the monotonic focusing factor, the non-monotonic focusing factor allows dynamic adjustment of the degree of match within different IoU value ranges, thereby more finely evaluating the model performance.

[0076] The WIoU loss function effectively improves the performance and generalization ability of the target detection model through its unique dynamic non-monotonic focusing mechanism and distance attention construction.

[0077] In step S300, the current fish detection image is input into the trained YOLOv8 target detection algorithm, and the fish detection result is output.

[0078] The trained YOLOv8 object detection algorithm will directly regress at multiple locations in the output image and output bounding boxes and classification categories for multiple objects.

[0079] Embodiment 1 of the present invention proposes a lightweight fish detection method based on improved YOLOv8, which takes fish grown in a breeding environment as the research object, establishes a fish data set to address the problem of low target detection recognition rate caused by mutual occlusion between fish; uses the improved YOLOv8 target detection algorithm to complete the target detection task more accurately and quickly.

[0080] A lightweight fish detection method based on improved YOLOv8 proposed in Example 1 of the present invention adopts WIoU as the loss function. The convergence loss value and convergence speed of the WIoU loss function are better than CIoU, DIoU and GIoU. In order to achieve the goal of lightweight model, FasterBlock is introduced to form the C2f-Faster module. Compared with the original model, the weight of the improved model is reduced to 80% of the original model. In addition, in order to reduce the accuracy loss and occlusion problems caused by lightweight model, the CBAM attention mechanism is introduced, and the accuracy of the improved model is improved.

[0081] Example 2

[0082] Based on the lightweight fish detection method based on improved YOLOv8 proposed in Example 1 of the present invention, Example 2 of the present invention further proposes a lightweight fish detection system based on improved YOLOv8.

[0083] Figure 7 A schematic diagram of a lightweight fish detection system based on improved YOLOv8 proposed in Example 2 of the present invention, the system comprising: a preprocessing module, a building module and a detection module;

[0084] The preprocessing module is used to annotate the acquired historical fish detection images to obtain a fish detection image dataset;

[0085] A module is established to establish a YOLOv8 target detection algorithm for fish detection; the YOLOv8 target detection algorithm is trained using a fish detection image data set to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm.

[0086] The detection module is used to input the current fish detection image into the trained YOLOv8 target detection algorithm and output the fish detection result.

[0087] In the preprocessing module: the process of labeling the acquired historical fish detection images includes: labeling the acquired historical fish detection images with labels to generate an xml type file with a labeling form; and then converting the xml type file into a txt type file.

[0088] In the establishment module: the process of using the fish detection image data set to train the YOLOv8 target detection algorithm to obtain the trained YOLOv8 target detection algorithm includes: dividing the fish detection image data set into a training set, a verification set, and a test set according to a preset ratio; using the training set to train the YOLOv8 target detection algorithm; using the verification set to verify the output result of the trained YOLOv8 target detection algorithm; and using the test set to test the output result of the trained YOLOv8 target detection algorithm.

[0089] The neck network of the YOLOv8 target detection algorithm adopts the PANet structure, removes the 1*1 downsampling layer, and finally sends the three output branches of PANet to the detection head for loss calculation or result solution through upsampling and channel fusion.

[0090] The YOLOv8 target detection algorithm adopts a decoupled head structure to separate the classification and detection heads.

[0091] CBAM includes a channel attention module and a spatial attention module. The output feature map of the input feature map after passing through the channel attention module is then input into the spatial attention module to output the final feature map.

[0092] The feature map output by the channel attention module is represented as:

[0093] M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F)));

[0094] Among them, AvgPool(F) is the average pooling feature; MaxPool(F) is the maximum pooling feature; σ is the sigmoid function; F is the input feature map; F'=M c (F).

[0095] The final feature map M output by the spatial attention module s (F') is expressed as:

[0096] M s (F') = σ(f 7×7 ([AvgPool(F');MaxPool(F')]));

[0097] Among them, f 7×7 Represents a 7×7 convolutional layer.

[0098] The YOLOv8 target detection algorithm uses the bounding box regression loss function WIoU;

[0099] The calculation formula of WIoU is:

[0100] L Wlou =rR Wlou L Wlou ,R Wlou ∈[1,e),L lou ∈[0, 1];

[0101] Among them, R Wlou is the distance focusing mechanism; L lou is a common anchor frame; r is a non-monotonic focusing coefficient;

[0102] R Wlou L is used to enlarge the normal anchor box lou .

[0103] In the detection module, the trained YOLOv8 object detection algorithm will directly regress at multiple locations of the output image and output the bounding boxes and classification categories of multiple objects.

[0104] Embodiment 2 of the present invention proposes a lightweight fish detection system based on improved YOLOv8, which takes fish grown in a breeding environment as the research object, establishes a fish data set to address the problem of low target detection and recognition rate caused by mutual occlusion between fish; uses the improved YOLOv8 target detection algorithm to complete the target detection task more accurately and quickly.

[0105] Embodiment 2 of the present invention proposes a lightweight fish detection system based on improved YOLOv8, which uses WIoU as the loss function. The convergence loss value and convergence speed of the WIoU loss function are better than CIoU, DIoU and GIoU. In order to achieve the goal of lightweight model, FasterBlock is introduced to form the C2f-Faster module. Compared with the original model, the weight of the improved model is reduced to 80% of the original model. In addition, in order to reduce the accuracy loss and occlusion problems caused by lightweight model, the CBAM attention mechanism is introduced, and the accuracy of the improved model is improved.

[0106] For the description of the relevant parts of a lightweight fish detection system based on improved YOLOv8 provided in Example 2 of the present application, please refer to the detailed description of the corresponding parts in a lightweight fish detection method based on improved YOLOv8 provided in Example 1 of the present application, which will not be repeated here.

[0107] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment that includes a series of elements are inherent to the elements. In the absence of more restrictions, the elements limited by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or equipment that includes the elements. In addition, the above-mentioned technical solution provided in the embodiment of the present application is consistent with the corresponding technical solution in the prior art in principle, and the part is not described in detail, so as not to repeat too much.

[0108] Although the above describes the specific implementation of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. For those skilled in the art, other different forms of modifications or deformations can be made on the basis of the above description. It is not necessary and impossible to list all the implementation methods here. On the basis of the technical solution of the present invention, various modifications or deformations that can be made by those skilled in the art without creative work are still within the scope of protection of the present invention.

Claims

1. A lightweight fish detection method based on improved YOLOv8, characterized in that: The following steps are involved: Annotate the acquired historical fish detection images to obtain a fish detection image dataset; A YOLOv8 target detection algorithm for fish detection is established; the YOLOv8 target detection algorithm is trained using a fish detection image dataset to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm. Input the current fish detection image into the trained YOLOv8 target detection algorithm and output the fish detection result.

2. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The process of labeling the acquired historical fish detection images includes: The acquired historical fish detection images are annotated with tags to generate an XML file of the annotated form; Then convert the xml type file into a txt type file.

3. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The process of training the YOLOv8 target detection algorithm using the fish detection image data set to obtain the trained YOLOv8 target detection algorithm includes: The fish detection image dataset is divided into a training set, a validation set, and a test set according to a preset ratio; The YOLOv8 target detection algorithm is trained using the training set; the output results of the YOLOv8 target detection algorithm after training are verified using the validation set; and the output results of the YOLOv8 target detection algorithm after training are tested using the test set.

4. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The method also includes: the neck network of the YOLOv8 target detection algorithm adopts a PANet structure, removes a 1*1 downsampling layer, and finally sends the three output branches of PANet to the detection head for loss calculation or result solution through upsampling and channel fusion.

5. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The method also includes that the YOLOv8 target detection algorithm adopts a decoupled head structure to separate the classification and detection heads.

6. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The CBAM includes a channel attention module and a spatial attention module. The output feature map of the input feature map after passing through the channel attention module is then input into the spatial attention module to output the final feature map.

7. A lightweight fish detection method based on improved YOLOv8 according to claim 6, characterized in that: The feature map output by the channel attention module is represented as: M c (F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F))); Among them, AvgPool(F) is the average pooling feature; MaxPool(F) is the maximum pooling feature; σ is the sigmoid function; F is the input feature map; F'=M c (F).

8. A lightweight fish detection method based on improved YOLOv8 according to claim 7, characterized in that: The final feature map M output by the spatial attention module s (F') is expressed as: M s (F')=σ(f 7×7 ([AvgPool(F');MaxPool(F')])); Among them, f 7×7 Represents a 7×7 convolutional layer.

9. A lightweight fish detection method based on improved YOLOv8 according to claim 1, characterized in that: The method also includes: the YOLOv8 target detection algorithm adopts a bounding box regression loss function WIoU; The calculation formula of WIoU is: L Wlou =rR Wlou L Wlou ,R Wlou ∈[1,e),L lou ∈[0,1]; Among them, R Wlou is the distance focusing mechanism; L lou is a common anchor frame; r is a non-monotonic focusing coefficient; R Wlou L is used to enlarge the normal anchor box lou .

10. A lightweight fish detection system based on improved YOLOv8, characterized in that: It includes a pre-processing module, a building module and a detection module; The preprocessing module is used to annotate the acquired historical fish detection images to obtain a fish detection image data set; The establishment module is used to establish a YOLOv8 target detection algorithm for fish detection; the YOLOv8 target detection algorithm is trained using a fish detection image data set to obtain a trained YOLOv8 target detection algorithm; wherein FasterBlock in FasterNet is introduced into the backbone network of the YOLOv8 target detection algorithm to replace the Bottleneck module in C2f to form a C2f-Faster module; and CBAM is embedded in the feature extraction layer of the YOLOv8 target detection algorithm; and the loss function CIoU is replaced by WIoU in the target detection algorithm. The detection module is used to input the current fish detection image into the trained YOLOv8 target detection algorithm and output the fish detection result.