Live pig weight estimation system and method
Patent Information
- Application Number
- CN202510262292.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2045-03-06
AI Technical Summary
[0005]本发明提供一种生猪体重估计系统及方法,用以解决现有技术中传统的生猪体重估计方法存在估算准确率不高,或者计算量较大导致计算效率不高的缺陷,实现更准确且更高效地估算生猪体重
[0019]The present invention provides a pig weight estimation system and method. The pig weight estimation system includes an image acquisition device and a first electronic device. The image acquisition device includes a moving mechanism, a supporting mechanism, and an image sensor. It can capture RGB and depth images of the pig vertically downwards using the image sensor. Combined with the moving mechanism, the image acquisition range can be flexibly adjusted, enabling more accurate, efficient, and flexible image acquisition of the pig without causing stress to the pig. The first electronic device preprocesses the depth image using the RGB image of the pig and then estimates the pig weight using an improved EfficientNetV2 model. This method obtains an estimated value of pig weight. Through optimized model training, it can effectively integrate spatial and three-dimensional information during pig weight estimation, significantly improving the accuracy of pig weight estimation. Furthermore, the lightweight design of the model reduces the amount and complexity of computation during the pig weight estimation process, significantly improving the speed and efficiency of pig weight estimation. It also reduces human intervention during pig weight estimation, better avoiding stress reactions in pigs and improving the practicality of pig weight estimation. It provides more reliable and efficient technical support for pig farming management and is suitable for rapid and automated monitoring of pig weight in large-scale farming scenarios.
Smart Images

Figure CN120283681B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart agriculture technology, and in particular to a system and method for estimating the weight of pigs. Background Technology
[0002] Pig weight is one of the important indicators for monitoring pig growth during pig farming, as it directly reflects the pig's health status and development progress. Quickly and accurately estimating pig weight can help producers promptly identify pigs with abnormal growth or those whose growth deviates from expected targets, thereby adjusting feeding strategies and reducing management labor and feed costs.
[0003] Traditional methods for estimating pig weight utilize computer vision, machine learning, or 3D sensor technologies. However, these methods rely on images of the pigs, which suffer from drawbacks such as causing stress in pigs, low image quality, and poor directional accuracy.
[0004] Furthermore, traditional methods for estimating pig weight in related technologies suffer from low accuracy or high computational complexity, leading to low efficiency. Therefore, improving the practicality, accuracy, and efficiency of pig weight estimation is a pressing technical problem that needs to be solved in this field. Summary of the Invention
[0005] This invention provides a pig weight estimation system and method to address the shortcomings of traditional pig weight estimation methods in the prior art, such as low estimation accuracy or high computational load leading to low computational efficiency, thereby achieving more accurate and efficient pig weight estimation.
[0006] This invention provides a pig weight estimation system, comprising: an image acquisition device and a first electronic device; the image acquisition device is electrically connected to the first electronic device; the image acquisition device includes a moving mechanism, a supporting mechanism, and an image sensor; the moving mechanism is connected to the supporting mechanism and is used to drive the supporting mechanism to move; the image sensor is mounted on the supporting mechanism, and the image sensor's shooting direction is perpendicular to the horizontal plane and downwards; the image sensor is used to acquire RGB images and depth images of a target pig located below the image sensor, and send the acquired RGB images and depth images of the target pig to the first electronic device; the first electronic device is used to, upon receiving the RGB images and depth images of the target pig, based on the... The RGB image of the target pig is used to preprocess the depth image of the target pig. The preprocessed depth image of the target pig is then input into a pig weight estimation model to obtain an estimated weight of the target pig output by the model. The pig weight estimation model is built on an improved EfficientNetV2 network and trained using the preprocessed depth image of the sample pig and the actual weight of the sample pig. The preprocessed depth image of the sample pig is obtained by preprocessing the depth image of the sample pig based on the RGB image of the sample pig. The method of preprocessing the depth image of the sample pig is the same as that of preprocessing the depth image of the target pig.
[0007] According to the present invention, a pig weight estimation system includes a support mechanism comprising a support base and a multi-axis robotic arm. One end of the multi-axis robotic arm is fixed to the support base, and the other end of the multi-axis robotic arm is continuous with the image sensor. The multi-axis robotic arm includes multiple connecting rods, which are rotatably connected in sequence.
[0008] According to the present invention, a pig weight estimation system is provided, wherein the first electronic device is specifically used to perform image recognition and instance segmentation on the RGB image of the target pig, obtain the mask of the target pig, and, if the mask of the target pig is complete, map the mask of the target pig onto the depth image of the target pig to obtain the segmentation result of the target pig in the depth image of the target pig, which is used as the depth image after preprocessing the target pig data.
[0009] According to the present invention, a pig weight estimation system is provided, wherein the pig weight estimation model includes: a backbone network and a weight estimation head module connected in sequence; the backbone network is constructed based on the improved EfficientNetV2 network, wherein the improved EfficientNetV2 network is an EfficientNetV2 network in which the SE module is replaced with the CBAM module.
[0010] According to the present invention, a pig weight estimation system includes a weight estimation head module comprising: a global average pooling unit, a first fully connected layer unit, a ReLU activation function unit, a regularization calculation unit, and a second fully connected layer unit connected in sequence.
[0011] According to a pig weight estimation system provided by the present invention, the first electronic device is specifically used to input the RGB image of the target pig into a pig recognition model to obtain the mask of the target pig output by the pig recognition model. The first electronic device is also used to map the mask of the target pig onto a blank image of the same size as the RGB image of the target pig. If it is determined that the mask of the target pig does not intersect the boundary of the blank image, or if the mask of the target pig intersects the boundary but the distance of the mask of the target pig from the boundary is less than a distance threshold, then it is determined that the mask of the target pig is complete. The pig recognition model is obtained by performing transfer learning on the training model based on the mask of the sample pig. The mask of the sample pig is obtained by performing image recognition and instance segmentation on the RGB image of the sample pig.
[0012] According to the present invention, a pig weight estimation system is provided, wherein the support base has a telescopic function, which can drive the multi-axis robotic arm to move in a direction perpendicular to the horizontal plane.
[0013] According to a pig weight estimation system provided by the present invention, a first electronic device is electrically connected to at least one of the support base, the multi-axis robotic arm, and the moving mechanism; when electrically connected to the moving mechanism, the first electronic device is used to control the moving direction and / or moving distance of the moving mechanism; when electrically connected to the multi-axis robotic arm, the first electronic device is used to control the included angle between at least two adjacent connecting rods of the multi-axis robotic arm; when electrically connected to the support base, the first electronic device is used to control the height of the support base.
[0014] According to the present invention, a pig weight estimation system includes an image acquisition device further comprising a second electronic device; the second electronic device is electrically connected to at least one of the support base, the multi-axis robotic arm, and the moving mechanism; when electrically connected to the moving mechanism, the second electronic device is used to control the moving direction and / or moving distance of the moving mechanism; when electrically connected to the multi-axis robotic arm, the second electronic device is used to control the included angle between at least two adjacent connecting rods of the multi-axis robotic arm; and when electrically connected to the support base, the second electronic device is used to control the height of the support base.
[0015] This invention also provides a method for estimating pig weight based on any of the pig weight estimation systems described above, comprising: acquiring an RGB image and a depth image of a target pig, wherein the RGB image and depth image of the target pig are acquired using an image sensor located above the target pig; performing data preprocessing on the depth image of the target pig based on the RGB image of the target pig to obtain a preprocessed depth image of the target pig; inputting the preprocessed depth image of the target pig into a pig weight estimation model to obtain an estimated value of the target pig weight output by the pig weight estimation model; wherein the pig weight estimation model is constructed based on an improved EfficientNetV2 network and trained based on the preprocessed depth image of sample pigs and the actual weight value of the sample pigs; the preprocessed depth image of the sample pigs is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs; the method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs.
[0016] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the above-described methods for estimating pig weight.
[0017] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the pig weight estimation method as described above.
[0018] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-described methods for estimating pig weight.
[0019] The present invention provides a pig weight estimation system and method. The pig weight estimation system includes an image acquisition device and a first electronic device. The image acquisition device includes a moving mechanism, a supporting mechanism, and an image sensor. It can capture RGB and depth images of the pig vertically downwards using the image sensor. Combined with the moving mechanism, the image acquisition range can be flexibly adjusted, enabling more accurate, efficient, and flexible image acquisition of the pig without causing stress to the pig. The first electronic device preprocesses the depth image using the RGB image of the pig and then estimates the pig weight using an improved EfficientNetV2 model. This method obtains an estimated value of pig weight. Through optimized model training, it can effectively integrate spatial and three-dimensional information during pig weight estimation, significantly improving the accuracy of pig weight estimation. Furthermore, the lightweight design of the model reduces the amount and complexity of computation during the pig weight estimation process, significantly improving the speed and efficiency of pig weight estimation. It also reduces human intervention during pig weight estimation, better avoiding stress reactions in pigs and improving the practicality of pig weight estimation. It provides more reliable and efficient technical support for pig farming management and is suitable for rapid and automated monitoring of pig weight in large-scale farming scenarios. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the pig weight estimation system provided by the present invention.
[0022] Figure 2 This is a schematic diagram of the image acquisition device in the pig weight estimation system provided by the present invention.
[0023] Figure 3 This is a weight distribution map of sample pigs in the pig weight estimation system provided by this invention.
[0024] Figure 4 This is a schematic diagram of the process by which the first electronic device in the pig weight estimation system provided by the present invention performs data preprocessing on the depth image of the target pig.
[0025] Figure 5 This is a schematic diagram of the structure of the pig weight estimation model in the pig weight estimation system provided by the present invention.
[0026] Figure 6 This is a comparison diagram of the SE module and the CBAM module.
[0027] Figure 7 This is a schematic diagram of the structure of the weight estimation head module in the pig weight estimation model of the pig weight estimation system provided by the present invention.
[0028] Figure 8 This is a schematic diagram comparing the structure of the weight estimation head module in the pig weight estimation model provided by this invention with two other weight estimation variants.
[0029] Figure 9 This is a flowchart illustrating the pig weight estimation method provided by the present invention.
[0030] Figure 10 This is a schematic diagram of the structure of the first electronic device provided by the present invention. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0032] In the description of the invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0033] In the description of this application, the terms "first," "second," etc., are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, in the description of this application, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects have an "or" relationship.
[0034] It should be noted that pig weight is one of the important indicators for monitoring pig growth during the pig farming process. Pig weight directly reflects the pig's health status and developmental progress. Quickly and accurately estimating pig weight can help producers promptly identify pigs with abnormal growth or those whose growth deviates from expected targets, thereby reducing management labor and feed costs by adjusting feeding strategies.
[0035] In related technologies, producers typically measure pig weight by herding them onto a weighing scale, a method that yields the most accurate results. However, this method requires significant labor costs and can easily cause stress in pigs, potentially leading to reduced feed intake and frequency. Furthermore, excessive human contact may accelerate the spread of swine fever among pigs.
[0036] With the development of computer vision technology, image-based non-contact pig weight estimation has attracted great attention in the agricultural field. Related technologies utilize computer vision to achieve automatic, non-contact estimation of pig weight, which not only reduces human intervention during weight estimation and avoids stress reactions in pigs, but also lowers labor costs.
[0037] For example, traditional pig weight estimation methods based on computer vision and machine learning technologies can extract weight-related features from pig images, such as body shape parameters, using feature engineering. Then, a regression model is used to estimate the pig's weight based on these body shape parameters. However, these traditional pig weight estimation methods based on computer vision and machine learning technologies have certain limitations in feature selection, making it difficult to capture the complex nonlinear features in pig images, resulting in a relatively low accuracy in estimating pig weight.
[0038] Traditional pig weight estimation methods based on computer vision and machine learning technologies can further improve accuracy by utilizing models such as convolutional neural networks (CNNs) to automatically learn efficient feature representations. For example, a traditional pig weight estimation method based on computer vision and machine learning technologies can combine a pig instance segmentation model based on Mask R-CNN (Mask Region-based Convolutional Neural Network) with an improved ResNet (Residual Network) weight estimation algorithm to achieve real-time pig weight estimation. Another example is that a traditional pig weight estimation method based on computer vision and machine learning technologies can extract the pig's contour using the Mask R-CNN pig instance segmentation model, convert the mask image to a binary image to optimize contour accuracy, and then use XGBoost to correct body length, hip width, and the distance from the camera to the pig's back, employing three feature combination strategies to predict the pig's weight.
[0039] However, while the traditional pig weight estimation methods based on computer vision and machine learning have achieved good results on specific datasets, their generalization ability is limited. Different breeds and / or different growth stages of pigs may exhibit significant differences in morphology and weight, leading to a decrease in the accuracy of these methods when applied to new pig populations. Furthermore, these traditional pig weight estimation methods based on computer vision and machine learning are not robust to different lighting conditions.
[0040] With the development of 3D sensor technology, depth images and point cloud data are increasingly being applied to pig weight estimation. This 3D data not only accurately captures the volume and shape information of pigs but also avoids the impact of occlusion or changes in lighting on the weight estimation results. For example, traditional pig weight estimation methods based on 3D sensor technology can extract the pig's body size parameters from the surface point cloud and construct stepwise regression, ridge regression, and partial least squares weight regression models for weight estimation. Another example is the integration of pig back body size parameters with convolutional neural networks to estimate the pig's weight. However, 3D data is large in size, requiring higher processing and storage resources, leading to a significant increase in computational costs.
[0041] Therefore, a ConvNet-based live weight estimation method has been proposed to address traditional pig weight estimation techniques. This method predicts pig weight using only depth images without feature extraction. Traditional pig weight estimation methods can also employ regression networks similar to BotNet. Furthermore, some traditional methods utilize RGB-D two-stream networks to simultaneously fuse texture information from RGB images and geometric information from depth images, further improving the accuracy of pig weight estimation in certain models.
[0042] However, the traditional pig weight estimation methods mentioned above significantly increase the number of parameters and computational complexity when estimating pig weight, resulting in a large computational load and a significant decrease in the efficiency of pig weight estimation.
[0043] In pig weight estimation, the choice of image acquisition method has a significant impact on practical applications. Traditional pig image acquisition methods in related technologies mainly include confined space acquisition, channel acquisition, and free environment acquisition.
[0044] Confined space acquisition refers to restricting pigs to a narrow area using fences or barriers. Because the acquisition range is small and fixed, the resulting images of pigs are easier to segment. However, this method can easily cause stress in pigs, which is detrimental to their healthy growth.
[0045] The channel acquisition method involves mounting a camera above a channel, driving the pigs through it, capturing the video stream, and using object detection algorithms to extract image frames of the pigs passing through the channel, thus obtaining an image of the pigs. However, the channel acquisition method is prone to lower accuracy in estimating pig weight if the pigs are located at the edge of the image.
[0046] The free-environment acquisition method involves taking images of pigs at watering points or feed troughs in the pigsty. While this method meets the requirement of non-invasive acquisition, the limited field of view of the camera usually prevents the acquisition of images for every single pig. Furthermore, the randomness of pigs appearing in the images makes it difficult to estimate the weight of a particular pig.
[0047] Therefore, the application effect of the above-mentioned traditional image acquisition methods in actual breeding scenarios is still limited, and it is necessary to further improve their practicality in pig image acquisition.
[0048] In summary, traditional pig weight estimation methods suffer from the following technical shortcomings: First, some traditional methods rely on fixed-location image acquisition devices or complex constraint structures, making them difficult to adapt to the dynamic and complex real-world environment of pig farms, thus affecting their practicality and scalability. Second, while traditional methods that estimate weight based on body size are simple and intuitive, they depend on precise extraction of body size parameters. However, in real-world environments, pig body contours are complex, and issues such as movement and occlusion exist, making it difficult to guarantee the accuracy of body size measurements. Finally, traditional pig weight estimation methods lack targeted optimization in model design, especially in improving the performance of feature extraction and weight estimation. Although some deep learning models improve estimation accuracy, their complex structures limit their application in resource-constrained environments.
[0049] Therefore, how to develop more flexible and efficient pig image acquisition devices, improve the accuracy of pig weight estimation, reduce the complexity and computational load of pig weight estimation, and thus improve the efficiency of pig weight estimation, is a technical problem that urgently needs to be solved in this field.
[0050] To address the aforementioned technical problems, this invention provides a pig weight estimation system. The pig weight estimation system provided by this invention includes a portable image acquisition device and electronic equipment, and proposes a lightweight network based on an improved EfficientNetV2. Utilizing pig depth images after instance segmentation, it enables more convenient, efficient, and non-contact estimation of pig weight in actual pig farm management.
[0051] The pig weight estimation system provided by this invention includes a mobile image acquisition device, allowing farmers to operate flexibly within the farm environment without having to drive pigs through passageways, thus achieving efficient acquisition of images of the pigs' backs. This invention proposes a lightweight pig weight estimation model based on an improved EfficientNetV2 network that utilizes spatial structural information from depth images. A CBAM attention mechanism is introduced into the EfficientNetV2 network to enhance its ability to capture spatial features.
[0052] The following is combined Figures 1-8 This invention describes the pig weight estimation system provided by the present invention.
[0053] Figure 1 This is a schematic diagram of the pig weight estimation system provided by the present invention. The following is a combination of... Figure 1 The pig weight estimation system provided by this invention is described below. Figure 1 As shown, the pig weight estimation system 101 includes: an image acquisition device 102 and a first electronic device 103; the image acquisition device 102 is electrically connected to the first electronic device 103.
[0054] The image acquisition device 102 includes a moving mechanism, a supporting mechanism, and an image sensor; the moving mechanism is connected to the supporting mechanism and is used to drive the supporting mechanism to move.
[0055] The image sensor is mounted on the support mechanism. The image sensor's shooting direction is perpendicular to the horizontal plane and downwards. The image sensor is used to acquire RGB images and depth images of the target pig located below the image sensor, and then sends the acquired RGB images and depth images of the target pig to the first electronic device 103.
[0056] Specifically, the target pig is the object of estimation provided by the pig weight estimation system 101 of this invention. Based on the pig weight estimation system 101 provided by this invention, the weight of the target pig can be estimated to obtain the estimated weight value of the target pig.
[0057] It should be noted that the target pig in the embodiments of the present invention can be determined based on actual needs. For example, in the embodiments of the present invention, each pig in the pigsty can be sequentially determined as the target pig; or, in the embodiments of the present invention, any pig in the pigsty can be determined as the target pig according to actual needs.
[0058] In this embodiment of the invention, the moving mechanism in the image acquisition device 102 can be used to move the image sensor above the target pig. The support mechanism in this embodiment of the invention can have degrees of freedom in both the horizontal and vertical directions, thus allowing the image sensor to be moved above the target pig using both the moving mechanism and the support mechanism.
[0059] It should be noted that, in the embodiments of the present invention, the shooting direction of the image sensor is a direction that extends away from the image sensor, passing through the center of the image sensor lens and perpendicular to the plane where the image sensor lens is located.
[0060] Figure 2 This is a schematic diagram of the image acquisition device in the pig weight estimation system provided by the present invention. As an optional embodiment, such as... Figure 2 As shown, the support mechanism includes a support base 201 and a multi-axis robotic arm 202. One end of the multi-axis robotic arm 202 is fixed to the support base 201, and the other end of the multi-axis robotic arm 202 is continuous with the image sensor 203. The multi-axis robotic arm 202 includes multiple connecting rods, which are rotatably connected in sequence.
[0061] Specifically, the support mechanism in this embodiment of the invention includes a support base 201 and a multi-axis robotic arm 202. The multi-axis robotic arm 202 consists of multiple connecting rods, which are connected in sequence through rotary joints. The rotary joints allow relative rotation between adjacent connecting rods, thereby enabling the multi-axis robotic arm 202 to bend and extend in three-dimensional space.
[0062] By adjusting the angle between the connecting rods in the multi-axis robotic arm 202, the image sensor 203 can be moved above the target pig.
[0063] Optionally, the support mechanism in the embodiments of the present invention can be made of aluminum profile, which is lightweight, has high strength and relatively low price.
[0064] Optionally, the moving mechanism 204 may include four pulleys and a brake to ensure the stability of the moving mechanism 204 during movement.
[0065] As an optional embodiment, the support base 201 has a telescopic function, which enables the multi-axis robotic arm 202 to move in a direction perpendicular to the horizontal plane.
[0066] As an optional embodiment, the first electronic device 103 is electrically connected to at least one of the support base 201, the multi-axis robotic arm 202, and the moving mechanism 204; when electrically connected to the moving mechanism 204, the first electronic device 103 is used to control the moving direction and / or moving distance of the moving mechanism 204; when electrically connected to the multi-axis robotic arm 202, the first electronic device 103 is used to control the included angle between at least two adjacent connecting rods in the multi-axis robotic arm 202; when electrically connected to the support base 201, the first electronic device 103 is used to control the height of the support base 201.
[0067] As an optional embodiment, the image acquisition device 102 further includes a second electronic device; the second electronic device is electrically connected to at least one of the support base 201, the multi-axis robotic arm 202, and the moving mechanism 204; when electrically connected to the moving mechanism 204, the second electronic device is used to control the moving direction and / or moving distance of the moving mechanism 204; when electrically connected to the multi-axis robotic arm 202, the second electronic device is used to control the included angle between at least two adjacent connecting rods in the multi-axis robotic arm 202; when electrically connected to the support base 201, the second electronic device is used to control the height of the support base 201.
[0068] Optionally, the second electronic device in this embodiment of the invention can be a laptop terminal with a quad-core, eight-thread i7-8650 CPU and 8GB of memory, running Windows, and powered by an external power bank.
[0069] As an optional embodiment, the image sensor 203 includes an RGB image sensor 203 and a depth image sensor 203.
[0070] Optionally, the depth image sensor 203 in this embodiment of the invention can be an Orbbec Femto Bolt depth camera. The working mode of the depth camera is set to WFOV 2X2BINNED, the field of view of the acquired depth image is 120°×120°, the effective measurement range is 0.25 to 2.88 meters, and the frame rate is 30 frames / second.
[0071] It should be noted that, in this embodiment of the invention, after D2C alignment, the RGB image and depth image acquired by the RGB image sensor 203 and the depth image sensor 203 maintain the same resolution and pixel count, and the depth image can be saved in 16-bit depth format.
[0072] Optionally, the resolution of the RBG image sensor 203 is set to 1920×1080.
[0073] It is understandable that, since the image sensor 203 is shooting in a direction perpendicular to the horizontal plane and downwards, the RGB image and depth image of the target pig are the RGB image and depth image of the back of the target pig.
[0074] In this embodiment of the invention, the moving mechanism is connected to the supporting mechanism and can drive the supporting mechanism to move, allowing the image acquisition device to be adjusted in a larger spatial range. This provides users with greater shooting freedom and enables the acquisition of RGB and depth images of any pig as needed. The supporting mechanism includes a supporting base and a multi-axis robotic arm, which is composed of multiple connecting rods that are rotated sequentially. This allows the image sensor to achieve precise positioning and shooting in three-dimensional space. By adjusting the rotation angle of each connecting rod, the image sensor can be flexibly moved above the target pig. By integrating the moving mechanism, the supporting mechanism, and the image sensor, the image acquisition device automates and simplifies the shooting process. Users can quickly adjust the shooting position of the image sensor with simple operations, significantly improving shooting efficiency. This device better adapts to the dynamic and complex real-world environment of farms, reduces manual intervention when acquiring pig images, better avoids stress reactions in pigs, and improves the practicality of pig weight estimation. It provides a more accurate and efficient data foundation for pig weight estimation, enhancing its applicability and widespread adoption.
[0075] The first electronic device 103 is used to, upon receiving an RGB image and a depth image of a target pig, preprocess the depth image of the target pig based on the RGB image of the target pig, input the preprocessed depth image of the target pig into a pig weight estimation model, and obtain an estimated value of the target pig weight output by the pig weight estimation model.
[0076] The pig weight estimation model is built on an improved EfficientNetV2 network and trained on the depth image of the sample pigs after preprocessing the sample pig data and the actual weight of the sample pigs. The depth image of the sample pigs after preprocessing the sample pig data is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs. The method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs.
[0077] Specifically, the first electronic device 103 in this embodiment of the invention may be an electronic device such as a computer or a server.
[0078] Optionally, the first electronic device 103 can be configured to run on an Ubuntu 18.04 system, and the hardware configuration of the first electronic device 103 includes an Intel Xeon Platinum 8375C CPU and an NVIDIA RTX A6000 GPU with 24GB of video memory.
[0079] Upon receiving the RGB image and depth image of the target pig, the first electronic device 103 can perform data preprocessing on the depth image of the target pig based on the RGB image of the target pig through numerical calculation, mathematical statistics, and deep learning, and obtain the preprocessed depth image of the target pig.
[0080] After obtaining the depth image of the target pig data after preprocessing, the depth image of the target pig data after preprocessing can be input into the pig weight estimation model to obtain the estimated value of the target pig weight output by the above pig weight estimation model.
[0081] It should be noted that the actual weight of the sample pigs in this embodiment of the invention can be obtained in the following way: First, each sample pig is weighed using an electronic scale, the initial weight value is recorded, the instrument is zeroed, and a second weighing is performed. Each sample pig is weighed three times, and the average of the three weights is taken as the actual weight of the sample pig, and the corresponding number is recorded.
[0082] Data collection is scheduled between 7:00 and 8:00 every day. This period is before the pigs eat, when the herd is active and almost all of them are standing. They usually gather around the feed trough before being fed, which makes data collection easier.
[0083] It is understandable that the sample pigs can be determined based on actual circumstances. In this embodiment of the invention, pigs of different weights within a pig farm can be selected as sample pigs. Figure 3 This is a weight distribution map of sample pigs in the pig weight estimation system provided by this invention.
[0084] In this embodiment of the invention, the image acquisition device 102 can be used to acquire RGB images and depth images of sample pigs.
[0085] Specifically, the experimenter can control the moving mechanism 204 and / or the support mechanism through the first electronic device 103 or the second electronic device to move the image sensor 203 above each sample pig, and keep the shooting direction of the image acquisition device 102 perpendicular to the horizontal plane and downward.
[0086] To reduce duplicate frames, the image sensor 203 in this embodiment of the invention can acquire and save one frame every 3 seconds, acquiring approximately 150 RGB and depth images per sample pig. By acquiring RGB and depth images of approximately 10 sample pigs per day, a total of 145 sample pigs with varying weights were collected, covering weight changes throughout the pig's lifespan.
[0087] After obtaining the RGB and depth images of the sample pigs, images that do not contain the sample pigs or are missing from the above images can be removed.
[0088] It is understandable that there is a correspondence between the actual weight of the sample pigs and the RGB and depth images of the sample pigs.
[0089] It should be noted that the pig weight estimation model in this embodiment of the invention is trained using the PyTorch deep learning framework, with the relevant environment including CUDA 11.3, PyTorch 1.9.0, and Python 3.8. Depth images are all proportionally adjusted to a resolution of 224×224. During training, random horizontal flipping, vertical flipping, and rotation are also applied for data augmentation. Specifically, to prevent excessive missing values due to rotation of the pig's back, the random rotation angle is limited to within 20° in this embodiment. The parameter settings are as follows: the optimizer is AdamW, the iteration period is set to 100 epochs, and the learning rate is set to... The weight decay is set to We used a cosine annealing (LR) learning rate adjustment strategy with a batch size of 32.
[0090] Mean Squared Error (MSE) was used as the loss function during the training of the pig weight estimation model. The MSE loss function guides the model's learning process by measuring the squared error between the predicted and actual weight values. Its formula is defined as follows: in, This represents the weight value predicted by the model. This represents the actual weight value. This refers to the sample size. The main advantage of using MSE as the loss function is its greater sensitivity to larger errors, effectively penalizing significant biases in the model's weight predictions. This characteristic is particularly important for achieving accurate weight estimation, as small errors in pig weight prediction can accumulate into large actual deviations.
[0091] In this embodiment of the invention, four evaluation metrics are used to evaluate the trained pig weight estimation model. These four metrics are: Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Root Mean Square Error (RMSE), and Coefficient of Determination (CDO). MAE is used to measure regression error and reflects the actual error of the predicted values. The formula for calculating MAE is as follows: in, This is a test image. The true value, This is a predicted value.
[0092] MAPE is used to measure the goodness of fit of a model. The smaller the MAPE value, the better the model fits and the higher the accuracy. The formula for calculating MAPE is as follows: RMSE represents the sample standard deviation of the difference between the predicted and actual values, and can be used to reflect the degree of fluctuation in weight measurement error. The formula for calculating RMSE is as follows: Coefficient of determination ( The value is used to measure the fit of the model; the closer the value is to 1, the better the fit. The calculation formula is as follows: in, It is the average value of the true values of the test image.
[0093] The pig weight estimation system in this embodiment of the invention includes an image acquisition device and a first electronic device. The image acquisition device includes a moving mechanism, a supporting mechanism, and an image sensor. It can capture RGB images and depth images of the pig vertically downward using the image sensor. Combined with the moving mechanism, the image acquisition range can be flexibly adjusted, enabling more accurate, efficient, and flexible image acquisition of the pig without causing stress to the pig. The first electronic device uses the RGB images of the pig to preprocess the depth images, and then uses an improved EfficientNetV2 model to estimate the pig weight, obtaining an estimated value of the pig weight. Through optimized training of the model, spatial and three-dimensional information can be effectively integrated during pig weight estimation, significantly improving the accuracy of pig weight estimation. Furthermore, the lightweight design of the model reduces the amount and complexity of computation during the pig weight estimation process, significantly improving the speed and efficiency of pig weight estimation. It reduces human intervention during pig weight estimation, better avoids stress to the pig, and improves the practicality of pig weight estimation. It provides more reliable and efficient technical support for pig farming management and is suitable for rapid and automated monitoring of pig weight in large-scale farming scenarios.
[0094] Figure 4 This is a schematic diagram illustrating the process of data preprocessing of a depth image of a target pig by the first electronic device in the pig weight estimation system provided by the present invention. As an optional embodiment, the first electronic device 103 is specifically used to perform image recognition and instance segmentation on the RGB image of the target pig. After obtaining the mask of the target pig, and ensuring the mask is complete, the mask is mapped onto the depth image of the target pig to obtain the segmentation result of the target pig in the depth image, which serves as the preprocessed depth image of the target pig.
[0095] Specifically, in this embodiment of the invention, deep learning technology can be used to identify the target pig in the RGB image of the target pig and perform instance segmentation on the identified target pig to obtain the mask of the target pig.
[0096] After obtaining the mask of the target pig, a conditional judgment can be used to determine whether the mask is complete. If the mask is complete, it can be mapped onto the depth image of the target pig to obtain the segmentation result of the target pig in the depth image, which serves as the preprocessed depth image of the target pig data.
[0097] As an optional embodiment, the first electronic device 103 is specifically used to input the RGB image of the target pig into the pig recognition model to obtain the target pig mask output by the pig recognition model. The first electronic device 103 is also used to map the target pig mask onto a blank image of the same size as the RGB image of the target pig. If it is determined that the target pig mask does not intersect with the boundary of the blank image, or if the target pig mask intersects with the boundary but the distance of the target pig mask to the boundary is less than a distance threshold, then it is determined that the target pig mask is complete. The pig recognition model is obtained by performing transfer learning on the training model based on the sample pig mask. The sample pig mask is obtained by performing image recognition and instance segmentation on the RGB image of the sample pig.
[0098] Specifically, since RGB images have texture and color information, the accuracy of instance segmentation is higher than that of depth images. Therefore, in this embodiment of the invention, actual segmentation is performed based on RGB images.
[0099] In this embodiment of the invention, EISeg software can be used to label sample pigs in RGB images of a subset of pigs, serving as training samples. Then, based on these training samples, transfer learning can be performed on the general pre-trained model SAM2 to obtain a pig identification model.
[0100] After inputting the RGB image of the target pig into the above pig recognition model, the mask of the target pig in the RGB image of the target pig output by the above pig recognition model can be obtained.
[0101] After obtaining the mask of the target pig in the RGB image of the target pig, the mask of the target pig can be mapped onto a blank image of the same size as the RGB image of the target pig.
[0102] If it is determined that the mask of the target pig does not intersect with the boundary of the aforementioned blank image, or if the mask of the target pig intersects with the boundary of the aforementioned blank image but the distance between the mask of the target pig and the boundary of the aforementioned blank image is less than a distance threshold, then the mask of the target pig can be determined to be complete. Furthermore, based on the correspondence between the RGB image and the depth image of the target pig, the mask of the target pig can be mapped to the depth image of the target pig to obtain the segmentation result of the target pig in the depth image. This result is used as the depth image after the target pig data processing and is used as the input of the pig weight estimation model.
[0103] It should be noted that the distance threshold in the embodiments of the present invention can be determined based on prior knowledge and / or actual conditions. For example, the range of the distance threshold can be 13 to 17 pixels. The specific value of the distance threshold is not limited in the embodiments of the present invention.
[0104] It should be noted that after obtaining the above-mentioned pig identification model, image recognition and instance segmentation can be performed on the RGB images of the remaining unlabeled sample pigs based on the above-mentioned pig identification model to obtain the mask of the sample pigs in the RGB images of the remaining unlabeled sample pigs.
[0105] After obtaining the mask of the sample pig in the RGB image of the sample pig, the mask of the sample pig can be mapped onto a blank image of the same size as the RGB image of the sample pig.
[0106] If it is determined that the mask of the sample pig does not intersect with the boundary of the aforementioned blank image, or if the mask of the sample pig intersects with the boundary of the aforementioned blank image but the distance between the mask of the sample pig and the boundary of the aforementioned blank image is less than a distance threshold, then the mask of the sample pig can be determined to be complete. Furthermore, based on the correspondence between the RGB image and the depth image of the sample pig, the mask of the sample pig can be mapped to the depth image of the sample pig to obtain the segmentation result of the sample pig in the depth image of the sample pig, which is used as the depth image after the sample pig data processing.
[0107] After obtaining depth images of the sample pigs that correspond to the actual weight of the sample pigs, the processed pig images can be divided into training and testing sets. These sets are used for training and testing the pig weight estimation model, respectively, to obtain a well-trained pig weight estimation model. The sample pigs in the testing set are randomly selected pigs with a uniform weight distribution, while the sample pigs in the training set are all pigs other than those in the testing set.
[0108] When training the initial model built on the improved EfficientNetV2 network, the depth images of pigs in the training set after processing can be used as training samples, and the actual weight of the pigs corresponding to the depth images of pigs in the training set after processing can be used as sample labels. The initial model can then be trained to obtain a well-trained pig weight estimation model.
[0109] It should be noted that after obtaining the mask of the sample pig in the RGB image of the sample pig in the embodiment of the present invention, a comparative experiment can be conducted on the trained pig weight estimation model based on the mask of the sample pig in the RGB image of the sample pig and the segmentation result of the sample pig in the depth image of the sample pig, so as to evaluate the performance of the trained pig weight estimation model.
[0110] In this embodiment of the invention, the first electronic device uses a pig identification model obtained based on transfer learning to perform instance segmentation on the RGB image of the target pig. After generating a mask for the target pig, it performs a mask integrity check to ensure that the mask of the target pig is truncated or occluded. Then, it maps the mask of the target pig to a depth image, which can accurately obtain the segmentation result of the target pig in the depth image. As a depth image after preprocessing the target pig data, it can effectively remove background noise interference in the depth image of the target pig, achieve accurate alignment between the RGB image and the depth image of the target pig, significantly improve the reliability of data preprocessing of the depth image of the target pig, reduce errors caused by incomplete image acquisition through mask integrity verification, and enhance data consistency through spatial alignment of the RGB image and the depth image. It provides high-precision input for the pig weight estimation model, thereby improving the robustness and accuracy of the pig weight estimation system, and is suitable for the automated monitoring needs of large-scale breeding scenarios.
[0111] Figure 5 This is a schematic diagram of the structure of the pig weight estimation model in the pig weight estimation system provided by this invention. Figure 5 As shown, as an optional embodiment, the pig weight estimation model includes: a backbone network and a weight estimation head module connected in sequence; the backbone network is constructed based on an improved EfficientNetV2 network, which is an EfficientNetV2 network in which the SE module is replaced with a CBAM module.
[0112] Specifically, after obtaining the preprocessed depth image of the target pig data, each pixel in the preprocessed depth image represents the actual distance between the image sensor 203 and a point on the back of the target pig, reflecting the spatial structure information of the target pig's back. The trained live-group weight estimation model can extract the morphological and volumetric features of the target pig from the preprocessed depth image, and then establish a regression relationship between these features and the weight of the target pig to estimate its weight.
[0113] To accommodate the requirement of most deep learning networks for three-channel input, this embodiment of the invention copies the depth image's single-channel number three times. Considering the real-time and efficiency requirements for pig weight estimation in practical applications, the EfficientNetV2 network is selected to construct the backbone network of the pig weight estimation model.
[0114] Building upon this foundation, to enhance the spatial information capture capability of the pig weight estimation model, this embodiment of the invention replaces the original SE (Squeeze-and-Excitation) module in the EfficientNetV2 network with the CBAM (Convolutional Block Attention Module) module. For the morphological and volumetric features of the target pig extracted by the backbone network, a weight estimation head module is designed to process these features and estimate the weight of the target pig.
[0115] During training, the pig weight estimation model is trained by taking preprocessed depth images of corresponding sample pig data and the actual weight values of the sample pigs as input. The optimizer continuously adjusts the model parameters of the pig weight estimation model, minimizes the loss function, and finally obtains the trained pig weight estimation model.
[0116] It should be noted that EfficientNetV2 is a highly efficient convolutional neural network. By combining training-aware neural architecture search (NAS) and progressive learning strategies, EfficientNetV2 has achieved excellent performance on multiple benchmark datasets.
[0117] The SE module is a channel attention mechanism that dynamically adjusts the weights of each channel to make the network focus on the more important feature channels. The CBAM module combines channel attention and spatial attention, using a two-step attention mechanism to enhance the feature representation of important channels and spatial regions respectively.
[0118] It should be noted that the EfficientNetV2 network architecture consists of multiple stages, each using different modules. For example... Figure 5 As shown, the backbone network in the pig weight estimation model consists of 8 stages, each using a different module.
[0119] Stage 0 contains a convolution calculation module (Conv 3×3) used to perform convolution calculations on the input image with a kernel of 3×3 and a stride of 2. Stage 0 has 1 layer.
[0120] The first stage (Stage 1) has a stride of 1 and a scaling factor of 1, and uses a CBAM module to replace the SE module's fused moving inverse convolutional module (CBAM Fused-MBConv1). The second stage has 2 layers.
[0121] The second stage (Stage 2) has a stride of 2 and a scaling factor of 4, and uses the CBAM module to replace the SE module with the fused moving inverse convolutional module (CBAM Fused-MBConv4). The third stage has 3 layers.
[0122] The third stage (Stage 3) has a stride of 2 and a scaling factor of 4, and uses the CBAM module to replace the SE module with the fused moving inverse convolutional module (CBAM Fused-MBConv4). The fourth stage has 3 layers.
[0123] The fourth stage (Stage 4) has a stride of 2 and a scaling factor of 4, and replaces the SE module with a moving inverse convolutional module (CBAM MBConv4). The fifth stage has 4 layers.
[0124] The fifth stage (Stage 5) has a stride of 1, a scaling factor of 6, and replaces the SE module with a moving inverse convolutional module (CBAM MBConv6). The fifth stage has 6 layers.
[0125] Stage 6 has a stride of 2, a scaling factor of 6, and uses the CBAM module to replace the SE module's moving inverse convolutional module (CBAM MBConv6). Stage 6 has 12 layers.
[0126] Stage 7 includes convolutional, pooling, and fully connected computation modules (Conv 1×1, Pooling, and FC) to sequentially perform convolutional computation with 1×1 kernels, pooling computation, and fully connected computation on the input feature image. Stage 7 has one layer.
[0127] It should be noted that MBConv stands for Mobile Inverted Bottleneck Convolution, which is a high-efficiency convolution module.
[0128] like Figure 5 As shown, the fusion MBConv module in this embodiment of the invention, which replaces the SE module with the CBAM module, may include a convolution calculation module (Conv 3×3), a CBAM module, a convolution calculation module (Conv 1×1), and a feature fusion module connected in sequence. The feature fusion module is used to fuse the input of the convolution calculation module (Conv 3×3) and the output of the convolution calculation module (Conv 1×1).
[0129] like Figure 5 As shown, the MBConv module in this embodiment of the invention, which replaces the SE module with the CBAM module, may include a convolution calculation module (Conv 3×3), a depthwise separable convolution calculation module (Depthwise Conv 1×1), a CBAM module, a convolution calculation module (Conv 1×1), and a feature fusion module connected in sequence. The feature fusion module is used to fuse the input of the convolution calculation module (Conv 3×3) and the output of the convolution calculation module (Conv 1×1).
[0130] In this embodiment of the invention, the backbone network of the pig weight estimation model is constructed based on the advanced EfficientNetV2 network, primarily due to EfficientNetV2's superior performance in convolutional neural networks (CNNs) and its powerful ability to represent fine-grained features. Compared to EfficientNetV1, EfficientNetV2 performs better in resource-constrained environments, making it highly suitable as the backbone network for pig weight estimation models. Its design combines the Moving Inverse Bottleneck Convolution (MBConv) module and the Fused Moving Inverse Bottleneck Convolution (Fused-MBConv) module, fully leveraging the advantages of both in the network structure. The MBConv module expands and compresses channels through inverse bottleneck design, balancing the network's expressive power and computational cost; while the Fused-MBConv module further simplifies this process, improving performance through a fusion layer.
[0131] To further enhance the ability of the trained pig weight estimation model to capture spatial and channel features, this embodiment of the invention improves the EfficientNetV2 network by replacing the SE module in the EfficientNetV2 network with the CBAM module, thereby enhancing the pig weight estimation model's focus on key regional features and optimizing spatial information processing capabilities.
[0132] The SE module primarily models the importance of each channel using a channel attention mechanism. However, in depth images, spatial information is particularly crucial for pig weight estimation, and channel attention alone may not be sufficient to capture key geometric features in the depth image. Therefore, this embodiment introduces the CBAM mechanism into the EfficientNetV2 network. The CBAM module, while retaining the channel attention mechanism, further incorporates a spatial attention mechanism, combining global and local information from the input features to model the spatial distribution of the feature map. This design enables the network to more accurately focus on important regions in the depth image, such as the key geometric structures of the pig's back.
[0133] Figure 6 This is a comparison diagram of the SE module and the CBAM module. (For example...) Figure 6 As shown, the CBAM module uses intermediate feature maps As input, a one-dimensional channel attention map is inferred sequentially through the channel attention module and the spatial attention module. A two-dimensional spatial attention graph ,like Figure 6 As shown in (b). The entire attention processing process can be summarized as follows: in, This represents an element-wise multiplication operation. During the multiplication process, attention values are broadcast (copied) as needed: channel attention values are broadcast along the spatial dimension, while spatial attention values are broadcast along the channel dimension. The final result is... It is the output feature map.
[0134] In the channel attention module, two different spatial context descriptors are generated: and , representing the average pooling feature and the max pooling feature, respectively. These two descriptors are then fed into a shared network to generate channel attention maps. After the shared network is applied to each descriptor separately, its output feature vectors are merged by summing element-wise. The formula for calculating channel attention is: in, This represents the sigmoid function. , Where r is the scaling ratio. It's important to note the weights of the MLP. and It is shared across the two inputs, and, It is followed by the ReLU activation function.
[0135] In the spatial attention module, the spatial attention map is generated by utilizing the spatial relationships of features. Unlike channel attention, spatial attention focuses on identifying "where" the information-rich regions are, thus complementing channel attention. First, average pooling and max pooling operations are applied along the channel axes and concatenated to generate an efficient feature descriptor. Then, a standard convolutional layer is applied to the concatenated feature descriptor to generate the spatial attention map. It encodes the locations that need to be emphasized or suppressed. The channel information of the feature map is aggregated through two pooling operations to generate two two-dimensional maps: and , representing the average pooling feature and max pooling feature across channels, respectively. These features are then concatenated and passed through a standard convolutional layer to generate a two-dimensional spatial attention map. The formula for calculating spatial attention is: in, This represents the sigmoid function. Indicates the kernel size as The convolution operation.
[0136] Figure 7 This is a schematic diagram of the structure of the weight estimation head module in the pig weight estimation model of the pig weight estimation system provided by this invention. Figure 7 As shown, in an optional embodiment, the weight estimation head module includes: a global average pooling unit, a first fully connected layer unit, a ReLU activation function unit, a regularization calculation unit, and a second fully connected layer unit connected in sequence.
[0137] Specifically, to further improve the computational accuracy of the pig weight estimation model, a lightweight weight estimation head module is designed in this embodiment of the invention. The purpose of the weight estimation head module is to further process the high-level features extracted from the backbone network in the pig weight estimation model and map them to the target space to complete the estimation of pig weight.
[0138] The Global Average Pooling (GAP) unit is used to aggregate global spatial information in the feature maps output by the backbone network. This operation effectively reduces the dimensionality of the feature maps by calculating the average value of each channel in the spatial dimension, while preserving the global contextual information of the input depth image.
[0139] The first fully connected layer (FC) unit maps the global feature vector generated by the global average pooling unit to a high-dimensional latent space, further exploring the complex relationship between input features and target weight. To introduce nonlinear characteristics, this embodiment of the invention sets a ReLU activation function unit (ReLU) after the global average pooling unit, which is used to calculate the ReLU activation function on the output of the global average pooling unit, thereby improving the ability of the pig weight estimation model to express nonlinear features.
[0140] In addition, to enhance the generalization ability of the pig weight estimation model and alleviate the overfitting problem, the weight estimation head module has a regularization computation unit (Dropout) after the ReLU activation function unit, which achieves the regularization effect by randomly dropping some neurons.
[0141] The second fully connected layer (FC) further maps the nonlinearly transformed and regularized features to the final target space, outputting the predicted value of the target pig weight.
[0142] Since pooling layers play a crucial role in feature learning and model generalization, this embodiment of the invention designs two additional weight estimation head variables to explore the impact of the aforementioned factors. Figure 8 This is a schematic diagram comparing the structure of the weight estimation head module in the pig weight estimation model provided by this invention with two other weight estimation variants. Figure 8 (a) is the weight estimation head module in the pig weight estimation model provided by the present invention.
[0143] like Figure 8 As shown in (b), the first variation of weight estimation replaces the global average pooling unit with a global max pooling unit (GMP). The global max pooling unit emphasizes the strongest local responses in the image by selecting the most salient features in each channel. The global max pooling unit focuses on capturing the most important regional information in feature extraction, which helps to improve the model's attention to key pig back features.
[0144] like Figure 8 As shown in (c), the second variation of weight estimation replaces the global average pooling unit with a generalized average pooling unit (GeM). The GeM balances the advantages and disadvantages of average pooling and max pooling by adjusting the pooling exponent. Its advantage lies in automatically selecting the appropriate pooling method based on task requirements, thereby effectively extracting features at different levels. In weight estimation tasks, the GeM can better adapt to features of different image content, improving the model's ability to learn fine-grained features.
[0145] The pig weight estimation model in this embodiment of the invention replaces the SE module in the EfficientNetV2 network with the CBAM module, and then constructs a pig weight estimation model based on the improved EfficientNetV2 network. This enhances the pig weight estimation model's ability to capture spatial and channel features, especially focusing on key geometric features in depth images, thereby achieving accurate estimation of pig weight in resource-constrained environments. By constructing a lightweight weight estimation head module, the computational load and complexity of the model can be further reduced without reducing the model's computational accuracy.
[0146] The pig weight estimation system 101 provided by this invention can be used for estimating pig weight within the relatively limited space of a single pigsty. Image acquisition is mainly selected during the active period before pigs eat, when pigs are usually located at the edge of the pigsty. Under these conditions, the image acquisition device 102 in the pig weight estimation system 101 provided by this invention can be effectively positioned directly above the pigs and complete data acquisition. The aforementioned image acquisition device has demonstrated good feasibility in pig farming scenarios, providing a reference and exploration direction for the future design of more flexible and wider-coverage data acquisition equipment.
[0147] Although the pig weight estimation model provided by this invention is based on depth images, this invention preprocesses the depth images based on the RGB images of pigs. The results show that the RGB image segmentation is significantly better than the depth image segmentation. This is because RGB images contain rich texture features, which helps to improve the accuracy of segmentation.
[0148] The pig weight estimation system 101 provided by this invention includes a portable image acquisition device 102 and a first electronic device 103. It can be used for non-contact estimation of pig weight, avoiding the traditional method of herding pigs through channels, significantly improving acquisition efficiency and reducing interference with the pigs. The proposed improved EfficientNetV2 lightweight model enhances the ability to capture spatial features of depth images by introducing a CBAM attention mechanism. Experimental results show that the pig weight estimation model provided by this invention outperforms other methods in weight estimation tasks, with a mean absolute error (MAE) of only 3.263 kg, while also possessing low computational complexity and resource consumption. Furthermore, a detailed comparison of the performance of different weight estimation heads further verifies the superiority of the proposed method. The pig weight estimation system 101 provided by this invention provides technical support and theoretical basis for non-contact weight estimation in intelligent farming scenarios, and has significant practical implications, helping to improve farming efficiency, animal welfare, and achieve refined management.
[0149] Based on the above embodiments, the present invention also provides a method for estimating pig weight based on any of the above pig weight estimation systems 101. Figure 9 This is a flowchart illustrating the pig weight estimation method provided by the present invention. Figure 9 As shown, the method includes the following steps: Step 901: Acquire the RGB image and depth image of the target pig, which are acquired using an image sensor located above the target pig; Step 902: Based on the RGB image of the target pig, perform data preprocessing on the depth image of the target pig to obtain the preprocessed depth image of the target pig. Step 903: Input the preprocessed depth image of the target pig data into the pig weight estimation model to obtain the estimated weight of the target pig output by the pig weight estimation model; The pig weight estimation model is built on an improved EfficientNetV2 network and trained on the depth image of the sample pig data after preprocessing and the actual weight of the sample pigs. The depth image of the sample pig data after preprocessing is obtained by preprocessing the depth image of the sample pig based on the RGB image of the sample pig.
[0150] It should be noted that the pig weight estimation method provided by this invention is implemented based on the aforementioned pig weight estimation system 101. The specific execution steps of the pig weight estimation method provided by this invention can be found in the above embodiments, and will not be repeated in the embodiments of this invention.
[0151] This invention preprocesses depth images using RGB images of pigs and then estimates pig weight using an improved EfficientNetV2 model. Through optimized model training, spatial and 3D information is effectively fused during weight estimation, significantly improving accuracy. Furthermore, the lightweight model design reduces computational load and complexity, significantly increasing speed and efficiency. This reduces human intervention and provides more reliable and efficient technical support for pig farming management, making it suitable for rapid, automated monitoring of pig weight in large-scale farming scenarios.
[0152] Figure 10 This is a schematic diagram of the structure of the first electronic device provided by the present invention. (See diagram below.) Figure 10As shown, the electronic device may include: a processor 1010, a communications interface 1020, a memory 1030, and a communications bus 1040, wherein the first electronic device 1031010, the communications interface 1020, and the memory 1030 communicate with each other through the communications bus 1040. The processor 1010 can call logic instructions in the memory 1030 to execute a pig weight estimation method. This method includes: acquiring an RGB image and a depth image of a target pig, the RGB image and depth image of the target pig being acquired using an image sensor located above the target pig; performing data preprocessing on the depth image of the target pig based on the RGB image of the target pig to obtain a preprocessed depth image of the target pig; inputting the preprocessed depth image of the target pig into a pig weight estimation model to obtain an estimated value of the target pig's weight output by the pig weight estimation model; wherein, the pig weight estimation model is constructed based on an improved EfficientNetV2 network and trained based on the preprocessed depth image of sample pigs and the actual weight value of the sample pigs; the preprocessed depth image of the sample pigs is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs; the method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs.
[0153] Furthermore, the logical instructions in the aforementioned memory 1030 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0154] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by the processor 1010, the computer can execute the pig weight estimation method provided by the above methods. The method includes: acquiring an RGB image and a depth image of a target pig, wherein the RGB image and depth image of the target pig are acquired using an image sensor located above the target pig; performing data preprocessing on the depth image of the target pig based on the RGB image of the target pig to obtain a preprocessed depth image of the target pig; and... The preprocessed depth image of the target pig data is input into the pig weight estimation model to obtain the estimated weight of the target pig output by the model. The pig weight estimation model is built based on an improved EfficientNetV2 network and is trained on the preprocessed depth image of the sample pig data and the actual weight of the sample pigs. The preprocessed depth image of the sample pig data is obtained by preprocessing the depth image of the sample pig based on the RGB image of the sample pig. The data preprocessing method for the depth image of the sample pig is the same as that for the depth image of the target pig.
[0155] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by processor 1010, is implemented to perform the pig weight estimation method provided by the above methods. This method includes: acquiring an RGB image and a depth image of a target pig, the RGB image and depth image of the target pig being acquired using an image sensor located above the target pig; performing data preprocessing on the depth image of the target pig based on the RGB image of the target pig to obtain a preprocessed depth image of the target pig; inputting the preprocessed depth image of the target pig into a pig weight estimation model to obtain an estimated value of the target pig weight output by the pig weight estimation model; wherein the pig weight estimation model is constructed based on an improved EfficientNetV2 network and trained based on the preprocessed depth image of sample pigs and the actual weight value of the sample pigs; the preprocessed depth image of the sample pigs is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs; the method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs.
[0156] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0157] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A pig weight estimation system, characterized in that, include: An image acquisition device and a first electronic device; the image acquisition device is electrically connected to the first electronic device; The image acquisition device includes a moving mechanism, a supporting mechanism, and an image sensor; the moving mechanism is connected to the supporting mechanism and is used to drive the supporting mechanism to move. The image sensor is mounted on the support mechanism. The image sensor's shooting direction is perpendicular to the horizontal plane and downwards. The image sensor is used to acquire RGB images and depth images of the target pig located below the image sensor, and to send the acquired RGB images and depth images of the target pig to the first electronic device. The first electronic device is used to, upon receiving the RGB image and depth image of the target pig, perform data preprocessing on the depth image of the target pig based on the RGB image of the target pig, input the preprocessed depth image of the target pig into a pig weight estimation model, and obtain an estimated value of the target pig weight output by the pig weight estimation model; The pig weight estimation model is built on an improved EfficientNetV2 network and trained on the depth image of the sample pigs after preprocessing the sample pig data and the actual weight of the sample pigs. The depth image of the sample pigs after preprocessing the sample pig data is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs. The method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs. The first electronic device is specifically used to input the RGB image of the target pig into the pig recognition model to obtain the mask of the target pig output by the pig recognition model. The first electronic device is also used to map the mask of the target pig onto a blank image of the same size as the RGB image of the target pig. If it is determined that the mask of the target pig does not intersect with the boundary of the blank image, or if the mask of the target pig intersects with the boundary but the distance of the mask of the target pig to the boundary is less than a distance threshold, then it is determined that the mask of the target pig is complete. The pig recognition model is obtained by performing transfer learning on the training model based on the mask of the sample pig. The mask of the sample pig is obtained by performing image recognition and instance segmentation on the RGB image of the sample pig.
2. The pig weight estimation system according to claim 1, characterized in that, The support mechanism includes a support base and a multi-axis robotic arm. One end of the multi-axis robotic arm is fixed to the support base, and the other end of the multi-axis robotic arm is continuous with the image sensor. The multi-axis robotic arm includes multiple connecting rods, and each connecting rod is rotatably connected in sequence.
3. The pig weight estimation system according to claim 1, characterized in that, The first electronic device is specifically used to perform image recognition and instance segmentation on the RGB image of the target pig, obtain the mask of the target pig, and, if the mask of the target pig is complete, map the mask of the target pig onto the depth image of the target pig to obtain the segmentation result of the target pig in the depth image of the target pig, which is used as the depth image after the target pig data preprocessing.
4. The pig weight estimation system according to claim 1, characterized in that, The pig weight estimation model includes: a backbone network and a weight estimation head module connected in sequence; the backbone network is constructed based on the improved EfficientNetV2 network, which is an EfficientNetV2 network in which the SE module is replaced with the CBAM module.
5. The pig weight estimation system according to claim 4, characterized in that, The weight estimation head module includes: a global average pooling unit, a first fully connected layer unit, a ReLU activation function unit, a regularization calculation unit, and a second fully connected layer unit connected in sequence.
6. The pig weight estimation system according to claim 2, characterized in that, The support base has a telescopic function, which can drive the multi-axis robotic arm to move in a direction perpendicular to the horizontal plane.
7. The pig weight estimation system according to claim 6, characterized in that, The first electronic device is electrically connected to at least one of the support base, the multi-axis robotic arm, and the moving mechanism; when electrically connected to the moving mechanism, the first electronic device is used to control the moving direction and / or moving distance of the moving mechanism; when electrically connected to the multi-axis robotic arm, the first electronic device is used to control the included angle between at least two adjacent connecting rods in the multi-axis robotic arm; when electrically connected to the support base, the first electronic device is used to control the height of the support base.
8. The pig weight estimation system according to claim 6, characterized in that, The image acquisition device further includes a second electronic device; the second electronic device is electrically connected to at least one of the support base, the multi-axis robotic arm, and the moving mechanism; when electrically connected to the moving mechanism, the second electronic device is used to control the moving direction and / or moving distance of the moving mechanism; when electrically connected to the multi-axis robotic arm, the second electronic device is used to control the included angle between at least two adjacent connecting rods of the multi-axis robotic arm; when electrically connected to the support base, the second electronic device is used to control the height of the support base.
9. A method for estimating pig weight based on the pig weight estimation system as described in any one of claims 1 to 8, characterized in that, include: The RGB and depth images of the target pig are acquired using an image sensor located above the target pig. Based on the RGB image of the target pig, the depth image of the target pig is preprocessed to obtain the preprocessed depth image of the target pig. The preprocessed depth image of the target pig data is input into the pig weight estimation model to obtain the estimated weight of the target pig output by the pig weight estimation model. The pig weight estimation model is constructed based on an improved EfficientNetV2 network and trained on the depth image of the sample pigs after preprocessing the sample pig data and the actual weight of the sample pigs. The depth image of the sample pigs after preprocessing the sample pig data is obtained by preprocessing the depth image of the sample pigs based on the RGB image of the sample pigs. The method of preprocessing the depth image of the sample pigs is the same as the method of preprocessing the depth image of the target pigs.
Citation Information
Patent Citations
Non-contact body weight measurement method and system for live pigs, electronic equipment and storage medium
CN116485823A
AI-based live pig abnormal behavior monitoring and early warning method and system
CN118658209A