Fish body growth prediction method
By combining YOLOv8 and Zhuang-Suen skeleton algorithms, Gompertz curves are generated, which solves the problem that traditional methods cannot predict fish growth, realizes accurate prediction of fish growth and dynamic adjustment of breeding strategies, and improves the efficiency and health of fish farming situation.
Patent Information
- Application Number
- CN202411523593.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2024-11-26
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional methods cannot effectively predict the growth of fish, and deep learning technology may lead to the omission of important feature information in complex growth environments, so it is impossible to adjust breeding strategies in real time.
The YOLOv8 deep neural network algorithm and Zhuang-Suen skeleton algorithm were used to predict the growth of fish by image processing and fitting the Gompertz growth curve, and the breeding strategy was adjusted according to the growth rate.
Accurate prediction of fish growth and dynamic adjustment of breeding strategies have been achieved, and the efficiency and health of fish farming have been improved.
Smart Images

Figure CN119027797A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of aquaculture, and in particular to a method for predicting fish growth. Background Art
[0002] Aquaculture is an important part of global food production and is now a major force in economic development. The huge demand for aquatic products has brought huge pressure on aquaculture. Therefore, improving the yield and quality of aquaculture and ensuring the growth and health of fish have become a top priority.
[0003] However, traditional methods, including manual measurement and observation, are not able to cope with this challenge well. Although these methods are commonly used, they are inefficient and may cause harm to fish, leading to challenges to fish welfare and health.
[0004] In this context, non-invasive detection technology based on machine vision has now been widely used in aquaculture. It has gradually replaced the inefficient traditional manual operation method because of its advantages of automatically collecting high-quality data and avoiding interference with fish growth. However, the application of such technology in the analysis process still requires the help of traditional image processing and machine learning technology. Of course, these technologies have certain limitations. For example, in complex growth environments, important feature information may be omitted due to reliance on manual feature extraction.
[0005] The emergence of deep learning technology has made it possible to overcome this challenge. Deep learning has the ability to efficiently process large amounts of data and obtain more accurate results. In particular, it has made great progress in vision-based information processing. For identifying target categories and locating target positions, deep learning-based target detection technology has given us a perfect answer. Its performance is so good that it has gradually been applied to aquaculture fields such as fish population monitoring, body length measurement, and behavior pattern analysis.
[0006] The object detection algorithm YOLOv8 is one of the well-known deep learning algorithms. When used, it can use the structural advantages of the deep learning network to detect fish with high precision and accurately segment fish from the background. Therefore, it is widely used to measure the body length of fish. Through YOLOv8, we can obtain the information and mask of the fish in the current video frame or picture, and get a binary image. Then, by introducing skeleton extraction algorithms, such as the Zhuang-Suen skeleton algorithm and the K3M algorithm, we can derive the relationship between skeleton length and body weight. However, this method can only analyze the immediate state of the fish and cannot predict the growth of the fish. For this reason, we propose a fish growth prediction method. Summary of the invention
[0007] To solve the above problems, the present invention provides a method for predicting fish growth. By using the YOLOv8 deep neural network algorithm and the Zhuang-Suen skeleton algorithm, we can identify the length of the fish and calculate the weight of the fish through the established logistics model. Then, we can collect weight data at different time points, fit these data, obtain the Gompertz growth curve of the fish, judge the growth of the fish, and adjust the breeding strategy.
[0008] To achieve the above object, the technical solution adopted by the present invention is: A method for predicting fish growth, comprising: Acquire fish images through a detection device, and input the fish images into a trained YOLOv8 detection model; Perform feature extraction on the fish image by using the YOLOv8 detection model to generate a feature map; Using an Anchor-free mechanism on the feature map, generating a target bounding box, wherein the target bounding box represents a position of the target in the image; Using binary cross entropy as classification loss to determine the confidence that the target bounding box is a fish body; The YOLOv8 detection model outputs a binary Mask for the target bounding box that meets the threshold, and the fish body shape is obtained through the binary Mask; Use the ZHUANG-SUEN skeleton algorithm to obtain the skeleton length of the fish, and use the logistics growth equation to obtain the weight of the fish at time t. , the expression of the logistics growth equation is: ; Among them, a is a dimensionless quantity, b is a constant, and l is the length of the fish body; A Gompertz curve is established according to the length of the fish skeleton, and the growth of the fish body is judged by the Gompertz curve. The expression of the Gompertz curve is: ; in, is the normal maximum weight of the fish, and k is the growth rate constant.
[0009] Preferably, the training of the YOLOv8 detection model includes: Obtain images of the fish to be tested through the detection equipment, calibrate the images and divide them into training set, verification set and test set; The YOLOv8 detection model is initialized using the transfer learning idea of the deep neural algorithm and the weights of the C0C0 public data set; After the YOLOv8 detection model is detected, the YOLOv8 detection model is trained using the training set. During the training process, the YOLOv8 detection model is evaluated using the validation set, and a validation curve is established according to the evaluation result. If the slope of the validation curve changes less than a preset value, the training is stopped, otherwise the number of the training sets is increased.
[0010] Preferably, the generating a target bounding box by using an Anchor-free mechanism on the feature map comprises: Generate the size of the fitted object based on the border distance / key point position of the feature map; Based on the dimensions, the location of the central area is obtained; The distances from the central area to each frame are predicted according to the position of the central area, and a series of target bounding boxes are generated according to the distances.
[0011] Preferably, the YOLOv8 detection model outputs a binary Mask for a target bounding box that meets a threshold, and obtaining the fish body shape through the binary Mask includes: Generate a binary mask of the same size as the target through an instance segmentation algorithm, where the target area is marked as white and the background area is marked as black; The target bounding box that meets the threshold is used as the input of the instance segmentation algorithm, and the decomposed target bounding box is superimposed on the original image of the target to obtain the shape of the fish body.
[0012] Preferably, the ratio of the training set, the validation set and the test set is 7:2:1.
[0013] Preferably, the preset value is 0.5.
[0014] The beneficial effects of the present invention are: The present application uses the YOLOv8 model to extract features from the fish image and generate a feature map, uses binary cross entropy as the classification loss, and judges the confidence of the target bounding box. The YOLOv8 detection model outputs a binary Mask for the target bounding box that meets the threshold to obtain the shape of the fish body, and uses the ZHUANG-SUEN skeleton algorithm to obtain the skeleton length of the fish. The weight of the fish body at the current time is obtained through the relationship between the skeleton length and the weight. Sampling can be performed every few days to obtain multiple groups of weight data. The growth rate constant of the fish body is obtained through the Gompertz curve, and it can be compared with the normal growth rate constant. The generation of the fish body is obtained through the difference in comparison. The breeding strategy can also be adjusted through the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1This is a flow chart of a method for predicting fish growth in a specific embodiment of the present invention; Figure 2 It is a training flow chart of the YOLOv8 detection model in a specific embodiment of the present invention; Figure 3 This is a flowchart of generating a target bounding box through an Anchor-free mechanism in a specific embodiment of the present invention. DETAILED DESCRIPTION
[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0017] See also Figure 1-Figure 3 As shown, the present invention relates to a method for predicting fish growth.
[0018] Example 1
[0019] refer to Figure 1 As shown, the specific scheme of the method for predicting fish growth of the present invention is as follows: The images of the fish to be measured are obtained through a monocular camera, the images are calibrated, and the images are divided into training set, validation set and test set with a data set ratio of 7:2:1 to generate the data set required for deep learning.
[0020] Using the transfer learning idea of the YOLOv8 deep neural algorithm, the weights of the C0C0 public data set are used to initialize YOLOv8, and the training set is used for training. After each training round, the model performance is evaluated using the validation set. According to the results of the model validation, the learning rate, batch size, and other hyperparameters are systematically adjusted. During the training process, each training round is validated using the validation set. If the validation curve of the training round and the loss rate converges (that is, the slope of the curve changes by less than 5 degrees), the training is stopped. Otherwise, the training samples are increased and the data enhancement of the training samples is performed to generate more samples, such as image rotation, flipping, scaling, and color transformation, to increase the generalization ability of the model. Repeat the training until the validation curve converges, and then the YOLOv8 model is established.
[0021] refer to Figure 2 As shown, the overall process of the YOLOv8 model is as follows: Input image, use pre-trained convolutional neural network, YOLOv8 as the backbone network, extract features from the input image, these features contain the semantic information of the image, which is used for subsequent object detection and segmentation. Use anchor-free mechanism on the extracted feature map, refer to Figure 3 As shown in the figure, according to the learned border distance / key point position, the object size is fitted, the center / center area is found first, and then the distance from the center to the four sides is predicted to generate a series of candidate target bounding boxes. After obtaining the target bounding box, BCE (binary cross entropy) is used as the classification loss to judge the confidence that the bounding box is a fish body, and obtain the expected target bounding box.
[0022] Compared with the Anchor-base setting, which needs to be manually designed (aspect ratio, scale size, number of anchors), different designs are required for different data sets, which is quite troublesome. The matching mechanism of Anchor-base makes the frequency of matching extreme scales (especially large / small objects) lower than the frequency of matching objects of moderate size. It is not easy for the network to learn these extreme samples during learning. At the same time, in order to take into account the prediction ability at multiple scales, the prediction boxes obtained by inference are relatively large, and the nms calculation during output processing will also be more time-consuming.
[0023] In anchor-based target detection algorithms, a large number of anchor boxes are usually preset on the image, and then the categories and positions of these anchor boxes are predicted through convolutional neural networks to achieve target detection. The anchor-free mechanism directly learns various box shapes during training, and does not rely on clustering during reasoning. Instead, it fits the object size based on the learned border distance / key point position, and does not rely on prior knowledge in the data set, so that the network has better expression ability for "object shape" and more generalization potential. There are improvements in the detection of moving objects and objects of different sizes, and it can also be more flexible when detecting occluded objects, greatly reducing the calculation time, and improving the sample matching mechanism.
[0024] Use YOLOv8 to detect the target in the image and identify the fish in the image. YOLOv8 will provide a bounding box for each detected target, indicating the location of the target in the image. Use a specialized instance segmentation algorithm (such as Mask or R-CNN) to further process the targets detected by YOLOv8. This application uses the Mask algorithm for instance segmentation. Mask is a technique for performing local operations on images or data. In image processing, Mask is usually a binary image (consisting of 0 and 1), where 1 represents the area to be processed and 0 represents the area not to be processed. In deep learning, Mask can also be a tensor, which is used to selectively mask or retain certain elements in the tensor.
[0025] The instance segmentation algorithm generates a binary mask of the same size as the original image for each target, in which the target area is marked as white (or 1) and the background area is marked as black (or 0).
[0026] Since YOLOv8 provides the bounding boxes of the target, these bounding boxes are used as input to the instance segmentation algorithm to limit the segmentation algorithm to search only in these areas. The binary masks generated by the instance segmentation algorithm are obtained. You can use these masks to extract the shape of the fish body and further optimize the masks through simple image processing operations (such as binarization, corrosion, dilation, etc.) to obtain a more accurate fish body shape. Finally, the segmented fish body shape is superimposed on the original image to achieve a visual result. After obtaining the shape of the fish through the YOLOv8 model, the pixel length of the fish skeleton is extracted using the ZHUANG-SUEN skeleton algorithm.
[0027] The Zhang-Suen skeleton algorithm is a widely used thinning algorithm and is also a common algorithm in skeleton extraction algorithms. The goal of this algorithm is to thin the edges of foreground objects in a binary image. In the initial state, the input is a binary image, where zero points represent the background and non-zero values represent the foreground. The algorithm consists of two iterative steps, which are executed alternately until no more changes occur. Specifically, the first step will traverse each pixel of the image and check whether the foreground color meets a series of conditions, including the number of foreground pixels adjacent to the current pixel, the number of 0-1 changes from a specific direction through the current pixel, and the status of adjacent pixels at a specific position. If a pixel meets these conditions, it will be marked for deletion. The second step is to actually delete these marked pixels based on the marking results of the first step.
[0028] Here are some of the main advantages of this algorithm: Simplicity: The algorithm is based on a simple iterative process. In each iteration, only the state of the current pixel and its neighboring pixels is considered. This makes the algorithm easy to understand and implement.
[0029] Efficiency: Since the algorithm only checks pixels under certain conditions in each iteration and uses simple rules to update the states of these points, it is efficient when processing large images.
[0030] Maintaining connectivity: The algorithm design ensures the connectivity of the skeleton during the thinning process. This means that the thinned skeleton remains continuous without breaks.
[0031] Centrality: The refinement result tends to be located at the geometric center of the original shape, which is particularly useful for applications that require the centerline or axis of symmetry of the shape.
[0032] Robustness: The algorithm is robust to noise and small shape changes and can tolerate these disturbances in the input image to a certain extent.
[0033] Wide Application: Due to the effectiveness and simplicity of the algorithm, it has been widely used in various fields such as character recognition, shape analysis, pattern recognition, medical image processing, etc.
[0034] Scalability: The basic framework of the algorithm can be easily combined with other image processing techniques to meet the needs of specific applications.
[0035] Easy to parallelize: Since each pixel in the algorithm is processed independently, it can be easily parallelized to further increase the processing speed.
[0036] Each time the ZHUANG-SUEN skeleton algorithm runs, it needs to traverse all non-zero pixels. When determining whether to delete or retain each pixel (P1), we need to pay attention to the values of the eight neighboring pixels (P2, P3, P4, P5, P6, P7, P8) around it. The order of P2 to P8 is specified by the algorithm and is used for subsequent judgment.
[0037] Table 1 Pixel distribution table P9 P2 P3 P8 P1 P4 P7 P6 P5 ; Each run of the algorithm requires two sub-stages, and a pixel can be set to zero only when all the requirements of a stage are met.
[0038] a) ; b) ; c) ; d) ; Where B(P1) represents the number of 8 adjacent non-zero values, and in Table 1, B(P1) = 3; A(P1) refers to the number of changes from P2 to P8, 0-1; a) ; b) ; c') ; d') ; The two stages only differ in steps (c) and (d). The purpose of (c) and (d) in stage one is to remove points on the boundary lines of the east and south sides, and corner points in the northwest corner. The purpose of (c') and (d') in stage two is to remove points on the boundary lines of the west and north sides, and corner points in the southeast corner. For a binary image, the algorithm needs to continuously iterate stage one and stage two until no new pixels are deleted in a certain stage, and the algorithm ends.
[0039] 4. In each iteration, the algorithm needs to maintain two storage spaces of the original image size, one for storing the input image, and the other for storing the non-zero points that have been traversed but not deleted, that is, the new image.
[0040] By using the above method to calculate the pixel length occupied by the skeleton, we can get the skeleton length of the fish body and the current weight of the fish. According to the logistics growth equation: ; Among them, a is a dimensionless quantity, the dimension of parameter b is M / (Lxa), and l is the length of the fish body.
[0041] The Logistics growth equation usually refers to the Logistic growth model, which is a mathematical model used to describe the change in the number of individuals in a biological population or other ecosystem over time.
[0042] 5. After a period of breeding, data collection and judgment are carried out again to obtain the latest fish skeleton length. The data is fitted into a Gompertz curve, which is a mathematical function model. It is an S-shaped curve with the characteristic of gradually slowing growth.
[0043] The characteristics of the Gompertz curve are: slow growth at the beginning and end, and rapid growth in the middle, which is similar to the growth curve of fish. The specific composition of the Gompertz curve is as follows: ;
[0044] in is the weight of the fish at time t, is the normal maximum weight of the fish, k is the growth rate constant. For different fish, different maximum fish weights and normal growth rate constants are set. The health of the fish can be judged by comparing the growth rate constants fitted by the sampling data.
[0045] This patent work is based on YOLOv8 to identify the fish body information in the video frame, and uses the zhuan-suen algorithm to process the mask image extracted by YOLOv8 to obtain the skeleton length of the fish body, identify and extract the skeleton length of the fish body, and obtain the weight of the fish body at the current time through the relationship between the skeleton length and weight. Sampling is carried out every few days to obtain multiple groups of weight data, and the growth rate constant of the fish body is obtained through the Gompertz curve. It can be compared with the normal growth rate constant, and the breeding strategy can be adjusted through the interpolation of the comparison.
[0046] The Gompertz growth curve has the following advantages: Accuracy: The Gompertz curve can accurately describe many real growth processes, especially when the growth trend is limited or constrained. For example, when describing biological populations or economic growth, the Gompertz curve can more accurately reflect the characteristics of the growth rate being faster at the beginning, then gradually slowing down, and finally approaching stagnation.
[0047] Flexibility: The Gompertz curve equation contains multiple parameters, such as the carrying capacity of the population, the steepness of the curve, and the intrinsic growth rate of the population. These parameters can be adjusted according to specific application scenarios to meet different prediction needs.
[0048] Predictability: The Gompertz curve can not only be used to describe past growth trends, but also to predict future growth. By fitting historical data, the parameters of the Gompertz curve can be estimated, and future growth trends can be predicted.
[0049] Compared with the use of Bayesian statistics, decision trees, random forests, and confidence interval calculation methods to judge confidence, this application adopts BCE (binary cross entropy) as the confidence judgment standard. Binary Cross-Entropy has the following advantages when used to judge confidence: Probabilistic output: The binary cross entropy loss function is usually used for binary classification problems, and its output is the probability of predicting that a sample belongs to a certain category. This allows the model to provide a probability value as a prediction result, which can be regarded as the model's confidence in the prediction result.
[0050] Directly measure the difference: Binary cross entropy directly measures the difference between the predicted probability distribution and the true probability distribution. Therefore, when the model outputs a high probability value, we can assume that the model has a high confidence in the prediction result.
[0051] Easy to optimize: The binary cross entropy loss function is continuous and differentiable, which means that you can use optimization algorithms such as gradient descent to minimize the loss function and thus optimize the parameters of the model. This helps the model better learn the features in the data and improve the confidence of the prediction results.
[0052] Applicable to unbalanced datasets: When dealing with unbalanced datasets, the binary cross entropy loss function can be adjusted in a weighted manner to balance the losses between different categories. This helps the model better handle unbalanced data and improves the confidence of the prediction results.
[0053] Strong interpretability: The output of the binary cross entropy loss function has a clear probabilistic meaning, which makes the model's prediction results easier to explain and understand. People can intuitively understand the model's confidence in a certain prediction result and make more informed decisions.
[0054] The above implementation modes are merely descriptions of the preferred implementation modes of the present invention, and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineering and technical personnel in the field shall fall within the protection scope determined by the claims of the present invention.
Claims
1. A method for predicting fish growth, characterized in that: include: Acquire fish images through a detection device, and input the fish images into a trained YOLOv8 detection model; Perform feature extraction on the fish image by using the YOLOv8 detection model to generate a feature map; Using an Anchor-free mechanism on the feature map, generating a target bounding box, wherein the target bounding box represents a position of the target in the image; Using binary cross entropy as classification loss to determine the confidence that the target bounding box is a fish body; The YOLOv8 detection model outputs a binary Mask for the target bounding box that meets the threshold, and obtains the fish body shape through the binary Mask and the instance segmentation algorithm; Use the ZHUANG-SUEN skeleton algorithm to obtain the skeleton length of the fish, and use the logistics growth equation to obtain the weight of the fish at time t. , the expression of the logistics growth equation is: ; Among them, a is a dimensionless quantity, b is a constant, and l is the length of the fish body; A Gompertz curve is established according to the length of the fish skeleton, and the growth of the fish body is judged by the Gompertz curve. The expression of the Gompertz curve is: ; in, is the normal maximum weight of the fish, and k is the growth rate constant.
2. The method for predicting fish growth according to claim 1, characterized in that: The training of the YOLOv8 detection model includes: Obtain images of the fish to be tested through the detection equipment, calibrate the images and divide them into training set, verification set and test set; The YOLOv8 detection model is initialized using the transfer learning idea of the deep neural algorithm and the weights of the C0C0 public data set; After the YOLOv8 detection model is detected, the YOLOv8 detection model is trained using the training set. During the training process, the YOLOv8 detection model is evaluated using the validation set, and a validation curve is established according to the evaluation result. If the slope of the validation curve changes less than a preset value, the training is stopped, otherwise the number of the training sets is increased.
3. The method for predicting fish growth according to claim 1, characterized in that: The generating of the target bounding box by using the anchor-free mechanism on the feature map includes: Generate the size of the fitted object based on the border distance / key point position of the feature map; Based on the dimensions, the location of the central area is obtained; The distances from the central area to each frame are predicted according to the position of the central area, and a series of target bounding boxes are generated according to the distances.
4. The method for predicting fish growth according to claim 1, characterized in that: The YOLOv8 detection model outputs a binary Mask for the target bounding box that meets the threshold, and obtaining the fish body shape through the binary Mask includes: Generate a binary mask of the same size as the target through an instance segmentation algorithm, where the target area is marked as white and the background area is marked as black; The target bounding box that meets the threshold is used as the input of the instance segmentation algorithm, and the decomposed target bounding box is superimposed on the original image of the target to obtain the shape of the fish body.
5. The method for predicting fish growth according to claim 2, characterized in that: The ratio of the training set, the validation set and the test set is 7:2:
1.
6. The method for predicting fish growth according to claim 2, characterized in that: The preset value is 0.5.
Citation Information
Patent Citations
An interference fringe center line fitting method based on Zhang-Suen image skeleton extraction
CN109712147A
Oval pompano body mass breeding method based on Gompertz model
CN110771547A
Detection method for identifying fish growth based on Mask-Rcnn
CN113591671A
Sick fish detection method, device and equipment, storage medium and product
CN118570837A
