A kind of backfat thickness detection method, device, equipment and storage medium
By combining prior and real-time characteristics of the pig body, and using regression and density models to analyze backfat thickness, the problem of high detection costs, low efficiency, and harm to the pig body in breeding pig farming has been solved, achieving efficient and accurate backfat thickness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE CHENGDU INFORMATION & TELECOMM TECH CO LTD
- Filing Date
- 2021-07-01
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies for detecting backfat thickness in breeding pigs are costly, inefficient, and may harm the pigs. Professional personnel are scarce, and the results are unreliable.
By acquiring prior and real-time characteristics of the pig, and using a pre-set regression model and density model for analysis, the backfat thickness is determined by combining the results of multiple models, thus avoiding close-contact measurement.
It improves the accuracy and efficiency of backfat thickness detection, reduces costs, and does not harm the pig.
Smart Images

Figure CN115578609B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent aquaculture technology, and in particular to a method, apparatus, equipment, and storage medium for detecting backfat thickness. Background Technology
[0002] In pig breeding, backfat thickness is considered a crucial physical indicator, widely used to guide health assessment and production capacity evaluation. To accurately measure backfat thickness, specialized equipment, such as ultrasound, is typically used. However, this method is costly and inefficient. Especially in large-scale farms, it incurs significant costs and reduces testing frequency; insufficient testing significantly diminishes the indicator's value. Furthermore, measuring backfat thickness with ultrasound requires close contact with the pig, potentially causing physiological and psychological harm.
[0003] In addition, experienced pig farmers can determine the backfat parameters of pigs based on their physical characteristics. However, since these are empirical parameters, such professionals are extremely scarce, and their experience is not easily standardized and replicated. Furthermore, the condition of the personnel can also affect the judgment results, which may seriously mislead production. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for detecting backfat thickness, which not only avoids harm to the pig body from close-contact measurement, but also improves the accuracy of backfat thickness detection, and reduces costs while increasing detection efficiency.
[0005] The technical solution of this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a method for detecting backfat thickness, the method comprising:
[0007] Obtain the prior and real-time features of the pig to be detected;
[0008] The first backfat thickness was determined by analyzing prior features and real-time features using a pre-defined regression model.
[0009] The second backfat thickness is determined by analyzing prior and real-time features using a pre-defined density model.
[0010] The backfat thickness of the pig to be tested is determined based on the first backfat thickness and the second backfat thickness.
[0011] Secondly, embodiments of this application provide a feature acquisition device, which includes at least an RFID reading module, an infrared sensor array module, a camera module, and a grid projection module; wherein,
[0012] The RFID reading module is used to acquire ear tag information of the pig so that the feature acquisition device can determine the prior features of the pig based on the ear tag information;
[0013] An infrared sensor array module is used to acquire a binary occlusion array image of the pig's body, so that the feature acquisition device can determine the pig's hip height and body height based on the binary occlusion array image.
[0014] The camera module is used to acquire a top-view image of the pig's body so that the feature acquisition device can determine the curvature of the pig's back based on the top-view image;
[0015] The raster projection module is used to acquire raster images so that the feature acquisition device can determine the body width and body length of the pig based on the raster images.
[0016] Thirdly, embodiments of this application provide a device for detecting the backfat thickness of pigs. This device includes an acquisition unit, a first analysis unit, a second analysis unit, and a determination unit.
[0017] The acquisition unit is configured to acquire the prior features and real-time features of the pig to be detected.
[0018] The first analysis unit is configured to use a preset regression model to analyze prior features and real-time features to determine the first backfat thickness.
[0019] The second analysis unit is configured to analyze prior features and real-time features using a preset density model to determine the second backfat thickness.
[0020] The determination unit is configured to determine the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness.
[0021] Fourthly, embodiments of this application provide a detection device, which includes a memory and a processor, wherein...
[0022] The memory is used to store computer programs that can run on the processor;
[0023] The processor is configured to execute the backfat thickness detection method as described in the first aspect when running the computer program.
[0024] Fifthly, embodiments of this application provide a computer storage medium storing a computer program that, when executed by a processor, implements the backfat thickness detection method as described in the first aspect.
[0025] The backfat thickness detection method, apparatus, device, and storage medium provided in this application involve acquiring prior and real-time features of the pig to be detected; analyzing the prior and real-time features using a preset regression model to determine a first backfat thickness; analyzing the prior and real-time features using a preset density model to determine a second backfat thickness; and finally determining the backfat thickness of the pig to be detected based on the first and second backfat thicknesses. This approach considers both real-time and prior features and combines the analysis results of multiple models to determine the backfat thickness. The models complement each other effectively, thus avoiding harm to the pig from close-contact measurements, improving the accuracy of backfat thickness detection, and reducing costs while increasing detection efficiency. Attached Figure Description
[0026] Figure 1 A schematic flowchart illustrating a backfat thickness detection method provided in an embodiment of this application;
[0027] Figure 2 This is a schematic diagram of the composition structure of a feature acquisition device provided in an embodiment of this application;
[0028] Figure 3 A schematic diagram of a binary occlusion array of a pig body provided in an embodiment of this application;
[0029] Figure 4 A schematic diagram illustrating the degree of curvature of a pig's back, provided as an embodiment of this application;
[0030] Figure 5 A schematic diagram illustrating the calculation of the body width and length of a pig, provided in an embodiment of this application;
[0031] Figure 6 A schematic diagram of the training process of a preset regression model provided in an embodiment of this application;
[0032] Figure 7 A schematic diagram of a training framework for a preset regression model provided in an embodiment of this application;
[0033] Figure 8 A flowchart illustrating another backfat thickness detection method provided in this application embodiment;
[0034] Figure 9 A schematic diagram of a framework for determining backfat thickness using a preset regression model, provided in an embodiment of this application;
[0035] Figure 10 A schematic diagram of the training process of a preset density model provided in an embodiment of this application;
[0036] Figure 11A schematic diagram of a training framework for a preset density model provided in an embodiment of this application;
[0037] Figure 12 A flowchart illustrating another backfat thickness detection method provided in this application embodiment;
[0038] Figure 13 A schematic diagram of a framework for determining backfat thickness using a preset density model, provided in an embodiment of this application;
[0039] Figure 14 A schematic flowchart illustrating another backfat thickness detection method provided in this application embodiment;
[0040] Figure 15 A schematic diagram of a framework for determining backfat thickness using a data fusion model, provided in an embodiment of this application;
[0041] Figure 16 A schematic diagram of the framework of a backfat thickness detection method provided in an embodiment of this application;
[0042] Figure 17 A schematic diagram of the composition structure of a backfat thickness detection device provided in an embodiment of this application;
[0043] Figure 18 This is a schematic diagram of the specific hardware structure of a detection device provided in an embodiment of this application;
[0044] Figure 19 This is a schematic diagram of the composition structure of a detection device provided in an embodiment of this application. Detailed Implementation
[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are merely for explaining the relevant application and not for limiting the application. Furthermore, it should be noted that, for ease of description, only the parts relevant to the application are shown in the accompanying drawings.
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0047] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0048] It should be noted that the terms "first, second, and third" used in the embodiments of this application are merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0049] With the development of computer and information technology, technologies such as neural networks, machine learning, and deep learning have been widely applied to construct complex models of image objects. Supervised deep learning technology, which mainly uses neural networks, builds models based on existing data and labels through loss optimization, such as building classification models based on images and categories.
[0050] There are two common methods for predicting backfat thickness (or simply fat thickness) based on deep learning: The first method involves acquiring physical characteristics of pigs, such as height, length, and back width, through planar image acquisition, and then combining this image data to predict fat thickness. The second method involves acquiring three-dimensional features of the pig body through depth cameras and then combining this 3D image data to predict fat thickness. However, the planar image prediction method suffers from poor generalization performance due to its single perspective and susceptibility to environmental influences; while the 3D image prediction method requires expensive depth cameras, resulting in high costs, and ambient noise significantly impacts the 3D modeling results.
[0051] There are two common approaches to predicting continuous body thickness based on deep learning: The first approach transforms the continuous value into a category interval, turning the prediction task into a classification task. For example, if the body thickness is 10mm, the model predicts a category within the (9,11)mm interval. While this method limits the prediction interval and prevents predictions that contradict common sense, it lacks precision. Furthermore, because the intervals are independent, the model cannot perceive the similar physical meanings of adjacent intervals. The second approach directly predicts the continuous value. This method can yield a precise prediction, but because neural networks use weighted multiplication for modeling, direct prediction has a certain probability of producing unexpected body thickness predictions.
[0052] Therefore, in order to improve the generalization performance of the model, it is necessary to design reasonable prior features for specific problems and scenarios, construct a neural network structure suitable for specific scenarios, design a suitable continuous value prediction algorithm, and design a reasonable post-processing algorithm for model prediction results in order to use neural networks to build a model to predict backfat thickness.
[0053] Based on this, this application provides a method for detecting backfat thickness. The basic idea of this method is as follows: acquire the prior features and real-time features of the pig to be detected; analyze the prior features and real-time features of the pig to be detected using a preset regression model to determine the first backfat thickness of the pig to be detected; analyze the prior features and real-time features of the pig to be detected using a preset density model to determine the second backfat thickness of the pig to be detected; and determine the backfat thickness of the pig to be detected based on the first backfat thickness and the second backfat thickness. Thus, when detecting backfat thickness in pigs, not only are real-time characteristics of the pig considered, but also prior characteristics are analyzed, and multiple preset models are used to predict backfat thickness. This eliminates the need for close contact with the pig during backfat thickness detection. Furthermore, because the backfat thickness is obtained by integrating the analysis of prior and real-time characteristics from multiple models, these models complement each other effectively, improving detection accuracy. This method is harmless to the pig, highly automated, and increases detection efficiency while reducing costs.
[0054] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0055] In one embodiment of this application, see [link to embodiment]. Figure 1 This illustration shows a flowchart of a backfat thickness detection method provided in an embodiment of this application. Figure 1 As shown, the method may include:
[0056] S101. Obtain the prior features and real-time features of the pig to be detected.
[0057] It should be noted that the backfat thickness detection method provided in this application embodiment can be used in the breeding pig process to determine the backfat thickness of the pig by analyzing the characteristic data of the pig's body. The backfat thickness can be used as a standard for judging the health of pigs and can also guide actual production. In addition, the backfat thickness detection method provided in this application embodiment can not only be used for backfat detection of breeding pigs, but also for backfat detection of other pigs, and even for backfat detection of other animals, such as cattle and sheep.
[0058] It should also be noted that this method can be applied to devices for detecting backfat thickness, or to detection equipment or systems that integrate such devices. Here, the detection equipment can be such as computers, smartphones, tablets, laptops, handheld computers, personal digital assistants (PDAs), navigation devices, servers, etc., and this application embodiment does not specifically limit it in this regard.
[0059] It should also be noted that the backfat thickness detection method provided in this application uses the prior features and real-time features of the pig to be detected as input to the model, enabling the model to output the corresponding backfat thickness based on the prior features and real-time features. Therefore, when performing backfat thickness detection, this application embodiment first obtains the prior features and real-time features of the pig to be detected.
[0060] In some embodiments, the prior features include at least one of the following: pig breed, weight, age, historical backfat thickness, and production information; wherein the production information includes at least one of the following: gestation stage, number of farrowings, and average litter size;
[0061] The real-time features include at least one of the following: hip height, body height, back curvature, body width, and body length.
[0062] Furthermore, this application embodiment also provides a feature acquisition device for acquiring prior features and real-time features. Here, this feature acquisition device can be applied to any scenario requiring the acquisition of pig body features, not just when acquiring features of the pig to be detected during backfat thickness detection. For example, it can be used when acquiring sample pig body features during model construction, or when it is necessary to determine other indicators of the pig body based on its features, etc.
[0063] See Figure 2 This illustrates a schematic diagram of the composition of a feature acquisition device 20 provided in an embodiment of this application. For example... Figure 2 As shown, the feature acquisition device 20 may include at least: an RFID module 201, an infrared sensor array module 202, a camera module 203, and a grid projection module 204; wherein,
[0064] RFID module 201 is used to acquire ear tag information of pigs so that the feature acquisition device can determine the prior features of pigs based on the ear tag information;
[0065] Infrared sensor array module 202 is used to acquire a binary occlusion array image of the pig body, so that the feature acquisition device can determine the rump height and body height of the pig body based on the binary occlusion array image;
[0066] The camera module 203 is used to acquire a top-view image of the pig's body so that the feature acquisition device can determine the curvature of the pig's back based on the top-view image;
[0067] The grid projection module 204 is used to acquire a grid image so that the feature acquisition device can determine the body width and body length of the pig based on the grid image.
[0068] Below, we will combine Figure 2The feature acquisition device 20 shown is used to specifically describe how to acquire prior features and real-time features. It should be noted that this example uses the acquisition of prior features and real-time features of the pig to be detected, but it can be understood that this method can be applied to any scenario that requires the acquisition of pig features.
[0069] In some embodiments, obtaining the prior features of the pig to be detected may include:
[0070] Ear tag information of the pig to be tested is obtained through the RFID module;
[0071] The prior features corresponding to the ear tag information are searched in the preset database, and the found prior features are determined as the prior features of the pig to be tested.
[0072] It should be noted that, as Figure 2 As shown, the feature acquisition device 20 may also include a limiting bar, and each module in the device can be arranged based on the limiting bar. For example, the RFID module 201 and the infrared sensor array module 202 are arranged on both sides of the limiting bar, and the camera module 203 and the grid projection module 204 are arranged above the limiting bar.
[0073] like Figure 2 As shown, for the pig to be tested, an ear tag is attached to one of its ears. The ear tag information of the pig to be tested can be obtained through the RFID module 201. The ear tag is one of the animal identification methods, used to prove the identity of livestock and is a mark that carries individual information of livestock. In this way, based on the ear tag information of the pig, the prior features corresponding to the ear tag information can be found from the preset database, that is, the prior features of the pig corresponding to the ear tag information.
[0074] It is understandable that ear tags can be applied to either the left or right ear of a pig. Figure 2 In the feature acquisition device 20 shown, considering the pig's current standing direction, and since the ear tag is applied to the pig's right ear, the RFID module 201 is positioned on the right side of the restraint bar near the pig's head. In practical use, the position and number of RFID modules 201 can be set according to the specific farming method; this embodiment does not impose specific limitations on this.
[0075] In this embodiment, the RFID module 201 can be an RFID reader or other equipment with radio frequency identification function.
[0076] In some embodiments, acquiring the real-time features of the pig to be detected may include:
[0077] The height of the rump and the height of the body of the pig to be tested are determined by the infrared sensor array module when the pig is standing.
[0078] The camera module is used to determine the curvature of the pig's back.
[0079] The width and length of the pig to be detected are determined using the grid projection module.
[0080] It should be noted that the characteristics of pigs, such as rump height and body height (also known as shoulder height), need to be collected by placing a device at a certain viewing angle. The device can be a camera, but because the spacing between the stalls is small, placing a camera on the side will result in not being able to capture the whole pig. Alternatively, a sliding camera can be used to take pictures and then stitch the images together. However, this method requires a sliding device, which makes it difficult to guarantee stability and also increases costs and stitching complexity.
[0081] This application proposes a method based on an infrared distance sensor array to determine whether a pig is standing and to measure the pig's hip height and body height.
[0082] In some embodiments, determining the hip height and body height of the pig to be detected while the pig is standing using an infrared sensor array module may include:
[0083] The binary occlusion array image of the pig to be detected is obtained through the infrared sensor array module.
[0084] Based on the binary occlusion array diagram, determine whether the pig to be detected is in a standing position;
[0085] If the pig to be tested is standing, the hip height and body height of the pig to be tested are determined according to the binary occlusion array diagram.
[0086] It should be noted that, in this embodiment of the application, a binary occlusion array image of the pig's body can be obtained through the infrared sensor array 202. Preferably, the binary occlusion array image obtained is the side view of the pig's body. Based on this binary occlusion array image, it can be determined whether the pig's body is standing, and also the pig's hip height and body height can be determined.
[0087] like Figure 2 As shown, the infrared sensor array 202 can be arranged on one side of the restraint fence located on the left or right side of the pig's body. Exemplarily, 8×9 sensor nodes can be arranged in an array with equal spacing. In practical applications, other numbers of sensor nodes with unequal spacing, or even denser or sparser arrangements, can also be selected for the array; this embodiment does not specifically limit this arrangement.
[0088] Thus, a binary occlusion array image of the pig's body can be obtained through the infrared sensor array 202. (See also...) Figure 3 This illustrates a schematic diagram of a binary occlusion array of a pig body provided in an embodiment of this application. Figure 3 As shown, in a binary occlusion array image, an infrared sensor (such as an infrared distance sensor) can obtain a signal indicating whether there is an object blocking the view in front. This makes the signal of the area where the pig is located different from other areas in the binary occlusion array image, thus enabling the pig to be separated from the binary occlusion array image.
[0089] Furthermore, the binary occlusion array map is used to determine whether the pig is standing. For example, a supervised method can be used to train a neural network, which can then determine whether the pig is standing. In this embodiment, the hip height and body height of the pig are determined based on the binary occlusion array map only when the pig is determined to be standing, in order to detect the backfat thickness. Backfat thickness detection is not performed on pigs that are not standing. This is because when the pig is not standing, features such as hip height and body height cannot be accurately obtained, leading to inaccurate backfat thickness analysis.
[0090] When the pig is determined to be standing, the positions of the forelegs and hindlegs can be obtained through a pre-trained neural network. The highest point of the hind leg array is the rump height, and the highest point of the foreleg array is the shoulder height.
[0091] In some embodiments, determining the back curvature of the pig to be detected via the camera module may include:
[0092] The camera module 203 acquires a top-view image of the pig to be detected;
[0093] From the top-view image, identify several key points of the spine of the pig to be inspected;
[0094] The curvature of the back of the pig to be tested is determined based on several key points of the spine.
[0095] It should be noted that, in this embodiment of the application, a top-view image of the pig's body can be acquired through the camera module 203, and the curvature of the pig's back can be determined based on the top-view image. For example... Figure 2 As shown, the camera module 203 can be positioned at a certain height above the limit bar 201, ensuring that a top-down view of the complete pig carcass can be captured. Here, the camera module 203 can be a camera or other equipment with video recording capabilities.
[0096] In this embodiment of the application, several key points of the spine on the back of a pig can be determined by deep learning technology. Preferably, 10 key points of the spine of the pig body are determined.
[0097] Specifically, determining the curvature of the back of the pig under test based on several key points of the spine can include:
[0098] Identify the head and hip key points among several spinal key points;
[0099] Draw perpendicular lines from the other key points to the head key point and the hip key point.
[0100] The sum of the vertical distances is calculated, and the ratio of the sum of the lengths of the verticals to the distance from the head key point to the buttock key point is determined as the back curvature of the pig to be tested.
[0101] It should be noted that after obtaining several key points of the pig's spine from the top-view image, a key point of the head and a key point of the rump can be determined from these key points. See also Figure 4 This illustration shows a schematic diagram of the degree of curvature of a pig's back, as provided in an embodiment of this application. Figure 4 As shown, among the 10 spinal key points, the two ends are the head key point and the hip key point, respectively. In this top view image, the head key point and the hip key point are connected, and then perpendicular lines are drawn from the other 8 key points to the line connecting the head key point and the hip key point. It should be noted that when the pig's spine is relatively straight, the other key points may lie partially or entirely on the line connecting the head key point and the hip key point. Strictly speaking, there is no perpendicular line in this case; they are just two overlapping points. However, for consistency, we will still refer to them as perpendicular lines here. But it can be understood that in this case, the perpendicular line is actually just a point and has no length.
[0102] In this embodiment of the application, the back curvature (also known as the curvature ratio) can be calculated using the following formula:
[0103]
[0104] It should be noted that in equation (1), the numerator is actually the sum of the lengths of the vertical lines, and the denominator is the length of the line connecting the head key point and the buttock key point.
[0105] Since the embodiments of this application determine the length of the line connecting the head key point and the rump key point and the length of each vertical line in the top view image of the pig, the lengths here refer to the pixel distance in the top view image, rather than the actual distance.
[0106] The degree of curvature of a pig's back can be measured by the calculated back curvature. Specifically, the larger the value, the greater the curvature; the closer the value is to 0, the smaller the curvature, and the closer it is to a straight state. Figure 4 As shown, (a) represents a more curved state, and (b) represents a more straight state.
[0107] In some embodiments, after obtaining the back curvature of the pig to be tested, the method may further include:
[0108] Determine whether the curvature of the back of the pig being tested exceeds a preset curvature threshold;
[0109] If the curvature of the back of the pig to be tested does not exceed the preset curvature threshold, then the backfat thickness of the pig to be tested will be measured.
[0110] If the curvature of the back of the pig to be tested exceeds the preset curvature threshold, the backfat thickness of the pig to be tested will not be measured.
[0111] It should be noted that the preset curvature threshold is used to compare with the curvature of the back of the pig to be tested, in order to determine whether it is necessary to continue measuring the backfat thickness of the pig to be tested based on the comparison result. It is a preset value, and the setting of this value is related to the characteristics of the pig itself. For example, this value may be different for different breeds of pigs or pigs at different stages of pregnancy; or, the value may also be different depending on the number of key points of the spine. The setting of the preset curvature threshold can be set according to specific circumstances, and this application embodiment does not impose specific limitations on it.
[0112] If the back curvature of the pig is too high, exceeding the preset curvature threshold, it indicates that the pig may not be in a normal state and its backfat thickness should not be measured. Therefore, this embodiment only measures backfat thickness in pigs with a low degree of back curvature, and does not measure backfat thickness in pigs with a high degree of back curvature.
[0113] It should also be noted that back curvature is not only used as a basis for determining whether to test backfat thickness in pigs. When the back curvature of a pig is low and backfat thickness testing is required, back curvature is also used as a real-time feature of the pig to be tested to predict its backfat thickness.
[0114] In some embodiments, determining the body width and body length of the pig to be detected via the grid projection module may include:
[0115] The raster projection module is used to acquire raster images;
[0116] The target pixel segmentation of the captured image of the pig to be detected is performed using a raster image to determine the boundary information of the pig to be detected in the captured image;
[0117] Based on the mapping relationship between the grid distance in the raster image and the pixel distance in the captured image, as well as the boundary information of the pig to be detected, the body width and body length of the pig to be detected are determined.
[0118] It should be noted that in this embodiment of the application, the grid is projected by the grid projection module 204, and at the same time, the camera module 203 can acquire a captured image including the grid image and the top view image of the pig body, so as to determine the width and length of the pig body according to the mapping relationship between pixel distance and actual distance.
[0119] like Figure 2 As shown, the grid projection module 204 is located above the limiting bar. The grid projection module 204 can project equidistant grids downwards, with some grids projected onto the ground and others onto the pig's body.
[0120] Since the grid spacing projected onto the ground changes linearly with the vertical projection distance, after installing the grid projection module 204 at a fixed height, the grid distance (that is, the actual width of a grid cell in the grid image) can be set. A mapping relationship between the grid distance and the pixel distance in the grid image can be established. Then, deep learning and other technologies can be used to segment the target pixels corresponding to the pig in the captured image, thus obtaining the boundary information of the pig in the captured image. Based on the mapping relationship between the grid distance in the grid image and the pixel distance in the captured image, as well as the boundary information of the pig to be detected, the body width and body length of the pig to be detected can be determined.
[0121] See Figure 5 This illustration shows a schematic diagram of the calculation of the body width and length of a pig according to an embodiment of this application. Figure 5 As shown, the actual distance between each grid is 10 centimeters. After conversion, the body length of the pig to be detected in the figure is 132.4 centimeters and the body width is 39.2 centimeters.
[0122] In addition, in this embodiment of the application, preferably, the grid projection module projects an invisible grid (invisible to animals, but can be photographed). In this way, in actual production, neither human eyes nor pig eyes can actually see the grid, thus avoiding the visible grid from causing harm to the pig.
[0123] Thus, based on the feature acquisition device 20 provided in this application embodiment, it is possible to acquire the prior features and real-time features of the pig body in real time. While achieving automated and accurate acquisition of pig body features, it also avoids the harm to the pig body caused by manual measurement of body thickness at close range.
[0124] S102. Analyze the prior features and real-time features using a preset regression model to determine the first backfat thickness.
[0125] S103. Analyze the prior features and real-time features using a preset density model to determine the second backfat thickness.
[0126] S104. Determine the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness.
[0127] It should be noted that after obtaining the prior and real-time features of the pig to be tested, the prior and real-time features can be analyzed according to the model to determine the backfat thickness of the pig.
[0128] In this embodiment, the backfat thickness of a pig can be determined by combining complementary multiple models; that is, the backfat thickness of a pig can be obtained by combining the prediction results of multiple models. First, the first backfat thickness and the second backfat thickness of the pig to be tested are obtained using a preset regression model and a preset density model, respectively; then, the backfat thickness of the pig is determined based on the first backfat thickness and the second backfat thickness.
[0129] In some embodiments, determining the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness may include:
[0130] Obtain the third backfat thickness, which is the backfat thickness determined during the most recent backfat thickness measurement of the pig to be tested;
[0131] The backfat thickness of the first, second, and third backfat layers is fused using a preset fusion model to determine the backfat thickness of the pig to be tested.
[0132] It should be noted that, in this embodiment of the application, the first backfat thickness, the second backfat thickness, and the third backfat thickness determined during the most recent backfat thickness measurement of the pig to be tested can be fused using a preset fusion model to obtain the backfat thickness of the pig to be tested. Here, the third backfat thickness can be the backfat thickness of the pig to be tested obtained most recently using the preset fusion model, or it can be the backfat thickness of the pig to be tested obtained after calibration by manual measurement most recently.
[0133] In some embodiments, after determining the backfat thickness of the pig to be tested, the method may further include:
[0134] Store the first back fat thickness, the second back fat thickness, and the back fat thickness in a preset database.
[0135] It should be noted that after obtaining the backfat thickness of the pig to be tested, the first backfat thickness, the second backfat thickness, and the backfat thickness can be stored in a preset database for querying when needed.
[0136] This embodiment provides a method for detecting backfat thickness. It involves acquiring prior and real-time features of the pig to be tested; analyzing these features using a preset regression model to determine a first backfat thickness; analyzing these features using a preset density model to determine a second backfat thickness; and finally, determining the total backfat thickness of the pig based on both the first and second backfat thicknesses. This method considers both real-time and prior features and combines the analysis results of multiple models to determine the final backfat thickness. The models complement each other effectively, improving the accuracy of backfat detection and increasing automation. This not only improves detection efficiency but also reduces costs and avoids the risk of injury to the pig from close-contact measurements.
[0137] In another embodiment of this application, a different method for detecting backfat thickness is provided, which determines backfat thickness using a preset regression model. This application also provides a method for training the preset regression model; see [link to relevant documentation]. Figure 6 It illustrates a schematic diagram of the training process of a preset regression model provided in an embodiment of this application, such as... Figure 6 As shown, the training process for a pre-defined regression model may include:
[0138] S601. Obtain the sample dataset.
[0139] The sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is a positive integer.
[0140] It should be noted that the preset regression model provided in this application embodiment is obtained by training on a sample dataset. Here, the sample dataset includes at least one prior feature and real-time feature of a sample pig, as well as the corresponding standard value of backfat thickness.
[0141] The prior and real-time features of the sample pigs can be obtained using the feature acquisition device described in the previous embodiment, which will not be elaborated here.
[0142] The standard value of backfat thickness refers to the backfat thickness of a sample pig obtained through manual collection, such as ultrasonic detection, under certain prior and real-time characteristics.
[0143] S602. Train the first preset neural network model based on the sample dataset to obtain the preset regression model.
[0144] It should be noted that after obtaining the sample dataset, the first preset neural network model can be trained using the sample dataset, with the prior features and real-time features of the sample pigs as input and the first backfat thickness as output, and finally the preset regression model is obtained.
[0145] In some embodiments, training the first preset neural network model based on the sample dataset to obtain the preset regression model may include:
[0146] The target classification group is determined based on the prior features of the i-th sample pig, where i is an integer greater than zero and less than or equal to N;
[0147] Within the target classification group, the predicted value of the first backfat thickness of the i-th sample pig is determined based on the prior features and real-time features of the i-th sample pig.
[0148] Based on the predicted value of the first backfat thickness and the standard value of the backfat thickness of the i-th sample pig, the value of the first loss function is determined, and the first preset neural network model is updated.
[0149] When the value of the first loss function is greater than or equal to the first threshold, increment i by 1 and return to the step of determining the target classification group based on the prior features of the i-th sample pig.
[0150] When the value of the first loss function is less than the first threshold, the updated first preset neural network model is determined as the preset regression model.
[0151] It should be noted that the preset regression model provided in this application embodiment is a dynamic interval classification model, which transforms the task of predicting continuous backfat thickness into a dynamic classification interval and offset regression task.
[0152] Specifically, for the i-th pig sample out of N sample pigs, the target classification group is first determined from multiple classification groups based on the prior features of the i-th sample pig. Here, classification group refers to the group classified according to different prior features, and each classification group includes several fat thickness intervals.
[0153] For example, pigs can be classified into three groups according to breed: Landrace pigs; Large White pigs; and Bosch pigs. The Landrace pig group includes the following five fat thickness intervals (unit: mm): (0,4], (4,6], (6,8], (8,12], (12,20]; the Large White pig group includes the following five fat thickness intervals (unit: mm): (0,10], (10,12], (12,14], (14,16], (16,20]; and the Bosch pig group includes the following five fat thickness intervals (unit: mm): (0,16], (16,17], (17,18], (18,19], (19,20).
[0154] As can be seen, although each classification interval group includes five intervals, and the overall range of the intervals is 0-20mm, the specific interval ranges included in each classification interval group are different due to different pig breeds. In other words, the embodiments of this application use different interval segmentation standards for different classification groups, and how to segment the intervals is related to the classification group corresponding to the prior characteristics of the pig.
[0155] It should be noted that this example uses pig breed as the basis for interval segmentation. In practical applications, more complex situations often arise, such as combining several prior features to determine specific intervals of different quantities and lengths. Whether to determine intervals using one prior feature or a combination of multiple prior features can be set according to the actual situation, and this application does not specifically limit this.
[0156] This application example uses the determination of target classification interval groups by pig species. Assuming the sample pig species is Large White, then the Large White group is the target classification group. Then, within this target classification group, the predicted value of the first backfat thickness of the i-th sample pig is determined based on the prior features and real-time features of the i-th sample pig.
[0157] In some embodiments, determining the predicted value of the first backfat thickness of the i-th sample pig based on the prior features and real-time features of the i-th sample pig may include:
[0158] Determine the target interval and the corresponding offset of the target interval;
[0159] The predicted value of the first backfat thickness is determined based on the target range and the offset.
[0160] It should be noted that the first preset neural network model predicts the confidence level of each interval in the target classification group based on the prior and real-time features of the sample pigs, and also predicts the offset of each interval. The interval with the highest confidence level prediction is determined as the target interval. The first backfat thickness prediction value is obtained by adding the center value of the target interval to the corresponding offset prediction value. The center value is calculated as the average of the interval endpoints.
[0161] In this way, the first backfat thickness prediction value of the i-th sample pig, the confidence prediction value of each interval in the target classification group, and the offset prediction value are obtained through the first preset neural network model; at the same time, the confidence standard value and offset standard value of each interval in the target classification group can be obtained based on the standard value of the backfat thickness of the sample pig.
[0162] Next, based on the predicted value of the first backfat thickness of the i-th sample pig and the standard value of the backfat thickness, the first loss function value is determined, and the first preset neural network model is updated.
[0163] It should be noted that the purpose of model training is to make the results predicted by the model as close as possible to the actual results. In other words, when the predicted confidence and bias values for each interval are as close as possible to, or even identical to, the standard confidence and bias values for that interval, the resulting predicted backfat thickness will naturally be closest to the standard backfat thickness value. Therefore, the first loss function value of the first preset neural network model is calculated based on each predicted value and each standard value, and the first preset neural network model is updated. Here, the update can be an update of the weights of the neural network layers of the first preset neural network model.
[0164] When the value of the first loss function is greater than or equal to the first threshold, it indicates that the model's accuracy is insufficient. At this point, increment i by 1, and then return to the step of determining the target classification group based on the prior features of the i-th sample pig. The first preset neural network model is then trained again using the next set of sample data.
[0165] When the value of the first loss function is less than the first threshold, it means that the model can achieve the preset accuracy. At this time, the updated first preset neural network model is determined as the preset regression model corresponding to the target classification group.
[0166] For example, see Figure 7 This diagram illustrates a training framework for a preset regression model provided in an embodiment of this application. Based on... Figure 7 The training of the preset regression model within the framework shown can be performed according to the following steps:
[0167] After the prior and real-time features of the sample pigs are fed into the data layer, the target classification group is first determined based on the prior features of the sample pigs.
[0168] exist Figure 7 The prior characteristics of the pigs in this sample included: breed: Large White pig; weight: 95–100 kg; age: 200–240 days; gestation stage: 60 days. Real-time characteristics included hip height, body height, degree of back curvature, and body length. Figure 8 The specific data of the real-time features are not shown, but it can be understood that these features have specific values in practice.
[0169] The backfat thickness of pigs is generally within 20mm, but the backfat thickness range varies among different breeds, ages, gestation stages, and sexes. The pre-defined regression model proposed in this application is a model based on dynamic backfat thickness range classification + offset regression. It can select different target classification groups according to different breeds, ages, gestation stages, and sexes, and then use a classifier (also called a range classification predictor) to classify according to the dynamic range hit rate. After classification, a corresponding regressor (also called an offset predictor) is used to predict the offset of the range center. In this application embodiment, the specific ranges included in different classification range groups can be pre-defined based on the prior characteristics of the pig. Here, three classification range groups are used as examples of different pig breeds, as shown in Table 1.
[0170] Table 1
[0171]
[0172] The sample pigs were Large White pigs, and the classification interval of group 2 (Large White pigs) in Table 1 was hit. That is, the target classification group is group 2 (Large White pigs). Therefore, the classifiers and regressors of group 1 (Landrace pigs) and group 3 (Poland pigs) were inactive.
[0173] After determining the target classification group, the confidence and offset prediction values for each thickness interval within the target classification group are obtained through classifiers and regressors. This step can be performed using neural network inference, such as by using the softmax activation function, to obtain the interval classification prediction results (i.e., the confidence prediction value for each thickness interval) and the offset prediction value.
[0174] like Figure 7 As shown, the prediction results are as follows: the confidence prediction value for the interval (0,10) is 0.2, the confidence prediction value for the interval (10,12) is 0.1, the confidence prediction value for the interval (12,14) is 0.6, the confidence prediction value for the interval (14,16) is 0.1, and the confidence prediction value for the interval (16,20) is 0.1.
[0175] The regressor for the second group (Large White pigs) predicts an offset for the center value of each node based on the prior and real-time features of the pigs being tested. For example... Figure 8 As shown, the prediction results are as follows: the predicted offset value for the interval (0,10) with a center value of 5 is 5.5, the predicted offset value for the interval (10,12) with a center value of 11 is 2.7, the predicted offset value for the interval (12,14) with a center value of 13 is 0.3, the predicted offset value for the interval (14,16) with a center value of 15 is -3.1, and the predicted offset value for the interval (16,20) with a center value of 18 is -4.2.
[0176] Here, the interval with the highest confidence prediction value is (12, 14), and its corresponding interval center value is 13. Next, the offset prediction value corresponding to the offset prediction node with an interval center value of 13 is taken, and the center value and the offset prediction value are added together. Finally, the predicted value of the first backfat thickness is 13 + 0.3 = 13.3.
[0177] Based on the standard value bh of backfat thickness of the sample pigs and the values of each interval in this group (q_l) i ,q_r i Calculate the interval classification standard value t_c i (i.e., the confidence level standard value), calculated as follows:
[0178] t_c i =I(q_l i ≤bh≤q_r i (2)
[0179] Among them, t_c i q_l represents the interval classification standard value, which is the true confidence value for that interval for the sample pigs; bh is the backfat thickness standard value, which is the backfat thickness value of the sample pigs measured manually, and can be obtained using existing methods such as ultrasonic detection; i Indicates the left endpoint of the interval; q_r i Indicates the right endpoint of the interval.
[0180] Formula (2) means: if the standard value of back fat thickness is within a certain range, then the standard value of the range is 1; if the standard value of back fat thickness is not within a certain range, then the standard value of the range is 0.
[0181] like Figure 7 As shown, the standard value for backfat thickness of the sample pigs is 13.6. Therefore, the probability that the standard value for backfat thickness falls within the interval (12, 14) is 100%, and the probability of falling within other intervals is 0. Thus, the interval classification standard value for the interval (12, 14) is 1, and the interval classification standard value for other intervals is 0.
[0182] Based on the standard value of body thickness bh and the center value c of each interval in this group. i Calculate the standard value of offset t_p i .
[0183] Wherein, the interval center value c i It is determined according to the following formula:
[0184]
[0185] That is, the center value of the interval is the average of the two endpoints of the corresponding interval.
[0186] The standard offset value is determined according to the following formula:
[0187] t_p i = bh - c i (4)
[0188] That is, the standard offset value is the difference between the standard backfat thickness value and the interval center value.
[0189] Among them, i is the interval index, representing which interval in the grouping interval group this interval is. In this example, 0 < i ≤ 5, and i is an integer.
[0190] Figure 7 It shows the calculation results of the interval classification standard value and the standard offset value with a standard backfat thickness of 13.6. It can be seen that within any interval, the sum of the interval center point and the standard offset value is the standard backfat thickness value. <It should be noted that the process of determining the target classification group based on prior features is consistent with the description in the aforementioned training of the preset regression model, and will not be repeated here. The determination of the preset regression model corresponding to the target classification group can be understood as follows: when the preset regression model provided in this application predicts backfat thickness, it first needs to determine the target classification group based on prior features, and then further predict backfat thickness within the target classification group. Therefore, it can be considered that there is a corresponding preset regression model for each classification group.
[0197] S803. Use a preset regression model to perform classification regression prediction on prior features and real-time features to determine the target interval and target offset.
[0198] In some embodiments, the preset regression model may include at least a preset classifier and a preset regressor. The step of using the preset regression model to perform classification and regression prediction on the prior features and the real-time features to determine the target interval and the target offset corresponding to the target interval may include:
[0199] The target classification group is classified into intervals using a preset classifier to obtain at least one classification interval, and the confidence level of each classification interval is determined based on prior features and real-time features.
[0200] Using a pre-defined regressor, prior features, and real-time features, regression prediction is performed on at least one classification interval to determine the offset of each classification interval.
[0201] Select the maximum value from the determined confidence levels, determine the classification interval corresponding to the maximum value as the target interval, and determine the offset corresponding to the target interval as the target offset.
[0202] It should be noted that the preset regression model provided in this application embodiment may include at least a preset classifier and a preset regressor (i.e., the classifier and regressor mentioned in the aforementioned process of training the preset regression model).
[0203] The preset classifier will segment the thickness range (e.g., 0-20mm) corresponding to the target classification group to obtain at least one classification interval (i.e., thickness interval). Examples of classification results are shown in Table 1. Here, the preset classifier is used to classify the target classification group into intervals to obtain at least one classification interval. The classification interval can be preset for different classification groups or can be divided based on features.
[0204] Meanwhile, a preset classifier can be used to predict the confidence level of each classification interval based on prior features and real-time features, thus obtaining the confidence level of each classification interval; a preset regressor can be used to predict the offset of each classification interval based on prior features and real-time features, thus obtaining the offset of each classification interval.
[0205] The classification interval corresponding to the maximum confidence score is determined as the target interval, and the offset corresponding to the target interval is the target offset.
[0206] S804. Determine the first backfat thickness based on the target range and the target offset.
[0207] The first backfat thickness is obtained based on the target range and the target offset.
[0208] In some embodiments, determining the first backfat thickness based on the target interval and the target offset may include:
[0209] Determine the center point of the target interval based on the target interval;
[0210] The first backfat thickness is obtained by adding the center point of the target interval and the target offset.
[0211] It should be noted that the center point of the target interval can be the average of the endpoints of the target interval. The sum of the center point of the target interval and the target offset is the first backfat thickness.
[0212] For example, see Figure 9 This illustrates a schematic diagram of a framework for determining backfat thickness using a preset regression model, as provided in an embodiment of this application. Figure 9 As shown, in this example, the target classification group is first determined based on the prior characteristics of the pig to be detected. The specific implementation process is the same as in the previous embodiment, and will not be repeated here. Here, the second group (Large White pig) classification interval is still hit, so the classifiers and regressors of the first and third groups are both inactive.
[0213] Then, the classifier for the second group (large white pigs) predicts a confidence score for each node (i.e., each interval) in the target classification group based on prior features and real-time features. For example... Figure 7 As shown, the prediction results are as follows: the confidence level of the interval (0,10) is 0.2, the confidence level of the interval (10,12) is 0.1, the confidence level of the interval (12,14) is 0.6, the confidence level of the interval (14,16) is 0.1, and the confidence level of the interval (16,20) is 0.1.
[0214] The regressor for the second group (Large White pigs) predicts an offset for each interval based on prior and real-time features. For example... Figure 9As shown, the prediction results are as follows: the offset of the interval (0,10] corresponding to the center value of 5 is 5.5, the offset of the interval (10,12] corresponding to the center value of 11 is 2.7, the offset of the interval (12,14] corresponding to the center value of 13 is 0.3, the offset of the interval (14,16] corresponding to the center value of 15 is -3.1, and the offset of the interval (16,20] corresponding to the center value of 18 is -4.2.
[0215] Here, the interval with the highest confidence level is (12, 14], and its corresponding interval center value is 13. The offset corresponding to the interval with an interval center value of 13 is the target offset. Adding the center value to the target offset, the final predicted first backfat thickness is 13 + 0.3 = 13.3.
[0216] Compared with related technologies, the preset regression model provided in this application uses interval prediction, which can effectively suppress the generation of abnormal backfat thickness prediction values compared with continuous value prediction. It dynamically determines the fat thickness interval based on the prior characteristics of the pig, which can solve the problem of unreasonable interval design caused by different species and other prior characteristics. Offset regression prediction can solve the problem that interval prediction cannot obtain continuous values. Finally, prediction based on this model can obtain a more accurate first backfat thickness.
[0217] In another embodiment of this application, a further method for detecting backfat thickness is provided. This method determines backfat thickness using a preset density model. The embodiments of this application also provide a training method for the preset density model; see [link to relevant documentation]. Figure 10 It illustrates a schematic diagram of the training process of a preset density model provided in an embodiment of this application, such as... Figure 10 As shown, the training process of the preset probability density model may include:
[0218] S1001. Obtain the sample dataset.
[0219] The sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is a positive integer.
[0220] It should be noted that the method for obtaining the sample dataset is the same as in the aforementioned embodiments, and will not be repeated here.
[0221] S1002. Train the second preset neural network model based on the sample dataset to obtain the preset density model.
[0222] It should be noted that after obtaining the sample dataset, the second preset neural network model can be trained using the sample dataset, with the prior features and real-time features of the sample pigs as input and the second backfat thickness as output, to finally obtain the preset density model.
[0223] In some embodiments, training the second preset neural network model based on the sample dataset to obtain the preset density model includes:
[0224] Determine the preset fat thickness range;
[0225] Sample the preset thickness range according to the preset sampling interval to obtain at least one sampling point;
[0226] Based on the prior features and real-time features of the i-th sample pig, determine the probability density prediction value corresponding to at least one sampling point, where i is an integer greater than zero and less than or equal to N;
[0227] Determine the probability density standard value corresponding to at least one sampling point based on the standard value of backfat thickness of the i-th sample pig;
[0228] Based on the probability density prediction value and the standard probability density value corresponding to at least one sampling point, the second loss function value is determined, and the second preset neural network model is updated.
[0229] When the value of the second loss function is greater than or equal to the second threshold, increment i by 1 and return to the step of determining the probability density prediction value corresponding to at least one sampling point based on the prior features and real-time features of the i-th sample pig.
[0230] When the value of the second loss function is less than the second threshold, the updated second preset neural network model is determined as the preset density model.
[0231] It should be noted that when training the second preset neural network model, the preset fat thickness range is first determined. Generally, the back fat thickness of pigs is within 20mm. For example, the preset fat thickness range can be (0,20]mm.
[0232] Then, the preset thickness range is sampled according to a preset sampling interval to obtain at least one sampling point. In this embodiment, a sampling point can represent a specific numerical point or a sampling range. For example, sampling the preset thickness range of (0, 20] mm at a sampling interval of 0.5 mm yields 40 sampling points: 0.5, 1, 1.5...19, 19.5, 20. Alternatively, the preset thickness range can be sampled according to a preset sampling interval to obtain at least one sampling interval. For example, sampling the preset thickness range of (0, 20] mm at a sampling interval of 0.5 mm yields 40 sampling intervals: (0, 0.5], (0.5, 1], (1, 1.5],...(19, 19.5], (19.5, 20]. In subsequent steps, sampling points are used for description, but it is understood that a sampling point can represent a specific numerical point or a sampling range.
[0233] Next, based on the prior features and real-time features of the i-th sample pig, the probability density prediction value corresponding to at least one sampling point is determined. For example, 40 probability density prediction values are obtained.
[0234] Meanwhile, based on the standard probability density prediction value corresponding to at least one sampling point of the backfat thickness standard value of the i-th sample pig, for example, 40 probability density standard values were obtained.
[0235] Next, based on the predicted probability density value and the standard probability density value corresponding to the i-th sample pig, the second loss function value is determined, and the second preset neural network model is updated.
[0236] It should be noted that the purpose of model training is to make the results predicted by the model as close as possible to the actual results. In other words, when the predicted probability density value at each sampling point is as close as possible to, or even the same as, the predicted second backfat thickness value will naturally be closest to the standard backfat thickness value. Therefore, the second loss function value of the second preset neural network model is calculated based on each predicted value and each standard value, and the second preset neural network model is updated simultaneously. Here, the update can be an update of the weights of the neural network layers of the second preset neural network model.
[0237] When the value of the second loss function is greater than or equal to the second threshold, it indicates that the model's accuracy is insufficient. At this point, increment i by 1 and return to the step of determining the probability density prediction value corresponding to at least one sampling point based on the prior features and real-time features of the i-th sample pig. The second preset neural network model is then trained using the next set of sample data.
[0238] When the value of the second loss function is less than the second threshold, it indicates that the model can achieve the preset accuracy. At this time, the updated second preset neural network model is determined as the preset density model.
[0239] It should also be noted that the basic idea of the preset probability density model provided in this application embodiment is as follows: Idea 1: In the prediction of backfat thickness intervals, intervals with closer intervals are more correlated than intervals with farther intervals. For example, the correlation between intervals (10, 12] and (8, 10] is much greater than that between intervals (0, 2]. However, traditional classification algorithms using one-hot data classification do not have this idea in their data representation. Idea 2: The standard value of backfat thickness of sample pigs is obtained from manual collection, which inevitably contains noise. Therefore, we can assume that the manually collected backfat thickness is p = g + μ, where p is the manually collected backfat thickness, g is the true standard value of backfat thickness, and μ is the collection noise. The specific value of g is unknown, but the smaller μ is, the closer p is to g. We expect g to approximate p, that is, we assume μ ~ N(0, σ 2 ).
[0240] According to the Gaussian distribution function, the probability distribution of p is as follows:
[0241]
[0242] Where x represents the possible values of back fat thickness, p(x) represents the probability density of back fat thickness being x, σ represents the standard deviation, and p represents the back fat thickness collected manually.
[0243] By sampling the continuous distribution in formula (5), we can obtain the discrete value in formula (6), as shown below:
[0244]
[0245] Where JG is the sampling interval, which can be set to 0.5, i is the sampling index value, ranging from (-∞, +∞), and p... i This represents the probability density value at the i-th sampling point. It can be understood that p... i This represents the probability density value at the i-th sampled value point or within the sampled interval. For example, the interval (0, 20] is sampled at a sampling interval of 0.5. When p... i When p represents the probability density value at the i-th sampled value point, p1 represents the probability density value at sampled value point 0.5; when p i When p1 represents the probability density value of the i-th sampling interval, it represents the probability density value of the sampling interval (0, 0.5].
[0246] To ensure the neural network can fit the data, a windowing method is used, letting... as well as At that time, p i =0, where, when p i This represents the probability density value in the i-th sampling interval. The sampling index value corresponding to the interval with the largest probability density value; when p i This represents the probability density value at the i-th sample point. This represents the sampling index value of the sampled numerical point with the largest probability density value. To ensure the meaning of the probability, i.e., to guarantee JG×∑p i =1, will and Density energy is evenly distributed within the range Within the range, we obtain equation (7), where the variance can be calculated based on the backfat thickness collected manually in history.
[0247]
[0248] Where, p i This represents the standard value of the probability density at point i, and... One-to-one correspondence; P σ σ represents the probability value within the standard deviation interval, typically taken as 0.68; σ is the set Gaussian distribution variance, a hyperparameter; p is the manually collected backfat thickness, and... Correspondingly, equation (7) is called the pseudo-Gaussian discrete vector of p.
[0249] Based on the above approach, when training the preset probability density model, sampling is performed within a preset backfat thickness range according to a preset sampling interval. For example, if the maximum backfat thickness is 20mm and the preset sampling interval is 0.5mm, then 40 sampling points can be obtained. It can be understood that the backfat thickness must be greater than 0.
[0250] In this embodiment, by assuming that the noise of the manually collected backfat thickness follows a normal distribution, both the manually collected backfat thickness and the predicted backfat thickness can be converted into a pseudo-Gaussian discrete vector as shown in Equation (7). When the second preset neural network model predicts the pseudo-Gaussian discrete vector based on the prior features and real-time features of the sample pig, the predicted pseudo-Gaussian discrete vector includes the predicted probability density value of each sampling point. Based on these probability density prediction values, the second predicted backfat thickness value can also be obtained. At the same time, the standard value of backfat thickness (i.e., the manually collected backfat thickness) can also be directly converted into a standard pseudo-Gaussian discrete vector, which includes the standard probability density value of each sampling point obtained based on the standard value of backfat thickness.
[0251] In this way, we obtain the probability density prediction value of each sampling point predicted by the second preset neural network model based on the prior features and real-time features of the sample pigs, and at the same time, we obtain the probability density standard value of each sampling point based on the backfat thickness standard value.
[0252] Then, based on each predicted value and the standard value, the second loss function value is determined, and the weights of the second preset neural network model are updated.
[0253] For example, see Figure 11 This diagram illustrates a training framework for a preset density model provided in an embodiment of this application. Based on Figure 11 The framework shown can be used to train a pre-defined density model by following these steps:
[0254] The methods for obtaining prior features and real-time features are as described in the previous embodiments and will not be repeated here. Based on the aforementioned ideas, the standard value p of the backfat thickness of the sample pig can be transformed into a pseudo-Gaussian discrete vector according to equation (7), and then prediction can be made based on the prior features and real-time features of the sample pig, such as using the softmax function for estimation. In this example, assuming the sampling interval JG = 0.5 and the maximum backfat thickness is 20mm, 40 softmax nodes need to be set, and each node is responsible for predicting the probability density prediction value of the corresponding sampling point (i.e., the sampling value point or sampling interval).
[0255] like Figure 11 As shown, the left side illustrates the pseudo-Gaussian discrete vector predicted by the second preset neural network model based on the prior and real-time features of the sample pigs. That is, at each node, a predicted probability density value is predicted for the sampling point. The right side illustrates the standard pseudo-Gaussian discrete vector constructed based on the standard value of the backfat thickness of the sample pigs, where a standard probability density value is obtained at each node. Since the second preset neural network model is still quite inaccurate, the two differ significantly. Next, the loss is calculated based on the predicted probability density value and the standard probability density value, and the weights of the second preset neural network model are updated. Then, the second preset neural network model is trained again based on the data of the next set of sample pigs until the model reaches the preset accuracy. The calculation of loss and the updating of neural network weights can be implemented using general techniques, which will not be elaborated here.
[0256] Next, the method for determining backfat thickness using a preset density model, provided in the embodiments of this application, will be described in detail. See [link to relevant documentation]. Figure 12 This illustration shows a flowchart of another backfat thickness detection method provided in this application embodiment. This method utilizes a preset density model to analyze the prior and real-time features of the pig to be detected, determining the second backfat thickness of the pig. For example... Figure 12 As shown, the method may include:
[0257] S1201. Obtain the prior features and real-time features of the pig to be detected.
[0258] It should be noted that the implementation method of this step is the same as that of the aforementioned embodiments, and will not be repeated here.
[0259] S1202, Determine the preset fat thickness range.
[0260] S1203. Sample the preset thickness range according to the preset sampling interval to obtain at least one sampling point.
[0261] It should be noted that the implementation methods of steps S1202 and S1203 are consistent with the sampling methods used in the aforementioned training of the preset model, and will not be repeated here.
[0262] S1024. Using a preset density model, determine the probability density prediction value corresponding to at least one sampling point based on prior features and real-time features, and determine the second backfat thickness based on at least one sampling point, a preset sampling interval, and the probability density prediction value corresponding to at least one sampling point.
[0263] In some embodiments, determining the second backfat thickness based on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point includes:
[0264] The second backfat thickness is obtained by performing density integration on at least one sampling point, a preset sampling interval, and the probability density prediction value corresponding to at least one sampling point.
[0265] It should be noted that the density integral operation for at least one sampling point, a preset sampling interval, and the probability density prediction value corresponding to at least one sampling point can be performed according to the following formula:
[0266]
[0267] in, The second thickness of back fat. Let JG be the predicted probability density value at the i-th sampling point (i.e., the sampling value point or sampling interval), JG be the sampling interval, N be the same as the total number of sampling points, and P be the probability density value at the i-th sampling point (i.e., the sampling value point or sampling interval). i Let be the sampled value of the i-th sampled value point or the center value of the i-th sampled interval, where the center value of the sampled interval is the average value of the endpoints of the sampled interval.
[0268] For example, see Figure 13 This illustration shows a schematic diagram of a framework for determining backfat thickness using a preset density model, as provided in an embodiment of this application. Figure 13 As shown in the figure, in this example, the probability density prediction value for each preset interval is first obtained using a preset density model. Then, the probability density prediction values are accumulated according to the formula shown in the figure to obtain the second backfat thickness. Figure 13 In the example, P i Taking the sampling value of the i-th sampling point as an example, JG is 0.5, σ is 5, and the maximum backfat thickness is 20mm. Then, 40 sampling points can be obtained, N is 40, and the final predicted backfat thickness of the pig is 14.023mm.
[0269] Compared with related technologies, the preset density model provided in this application assumes that the error of manually measured backfat thickness follows a Gaussian distribution. This allows the model to avoid over-reliance on standard data, increasing its tolerance to errors introduced by manual backfat thickness measurements. It also solves the problem of classification tasks being unable to obtain continuous values. Finally, predictions based on this model can yield a more accurate second backfat thickness.
[0270] In another embodiment of this application, see [link to application]. Figure 14 The diagram illustrates a flowchart of another backfat thickness detection method provided in this application. This method uses a preset fusion model to fuse the first backfat thickness, the second backfat thickness, and the third backfat thickness to determine the backfat thickness of the pig to be detected. Figure 14 As shown, the method may include:
[0271] S1401. Determine the first weight value corresponding to the first back fat thickness, the second weight value corresponding to the second back fat thickness, and the third weight value corresponding to the third back fat thickness.
[0272] It should be noted that the first weight value, the second weight value, and the third weight value can be preset fixed values, or they can be dynamically determined based on the corresponding model and / or backfat thickness value.
[0273] In this embodiment of the application, preferably, the weight values of the three backfat thicknesses are determined based on the variance of their historical values by assuming that the noise of the three backfat thicknesses all follow a Gaussian distribution and are independent of each other.
[0274] In some embodiments, determining the first weight value corresponding to the first backfat thickness, the second weight value corresponding to the second backfat thickness, and the third weight value corresponding to the third backfat thickness includes:
[0275] Acquire the first historical backfat data, the second historical backfat data, and the third historical backfat data of the pig to be tested within a preset historical time period; wherein, the first historical backfat data represents the backfat thickness data obtained using a preset regression model within the preset historical time period; the second historical backfat data represents the backfat thickness data obtained using a preset density model within the preset historical time period; and the third historical backfat data represents the backfat thickness data obtained using a preset fusion model and / or manually collected within the preset historical time period.
[0276] Determine the first variance of the first historical backfat data, determine the second variance of the second historical backfat data, and determine the third variance of the third historical backfat data;
[0277] The weight values of the preset body thickness data fusion model are determined based on the first variance, the second variance, and the third variance.
[0278] It should be noted that the backfat thickness detection method provided in this application can automatically detect the backfat thickness of the pig at regular intervals. This detection time can be 1 minute, 10 minutes, 1 hour, or 1 day, etc., and this application does not specifically limit it. However, generally speaking, pigs are growing every moment, so a more frequent time interval (e.g., 5 minutes, 10 minutes, etc.) can be selected to detect the backfat thickness of the pig.
[0279] The first historical backfat data represents the backfat thickness data obtained using a preset regression model within a preset historical period; the second historical backfat data represents the backfat thickness data obtained using a preset density model within a preset historical period; and the third historical backfat data represents the backfat thickness data obtained using a preset fusion model and / or manually collected within a preset historical period.
[0280] Here, the preset historical time refers to a certain period of time before the current detection of pig backfat thickness. For example, assuming that the backfat thickness of pigs is detected at 5-minute intervals and the preset historical time is 1 hour, then the first historical backfat data refers to the maximum of 12 predicted values obtained each time within this hour using the preset regression model. The reason for the maximum of 12 is that, as mentioned above, backfat thickness prediction is not performed on pigs in abnormal states, such as when they are not standing or when their backs are bent too high.
[0281] Similarly, the second historical backfat data refers to the maximum of 12 predicted values obtained each time within this hour using a preset density model.
[0282] The third historical backfat data refers to up to 12 backfat thickness data points obtained within this hour using a preset fusion model and / or manual collection. The third historical backfat data may be obtained entirely using the preset fusion model; it may be obtained entirely manually; or it may be partially obtained using the preset fusion model and partially manually. This application does not specifically limit this aspect.
[0283] It should also be noted that the first variance is obtained by calculating the variance of the first historical backfat data; the second variance is obtained by calculating the variance of the second historical backfat data; and the third variance is obtained by calculating the variance of the third historical backfat data.
[0284] Next, the weight values of the preset back fat thickness data fusion model are obtained by calculating based on the first variance, the second variance, and the third variance. The weight values include the weight values of the first back fat thickness, the second back fat thickness, and the third back fat thickness, and the sum of the three is 1.
[0285] S1402. The first backfat thickness, the second backfat thickness, and the third backfat thickness are calculated by weighting the first weight value, the second weight value, and the third weight value to obtain the backfat thickness of the pig to be tested.
[0286] It should be noted that the preset fusion model provided in this application embodiment can predict the backfat thickness of pigs based on weighted calculation, as shown in the following formula:
[0287]
[0288] in, This indicates the backfat thickness of the pig obtained using a preset fusion model; This represents the first back fat thickness, which is the back fat thickness value predicted using a preset regression model. This represents the second backfat thickness, which is the backfat thickness value predicted using a preset density model. The third back fat thickness represents the back fat thickness value most recently obtained using a preset fusion model. Alternatively, the third back fat thickness can also be the back fat thickness value most recently obtained through manual correction, such as through manual measurement methods like ultrasonic detection. k1 represents the weight value of the first back fat thickness; k2 represents the weight value of the second back fat thickness; and (1-k1-k2) represents the weight value of the third back fat thickness.
[0289] The main idea of the preset fusion model provided in this application embodiment is as follows: it is assumed that the predicted value (first backfat thickness) obtained by the aforementioned preset regression model, the predicted value (second backfat thickness) obtained by the preset density model, and the historical backfat thickness data (third backfat thickness) all contain noise. Here, it is assumed that the noise all follow a Gaussian distribution and are independent of each other.
[0290] Therefore, the equation of state for the first back fat thickness, the second back fat thickness, and the third back fat thickness is as follows:
[0291]
[0292] Where z1 represents the actual value of the first backfat thickness; z1 represents the predicted value of the first back fat thickness, i.e., the first back fat thickness in the embodiments of this application; z2 represents the actual value of the second back fat thickness. z1 represents the predicted value of the second back fat thickness, i.e., the second back fat thickness in the embodiments of this application; z2 represents the actual value of the third back fat thickness. The predicted value of the third back fat thickness is represented, i.e., the back fat thickness in the embodiments of this application; w is the noise of the first back fat thickness; v is the noise of the second back fat thickness; and u is the noise of the third back fat thickness.
[0293] The three data parts are then combined using weights, as shown in the following formula:
[0294] z=k1z1+k2z2+(1-k1-k2)z3 (11)
[0295] Wherein, k1 represents the weight value of the true value of the first back fat thickness, which is the same as the weight value of the first back fat thickness; k2 represents the weight value of the true value of the second back fat thickness, which is the same as the weight value of the second back fat thickness; (1-k1-k2) represents the weight value of the true value of the third back fat thickness, which is the same as the weight value of the third back fat thickness.
[0296] Thus, the problem of integrating these three factors is essentially the problem of optimizing k1 and k2. The variance of z is calculated using the following formula:
[0297] var(z)=var(k1z1+k2z2+(1-k1-k2)z3)=k1 2 σ1 2 +k2 2 σ2 2 +(1-k1-k2) 2 σ3 2 (12)
[0298] Taking the partial derivatives of k1 and k2 in equation (12) respectively, and setting the partial derivatives to 0, we can obtain the following system of equations:
[0299]
[0300] Solve the system of equations (13) as follows:
[0301]
[0302]
[0303]
[0304] In this way, the optimal fusion weight values k1 and k2 can be directly calculated through variance, and then the final backfat thickness can be obtained according to equation (9).
[0305] See Figure 15 It illustrates a schematic diagram of a framework for determining backfat thickness using a data fusion model, as provided in an embodiment of this application. Figure 15 As shown, the variance σ1 is first calculated based on the first, second, and third historical backfat data. 2 σ2 2 σ3 2Here, the variance of the historical backfat data for the past 5 historical moments, namely time t-1, time t-2, time t-3, time t-4, and time t-5, is calculated. Then, the optimal fusion weight values k1 and k2 are calculated according to equations (15) and (16). Finally, the first backfat thickness and the second backfat thickness at the current moment are determined according to the method of the aforementioned embodiment, and the backfat thickness at the previous moment, i.e., the third backfat thickness, is extracted. Finally, the current moment t, i.e., the backfat thickness at this moment, is calculated according to equation (9).
[0306] For example, see Figure 16 It shows a schematic diagram of the framework of a backfat thickness detection method provided in an embodiment of this application, such as... Figure 16 As shown, after obtaining the prior features and real-time features of the pig to be tested, these feature data are sequentially fed into the feature layer, neural network layer, prediction layer, and data fusion layer to determine the backfat thickness of the pig to be tested.
[0307] The feature layer mainly processes prior features and real-time features. It embeds the discrete features in the two parts to obtain the embedding features. It obtains the convolutional neural network (CNN) features from the image data through a convolutional neural network. The obtained embedding features and CNN features are sent to the neural network layer for processing. This neural network layer can include two fully connected network layers and one dropout and attention layer.
[0308] The prediction layer consists of two parts. One part determines the first backfat thickness based on a preset regression model, which can be achieved using the classifier and regressor shown in the diagram. The other part determines the second backfat thickness based on a preset density model, which can be achieved using the probability density predictor shown in the diagram. The final layer is the data fusion layer, which fuses the first, second, and third backfat thicknesses based on a preset fusion model to obtain the backfat thickness of the pig to be detected. This can be achieved using a data fusion unit.
[0309] In summary, the embodiments of this application mainly propose an automated method for measuring the backfat thickness of pigs. This method involves, as follows: Figure 2 The feature acquisition device shown is used to acquire prior and real-time features of the pig body. For example, the prior and real-time features of the pig body are acquired through the grid projection module, RFID module, camera module and infrared sensor array module of the device. Then, the feature is integrated and predicted by the algorithm server.
[0310] Since backfat measurement is primarily for breeding pigs, which are mainly raised in gestation stalls, a grid projection module is installed above the stall to project equidistant grids downwards. This, combined with image data, is used to acquire the pig's body length, back width (i.e., body width), and other body characteristics from a top-down perspective. An infrared sensor array module is installed on the side of the stall. This module includes multiple equidistantly arranged infrared distance sensors, which acquire digital signals indicating whether there are obstructions in front of the pig. The infrared sensor array module also acquires viewing angle characteristics, including body height and length. Through ear tags, RFID modules, and a pre-set database, historical characteristics of the pig can be obtained, such as breed, weight, age, historical backfat data, and production information. Production information includes gestation stage, number of litters, and average litter size.
[0311] In short, the backfat thickness detection method provided in this application mainly includes two parts: feature acquisition and model construction and prediction. Through methods such as... Figure 2 After the feature acquisition device acquires relevant features, the algorithm server performs calculations. The calculation process mainly involves sequentially feeding the feature data into the feature layer, neural network layer, prediction layer, and data fusion layer, such as... Figure 16 As shown. The feature layer mainly processes two types of features: prior features and real-time features. The neural network layer includes two fully connected layers and one dropout and attention layer. The prediction layer consists of two parts: one part is a method based on interval classification + interval center offset regression proposed in this application embodiment, that is, weight prediction is performed through a preset regression model; the other part is a weight interval density method based on Gaussian distribution proposed in this application embodiment, that is, weight prediction is performed through a preset density model. The last layer is the data fusion layer, which is a weight fusion method based on optimization theory proposed in this application embodiment, that is, weight fusion is performed through a prediction fusion model.
[0312] The feature layer primarily processes two types of features: prior features acquired through the RFID module, such as pig breed, weight, and age; and real-time features, mainly including rump height, body height, and body length. Embedding features are obtained by embedding discrete features from both types of features, and CNN features are obtained from image data through a convolutional neural network. The prior features are primarily obtained from a pre-set database by reading ear tag information using the RFID module.
[0313] The methods for obtaining real-time features are summarized as follows:
[0314] (I) Methods for obtaining body height and hip height characteristics
[0315] The body height and rump height of pigs need to be obtained by data collection using a device placed at a certain viewing angle. This device could be a camera, but due to the small spacing in the gestation crates, a side-mounted camera cannot capture the entire pig. Alternatively, a sliding camera can be used for image capture, followed by image stitching. However, this method suffers from stability issues due to the sliding mechanism, and also increases costs and stitching complexity.
[0316] This application proposes a method based on an infrared distance sensor array for determining whether a pig is standing and measuring its height. The steps include:
[0317] Step 1: Arrange the infrared sensors into an array at equal intervals, such as... Figure 2 For example, there are 8×9 sensor nodes; in actual deployment, the density can be increased.
[0318] Step Two: Arrange the infrared sensor array from Step One as follows Figure 2 Place as shown;
[0319] Step 3: Obtain the binary occlusion array image of the pig body output by the infrared sensor array, such as... Figure 3 As shown;
[0320] Step 4: Use a binary occlusion array to determine whether the pig is standing, and calculate the pig's hip height and shoulder height. A supervised neural network can be used to determine whether the pig is standing; after obtaining the positions of the forelegs and hind legs using a preset neural network, the highest point of the hind leg array is the hip height, and the highest point of the foreleg array is the shoulder height.
[0321] Step 5: Decide whether the backfat thickness can be measured based on the data. That is, do not measure the backfat thickness of pigs that are not standing.
[0322] (II) Methods for obtaining back curvature
[0323] The main steps in obtaining back curvature include:
[0324] Step 1: Obtain image data captured by the camera installed above the limit bar;
[0325] Step 2: Predict 10 key points of the spine on the back of the pig in the image. Key point prediction can be performed using general deep learning techniques.
[0326] Step 3: After connecting the key points of the head and buttocks, draw a perpendicular line from each key point to the line connecting the head and buttocks, such as... Figure 4 As shown;
[0327] Step 4: Calculate the back curvature according to formula (1), which serves as the basis for measuring the degree of back curvature. The larger the curvature ratio, the greater the degree of curvature; the closer the curvature ratio is to 0, the straighter the back is. Figure 4In the middle, the left figure (a) shows a more curved state, and the right figure (b) shows a more straight state.
[0328] If the back curvature exceeds the preset curvature threshold, the current body thickness estimate is abandoned; if the back curvature is within the preset curvature threshold, the back curvature is used as one of the real-time features.
[0329] (III) Methods for obtaining body length characteristics
[0330] The steps involved in obtaining body length features include:
[0331] Step 1: Install a grid projection device above the limit bar. The grid projection device will project equidistant grids.
[0332] Step 2: Since the grid spacing projected onto the ground changes linearly with the vertical projection distance, the grid distance can be set in the system after the grid projection device is installed at a fixed height, and a mapping relationship between the grid distance and the pixel distance in the image can be established through the grid distance.
[0333] Step 3: Use deep learning and other technologies to segment the target pixels of the pig's body in the image to obtain the boundaries of the pig's body in the image;
[0334] Step 4: Map the pixel length and pixel width of the boundary to the actual distance. A diagram illustrating the calculation of grid distance, pixel distance, and volume length is shown below. Figure 5 As shown.
[0335] (iv) Dynamic body thickness interval classification + offset regression algorithm (preset regression model training and prediction)
[0336] Conventional deep learning continuous value prediction methods, including category interval and direct prediction continuous value methods, are not suitable for back fat thickness detection scenarios. This application proposes a preset regression model based on dynamic fat thickness interval classification + offset regression algorithm to predict back fat thickness.
[0337] The backfat thickness of pigs is generally within 20mm, but the backfat thickness range is different for different breeds, ages, gestation stages, and sexes. The dynamic backfat thickness range classification + offset regression method proposed in this application selects different classification ranges according to different breeds, ages, gestation stages, and sexes. Then, a classifier is used to classify according to the dynamic range hit situation. After classification, the corresponding regressor is used to perform offset regression prediction of the range center. Table 1 shows three sets of classification range examples for different pig breeds.
[0338] For example, the process of using a pre-defined regression model to predict the first back fat thickness. Figure 9As shown, in this example, the prior data for pig species is Large White pigs, which hits group 2 in Table 1. Therefore, the classifiers and regressors in groups 1 and 3 are inactive, which is reflected in both the model prediction and model training stages. The group 2 classifier predicts a confidence level for each interval. In this example, the interval with the highest confidence level is (12, 14], corresponding to an interval center value of 13. Then, the predicted offset value of the classification interval corresponding to the interval center value of 13 is taken, and finally, the predicted body thickness is 13 + 0.3 = 13.3.
[0339] The training process of the model is as follows Figure 6 As shown, firstly, consistent with the reasoning steps, prior features are used to determine the target classification group, such as... Figure 6 Based on the breed of Large White pig, it was determined to be in Group 2. Then, a neural network was used for inference and prediction, such as using the softmax activation function, to obtain interval prediction results and offset prediction results. Next, based on the standard fat thickness value bh and the interval values (q_l) of this group... i ,q_r i Calculate the interval classification standard value t_c i The calculation method is as shown in equation (3). Based on the standard value of body thickness bh and the center values of each interval in this group. Calculate the standard value of offset t_p i The calculation method is as shown in equation (4). Where i is the interval index, and in this example, 0≤i≤5. Figure 7 The example shown is the calculation result with a thickness standard value of 13.6. Finally, the loss is calculated based on the previously calculated standard value and the predicted value, and the neural network weights are updated.
[0340] (V) Body thickness density prediction algorithm (preset density model training and prediction)
[0341] The approach is as follows: First, in backfat thickness prediction, intervals with closer intervals are more correlated than those with farther intervals. For example, the intervals (10,12] and (8,10] are far more correlated than the interval (0,2]. However, traditional classification algorithms using one-hot data lack this approach. Second, since the standard value of backfat thickness is obtained through manual collection, noise is inevitable. Therefore, we can assume that the manually collected backfat thickness is p = g + μ, where p is the manually collected backfat thickness, g is the actual standard value of backfat thickness, and μ is the collection noise. The exact value of g is unknown, but the smaller μ is, the closer p is to g. We expect g to approximate p, i.e., we assume μ ~ N(0,σ). 2According to the Gaussian distribution formula, the probability distribution of p is shown in equation (5). Sampling the continuous distribution in equation (5) yields the discrete value in equation (6), where JG is the sampling interval, which is assumed to be 0.5 in this example, and i is the sampling index value, ranging from (-∞, +∞). To ensure that the neural network can fit the data, a window method is used, letting... as well as At that time, p i =0. To ensure the meaning of probability, that is, to ensure JG×∑p i =1, will and Density energy is evenly distributed within the range Within the range, we obtain equation (7), where the variance can be calculated based on historical manual fat thickness data.
[0342] Based on the above approach, the steps of the body thickness interval prediction algorithm include:
[0343] Step 1: Convert the manually collected backfat thickness p into a pseudo-Gaussian discrete vector using equation (7);
[0344] Step 2: Softmax Training. Use softmax to predict the discrete vectors from Step 1. For example... Figure 11 As shown, assuming JG = 0.5 and the maximum fat thickness is 20mm, 40 softmax nodes need to be set up. Each node is responsible for predicting the corresponding fat thickness density value. The neural network is trained based on the transformed pseudo-Gaussian discrete standard value vector.
[0345] Step 3: Make predictions based on the neural network trained in the previous step to obtain pseudo-Gaussian prediction values;
[0346] Step 4: The density values are accumulated as shown in Equation (8) to obtain the final predicted fat thickness value. The reasoning process and density accumulation process are as follows: Figure 13 As shown.
[0347] (vi) Gaussian distribution-based thickness data fusion algorithm (preset fusion model prediction)
[0348] The backfat data fusion algorithm provided in this application mainly assumes that the predicted values obtained through a preset regression model, a preset density model, and historical backfat thickness (which can be manually calibrated) all contain noise, and that the noise all follows a Gaussian distribution and is independent of each other. Let the actual values of the three parts of data—the predicted value of the preset regression model, the predicted value of the preset density model, and the historical backfat thickness data—be z1, z2, and z3, respectively, and let their predicted values be z1, z2, and z3. and The state equation is shown in equation (10). By fusing the three data parts using weights k1 and k2, as shown in equation (11), the fusion problem becomes optimizing k1 and k2. Based on the previous assumptions, The variance is calculated as shown in equation (12).
[0349] right The variance expression is partially derived with respect to k1 and k2 and set to 0 to obtain the system of equations as shown in equation (13). Solving the system of equations (13) yields the expression for the optimal fusion of k1 and k2, as shown in equations (14)-(16).
[0350] The fusion process is as follows Figure 15 As shown, the variance σ1 is first calculated using historical data for each predicted data. 2 σ2 2 σ3 2 Then, calculate the optimal fusion weights k1 and k2 according to equations (15) and (16); then, make predictions according to the aforementioned models to obtain the predicted values z1 and z2 of the preset regression model and preset density model at the current time; finally, extract the historical predicted value z3 of the previous time and calculate the final predicted value at this time according to the previously calculated optimal weights k1 and k2.
[0351] The pre-defined regression model based on dynamic backfat thickness interval classification + offset regression algorithm provided in this application improves the prediction robustness of different prior features by transforming the continuous backfat thickness prediction task into a dynamic classification interval and offset regression task. The pre-defined density model based on backfat thickness density prediction algorithm provided in this application, by assuming that the error of manually collected backfat thickness follows a Gaussian distribution, proposes a pseudo-Gaussian data distribution prediction algorithm to improve robustness to errors in labeled data. The pre-defined fusion model based on Gaussian distribution backfat thickness data fusion algorithm provided in this application, by assuming that the three different prediction methods all follow independent Gaussian distributions, designs a Gaussian optimal backfat thickness data fusion method.
[0352] The back curvature calculation method provided in this application is based on the localization of key points on the spine and is designed to measure the degree of back curvature. This application also provides a method for measuring the hip height and body height of live pigs based on an infrared distance sensor array. Furthermore, this application provides a method for measuring the body length and width of live pigs based on an invisible light projection grid device.
[0353] Compared with related technologies, the technical solutions of the embodiments of this application have at least the following advantages:
[0354] (1) The first backfat thickness is determined by using a preset regression model. This is an algorithm based on dynamic backfat thickness interval classification and offset regression. Compared with continuous value prediction, backfat thickness interval prediction can effectively suppress the generation of abnormal backfat thickness prediction results. Dynamic backfat thickness interval can solve the problem of unreasonable interval design caused by prior features such as different varieties. Offset regression can solve the problem that interval prediction cannot obtain continuous values.
[0355] (2) The second backfat thickness is determined by using a preset density model. This is a Gaussian distribution-based fat thickness density prediction algorithm: it does not rely too much on labeled data (i.e. standard data), which improves the model's tolerance to errors caused by manually collected backfat thickness and also solves the problem that classification tasks cannot obtain continuous result values.
[0356] (3) Using a preset fusion model to determine backfat thickness is a Gaussian distribution-based backfat thickness data fusion algorithm: it can suppress high-frequency prediction noise caused by on-site noise, that is, suppress the fluctuation of backfat thickness prediction in a short period of time; in the scheme of using multiple methods for prediction, using this model can minimize the prediction variance and improve the complementary performance of each method.
[0357] In other words, the feature acquisition methods, preset regression models, preset density models, and preset fusion proposed in the embodiments of this application can effectively utilize historical data and real-time on-site data, improving the accuracy of image-based fat thickness prediction. Compared with manual measurement methods such as B-ultrasound, it has advantages such as being harmless to pigs, having a high degree of automation, low cost, and high efficiency.
[0358] This application provides a method for detecting backfat thickness. The above embodiments illustrate the specific implementation of the aforementioned embodiments. As can be seen, the backfat thickness detection method provided in this embodiment constructs a preset regression model through dynamic backfat thickness interval classification and offset regression, and constructs a preset density model through backfat density prediction. The first backfat thickness and the second backfat thickness are obtained based on the preset regression model and the preset density model, respectively. Finally, the first backfat thickness, the second backfat thickness, and the third backfat thickness (i.e., the historical backfat thickness at the previous moment) are fused to obtain the optimal backfat thickness. This effectively combines historical and real-time features to detect the backfat thickness of pigs, improving the accuracy of backfat thickness prediction through the model, causing no harm to the pig, and offering a higher degree of automation, thus improving efficiency while reducing costs.
[0359] In another embodiment of this application, see [reference needed]. Figure 17 This illustration shows a schematic diagram of the composition of a backfat thickness detection device 170 provided in an embodiment of this application. Figure 17As shown, the backfat thickness detection device includes an acquisition unit 1701, a first analysis unit 1702, a second analysis unit 1703, and a determination unit 1704, wherein...
[0360] The acquisition unit 1701 is configured to acquire the prior features and real-time features of the pig to be detected.
[0361] The first analysis unit 1702 is configured to analyze the prior features and the real-time features using a preset regression model to determine the first backfat thickness.
[0362] The second analysis unit 1703 is configured to analyze the prior features and the real-time features using a preset density model to determine the second backfat thickness.
[0363] The determining unit 1704 is configured to determine the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness.
[0364] In some embodiments, the prior features include at least one of the following: pig breed, weight, age, historical backfat thickness, and production information; wherein the production information includes at least one of the following: gestation stage, number of farrowings, and average litter size;
[0365] The real-time features include at least one of the following: hip height, body height, back curvature, body width, and body length.
[0366] In some embodiments, the acquisition unit 1701 is further configured to acquire the ear tag information of the pig to be detected through a radio frequency identification (RFID) module; and to search for the prior features corresponding to the ear tag information from a preset database, and to determine the found prior features as the prior features of the pig to be detected.
[0367] In some embodiments, the acquisition unit 1701 is further configured to determine the hip height and body height of the pig to be detected when the pig to be detected is in a standing state via an infrared sensor array module; and to determine the back curvature of the pig to be detected via a camera module; and to determine the body width and body length of the pig to be detected via a grid projection module.
[0368] In some embodiments, the acquisition unit 1701 is further configured to acquire a binary occlusion array image of the pig to be detected through the infrared sensor array module; determine whether the pig to be detected is in a standing state based on the binary occlusion array image; and if the pig to be detected is in a standing state, determine the hip height and body height of the pig to be detected based on the binary occlusion array image.
[0369] In some embodiments, the acquisition unit 1701 is further configured to acquire a top-view image of the pig to be detected through the camera module; determine several key points of the spine of the pig to be detected from the top-view image; and determine the back curvature of the pig to be detected based on the several key points of the spine.
[0370] In some embodiments, the acquisition unit 1701 is further configured to acquire a grid image through the grid projection module; and to perform target pixel segmentation on the captured image of the pig to be detected using the grid image to determine the boundary information of the pig to be detected in the captured image; and to determine the body width and body length of the pig to be detected based on the mapping relationship between the grid distance in the grid image and the pixel distance in the captured image and the boundary information of the pig to be detected.
[0371] In some embodiments, the first analysis unit 1702 is further configured to: determine a target classification group and a preset regression model corresponding to the target classification group based on the prior features; perform classification regression prediction on the prior features and the real-time features using the preset regression model to determine a target interval and a target offset; and determine the first backfat thickness based on the target interval and the target offset.
[0372] In some embodiments, the preset regression model includes at least a preset classifier and a preset regressor. The first analysis unit 1702 is further configured to: use the preset classifier to classify the target classification group into intervals to obtain at least one classification interval; determine the confidence level of each classification interval based on the prior features and the real-time features; perform regression prediction on the at least one classification interval using the preset regressor, the prior features, and the real-time features to determine the offset of each classification interval; and select the maximum value from the determined confidence levels, determine the classification interval corresponding to the maximum value as the target interval, and determine the offset corresponding to the target interval as the target offset.
[0373] In some embodiments, the first analysis unit 1702 is further configured to determine the center point of the target interval based on the target interval; and to perform an addition operation on the center point of the target interval and the target offset to obtain the first backfat thickness.
[0374] In some embodiments, the second analysis unit 1703 is further configured to: determine a preset backfat thickness range; sample the preset backfat thickness range according to a preset sampling interval to obtain at least one sampling point; use the preset density model to determine the probability density prediction value corresponding to the at least one sampling point based on the prior features and the real-time features; and determine the second backfat thickness based on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point.
[0375] In some embodiments, the second analysis unit 1703 is further configured to perform density integration on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point to obtain the second backfat thickness.
[0376] In some embodiments, the determining unit 1704 is further configured to obtain a third backfat thickness, the third backfat thickness being the backfat thickness determined during the most recent backfat thickness detection of the pig to be detected; and to fuse the first backfat thickness, the second backfat thickness, and the third backfat thickness using a preset fusion model to determine the backfat thickness of the pig to be detected.
[0377] In some embodiments, the determining unit 1704 is further configured to determine a first weight value corresponding to the first backfat thickness, a second weight value corresponding to the second backfat thickness, and a third weight value corresponding to the third backfat thickness; and to perform a weighted calculation on the first backfat thickness, the second backfat thickness, and the third backfat thickness using the first weight value, the second weight value, and the third weight value to obtain the backfat thickness of the pig to be tested.
[0378] In some embodiments, such as Figure 17 As shown, the backfat thickness detection device 170 may further include a first training unit 1705, configured to acquire a sample dataset; wherein the sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is an integer greater than zero; and to train a first preset neural network model based on the sample dataset to obtain the preset regression model.
[0379] In some embodiments, the first training unit 1705 is further configured to: determine a target classification group based on the prior features of the i-th sample pig, where i is an integer greater than zero and less than or equal to N; and within the target classification group, determine a first backfat thickness prediction value of the i-th sample pig based on the prior features and real-time features of the i-th sample pig; determine a first loss function value based on the first backfat thickness prediction value and the standard backfat thickness value of the i-th sample pig, and update the first preset neural network model; and when the first loss function value is greater than or equal to a first threshold, increment i by 1 and return to the step of determining the target classification group based on the prior features of the i-th sample pig; and when the first loss function value is less than the first threshold, determine the updated first preset neural network model as the preset regression model corresponding to the target classification group.
[0380] In some embodiments, such as Figure 17 As shown, the backfat thickness detection device 170 may further include a second training unit 1706, configured to acquire a sample dataset; wherein the sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is an integer greater than zero; and to train a second preset neural network model based on the sample dataset to obtain the preset density model.
[0381] In some embodiments, the second training unit 1706 is further configured to: determine a preset backfat thickness interval; sample the preset backfat thickness interval according to a preset sampling interval to obtain at least one sampling point; determine the probability density prediction value corresponding to the at least one sampling point based on the prior features and real-time features of the i-th sample pig, where i is an integer greater than zero and less than or equal to N; determine the probability density standard value corresponding to the at least one sampling point based on the standard value of backfat thickness of the i-th sample pig; determine a second loss function value based on the probability density prediction value and the probability density standard value corresponding to the at least one sampling point, and update the second preset neural network model; increment i by 1 when the first loss function value is greater than or equal to a second threshold, and return to the step of determining the probability density prediction value corresponding to the at least one sampling point based on the prior features and real-time features of the i-th sample pig; and determine the updated second preset neural network model as the preset density model when the second loss function value is less than the second threshold.
[0382] In some embodiments, such as Figure 17 As shown, the back fat thickness detection device 170 may further include a storage unit 1707, configured to store the first back fat thickness, the second back fat thickness, and the back fat thickness into a preset database.
[0383] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0384] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or 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.) or processor to execute all or part of the steps of the method described in this embodiment. 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.
[0385] Therefore, this embodiment provides a computer storage medium storing a computer program that, when executed by at least one processor, implements the steps of the backfat thickness detection method described in any of the foregoing embodiments.
[0386] Based on the above-described composition of the backfat thickness detection device 170 and the computer storage medium, see [link to relevant documentation]. Figure 18 This illustrates a schematic diagram of the specific hardware structure of a detection device 180 provided in an embodiment of this application. For example... Figure 18 As shown, it may include: a communication interface 1801, a memory 1802, and a processor 1803; the various components are coupled together via a bus system 1804. It is understood that the bus system 1804 is used to implement communication between these components. In addition to a data bus, the bus system 1804 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 18 The various buses are all labeled as Bus System 1804. Among them, the communication interface 1801 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0387] Memory 1802 is used to store computer programs that can run on processor 1803;
[0388] Processor 1803, when running the computer program, performs the following:
[0389] Obtain the prior and real-time features of the pig to be detected;
[0390] The first backfat thickness was determined by analyzing prior features and real-time features using a pre-defined regression model.
[0391] The second backfat thickness is determined by analyzing prior and real-time features using a pre-defined density model.
[0392] The backfat thickness of the pig to be tested is determined based on the first backfat thickness and the second backfat thickness.
[0393] It is understood that the memory 1802 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 1802 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0394] The processor 1803 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1803 or by instructions in software form. The processor 1803 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 1802. Processor 1803 reads the information in memory 1802 and, in conjunction with its hardware, completes the steps of the above method.
[0395] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0396] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented within the processor or externally.
[0397] Alternatively, as another embodiment, the processor 1803 is further configured to perform the steps of the method described in any of the foregoing embodiments when running the computer program.
[0398] Based on the composition of the backfat thickness detection device 170 and the hardware structure diagram of the detection equipment 180, see [reference needed]. Figure 19 This illustrates a schematic diagram of the composition of a detection device 190 provided in an embodiment of this application. For example... Figure 19 As shown, the detection device 190 includes at least the backfat thickness detection device 170 as described in any of the foregoing embodiments.
[0399] For the detection equipment 190, since it considers both real-time features and prior features when determining backfat thickness, and combines the analysis results of multiple models to determine backfat thickness, the various models can complement each other well. This not only avoids harm to the pigs from close-contact measurement, but also improves the accuracy of backfat detection, and reduces costs while increasing detection efficiency.
[0400] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.
[0401] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0402] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0403] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0404] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0405] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0406] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for detecting backfat thickness, characterized in that, The method includes: Obtain the prior and real-time features of the pig to be detected; The first backfat thickness is determined by analyzing the prior features and the real-time features using a preset regression model. The prior features and real-time features are analyzed using a preset density model to determine the second backfat thickness; The backfat thickness of the pig to be tested is determined based on the first backfat thickness and the second backfat thickness. The step of analyzing the prior features and the real-time features using a preset density model to determine the second backfat thickness includes: Determine the preset fat thickness range; The preset thickness range is sampled according to a preset sampling interval to obtain at least one sampling point; Using the preset density model, the probability density prediction value corresponding to the at least one sampling point is determined based on the prior features and the real-time features, and the second backfat thickness is determined based on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point.
2. The method according to claim 1, characterized in that, The prior features include at least one of the following: pig breed, weight, age, historical backfat thickness, and production information; wherein the production information includes at least one of the following: gestation stage, number of farrowings, and average litter size; The real-time features include at least one of the following: hip height, body height, back curvature, body width, and body length.
3. The method according to claim 2, characterized in that, The acquisition of prior features of the pig to be tested includes: The ear tag information of the pig to be tested is obtained through the radio frequency identification (RFID) module; The prior features corresponding to the ear tag information are searched in the preset database, and the found prior features are determined as the prior features of the pig to be tested.
4. The method according to claim 2, characterized in that, The acquisition of real-time features of the pig to be detected includes: The hip height and body height of the pig to be tested are determined by the infrared sensor array module when the pig is standing. The curvature of the back of the pig to be tested is determined using a camera module. The width and length of the pig to be detected are determined using a grid projection module.
5. The method according to claim 4, characterized in that, The step of determining the hip height and body height of the pig to be detected when the pig is standing, using an infrared sensor array module, includes: The infrared sensor array module is used to obtain a binary occlusion array image of the pig to be detected. Based on the binary occlusion array diagram, determine whether the pig to be detected is in a standing state; If the pig to be tested is standing, the hip height and body height of the pig to be tested are determined according to the binary occlusion array diagram.
6. The method according to claim 4, characterized in that, The step of determining the back curvature of the pig under test using a camera module includes: The camera module is used to obtain a top-view image of the pig to be detected. From the top view image, determine several key points of the spine of the pig to be tested; The curvature of the back of the pig to be tested is determined based on the aforementioned key points of the spine.
7. The method according to claim 4, characterized in that, The step of determining the body width and body length of the pig to be detected through the grid projection module includes: The raster projection module is used to acquire a raster image; The raster image is used to perform target pixel segmentation on the captured image of the pig to be detected, and the boundary information of the pig to be detected in the captured image is determined. Based on the mapping relationship between the grid distance in the grid image and the pixel distance in the captured image, as well as the boundary information of the pig to be detected, the body width and body length of the pig to be detected are determined.
8. The method according to claim 1, characterized in that, The step of analyzing the prior features and the real-time features using a preset regression model to determine the first backfat thickness includes: Based on the prior features, the target classification group and the preset regression model corresponding to the target classification group are determined; The preset regression model is used to perform classification regression prediction on the prior features and the real-time features to determine the target interval and the target offset. The thickness of the first backfat is determined based on the target range and the target offset.
9. The method according to claim 8, characterized in that, The preset regression model includes at least a preset classifier and a preset regressor. The step of using the preset regression model to perform classification and regression prediction on the prior features and the real-time features to determine the target interval and the target offset corresponding to the target interval includes: The target classification group is classified into intervals using the preset classifier to obtain at least one classification interval, and the confidence level of each classification interval is determined based on the prior features and the real-time features. The preset regressor, the prior features, and the real-time features are used to perform regression prediction on the at least one classification interval to determine the offset of each classification interval; Select the maximum value from the determined confidence levels, determine the classification interval corresponding to the maximum value as the target interval, and determine the offset corresponding to the target interval as the target offset.
10. The method according to claim 8, characterized in that, Determining the first backfat thickness based on the target range and the target offset includes: Based on the target interval, determine the center point of the target interval; The first backfat thickness is obtained by adding the center point of the target interval and the target offset.
11. The method according to claim 1, characterized in that, Determining the second backfat thickness based on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point includes: The second backfat thickness is obtained by performing density integral calculation on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point.
12. The method according to claim 1, characterized in that, Determining the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness includes: Obtain the third backfat thickness, which is the backfat thickness determined during the most recent backfat thickness test of the pig to be tested; The backfat thickness of the pig to be tested is determined by fusing the first backfat thickness, the second backfat thickness, and the third backfat thickness using a preset fusion model.
13. The method according to claim 12, characterized in that, The step of fusing the first backfat thickness, the second backfat thickness, and the third backfat thickness using a preset fusion model to determine the backfat thickness of the pig to be tested includes: Determine the first weight value corresponding to the first back fat thickness, the second weight value corresponding to the second back fat thickness, and the third weight value corresponding to the third back fat thickness; The backfat thickness of the pig to be tested is obtained by weighting the first backfat thickness, the second backfat thickness, and the third backfat thickness using the first weight value, the second weight value, and the third weight value.
14. The method according to claim 1, characterized in that, The method further includes: Obtain a sample dataset; wherein the sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is an integer greater than zero; The first preset neural network model is trained based on the sample dataset to obtain the preset regression model.
15. The method according to claim 14, characterized in that, The step of training the first preset neural network model based on the sample dataset to obtain the preset regression model includes: The target classification group is determined based on the prior features of the i-th sample pig, where i is an integer greater than zero and less than or equal to N; Within the target classification group, the predicted value of the first backfat thickness of the i-th sample pig is determined based on the prior features and real-time features of the i-th sample pig. Based on the first predicted backfat thickness value and the standard backfat thickness value of the i-th sample pig, the first loss function value is determined, and the first preset neural network model is updated. When the value of the first loss function is greater than or equal to the first threshold, increment i by 1 and return to the step of determining the target classification group based on the prior features of the i-th sample pig; When the value of the first loss function is less than the first threshold, the updated first preset neural network model is determined as the preset regression model corresponding to the target classification group.
16. The method according to claim 15, characterized in that, The method further includes: Obtain a sample dataset; wherein the sample dataset includes prior features, real-time features, and standard backfat thickness values of N sample pigs, where N is an integer greater than zero; The second preset neural network model is trained based on the sample dataset to obtain the preset density model.
17. The method according to claim 15, characterized in that, The step of training the second preset neural network model based on the sample dataset to obtain the preset density model includes: Determine the preset fat thickness range; The preset thickness range is sampled according to a preset sampling interval to obtain at least one sampling point; The probability density prediction value corresponding to the at least one sampling point is determined based on the prior features and real-time features of the i-th sample pig, where i is an integer greater than zero and less than or equal to N; The probability density standard value corresponding to the at least one sampling point is determined based on the standard value of the backfat thickness of the i-th sample pig. Based on the probability density prediction value and the probability density standard value corresponding to the at least one sampling point, the second loss function value is determined, and the second preset neural network model is updated. When the value of the first loss function is greater than or equal to the second threshold, increment i by 1 and return to the step of determining the probability density prediction value corresponding to the at least one sampling point based on the prior features and real-time features of the i-th sample pig. When the value of the second loss function is less than the second threshold, the updated second preset neural network model is determined as the preset density model.
18. The method according to any one of claims 1 to 17, characterized in that, After determining the backfat thickness of the pig to be tested, the method further includes: The first back fat thickness, the second back fat thickness, and the back fat thickness are stored in a preset database.
19. A backfat thickness detection device, characterized in that, The backfat thickness detection device includes an acquisition unit, a first analysis unit, a second analysis unit, and a determination unit, wherein... The acquisition unit is configured to acquire prior features and real-time features of the pig to be detected. The first analysis unit is configured to analyze the prior features and the real-time features using a preset regression model to determine the first backfat thickness; The second analysis unit is configured to analyze the prior features and the real-time features using a preset density model to determine the second backfat thickness; The determining unit is configured to determine the backfat thickness of the pig to be tested based on the first backfat thickness and the second backfat thickness. The second analysis unit is further configured to: determine a preset backfat thickness range; sample the preset backfat thickness range according to a preset sampling interval to obtain at least one sampling point; use the preset density model to determine the probability density prediction value corresponding to the at least one sampling point based on the prior features and the real-time features; and obtain the second backfat thickness based on the at least one sampling point, the preset sampling interval, and the probability density prediction value corresponding to the at least one sampling point.
20. The backfat thickness detection device according to claim 19, characterized in that, The acquisition unit includes a feature acquisition device, which includes at least an RFID module, an infrared sensor array module, a camera module, and a grid projection module; wherein... The RFID module is used to acquire ear tag information of the pig, so that the feature acquisition device can determine the prior features of the pig based on the ear tag information; The infrared sensor array module is used to acquire a binary occlusion array image of the pig's body, so that the feature acquisition device can determine the pig's hip height and body height based on the binary occlusion array image. The camera module is used to acquire a top-view image of the pig's body, so that the feature acquisition device can determine the curvature of the pig's back based on the top-view image; The grid projection module is used to acquire a grid image so that the feature acquisition device can determine the body width and body length of the pig based on the grid image.
21. A testing device, characterized in that, The detection device includes a memory and a processor, wherein, The memory is used to store computer programs that can run on the processor; The processor is configured to execute the backfat thickness detection method as described in any one of claims 1 to 18 when running the computer program.
22. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which, when executed by a processor, implements the backfat thickness detection method as described in any one of claims 1 to 18.