Fish feeding strength detection method based on improved YoLoV8n
By improving the YoLoV8n network, using ABS convolution, SE attention mechanism and BiFPN connection, combined with αWIoU loss function, the problem of poor timeliness detection of existing fish feeding behavior is solved, and high accuracy and efficient fish feeding strength are achieved Testing, optimizes feed feeding and water quality management of aquaculture.
Patent Information
- Application Number
- CN202411246151.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-10
AI Technical Summary
The current aquaculture method for fish feeding behavior detection is poor in timeliness, making it difficult to quickly and accurately judge the strength of fish feeding, which affects the efficiency of feeding and water quality management.
Improve the YoLoV8n network, replace the CBS convolution of the Backbone layer into ABS convolution, introduce the SE attention mechanism, use BiFPN connection, and build an αWIoU loss function to improve the accuracy of the model's feature extraction and loss function.
It significantly improves the accuracy and speed of fish feed strength detection, provides better theoretical basis and data support, and optimizes fish feed feeding and water quality management.
Smart Images

Figure CN119107501A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for detecting fish feeding intensity based on improved YoLoV8n. Background Art
[0002] In intensive aquaculture, the feeding level of fish directly determines the production efficiency and breeding costs. Overfeeding not only causes feed waste, but also the decomposition of residual feed will produce toxic substances such as ammonia nitrogen, leading to eutrophication of water bodies and increasing the risk of fish disease; insufficient feed will increase the aggressiveness of fish, and they are prone to fight for food and cause injuries. Real-time quantification of fish feeding behavior and adjustment of feeding based on this will help solve the above problems; detecting fish feeding actions can obtain information such as fish feeding frequency and feeding time, providing theoretical basis and data support for optimizing feed placement.
[0003] At present, the research on aquaculture feeding intensity detection methods mainly focuses on the counting of aquatic animals and feed particles based on machine learning, while there are relatively few studies on the judgment of fish feeding behavior.
[0004] The patent with publication number CN114419432A performs cluster analysis on the fish position information in the image to be tested, obtains the fish aggregation degree, and identifies and counts the floating bait in the image to be tested; the obtained fish aggregation degree and the number of floating baits are input into the trained feeding intensity assessment model to obtain the feeding intensity type output by the feeding intensity assessment model. The feeding intensity assessment model adopts the BP neural network model, but too many or too few hidden layers of the BP neural network will affect the learning speed, local maximum values and under-fitting problems.
[0005] The patent with publication number CN116229501A uses the YOLO neural network and integrates the GMM Gaussian mixture model, inputs the fish key frame image set into the GMM Gaussian mixture model for moving target detection operation, obtains the GMM fish target bounding box, inputs the fish key frame image set into the YOLO neural network model for moving target detection target bounding box, and judges whether the GMM fish target bounding box and / or the YOLO fish target bounding box is a real fish target bounding box according to the preset judgment logic. This method takes a long time to detect, while the behavior of fish is rapid. It is difficult to detect quickly using this method, and judgment cannot be made in time, and the timeliness is poor. Summary of the invention
[0006] In view of the shortcomings of the existing methods, the present invention is based on an improved YoLoV8n network to identify the images of the water splashes caused by fish feeding and the degree of aggregation, accurately identify the feeding strength of fish, and provide a basis for feeding in fish farming.
[0007] The technical solution adopted by the present invention is: a method for detecting the feeding strength of fish based on improved YoLoV8n comprises the following steps:
[0008] Step 1: Collect fish feeding images, and mark and pre-process the images;
[0009] As a preferred embodiment of the present invention, the fish school feeding image includes: strong feeding and weak feeding.
[0010] As a preferred embodiment of the present invention, the feeding intensity is determined based on the fish gathering and water surface conditions.
[0011] As a preferred implementation of the present invention, preprocessing includes: image size adjustment and data enhancement.
[0012] Step 2: Build an improved YoLoV8n network, replace the CBS convolution of the Backbone layer with ABS convolution, and use AKConv for ABS convolution with a convolution kernel size of 3×3. AKConv is used to reduce the number of parameters in the Backbone layer and improve detection accuracy.
[0013] As a preferred embodiment of the present invention, improving the YoLoV8n network also includes: introducing the SE attention mechanism after the SPFF module of the Backbone layer.
[0014] As a preferred implementation of the present invention, improving the YoLoV8n network also includes: replacing the Concat connection of the Neck layer with a BiFPN connection.
[0015] As a preferred embodiment of the present invention, improving the YoLoV8n network also includes: replacing the CBS convolution of the Detect layer with an ABS convolution.
[0016] As a preferred embodiment of the present invention, improving the YoLoV8n network further includes: improving the loss function of the detection frame and constructing an αWIoU loss function, the formula is:
[0017] L α-WIoUv1 =R α-WIoU ×L α-IoU (4)
[0018]
[0019] L α-IoU =1-IoU α (6)
[0020] Where x and y represent the coordinates of the center point of the prediction box; gt and gt Represents the coordinates of the center point of the real box; Hg and W g Respectively represent the height and width of the minimum enclosed box formed by the predicted box and the true box; * represents H g and W g Separated from the computation graph; α is the exponentiation parameter.
[0021] As a preferred embodiment of the present invention, a fish feeding intensity detection system based on improved YoLoV8n includes: a memory for storing instructions executable by a processor; and a processor for executing instructions to implement a fish feeding intensity detection method based on improved YoLoV8n.
[0022] As a preferred embodiment of the present invention, a computer-readable medium stores a computer program code, and when the computer program code is executed by a processor, a method for detecting the intensity of fish feeding based on the improved YoLoV8n is implemented.
[0023] Beneficial effects of the present invention:
[0024] 1. Use AKConv to replace the CBS ordinary convolution layer and replace the CBS modules of Backbone and Head to improve the model feature extraction capability and reduce the number of model parameters;
[0025] 2. Replace the Concat connection of the Neck network with the bidirectional pyramid network BiFPN, and use BiFPN to fuse features of different scales to improve the generalization ability of the model;
[0026] 3. Introduce the SEA attention module after the SPFF model of the Backbone network to improve the model's ability to express implicit features;
[0027] 4. Improve the loss function. Use the power parameter to improve the loss function, fully consider the direction angle between the predicted box and the real box, and significantly improve the accuracy of the detection box. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a network structure diagram based on the improved YoLoV8n of the present invention;
[0029] Figure 2 is the initial sampling coordinate map of any convolution kernel size;
[0030] Figure 3 (a), (b) and (c) are the structure diagrams of FPN, PANet and BiFPN models respectively;
[0031] Figure 4 It is the module diagram of SE algorithm;
[0032] Figure 5 It is the SE process module diagram;
[0033] Figure 6 It is a schematic diagram of calculation parameters of the present invention;
[0034] Figure 7 It is the existing YoLoV8n PR map;
[0035] Figure 8 It is to improve the YoLoV8n PR map;
[0036] Fig. 9 This is a diagram showing the effect of identifying fish feeding intensity. DETAILED DESCRIPTION
[0037] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.
[0038] like Figure 1 As shown, a method for detecting fish feeding strength based on improved YoLoV8n comprises the following steps:
[0039] Step 1: Collect images of fish schools and classify them according to their feeding intensity, into strong feeding and weak feeding, and collect at least 500 images of each type;
[0040] The collected fish feeding intensity image set is preprocessed, including image resizing and data enhancement. The image resizing is performed using an adaptive image scaling mechanism. While scaling the image length and width, the remaining part is filled with gray to achieve a uniform resolution for the input image.
[0041] The labelimg dataset annotation method was used to annotate the fish types and assign strong feeding and weak feeding label information. The annotated data was directly exported as a YoLo format txt file, which recorded the fish behavior, water surface waves, location information, etc.; fish schools with high aggregation and water splashes on the water surface indicate strong feeding; fish schools with dispersed and calm water surface indicate weak feeding; finally, the annotated dataset was divided into training set, validation set, and test set in a ratio of 8:1:1.
[0042] Step 2: Use the training set to train the improved YoLoV8n model;
[0043] In the Backbone layer and the Head layer, the CBS module is replaced by the ABS module. The ABS module includes an adjustable kernel convolution (AKConv). The AKConv convolution gives the convolution kernel any number of parameters and any sampling shape, providing more choices for the trade-off between network overhead and performance. AKConv uses the feature that the number of convolution parameters can be linearly increased or decreased. AKConv selects a 3×3 convolution kernel to reduce the number of convolution parameters as an alternative to lightweight models. AKConv requires an irregular sampling network, so it is designed to generate the convolution kernel P. n The algorithm for the initial sampling coordinates of Figure 2 As shown, it shows the initial sampling coordinates generated by convolution of any size; because irregular convolutions rarely have a center point in terms of size, in order to adapt to the convolution size used, (0,0) is set as the sampling origin in the upper left corner of the algorithm. The corresponding convolution operation at position P0 is defined as follows:
[0044] Conv(P0)=∑ω×(P0+P n ) (1)
[0045] In the formula, ω represents the convolution parameter. Through a series of operations, AKConv solves the problem that irregular sampling coordinates cannot match the corresponding size of convolution operations.
[0046] Replace the Concat of YoLoV8n's Neck network with the Concat-BiFPN structure. In the Neck structure, multiple upsampling and downsampling operations will change the resolution of the image, resulting in loss of image feature information, which will further lead to insufficient learning of the model on the fish feeding characteristics, resulting in false detection and missed detection. The BiFPN structure increases the information transmission between feature maps of different network levels through jump links, so that the feature maps have more location information and detail information, which can help the model better focus on the fish feeding behavior. The BiFPN structure has fewer network nodes than the PANet structure, and the jump connection does not increase the fusion nodes. The introduction of BiFPN can exchange a small amount of computational cost for greater model performance benefits. The network structures of FPN, PANet and BiFPN are as follows: Figure 3 as shown in (a)(b)(c).
[0047] The core idea of the SE attention mechanism is to use two fully connected layers to calculate a vector for weighted average pooling of input information to obtain a 1×1×C weight matrix; Figure 4 As shown, different colors represent different values, which are used to measure the importance of the channel.
[0048] The SE attention mechanism consists of two main steps: squeeze and excitation; compression is to compress the information of each channel of the input feature map through a global average pooling operation; this means that for each channel, the average value of all spatial positions in the channel is calculated to obtain a global channel feature description; the purpose is to reduce the dimension of the feature map and convert the information of each channel into a scalar for subsequent calculations; excitation is to learn the weight of each channel through two fully connected (FC) layers to determine the corresponding importance of each channel; the first FC layer usually has a smaller dimension for dimensionality reduction, while the output of the second FC layer is a weight vector with the same number of channels; this weight vector represents the importance of each channel, that is, which channels are more critical to the current task.
[0049] The SE attention mechanism finally obtains a weighted feature map by multiplying the original feature map with the calculated channel weights channel by channel; this means that more important channels have higher weights in the final feature representation, while less important channels have lower weights. The generated weight matrix S (1×1×C) is multiplied by the corresponding channel of the feature map U (H×W×C), as shown in Figure 5 As shown in the figure, the H×W values of each channel in the feature map U are multiplied by the weight of the corresponding channel in S, and finally the extracted feature information is obtained; in addition, since the calculation of SE is differentiable and usually does not change the number of channels of the model, the SE attention mechanism can be directly embedded in the neural network model for training without the need for additional complex training process.
[0050] Adding the SE attention module after the SPPF layer can help the model automatically select important parts from the input information for processing, reducing the interference of irrelevant information on the model; and help the Backbone layer consciously extract the feature points belonging to the feeding behavior of fish, thereby achieving better detection effects and higher detection accuracy.
[0051] IoU (Intersection over Union) is the intersection ratio, which is the most commonly used indicator in target detection. In anchor-based methods, it is used to determine positive samples and negative samples. It can also be used to evaluate the distance between the output box (predictbox) and the ground-truth. Figure 6 As shown in (2), the IoU formula is:
[0052]
[0053] Where A represents the area of the predicted box, and B represents the area of the real box.
[0054] The existing YoLoV8n model uses the distance intersection-over-union loss function (DFL) and CIoU to calculate the regression loss of the bounding box, where the formula of CIoU is shown in formula (3):
[0055]
[0056] Among them, ρ 2 (b,b gt ) represents the Euclidean distance between the centroid of the real box and the predicted box, h and w represent the height and width of the predicted box, h gt and w gt Indicates the height and width of the real box, C h and C w Represent the height and width of the minimum enclosing box formed by the predicted box and the true box, respectively.
[0057] CIoU does not take into account the direction of mismatch between the true box and the predicted box, and uses the aspect ratio as one of the penalty factors of the loss function. If the aspect ratio of the true box and the predicted box is the same, but the width and height values are different, the penalty term cannot reflect the actual difference between the two boxes, resulting in reduced CIoU calculation accuracy.
[0058] WIoU combines a dynamic non-monotonic focusing mechanism and uses "outliers" to evaluate the quality of anchor boxes. The larger the outlier, the lower the quality of the anchor box, and its anchor box will be assigned a smaller gradient gain to focus the bounding box regression on higher quality anchor boxes.
[0059] Construct an αWIoU loss function that adaptively improves the weights of loss and gradient:
[0060] L α-WIoUv1 =R α-WIoU ×L α-IoU (4)
[0061]
[0062] L α-IoU =1-IoU α (6)
[0063] In the formula, x and y represent the coordinates of the center point of the prediction box, x gt and gt Represents the coordinates of the center point of the real box, H g and W g Respectively represent the height and width of the minimum enclosed box formed by the predicted box and the true box; * represents H g and W gIt is separated from the computational graph to avoid creating gradients that affect convergence; α is a unified power parameter representing the existing loss based on IoU; the α value is obtained by continuous optimization, and in this embodiment, α=2.
[0064] The parameter α is suitable for accurate prior box regression and object detection, providing stronger robustness for small datasets, as the accuracy of region box regression is improved.
[0065] The idea of transfer learning is used to use the YoLoV8n.pt weights as the improved training weights for the fish feeding intensity target detection model. At the same time, the default hyperparameters obtained by training YoLoV8n in the COCO dataset are used, with the learning rate set to 0.01; the hyperparameter optimization is set to SGD; the learning rate momentum is set to 0.937; the batch size is set to 32; and the number of iterations is set to 200.
[0066] In order to verify whether the improved YoLoV8n model of the present invention is effective, ablation experiments are carried out on five groups of networks using the same data set, and the experimental results are analyzed. The specific parameters are shown in Table 2.
[0067] As shown in Table 1 and Figure 7 , 8 As shown in the figure, numbers represent improved models. Models 2, 3, 4, 5, 6, and 7 are improvements to the original model: αWIoU loss function replaces the original loss function, BiFPN module replaces the PANet structure of the original model, SE attention mechanism module is added, AKConv replaces the ordinary convolution of the CBS module of Backbone; AKConv replaces the ordinary convolution of the CBS module of Detect; AKConv replaces the ordinary convolution of the CBS module of Backbone and Detect. In this process, only a single module is modified; Model 8 improves 4 modules at the same time, and these 5 models are used to detect the same image.
[0068] Table 1 Comparison of ablation test results
[0069]
[0070] It can be seen from the experimental data that under the same experimental conditions, after changing the loss function to SIoU, the model accuracy, recall rate and average precision increased by 4.8%, 1.2% and 1.2% respectively. Using the BiFPN structure to replace the PANet structure, the model accuracy, recall rate and average precision increased by 2.7%, 1.3% and 0.7% respectively. After adding the SE attention mechanism, the model accuracy, recall rate and average precision increased by 5.6%, 2.6% and 5% respectively. Using AKConv (variable kernel convolution) to replace the convolution layer of the CBS module, the model accuracy, recall rate and average precision increased by 2.9%, -0.4% and 0.5% respectively; compared with the YoLoV8n model, the improved model accuracy, recall rate and average precision increased by 11.9%, 4.9% and 6.7% respectively.
[0071] Improved YoLoV8n improves the accuracy and detection speed of the model on a lightweight basis; Fig. 9 It is a schematic diagram of the YoLoV8n model for detecting fish feeding intensity targets before and after improvement. It can be seen that the improved model also has a good detection effect in dense fish images; therefore, the method of the present invention has the advantages of high recognition accuracy, fast recognition speed, and low memory occupancy.
[0072] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A fish feeding strength detection method based on improved YoLoV8n, characterized in that: The following steps are involved: Step 1: Collect fish feeding images, and mark and pre-process the images; Step 2: Build an improved YoLoV8n network, replace the CBS convolution of the Backbone layer with ABS convolution, and use AKConv for ABS convolution with a convolution kernel size of 3×3. AKConv is used to reduce the number of parameters in the Backbone layer and improve detection accuracy.
2. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Improvements to the YoLoV8n network also include: introducing the SE attention mechanism after the SPFF module in the Backbone layer.
3. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Improving the YoLoV8n network also includes replacing the Concat connection of the Neck layer with a BiFPN connection.
4. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Improving the YoLoV8n network also includes replacing the CBS convolution of the Detect layer with ABS convolution.
5. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Improving the YoLoV8n network also includes: improving the loss function of the detection box and constructing the αWIoU loss function, the formula is: L α-WIoUv1 =R α-WIoU ×L α-IoU (4) L α-IoU =1-IoU α (6) Where x and y represent the coordinates of the center point of the prediction box; gt and gt Represents the coordinates of the center point of the real box; H g and W g Respectively represent the height and width of the minimum enclosed box formed by the predicted box and the true box; * represents H g and W g Separated from the computation graph; α is the exponentiation parameter.
6. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Fish feeding images include: strong and weak feeding.
7. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: The intensity of feeding is determined by the aggregation of fish and the water surface conditions.
8. The method for detecting fish feeding strength based on improved YoLoV8n according to claim 1, characterized in that: Preprocessing includes: Image resizing and data augmentation.
9. The fish feeding strength detection system based on improved YoLoV8n is characterized by: include: a memory for storing instructions executable by a processor; A processor, used for executing instructions to implement the fish feeding intensity detection method based on the improved YoLoV8n as described in any one of claims 1-8.
10. A computer readable medium storing computer program code, characterized in that: When the computer program code is executed by a processor, the method for detecting the intensity of fish feeding based on the improved YoLoV8n as described in any one of claims 1 to 8 is implemented.
