A method for shrimp growth prediction and digestive tract evaluation in a feeding table

By improving the annotation method and machine learning model, the problems of low efficiency and large error in monitoring body length and weight in shrimp farming have been solved. High-precision prediction of shrimp growth status and digestive tract assessment has been achieved, supporting farmers in scientific management and optimization of feeding strategies.

CN119919717BActive Publication Date: 2026-05-19INST OF OCEANOLOGY - CHINESE ACAD OF SCI +3
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INST OF OCEANOLOGY - CHINESE ACAD OF SCI
Filing Date
2024-12-30
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In the current shrimp farming process, the monitoring of body length and weight relies on manual operation, which is inefficient and easily triggers stress. Furthermore, traditional computer vision technology has errors and limitations in shrimp detection, making it difficult to meet the needs of production practice.

Method used

An improved annotation method was adopted to calculate the total visual length by removing the area above the middle of the compound eye and the caudal limb of the shrimp. Combined with image segmentation, classification and machine learning models, a prediction system was built, including dataset construction, segmentation model training, mask segmentation, total visual length calculation and weight prediction, to achieve shrimp growth status and digestive tract assessment.

Benefits of technology

The model improved the accuracy of predicting shrimp growth status and feeding conditions. The model's predicted length and weight achieved an accuracy rate of over 97% compared to manual measurements, enabling efficient and precise monitoring and management of shrimp growth.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919717B_ABST
    Figure CN119919717B_ABST
Patent Text Reader

Abstract

The application provides a method for predicting the growth of prawns and evaluating the digestive tract in a feeding table, comprising: constructing a data set based on an improved labeling method by taking images and videos of prawns; training a segmentation model on the constructed data set, performing mask segmentation on the pictures of prawns in the feeding table, fitting a skeleton line based on the extracted segmentation mask to calculate the visual total length, and calculating the weight according to the fitted visual total length-weight power function. Calculate the area of prawns based on the extracted segmentation mask, and calculate the weight according to the fitted area-weight power function. Combined with the visual total length and area characteristics, the prawn weight is jointly predicted by using a machine learning model. The application combines image segmentation classification, traditional fitting method and machine learning model integration to create an efficient and high-precision prediction method for the growth state and feeding condition of prawns, helping farmers to achieve more efficient and environmentally friendly production management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, specifically to a method for predicting shrimp growth and assessing the digestive tract in a feeding platform. Background Technology

[0002] Litopenaeus vannamei is one of the most important aquaculture species globally. With its rapid growth, excellent meat quality, and strong adaptability, it has become a pillar species in shrimp farming, widely used in China, Southeast Asia, and the Americas. In recent years, with the continuous growth of market demand, the production of Litopenaeus vannamei has increased significantly. However, along with the rapid increase in production, the need for refined management in Litopenaeus vannamei farming has become increasingly urgent. Regularly monitoring the body length, weight, and feeding status of shrimp can not only help farmers assess the suitability of the farming environment and the health level of the shrimp, but also assist farmers in scientific management. Furthermore, estimating the daily feed requirements based on the shrimp's weight and feeding status can optimize feeding strategies, reduce feed waste, improve feed conversion rate, and thus effectively reduce farming costs. It can also provide technical support for automated and intelligent feeding, solve the labor shortage in shrimp farming, and avoid the impact of disease transmission caused by manual management.

[0003] Currently, monitoring body length and weight during aquaculture still relies primarily on manual operation, involving the harvesting and weighing of a sample of shrimp. This method is not only labor-intensive and inefficient, but also prone to causing stress and physical damage, thus affecting shrimp growth and survival rates. Furthermore, manual monitoring is often subject to error. The moisture adhering to the shrimp's surface leads to significant deviations in weight measurement, and the results fluctuate considerably from one weighing to the next. When measuring body length, accuracy is also difficult to guarantee due to variations in the shrimp's body shape and improper handling.

[0004] In existing computer vision-based shrimp length and weight prediction tasks, the larger the shrimp's body area, the higher the predicted weight value. However, in the feeding platform, the area occupied by the shrimp's tail fan is 0.2183, but its actual weight accounts for only 0.0351, leading to a significant calculation error. Furthermore, traditional annotation methods have limitations: in detection tasks, rectangular boxes are typically used to label the size of the shrimp; while in segmentation tasks, the shrimp's outline is used for annotation. This approach results in the model ultimately identifying the shrimp length as the total length from the tip of the second antennal scale to the end of the telson, rather than the biologically defined body length or total length. It is also mostly limited to a single shrimp and requires a uniform white background, making it difficult to meet the practical needs of production. Summary of the Invention

[0005] To overcome the inconvenience of manual operation and the limitations of traditional computer vision technology in shrimp detection, this invention proposes a method for predicting shrimp growth and assessing their digestive tract in a feeding platform. This method provides an innovative technology for automated monitoring in shrimp farming, effectively improving monitoring accuracy and providing a scientific basis for optimizing feeding strategies and production management.

[0006] This invention proposes an improved annotation method. Firstly, by removing the area above the middle of the compound eye and the caudal limbs, the tail fan area ratio is reduced to 0.06, significantly decreasing the error in weight prediction based on area. Secondly, when using this improved method for annotation, the starting point (middle of the compound eye) and the ending point (end of the caudal limb) are easier to accurately locate compared to the tip of the frontal horn, the base of the eye stalk, and the end of the caudal segment. This reduces errors from manual annotation and avoids the phenomenon of frontal horn defects.

[0007] Furthermore, traditional annotation methods have certain limitations: traditional models calculate shrimp length from the tip of the second antennal scale to the end of the telson, rather than the biologically defined body length or total length. They are also mostly limited to a single shrimp and require a uniform white background, making them difficult to meet the practical needs of production. This invention, based on an improved annotation method, calculates the visual total length (from the middle of the compound eye to the end of the telson), overcoming this limitation. It achieves an accuracy of 98.19% compared to the actual total length and can effectively replace the actual total length.

[0008] It is worth noting that the accuracy of the length and weight predictions in this invention is derived by comparing the actual values ​​with 20 sets of manually measured shrimp data, rather than from the model's direct predictions. Although there have been some previous predictions of shrimp length and weight, these models typically lack direct comparison with actual manually measured values. By introducing this comparison, this invention not only verifies the model's accuracy but also further ensures its reliability.

[0009] Finally, this invention achieves the assessment of shrimp body length, weight, and digestive tract status through monitoring feeding platforms. Feeding platforms are widely used in factory farming, elevated ponds, outdoor ponds, and greenhouse farming to detect shrimp growth and uneaten feed. Analysis of shrimp images within the feeding platform makes this invention more closely aligned with actual production needs. Simultaneously, the out-of-water environment captured by the feeding platform images avoids many uncertainties common in current underwater monitoring (such as water flow, transparency, and camera maintenance). Furthermore, this invention classifies the gastrointestinal status of shrimp within the feeding platform, identifying three states: "empty," "semi-full," and "full," to assess the shrimp's feeding status, achieving for the first time a digestive tract assessment of shrimp in an out-of-water state within the feeding platform. By integrating image segmentation, classification, traditional fitting methods, and machine learning models, this invention further improves the accuracy and precision of predicting shrimp growth status and feeding behavior, laying the foundation for precise factory feeding and growth monitoring, and helping farmers achieve more efficient and environmentally friendly production management.

[0010] The technical solution adopted by the present invention to achieve the above objectives is: a method for predicting the growth of shrimp and assessing their digestive tract in a feeding platform, comprising the following steps:

[0011] 1) Collect raw images of shrimp and construct a dataset based on an improved annotation method to propose a method for measuring the visual total length of shrimp based on the annotations, in order to replace the total length measurement.

[0012] 2) Train the segmentation model based on the constructed dataset, optimize the network parameters, and obtain a parameter-optimized segmentation model;

[0013] 3) Using the optimized segmentation model, the original image of the shrimp is segmented by masking to obtain the segmented and cropped shrimp image;

[0014] 4) Fit skeleton lines based on the extracted segmentation mask to calculate the visual full length;

[0015] 5) Calculate the shrimp weight based on the fitted visual total length-weight calculation model;

[0016] The shrimp area is calculated based on the extracted segmentation mask, and the shrimp weight is calculated based on the fitted area-weight calculation model.

[0017] Based on visual total length and area features, a machine learning model is used to jointly predict shrimp weight.

[0018] Use any one of the three models above as the shrimp weight calculation model;

[0019] 6) Acquire the original image of the shrimp to be tested. After steps 3) to 4), obtain the visual full length and segmentation mask of the shrimp to be tested. The predicted shrimp weight is obtained through the shrimp weight calculation model.

[0020] 7) Based on the segmented and cropped individual shrimp images obtained in step 3), construct a digestive tract status assessment dataset and train the classification model to obtain an optimized classification model; for the original image of the shrimp to be tested, after step 3), classify the gastrointestinal status using the optimized segmentation model to assess the shrimp's feeding status.

[0021] The improved labeling method is as follows: starting from the middle of the compound eye of the shrimp, marking is made along the outline of the shrimp in the cephalothorax and abdominal segments. The tail fan area is marked only along the telson. The end of the final mark is flush with the end of the telson to remove the area above the middle of the compound eye and the area of ​​the telson.

[0022] The total visual length is the shrimp length calculated based on an improved annotation method, which is the distance from the middle of the compound eye to the end of the telson.

[0023] The dataset was constructed by: based on an improved annotation method, and according to the two most common poses of shrimp, the annotation categories of the images were divided into two categories: the side view of the shrimp and the back view of the shrimp.

[0024] The dataset is divided into a training set and a validation set, with the training set containing 80% of the data and the validation set containing 20% ​​of the data, used for training the split model.

[0025] The process of fitting skeleton lines based on the extracted segmentation mask to calculate the visual full length includes the following steps:

[0026] 1) For the segmentation mask extracted by the segmentation model, the size of the segmentation mask is adjusted by nearest neighbor interpolation to match the size of the original image. Then, the adjusted mask is skeletonized by a thinning algorithm to obtain the skeleton image.

[0027] 2) Use graph theory to extract the principal axis from the skeleton image and remove redundant branches:

[0028] First, construct the graph structure of the skeleton image: find the positions of all non-zero pixels in the skeleton image as nodes in the graph structure; then, use the networkx library to construct an undirected graph G, where each skeleton pixel is a node, and traverse each node to connect it with its surrounding 8 non-zero pixels to construct a connected graph to represent the original skeleton.

[0029] Then, the main axis is found by extracting all nodes with a degree of 1, i.e., the endpoints of the skeleton; if the number of endpoints is less than two, it means that a valid main axis cannot be found, and the connected graph is returned; by traversing all combinations of endpoints, the longest simple path in the graph structure is found, i.e. the path that does not repeatedly pass through any node, and this path is regarded as the main axis of the skeleton.

[0030] Finally, generate the main axis image: create an image of the same size as the skeleton image and mark the pixels on the main axis path as 255, thus obtaining a skeleton image containing only the main axis;

[0031] 3) Finally, the pixel length of the skeleton is calculated by counting the number of non-zero pixels in the skeleton image containing the main axis, and then converted into the visual full length of the actual object according to the given pixel-to-centimeter ratio.

[0032] The process of calculating shrimp weight based on a fitted visual full-length-weight calculation model, and calculating shrimp area based on extracted segmentation masks, and then calculating shrimp weight based on a fitted area-weight calculation model, includes the following steps:

[0033] (1) Construct the relationship between visual total length and body weight: W = aL b Where W represents body weight, L represents total visual length, and a and b are constants; W and L are obtained through manual measurement.

[0034] The relationship between visual total length and body weight is fitted to obtain constants a and b, forming a visual total length-body weight calculation model;

[0035] The visual total length, calculated based on the skeleton lines fitted by the segmentation mask, is then calculated using the visual total length-weight model: W = 0.00899L. 2.95724 Estimate the weight of the shrimp;

[0036] (2) Establish the relationship between area and weight: W = aA b Where W represents weight, which is obtained through manual measurement; A represents area, namely the back area or side area, which is obtained manually using image processing software; and a and b are constants.

[0037] Based on the segmentation mask area, the weight is calculated by matching the corresponding fitting formula according to the detected category;

[0038] If the shrimp's back is detected, the area-weight calculation model is W = 0.52293A. 1.31166 ;

[0039] If the detected area is the side of the shrimp, the area-weight calculation model is W = 0.43735A. 1.29824 .

[0040] The method of jointly predicting shrimp weight using a machine learning model based on visual total length and area features includes the following steps:

[0041] A back training dataset was constructed using manually measured visual total length, back area, and weight. A side training dataset was constructed using manually measured visual total length, side area, and weight. Two LightGBM models were trained on each dataset to obtain a LightGBM model that predicts weight based on back area and a LightGBM model that predicts weight based on side area.

[0042] The original image of the shrimp to be tested is used to calculate the visual full length and segmentation mask area by fitting the skeleton line. The trained LightGBM model is used for joint prediction, and the corresponding LightGBM model is matched according to the detection category to estimate the weight.

[0043] Step 7) is as follows:

[0044] For the segmentation mask and category information obtained by the optimized segmentation model, the target region is extracted by performing a bitwise AND operation between the mask and the original image, then individual shrimp images are cropped out and stored according to category.

[0045] The stored shrimp images were manually classified according to their digestive tract status into three categories: empty, not fully plump, and plump. A digestive tract status assessment dataset was constructed, and a classification model was used for training and parameter optimization.

[0046] The collected shrimp images were segmented using a mask, and the trained classification model was used to assess the degree of digestive tract fullness.

[0047] A system for predicting shrimp growth and assessing the digestive tract in a feeding platform includes:

[0048] The dataset construction module is used to collect raw images of shrimp and construct the dataset based on an improved annotation method to propose a method for measuring the visual total length of shrimp based on the annotations, in order to replace the total length measurement.

[0049] The segmentation model training module is used to train the segmentation model based on the constructed dataset, optimize the network parameters, and obtain a parameter-optimized segmentation model.

[0050] The mask segmentation module is used to perform mask segmentation on the original image of shrimp using an optimized segmentation model, and obtain the segmented and cropped shrimp image.

[0051] The mask segmentation module is used to fit skeleton lines based on the extracted segmentation mask to calculate the visual full length;

[0052] The shrimp weight calculation model building module is used to calculate the shrimp weight based on the fitted visual full-length-weight calculation model; calculate the shrimp area based on the extracted segmentation mask, and calculate the shrimp weight based on the fitted area-weight calculation model; and jointly predict the shrimp weight using a machine learning model based on visual full-length and area features; and use any one of the above three models as the shrimp weight calculation model.

[0053] The shrimp weight prediction module is used to acquire the original image of the shrimp to be tested, and obtain the visual full length and segmentation mask of the shrimp through the mask segmentation module. The shrimp weight prediction is obtained through the shrimp weight calculation model.

[0054] The gastrointestinal state prediction module is used to construct a digestive tract state assessment dataset based on the segmented and cropped individual shrimp images obtained by the mask segmentation module, and to train the classification model to obtain an optimized classification model. For the original image of the shrimp to be tested, after passing through the mask segmentation module, the optimized segmentation model is used to classify the gastrointestinal state to assess the shrimp's feeding status.

[0055] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for predicting shrimp growth and assessing the digestive tract in a feeding platform.

[0056] The present invention has the following beneficial effects and advantages:

[0057] The improved annotation method of this invention effectively reduces the weight prediction error caused by the tail fan area, thereby improving prediction accuracy and providing a simpler and more effective annotation method. Furthermore, to improve measurement consistency and overcome the limitations of traditional length measurement, a new "visual full length" method is proposed. A prediction system is constructed by analyzing shrimp images in the feeding platform and combining image segmentation (YOLOv8n-SEG) and classification (YOLOv8n-CLS), traditional fitting, and a machine learning model (LightGBM). The model's predicted length and weight achieve a high accuracy of over 97% compared to manual measurements, demonstrating good stability and versatility. The model also classifies the digestive tract filling status of shrimp, enabling monitoring of shrimp feeding. Attached Figure Description

[0058] Figure 1 A schematic diagram of the video shooting device of the present invention is shown;

[0059] Figure 2The following diagrams illustrate the improved shrimp labeling method and labeling schematics of the present invention: a) Measurement methods for different lengths; b) Shrimp body parts; c) Traditional labeling method; d) Improved labeling method; e) Common shrimp postures in the feeding platform; f) Labeling using the improved labeling method.

[0060] Figure 3 The model structure and prediction flowchart of the present invention are shown;

[0061] Figure 4 An example diagram of skeleton branch removal of the present invention is shown;

[0062] Figure 5 A power function model diagram of the total visual length, area, and weight of the present invention is shown;

[0063] Figure 6 The prediction and verification graphs of the model of the present invention are shown;

[0064] Figure 7 A digestive tract assessment diagram of the present invention is shown;

[0065] Figure 8 The diagram illustrates the process of predicting shrimp length and weight, as well as assessing the degree of digestive tract fullness, according to the present invention. Detailed Implementation

[0066] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0067] This invention provides a method for predicting shrimp growth and assessing the digestive tract in a feeding platform. The method includes: capturing images and videos of shrimp in the feeding platform; constructing a dataset based on an improved annotation method; and proposing a "visual total length" measurement method to replace total length measurement based on the annotated shrimp. The constructed dataset is used to train a segmentation model. The trained model is used to perform mask segmentation on the images of shrimp in the feeding platform. Skeleton lines are fitted based on the extracted segmentation masks to calculate the visual total length, and the weight is calculated based on the fitted visual total length-weight power function. The shrimp area is calculated based on the extracted segmentation masks, and the weight is calculated based on the fitted area-weight power function. Combining visual total length and area features, a machine learning model (LightGBM) is used to jointly predict the shrimp weight. The model prediction results are compared with manually measured data to calculate the accuracy. Finally, gastrointestinal status is classified based on the segmented shrimp images to assess the shrimp's feeding status. This invention integrates image segmentation and classification, traditional fitting methods, and machine learning models to create a highly efficient and accurate method for predicting shrimp growth status and feeding behavior, helping farmers achieve more efficient and environmentally friendly production management. It has broad practical application value and lays the foundation for precise feeding and real-time growth assessment in future intelligent shrimp farming.

[0068] like Figure 8 As shown. A method for predicting shrimp growth and assessing the digestive tract in a feeding platform includes the following steps:

[0069] Images and videos were taken of the shrimp in the feeding platform.

[0070] A dataset was constructed based on an improved annotation method, and a "visual total length" measurement method was proposed based on the annotated shrimp to replace the total length measurement.

[0071] The segmentation model is trained based on the constructed dataset, the network parameters are optimized to obtain a parameter-optimized segmentation model, and the images of shrimp in the feeding platform are segmented using a mask.

[0072] The skeleton lines are fitted based on the extracted segmentation mask to calculate the visual total length, and the weight is calculated using a power function of the fitted visual total length minus the body weight. The shrimp area is calculated based on the extracted segmentation mask, and the body weight is calculated using a density function of the fitted area minus the body weight.

[0073] Based on visual total length and area features, a machine learning model (LightGBM) is used to jointly predict shrimp weight.

[0074] The accuracy rate is calculated by comparing the results of model predictions with manually measured data.

[0075] Gastrointestinal status was classified based on segmented shrimp images to assess the shrimp's feeding status.

[0076] Specifically, the process of taking images and videos of the shrimp in the feeding platform involves:

[0077] To ensure the reliability and consistency of video acquisition during the process, we designed a video acquisition device. This device mainly consists of a feeding tank, an oxygen pump, a feeding platform, a data acquisition bracket, and a smartphone. The feeding platform is raised from underwater every hour to capture video or images, with each acquisition lasting 30 seconds. The acquired video is extracted into frames at 3 seconds per frame. Figure 1 As shown.

[0078] Specifically, the improved annotation method is as follows:

[0079] For conventional shrimp labeling methods (marking along the entire edge of the shrimp, such as...) Figure 2 As shown by the blue line in C), an improved new annotation method was designed. Figure 2As shown by the green line in section d, the improved annotation method starts from the middle of the compound eye of the shrimp, marking along the shrimp's outline in the cephalothorax and abdominal segments. In the telson region, marking is done only along the telson, with the final mark aligned with the end of the telson. This method eliminates the area above the middle of the compound eye and the area of ​​the telson. On one hand, it significantly reduces the error in predicting body weight based on area. On the other hand, when using this improved method for annotation, the starting point (middle of the compound eye) and the ending point (end of the telson) are easier to accurately locate compared to the tip of the rostrum, the base of the eyestalk, and the end of the telson, thus reducing errors from manual annotation. Figure 2 As shown.

[0080] Specifically, the measurement method for "full visual length" is as follows:

[0081] Based on an improved annotation method, the length of shrimp was calculated from the middle of the compound eye to the end of the telson. A new length measurement method, "visual total length," was proposed to replace the traditional total length measurement. Correlation analysis was performed on the total length and visual total length of 689 shrimp measured manually. The biological body length of a shrimp refers to the length from the base of the eyestalk to the end of the telson, while the total length is the length from the tip of the rostrum to the end of the telson.

[0082] Correlation analysis showed a very strong linear relationship between visual full-length and conventional full-length images, with a Pearson correlation coefficient of 0.994. The coefficient of determination (R²) obtained from linear regression analysis... 2 The coefficient of variation (COP) was 0.994. Bland-Altman analysis showed that most data points fell within the range of [-0.2319 cm, 0.1629 cm], further demonstrating the high consistency and substitutability between visual full length and traditional full length. Simultaneously, the visual full length measurement method effectively avoided problems related to frontal horn injury, thereby reducing measurement errors.

[0083] Specifically, the dataset is constructed as follows:

[0084] Based on the improved annotation method, we constructed the dataset. First, we extracted one frame every 3 seconds from the captured video, selecting a total of 1318 images for manual annotation. We then manually labeled each shrimp in the captured images using X-anyLabeling software. Based on the two most common shrimp postures in the feeding platform (side and back), the annotation categories were divided into two types: "Lateral side of the shrimp" and "Dorsal side of the shrimp". Ultimately, a total of 6994 shrimp were annotated. The dataset was divided into a training set and a validation set, with the training set containing 80% of the data (1055 images, 5557 shrimp) and the validation set containing 20% ​​of the data (263 images, 1437 shrimp).

[0085] Specifically, the steps for extracting the segmentation mask and fitting the skeleton lines to calculate the visual full length are as follows:

[0086] The constructed segmentation dataset (1318 images, 6994 shrimp in total) was trained using YOLOv8n-seg. The main architecture of YOLOv8 is as follows: Figure 3 As shown, it includes a backbone feature extraction network (Backbone), a feature fusion network (Neck), and a head. YOLOv8 applies adaptive anchor boxes, adaptive scaling, grayscale padding, and mosaic data augmentation at the input to improve inference speed, image quality, and model generalization ability. Its backbone network is an improved version of CSPDarknet53 (i.e., Darknet53 in YOLOv7), combined with C2f and SPPF modules. The C2f module borrows the ELAN structure from YOLOv7, enhancing gradient flow through cross-layer connections. The Neck part integrates FPN and PAN structures, enabling the output features to possess both positional and semantic information. The head adopts a decoupled head structure, learning coordinate and classification information through branches, reducing computational complexity and enhancing generalization ability. Figure 3 As shown.

[0087] After training, the YOLO v8n-seg model achieved an overall precision (P) of 0.958, a recall (R) of 0.957, and mAP50 and mAP50-95 of 0.981 and 0.789, respectively. In detecting different body parts, the precision for the lateral side of the shrimp was 0.969, the recall was 0.965, and the mAP50 and mAP50-95 were 0.99 and 0.795, respectively; the precision for the dorsal side was 0.946, the recall was 0.948, and the mAP50 and mAP50-95 were 0.973 and 0.783, respectively. The model had 3.3 × 10⁶ parameters, 1.2 × 10¹⁰ floating-point operations, and a frame rate (FPS) of 175.44 frames per second.

[0088] The trained YOLO v8n-seg model is used to extract the segmentation mask of objects from the input image. During the inference phase, the model calculates the segmentation mask and class index of the target object through forward propagation. The inference results are stored in `results[0].masks.data`. Subsequently, the segmentation mask is converted from PyTorch tensor format to NumPy array by calling the `.cpu().numpy()` method for subsequent image processing. The extracted mask is a two-dimensional array containing multiple objects, and the mask region of each object is represented by binary data (0 represents the background, 1 represents the object pixels).

[0089] A series of image processing operations are performed on the segmentation mask to calculate the visual full length of the object. First, the segmentation mask is resized to match the original input image to ensure pixel consistency in subsequent calculations. This resizing uses nearest-neighbor interpolation (`cv2.INTER_NEAREST`), which is suitable for segmentation masks because it does not generate new colors, thus preserving the mask's category information. Next, the resized mask image is skeletonized using the `thinning` function from OpenCV's `ximgproc` module, based on the Zhang-Suen fast parallel thinning algorithm. Skeletonization is a morphological operation designed to extract the centerline of an object. The input is a binary image (containing only pixel values ​​0 and 255), and the output is the skeleton of the object, with all skeleton pixel values ​​set to 255.

[0090] like Figure 4 As shown. After skeletonization, the resulting skeleton image may contain many branches that do not belong to the object's principal axes. To ensure accurate length measurement, graph theory is used to extract the principal axes of the skeleton. Figure 4 ):

[0091] (1) Graph construction: Each non-zero pixel in the skeleton image S(x,y) is regarded as a node V in an undirected graph G=(V,E), where the edge E connects the adjacent pixels in the 8-connected neighborhood.

[0092] (2) Endpoint identification: Nodes with a degree of 1 (connected to only one other node) are identified as endpoints and form the endpoint set End_nodes. v represents an endpoint, and deg(v) represents the degree of node v, i.e., the number of edges connected to node v;

[0093] End_nodes={v∈V∣deg(v)=1}

[0094] (3) Longest path selection: Among all endpoint pairs, select the longest simple path Pmain as the main axis.

[0095] p i,j This represents the simple path between all endpoint pairs (i,j).

[0096] (4) Branch removal: Generate the main axis skeleton Smain by retaining only the pixels on the Pmain path.

[0097] Finally, the pixel length of the skeleton is calculated by counting the number of non-zero pixels in the main axis skeleton image, and then converted into the visual full length of the actual object according to the given pixel-to-centimeter ratio.

[0098] Specifically, the area of ​​the shrimp is calculated as follows:

[0099] The actual area is obtained by counting the number of non-zero pixels in the segmentation mask and then multiplying it by the square of the pixel-to-centimeter ratio.

[0100] Specifically, the steps for calculating shrimp weight include:

[0101] Construct the relationship between visual total length and body weight, and substitute visual total length as the independent variable into the equation w = aL b Where w represents body weight, L represents total visual length, and a and b are constants. The power function formula constructed using data from 689 shrimp samples of total visual length and body weight is W = 0.00899L. 2.95724 R 2 It is 0.97491.

[0102] To establish the relationship between area and weight, the area of ​​the shrimp's back and side are used as independent variables in the equation w = aA. b Where w represents body weight, A represents the replacement area, and a and b are constants. The dorsal and lateral areas of 689 shrimp were calculated using ImageJ software, and the calculated areas were used to construct a power function formula with the body weight data: W = 0.52293A. 1.31166 R 2 The values ​​are 0.96177 and W = 0.43735A. 1.29824 R 2 It is 0.95626. Figure 5 As shown.

[0103] A LightGBM model was trained to predict body weight based on the visual total length, lateral surface area, and dorsal surface area of ​​517 shrimp. When predicting body weight using a combination of visual total length and lateral surface area, the root mean square error (RMSE) was 0.5692g and the mean absolute error (MAE) was 0.4077g; while when predicting body weight using a combination of visual total length and dorsal surface area, the RMSE was 0.5300g and the MAE was 0.4116g.

[0104] Based on the calculated total visual length, the empirical formula W = 0.00899L was used for fitting. 2.95724 Estimate the weight of an object.

[0105] Based on the shrimp area determined by the segmentation mask, the weight is calculated using a fitted formula matched to the detected category (back / side). If the shrimp's back is detected, the formula is W = 0.52293A. 1.31166 If the detected part is the side of the shrimp, the formula is W = 0.43735A. 1.29824

[0106] By combining visual full-length and area data, a pre-trained LightGBM model is used for joint prediction, and the corresponding LightGBM model is matched according to the detection category (back / side) to estimate weight.

[0107] The model can batch process single images, multiple images from a folder, and multiple frames from a video. Multi-threaded parallel processing is achieved through the `ThreadPoolExecutor` function, effectively improving image processing efficiency. Each batch processes a group of images, extracts the skeleton length, and calculates the mean of each image for storage. For video processing, the code can extract frames from a video at specified intervals and perform model segmentation and skeleton length calculation on each frame. Furthermore, the code provides visualization functionality; when visualization is enabled, the generated images will include object segmentation masks and skeleton annotations, and will be saved to a specified output directory, allowing users to visually view the segmentation and skeleton extraction results.

[0108] Specifically, the model's predictions are compared with manually measured data to calculate the accuracy.

[0109] The model-predicted visual total length and weight of 20 groups of shrimp were compared with manual measurements (including total length, visual total length, and weight). The number of shrimp in the first 10 groups gradually increased from 1 to 15, almost covering the entire feeding platform, with varying sizes within each group. After model prediction, each group of shrimp was manually measured, recording its total length, visual total length, and weight. The latter 10 groups were manually selected to control the length difference between groups to within 3 mm (the error range of manual measurement). Each group contained 3 to 8 shrimp, with 5 being the majority, with visual total length ranging from 11.7 to 14.4 cm and weight ranging from 12.62 to 25.1 g. Figure 6 As shown.

[0110] Specifically, the gastrointestinal status was classified and assessed for the segmented shrimp images as follows:

[0111] The trained YOLOv8n-seg model extracts segmentation masks and category information. Target regions are extracted using a bitwise AND operation between the mask and the original image. Then, bounding box images with non-zero pixels are cropped and classified according to category ("Lateral side of the shrimp" and "Dorsal side of the shrimp"). 3377 images of shrimp in the feeding platform were collected and manually classified according to their digestive tract state into three categories: "empty" (1386 images), "semi-full" (1008 images), and "full" (983 images). The model was then trained using a classification model (YOLOv8n-cls).

[0112]

[0113] cropped_img=masked_img[min_y:max_y+1,min_x:max_x+1]

[0114] Where `img(x,y)` represents the pixel values ​​of the original image, `mask(x,y)` represents the mask values ​​(1 for the target region, 0 for the background), `mask_img(x,y)` is the current mask image, `masked_img(x,y)` is the image containing only the target region (i.e., the mask image from the previous iteration), `cropped_img` represents the cropped target region image, and `min_y` and `max_y` represent the start and end positions of non-zero pixels in the y-direction. `min_x` and `max_x` represent the start and end positions of non-zero pixels in the x-direction. The +1 is added because Python slices do not include the end index, so 1 is added to ensure that the boundary is included.

[0115] After training, the model achieved an accuracy rate of 89.9% in assessing the shrimp's digestive tract from a dorsal perspective and 86.9% from a lateral perspective, effectively evaluating the fullness of the digestive tract. Figure 7 As shown.

[0116] This invention analyzes images of shrimp captured in a feeding platform and constructs a prediction system by combining image segmentation (YOLOv8n-SEG) classification (YOLOv8n-CLS), traditional fitting, and a machine learning model (LightGBM). The accuracy rate for predicting total visual length was 98.19%; the accuracy rate for predicting total visual length compared to actual total length was also 98.19%. Regarding weight prediction, the accuracy rate was 95.45% using only total visual length, 96.55% using area, and 97.36% when combining total visual length and area.

[0117] Furthermore, a function was fitted based on the biological body length and visual total length of 167 shrimp to enable the calculation of the shrimp's biological body length from the visual total length. The function is L = 0.8391·Lv 1.0133 R 2 The value is 0.9845, where L is the biological body length and Lv is the visual total length.

Claims

1. A method for predicting shrimp growth and assessing the digestive tract in a feeding platform, characterized in that, Includes the following steps: 1) Collect raw images of shrimp and construct a dataset based on an improved annotation method to propose a method for measuring the visual total length of shrimp based on the annotations, in order to replace the total length measurement. 2) Train the segmentation model based on the constructed dataset, optimize the network parameters, and obtain a parameter-optimized segmentation model; 3) Using the optimized segmentation model, the original image of the shrimp is segmented by masking to obtain the segmented and cropped shrimp image; 4) Fit skeleton lines based on the extracted segmentation mask to calculate the visual full length; 5) Calculate the shrimp weight based on the fitted visual total length-weight calculation model; The shrimp area is calculated based on the extracted segmentation mask, and the shrimp weight is calculated based on the fitted area-weight calculation model. Based on visual total length and area features, a machine learning model is used to jointly predict shrimp weight. Use any one of the three models above as the shrimp weight calculation model; 6) Acquire the original image of the shrimp to be tested. After steps 3) to 4), obtain the visual full length and segmentation mask of the shrimp to be tested. The predicted shrimp weight is obtained through the shrimp weight calculation model. 7) Based on the segmented and cropped individual shrimp images obtained in step 3), construct a digestive tract status assessment dataset and train the classification model to obtain an optimized classification model; for the original image of the shrimp to be tested, after step 3), classify the gastrointestinal status using the optimized segmentation model to assess the shrimp's feeding status. The improved labeling method is as follows: starting from the middle of the compound eye of the shrimp, marking is made along the outline of the shrimp in the cephalothorax and abdominal segments, and the tail fan area is marked only along the telson. The end of the final mark is flush with the end of the telson to remove the area above the middle of the compound eye and the area of ​​the telson. The total visual length is the shrimp length calculated based on an improved annotation method, which is the distance from the middle of the compound eye to the end of the telson. The process of fitting skeleton lines based on the extracted segmentation mask to calculate the visual full length includes the following steps: 1) For the segmentation mask extracted by the segmentation model, the size of the segmentation mask is adjusted by nearest neighbor interpolation to match the size of the original image. Then, the adjusted mask is skeletonized by a thinning algorithm to obtain the skeleton image. 2) Use graph theory to extract the principal axis from the skeleton image and remove redundant branches: First, construct the graph structure of the skeleton image: find the positions of all non-zero pixels in the skeleton image as nodes in the graph structure; then, use the networkx library to construct an undirected graph G, where each skeleton pixel is a node, and traverse each node to connect it with its surrounding 8 non-zero pixels to construct a connected graph to represent the original skeleton. Then, the main axis is found by extracting all nodes with a degree of 1, i.e., the endpoints of the skeleton; if the number of endpoints is less than two, it means that a valid main axis cannot be found, and the connected graph is returned; by traversing all combinations of endpoints, the longest simple path in the graph structure is found, i.e. the path that does not repeatedly pass through any node, and this path is regarded as the main axis of the skeleton. Finally, generate the main axis image: create an image of the same size as the skeleton image and mark the pixels on the main axis path as 255, thus obtaining a skeleton image containing only the main axis; 3) Finally, the pixel length of the skeleton is calculated by counting the number of non-zero pixels in the skeleton image containing the main axis, and then converted into the visual full length of the actual object according to the given pixel-to-centimeter ratio. The process of calculating shrimp weight based on a fitted visual full-length-weight calculation model, and calculating shrimp area based on extracted segmentation masks, and then calculating shrimp weight based on a fitted area-weight calculation model, includes the following steps: (1) Construct the relationship between visual total length and body weight: W = aL b Where W represents body weight, L represents total visual length, and a and b are constants; W and L are obtained through manual measurement; The relationship between visual total length and body weight is fitted to obtain constants a and b, forming a visual total length-body weight calculation model; The visual total length, calculated based on the skeleton lines fitted by the segmentation mask, is then calculated using the visual total length-weight model: W=0.00899L. 2.95724 Estimate the weight of the shrimp; (2) Construct the relationship between area and weight: W = aA b Where W represents weight, which is obtained through manual measurement; A represents area, namely the back area or side area, which is obtained through manual measurement using image processing software; and a and b are constants. Based on the segmentation mask area, the weight is calculated by matching the corresponding fitting formula according to the detected category; If the shrimp's back is detected, the area-weight calculation model is W=0.52293A. 1.31166 ; If the detected area is the side of the shrimp, the area-weight calculation model is W=0.43735A. 1.29824 ; The method of jointly predicting shrimp weight using a machine learning model based on visual total length and area features includes the following steps: A back training dataset was constructed using manually measured visual total length, back area, and weight. A side training dataset was constructed using manually measured visual total length, side area, and weight. Two LightGBM models were trained on each dataset to obtain a LightGBM model that predicts weight based on back area and a LightGBM model that predicts weight based on side area. The original image of the shrimp to be tested is used to calculate the visual full length and segmentation mask area by fitting the skeleton line. The trained LightGBM model is used for joint prediction, and the corresponding LightGBM model is matched according to the detection category to estimate the weight. Step 7), as follows: For the segmentation mask and category information obtained by the optimized segmentation model, the target region is extracted by performing a bitwise AND operation between the mask and the original image, then individual shrimp images are cropped out and stored according to category. The stored shrimp images were manually classified according to their digestive tract status into three categories: empty, not fully plump, and plump. A digestive tract status assessment dataset was constructed, and a classification model was used for training and parameter optimization. The collected shrimp images were segmented using a mask, and the trained classification model was used to assess the degree of filling of the digestive tract.

2. The method for predicting shrimp growth and assessing the digestive tract in a feeding platform according to claim 1, characterized in that, The dataset was constructed by: based on an improved annotation method, and according to the two most common poses of shrimp, the annotation categories of the images were divided into two categories: the side view of the shrimp and the back view of the shrimp. The dataset is divided into a training set and a validation set, with the training set containing 80% of the data and the validation set containing 20% ​​of the data, used for training the split model.

3. A system for predicting shrimp growth and assessing the digestive tract in a feeding platform, the system being used to implement the method for predicting shrimp growth and assessing the digestive tract in a feeding platform as described in any one of claims 1-2, characterized in that, include: The dataset construction module is used to collect raw images of shrimp and construct the dataset based on an improved annotation method to propose a method for measuring the visual total length of shrimp based on the annotations, in order to replace the total length measurement. The segmentation model training module is used to train the segmentation model based on the constructed dataset, optimize the network parameters, and obtain a parameter-optimized segmentation model. The mask segmentation module is used to perform mask segmentation on the original image of shrimp using an optimized segmentation model, and obtain the segmented and cropped shrimp image. The mask segmentation module is used to fit skeleton lines based on the extracted segmentation mask to calculate the visual full length; The shrimp weight calculation model building module is used to calculate the shrimp weight based on the fitted visual full-length-weight calculation model; calculate the shrimp area based on the extracted segmentation mask, and calculate the shrimp weight based on the fitted area-weight calculation model; and jointly predict the shrimp weight using a machine learning model based on visual full-length and area features; and use any one of the above three models as the shrimp weight calculation model. The shrimp weight prediction module is used to acquire the original image of the shrimp to be tested, and obtain the visual full length and segmentation mask of the shrimp through the mask segmentation module. The shrimp weight prediction is obtained through the shrimp weight calculation model. The gastrointestinal state prediction module is used to construct a digestive tract state assessment dataset based on the segmented and cropped individual shrimp images obtained by the mask segmentation module, and to train the classification model to obtain an optimized classification model. For the original image of the shrimp to be tested, after passing through the mask segmentation module, the optimized segmentation model is used to classify the gastrointestinal state to assess the shrimp's feeding status.

4. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements a method for predicting shrimp growth and assessing the digestive tract in a feeding platform as described in any one of claims 1-2.