Pig backfat thickness detection method and system, electronic device and storage medium

Through the contactless detection method of two-dimensional image and backfat growth rate characteristics, combined with feature extraction and support vector machine regression model, the problems of low detection accuracy and biosafety of pigs in the prior art are solved, and high Accurate and convenient detection effect.

CN115063837BActive Publication Date: 2024-12-31HUAZHONG AGRI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210659802.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-13
Publication Date
2024-12-31
Estimated Expiration
2042-06-13

AI Technical Summary

Technical Problem

The existing pig backfat thickness detection methods have low measurement accuracy and large errors, and the ultrasonic measurement method is contact-type, which can easily lead to stress response and cross-infection, and has low biosafety.

Method used

Using a contactless detection method based on two-dimensional images, the back fat thickness of the pigs is determined by obtaining the back image and back fat growth rate characteristics at the top angle of the pigs, combining the feature extraction model and the support vector machine regression model, and determining the back fat thickness of the pigs is avoided by avoiding contact. Measurement and human error.

Benefits of technology

It realizes high-precision, low-cost and convenient contactless pig backfat thickness detection, reduces errors, avoids stress responses, and improves measurement accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115063837B_ABST
    Figure CN115063837B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for detecting pig backfat thickness, an electronic device and a storage medium, wherein the method comprises: obtaining a target pig image and a backfat growth rate characteristic of a pig to be detected; wherein the pig image is a back image of the pig at a top-down angle; the backfat growth rate characteristic is used to indicate the genetic characteristics of the pig backfat thickness; the target pig image and the backfat growth rate characteristic of the pig to be detected are input into a pig backfat thickness detection model to determine the backfat thickness of the pig to be detected. The two-dimensional image of the pig can be used to perform non-contact backfat thickness measurement, effectively reducing measurement errors and improving measurement accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for detecting pig backfat thickness, electronic equipment and a storage medium. Background Art

[0002] The backfat thickness of pigs is an important indicator to measure their growth status. Backfat thickness is often used to monitor the physical condition of pigs in production. In particular, the backfat thickness of pregnant sows is closely related to their service life and reproductive performance. Measuring the backfat thickness of pregnant sows is a necessary part of the production process of large-scale pig farms. Since different stages of pregnancy have different requirements for the backfat thickness of sows, and the backfat thickness of sows is often used to divide the feeding stages in production, it is necessary to dynamically monitor the backfat thickness of pregnant sows.

[0003] At present, the main methods used in production to detect pig backfat thickness are visual pressing method and ultrasonic measurement method. In addition, with the development of modern information technology, some technologies that use computer vision technology to measure pig backfat thickness have begun to emerge. However, the visual pressing method and the measurement method based on computer vision in the above methods have the defects of low measurement accuracy and large errors. The ultrasonic measurement method is a contact measurement. Due to the difficulty in securing live pigs, pigs are prone to stress reactions under contact measurement, and using one measuring instrument to measure multiple pigs is prone to cross-infection, and the biosafety is not high.

[0004] Therefore, how to provide a pig backfat thickness detection method and system, electronic equipment and storage medium, use the two-dimensional image of the pig to perform non-contact backfat thickness measurement, effectively reduce measurement errors, and improve measurement accuracy. Summary of the invention

[0005] In view of the defects in the prior art, the embodiments of the present invention provide a method and system for detecting the backfat thickness of pigs, an electronic device and a storage medium.

[0006] The present invention provides a method for detecting pig backfat thickness, comprising:

[0007] Obtaining a target pig image and back fat growth rate characteristics of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; and the back fat growth rate characteristics are used to represent the genetic characteristics of the pig's back fat thickness;

[0008] The target pig image and backfat growth rate characteristics of the pig to be tested are input into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0009] According to the pig backfat thickness detection method provided by the present invention, the target pig image and backfat growth rate characteristics of the pig to be detected are obtained, which specifically includes:

[0010] Raise the pigs to be tested based on the preset feeding conditions;

[0011] Measure the back fat value of the pigs to be tested according to the preset period;

[0012] The difference between the back fat value of the tested pig within the preset period and the divisor of the preset period is calculated, and the divisor is used as the back fat growth rate characteristic of the tested pig.

[0013] According to the pig backfat thickness detection method provided by the present invention, the pig backfat thickness detection model includes: a feature extraction model and a backfat thickness detection model;

[0014] Inputting the target pig image and backfat growth rate characteristics of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested, specifically including:

[0015] Input the target pig image into the feature extraction model to determine the target feature vector;

[0016] The target feature vector and the backfat growth rate characteristics of the pigs to be tested are input into the backfat thickness detection model to determine the backfat thickness of the pigs to be tested.

[0017] According to the pig backfat thickness detection method provided by the present invention, the feature extraction model includes: a feature extraction layer and a feature dimension reduction layer;

[0018] The target pig image of the pig to be tested is input into the feature extraction model to determine the target feature vector, specifically including:

[0019] Input the image to be recognized into the feature extraction layer, and determine the initial feature map according to the feature extraction layer;

[0020] The initial feature map is input into the feature dimension reduction layer, and the target feature vector is determined according to the feature dimension reduction layer.

[0021] According to the pig backfat thickness detection method provided by the present invention, before the step of inputting the target pig image of the pig to be detected into the feature extraction model and determining the target feature vector, it also includes: determining the network structure of the feature extraction model;

[0022] Determine the network structure of the feature extraction model, including:

[0023] Based on the CNN model, the fully connected layer is replaced by an adaptive average pooling layer and a 1 × 1 convolution layer.

[0024] According to the pig backfat thickness detection method provided by the present invention, the backfat thickness detection model is a support vector machine regression model whose kernel function is a Gaussian kernel function.

[0025] According to the pig backfat thickness detection method provided by the present invention, before the step of inputting the target pig image and the backfat growth rate characteristics of the pig to be detected into the pig backfat thickness detection model to determine the backfat thickness of the pig to be detected, it also includes: training the feature extraction model;

[0026] Train the feature extraction model, including:

[0027] The feature extraction model was trained using a sample pig image set;

[0028] Based on the target loss function, an adaptive moment estimation optimization algorithm is used to update the network parameters of the feature extraction model, and the feature extraction model is iteratively trained based on the updated network parameters until the feature extraction model converges; wherein the target loss function is a mean square error function.

[0029] The present invention also provides a pig backfat thickness detection system, comprising: a pig feature acquisition unit and a pig backfat detection unit;

[0030] A pig feature acquisition unit is used to acquire a target pig image and a back fat growth rate feature of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; and the back fat growth rate feature is used to represent the genetic characteristics of the pig's back fat thickness;

[0031] The pig backfat detection unit is used to input the target pig image and backfat growth rate characteristics of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0032] The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned methods for detecting pig backfat thickness are implemented.

[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the above-mentioned methods for detecting pig backfat thickness are implemented.

[0034] The pig backfat thickness detection method and system, electronic device and storage medium provided by the present invention collect the back image of the pig to be tested at a top-down angle, combine the backfat growth rate used to characterize the genetic characteristics of the backfat thickness of the pig to be tested, and determine the backfat thickness of the pig to be tested through the pig backfat thickness detection model. Using the top-down two-dimensional image as the detection basis can effectively avoid the pig from having a stress response, fully consider the genetic factors of the pig backfat thickness, reflect the physical differences of individual pigs, effectively reduce the error of backfat thickness detection based on the image, and improve the measurement accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 A flow chart of the pig backfat thickness detection method provided by the present invention;

[0037] Figure 2 A schematic diagram of the structure of a pig backfat thickness detection model provided by the present invention;

[0038] Figure 3 A schematic diagram of the image preprocessing method provided by the present invention;

[0039] Figure 4 An initial pig image provided by the present invention;

[0040] Figure 5 The target pig image provided by the present invention;

[0041] Figure 6 A schematic diagram of the feature extraction model framework structure provided by the present invention;

[0042] Figure 7 A schematic diagram of the structure of the CNN-BGR-SVR backfat detection model provided by the present invention;

[0043] Figure 8 A schematic diagram of the process flow of the pig backfat thickness detection method provided by the present invention;

[0044] Fig. 9 A schematic diagram of the structure of a pig backfat thickness detection system provided by the present invention;

[0045] Fig.10 A schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] Currently, the existing methods for detecting pig backfat thickness mainly include: visual pressing method, ultrasonic measurement method and measurement method based on computer vision.

[0048] Among them, the visual pressing method is that the breeder estimates the back fat value of the pig by visual observation or by pressing the pig's back.

[0049] The specific operation of the ultrasonic measurement method is: use the probe of the ultrasonic measuring instrument to touch the pig's back, and obtain the pig's back fat value by reading the numerical value or image displayed on the measuring instrument.

[0050] The computer vision-based measurement method includes using a Kinect sensor to capture a rear view of the pig from 0.5 to 1 m away from the pig's hindquarters, obtaining a visualized image through the Kinect Fusion function, and then using Geomagic software to remove the limiting fences in front of and on both sides of the pig in the image, retaining only the pig's hindquarters point cloud data and performing smoothing. Finally, the hip curvature radius feature is extracted from the point cloud data, and a linear model of it and back fat thickness is established.

[0051] However, the above methods have certain defects. The visual pressing method, which is currently the most widely used in production, has the defects of low measurement accuracy and large errors, and it is difficult to meet production needs; the ultrasonic measurement method is a contact measurement. Due to the difficulty in restraining live pigs, pigs are prone to stress reactions under contact measurement, and cross-infection is prone to occur when using one measuring instrument to measure multiple pigs, and the biosafety is not high; the Kinect-based non-contact body condition scoring method for pigs adopts the method of artificial custom features. Although the depth images used can obtain more dimensional body shape information, its accuracy is greatly affected by the environment, and the cost is relatively high compared to ordinary RGB cameras, and its usage scenarios are limited.

[0052] In order to overcome the shortcomings of the above-mentioned prior art, the present invention provides a method for detecting pig backfat thickness, which uses two-dimensional images of pigs and combines the characteristics that can represent the physical differences of individual pigs to establish a pig backfat thickness detection model. The purpose is to provide a low-cost, convenient, automatic and accurate non-contact pig backfat detection method.

[0053] The present invention can be widely applied to the detection of pigs in different physiological states, such as sows in pregnancy and lactation. In the actual application of the present invention, when performing detection in a specific physiological stage, the sample type used in model training should be adaptively adjusted. Furthermore, the present invention can also be adaptively applied to the detection of other animals that need to perform backfat thickness detection, or knowledge transfer can be applied to other fields.

[0054] Figure 1 The present invention provides a flow chart of the pig backfat thickness detection method, as shown in Figure 1 As shown, an embodiment of the present invention provides a method for detecting pig backfat thickness, comprising:

[0055] Step S1, obtaining a target pig image and a back fat growth rate characteristic of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; and the back fat growth rate characteristic is used to indicate the genetic characteristics of the pig's back fat thickness;

[0056] Step S2, inputting the target pig image and backfat growth rate characteristics of the pig to be tested into a pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0057] Specifically, because the backfat thickness of pigs is affected by multiple factors such as genetics, nutrition and environment, the growth rate of backfat in different pigs is inconsistent. Backfat thickness of pigs is a medium-to-high heritability trait (h 2 =0.4~0.6), which can be stably inherited to the offspring, resulting in the difference of "easy to get fat or thin" physique of pigs. The prior art method for measuring backfat thickness of pigs does not take into account the difference of "easy to get fat or thin" physique of individuals, has certain limitations, and affects the detection accuracy of backfat thickness. Therefore, the present invention introduces the backfat growth rate (BGR) feature to indicate the genetic characteristics of pig backfat thickness.

[0058] In step S1, a back image of the pig to be tested at a top-down angle is collected as a target pig image, and the back growth rate characteristics of the pig to be tested are determined.

[0059] It is understandable that the back fat growth rate characteristic represents the influence of pig genetic factors on pig back fat growth, including all characteristics that can characterize the influence of genetics and genes on individual back fat changes, but not limited to back fat growth rate, genes that affect pig back fat changes or all genes of an individual, genes that affect individual paternal or maternal back fat changes, and the law of individual paternal and maternal back fat changes, etc. In the actual application of the present invention, the specific expression form of the back fat growth rate characteristic can be selected according to actual needs, and the present invention does not limit this.

[0060] In step S2, the target pig image and backfat growth rate characteristics of the pig to be tested obtained in step S1 are input into a pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0061] It is understandable that before performing backfat thickness detection based on the trained pig backfat thickness detection model, the pig backfat thickness detection model needs to be trained based on the sample pig image set and the sample backfat growth rate feature set. The specific neural network model structure and the neural network training method can be selected according to actual needs, and the present invention is not limited to this.

[0062] The method for detecting the back fat thickness of pigs provided by the present invention determines the back fat thickness of the pigs to be tested by collecting the back image of the pigs to be tested at a top-down angle, combining the back fat growth rate used to characterize the genetic characteristics of the back fat thickness of the pigs to be tested, and determining the back fat thickness of the pigs to be tested through the pig back fat thickness detection model. Using the top-down two-dimensional image as the detection basis can realize non-contact detection of back fat thickness, effectively avoid the pigs from having a stress reaction, and fully consider the genetic factors of the pigs' back fat thickness, reflecting the physical differences of individual pigs, effectively reducing the error of back fat thickness detection based on images, and improving the measurement accuracy.

[0063] Optionally, according to the pig backfat thickness detection method provided by the present invention, obtaining the target pig image and backfat growth rate characteristics of the pig to be detected specifically includes:

[0064] Raise the pigs to be tested based on the preset feeding conditions;

[0065] Measure the back fat value of the pigs to be tested according to the preset period;

[0066] The difference between the back fat value of the tested pig within the preset period and the divisor of the preset period is calculated, and the divisor is used as the back fat growth rate characteristic of the tested pig.

[0067] Specifically, considering the difficulty of expressing the genetic factors of pig backfat thickness in actual production applications and the production cost, the present invention defines the rate of backfat change within a certain period as the backfat growth rate characteristic.

[0068] Since pig backfat thickness is affected by genes, nutrition and environment, when the environment and nutrition conditions are the same, genes become the main factor affecting the change of pig backfat thickness. Therefore, in order to obtain the target pig image and backfat growth rate characteristics of the pig to be tested, it is necessary to feed the pig to be tested based on the preset feeding conditions.

[0069] The preset feeding conditions include the pig growth environment and daily feed intake, etc. It should be noted that in actual application, the specific number of preset feeding condition types and the quantitative conditions to be maintained can be set according to actual conditions, and the present invention does not limit this.

[0070] During the feeding process, the back fat value of the pigs to be tested is measured according to a preset period. For example, the preset period is set to 15 days. When all the pigs have the same growth environment and daily feed intake, the back fat value of each pig is measured twice, with an interval of 15 days. It should be noted that in actual application, the specific preset period duration can be set according to actual conditions, and the present invention is not limited to this.

[0071] The difference between the back fat value of the tested pig within the preset period and the divisor of the preset period is calculated, and the divisor is used as the back fat growth rate characteristic of the tested pig.

[0072] The method for detecting the back fat thickness of pigs provided by the present invention determines the back fat thickness of the pigs to be tested by collecting the back image of the pigs to be tested at a top-down angle, combining the back fat growth rate used to characterize the genetic characteristics of the back fat thickness of the pigs to be tested, and determining the back fat thickness of the pigs to be tested through the pig back fat thickness detection model. Using the top-down two-dimensional image as the detection basis can realize non-contact detection of back fat thickness, effectively avoiding the pigs from having a stress response. The rate of back fat change within a certain period is defined as the back fat growth rate characteristic, and the genetic factors of the back fat thickness of the pigs are fully considered. The accurate expression of the physical differences of individual pigs can be realized at a low cost, effectively reducing the error of back fat thickness detection based on images, and improving the measurement accuracy.

[0073] Optionally, according to the pig backfat thickness detection method provided by the present invention, the pig backfat thickness detection model includes: a feature extraction model and a backfat thickness detection model;

[0074] Inputting the target pig image and backfat growth rate characteristics of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested, specifically including:

[0075] Input the target pig image into the feature extraction model to determine the target feature vector;

[0076] The target feature vector and the backfat growth rate characteristics of the pigs to be tested are input into the backfat thickness detection model to determine the backfat thickness of the pigs to be tested.

[0077] Specifically, Figure 2 The schematic diagram of the pig backfat thickness detection model provided by the present invention is as follows: Figure 2 As shown, the pig back fat thickness detection model includes: a feature extraction model and a back fat thickness detection model.

[0078] When testing the back fat thickness of the pig to be tested, the target pig image is input into the feature extraction model, the image features of the target pig image are extracted, and the target feature vector is determined.

[0079] This method uses a feature extraction model to automatically learn features related to backfat thickness from pigs' overhead images. Compared with the traditional method of extracting artificially specified features from images through manual annotation or algorithms, the feature extraction model can automatically learn from images based on given label values ​​and extract low-level and high-level features that are suitable for the real label value, which can overcome the limitations of artificially defined features and greatly enrich the possibilities of features that can be obtained.

[0080] It is understandable that after obtaining the top view of the pig to be tested, the image may be pre-processed. Figure 3 A schematic diagram of the image preprocessing method provided by the present invention. Figure 4 The initial pig image (color image) provided by the present invention, Figure 5 For the target pig image provided by the present invention, preferably, when obtaining Figure 4 After the top view of the pig shown is the initial pig image, in order to further improve the accuracy of detection, use Figure 3 The image preprocessing method shown in FIG. 1 is used to preprocess the image, and the initial pig image is grayed, cropped and scaled, and normalized and standardized to obtain the image as shown in FIG. Figure 5 The target pig image is shown in Figure 1. The mean and standard deviation required for image standardization calculation are obtained from the training set in the sample image set.

[0081] For example: The specific operation process of image cropping and scaling is to crop the original 1280×720 pixel initial pig image to 1080×450 pixel size while retaining the complete target pig in the image, and scale it to 240×100 pixel size as the target pig image input feature extraction model.

[0082] After determining the target feature vector, the target feature vector and the backfat growth rate characteristics of the pig to be tested are input into the backfat thickness detection model, and the backfat thickness is predicted based on the target feature vector and the backfat growth rate characteristics of the pig to be tested to determine the backfat thickness of the pig to be tested.

[0083] It should be noted that the input of the backfat thickness detection model is the target feature vector and the backfat growth rate characteristics of the pig to be tested, and the output is the backfat thickness of the pig to be tested. The specific structure of the backfat thickness detection model and the training method used can be selected according to actual needs, and the present invention does not limit this.

[0084] The method for detecting the back fat thickness of pigs provided by the present invention determines the back fat thickness of the pigs to be tested by collecting the back images of the pigs to be tested at a top-down angle, combining the back fat growth rate used to characterize the genetic characteristics of the back fat thickness of the pigs to be tested, and determining the back fat thickness of the pigs to be tested through a pig back fat thickness detection model. With the top-down two-dimensional image as the detection basis, an ordinary RGB camera can meet the needs of image acquisition, which is lower in cost than a depth camera, less sensitive to the environment, more widely applicable, and more in line with the needs of large-scale production. By automatically learning the features related to the back fat thickness of the pigs from the top-down images of the pigs through the feature extraction model, the limitations of artificially defined features can be overcome, the possibility of features that can be obtained is greatly enriched, and the accuracy of back fat thickness detection can be effectively improved.

[0085] Optionally, according to the pig backfat thickness detection method provided by the present invention, the feature extraction model includes: a feature extraction layer and a feature dimension reduction layer;

[0086] The target pig image of the pig to be tested is input into the feature extraction model to determine the target feature vector, specifically including:

[0087] Input the image to be recognized into the feature extraction layer, and determine the initial feature map according to the feature extraction layer;

[0088] The initial feature map is input into the feature dimension reduction layer, and the target feature vector is determined according to the feature dimension reduction layer.

[0089] Specifically, Figure 6 The schematic diagram of the feature extraction model framework provided by the present invention is as follows: Figure 6 As shown, the feature extraction model includes: a feature extraction layer and a feature dimension reduction layer.

[0090] When extracting image features of an image to be identified based on a feature extraction model, the image to be identified is input into a feature extraction layer, and an initial feature map is determined according to the feature extraction layer;

[0091] The initial feature map is input into the feature dimension reduction layer, and the initial feature map is reduced in dimension according to the feature dimension reduction layer to determine the target feature vector.

[0092] The pig backfat thickness detection method provided by the present invention determines the backfat thickness of the pig to be tested by collecting the back image of the pig under the top view angle, combining the backfat growth rate used to characterize the genetic characteristics of the backfat thickness of the pig to be tested, and determining the backfat thickness of the pig to be tested through the pig backfat thickness detection model. The feature extraction model automatically learns the features related to the backfat thickness of the pig from the top view image, and performs feature dimension reduction, which greatly enriches the possibility of the features that can be obtained, reduces the amount of calculation, and can effectively improve the accuracy of backfat thickness detection and improve the detection speed.

[0093] Optionally, according to the pig backfat thickness detection method provided by the present invention, before the step of inputting the target pig image of the pig to be detected into the feature extraction model and determining the target feature vector, it also includes: determining the network structure of the feature extraction model;

[0094] Determine the network structure of the feature extraction model, including:

[0095] Based on the CNN model, the fully connected layer is replaced by an adaptive average pooling layer and a 1 × 1 convolution layer.

[0096] Specifically, Figure 7 The schematic diagram of the CNN-BGR-SVR backfat detection model structure provided by the present invention is as follows: Figure 6 and Figure 7 As shown, the present invention is described in detail by taking the feature extraction model as the CNN model framework and the backfat thickness detection model as the support vector machine regression model framework as an example.

[0097] Before inputting the target pig image of the pig to be tested into the feature extraction model and determining the target feature vector, the method further includes: determining the network structure of the feature extraction model.

[0098] As an important branch of deep learning, CNN (Convolutional Neural Network) plays an important role in the field of image recognition and classification. CNN is usually composed of three structures: convolutional layer, pooling layer, and fully connected layer. The three types of neural layers perform their respective functions and work together to complete the mapping process from input image to output label.

[0099] As the core layer of CNN, the convolution layer is used to learn the features of the input image. Its local connection and weight sharing characteristics greatly reduce the number of parameters of the neural network, speed up the learning speed, and avoid overfitting to a certain extent. Convolution calculation is an integral operation of input data and convolution kernel. Two-dimensional convolution is commonly used in image processing. The calculation formula is:

[0100]

[0101] In the formula, is the jth picture output by the lth layer, is the jth picture input to the lth layer, is the convolution kernel of the lth layer, is the j-th bias number of the l-th layer, and f is the activation function.

[0102] Pooling layers are often placed between convolutional layers to reduce data dimensions, prevent overfitting, simplify network computational complexity, and represent images with higher-level features, thereby enhancing the network's expressive power. Common operations include maximum pooling and average pooling, and the calculation formula is:

[0103]

[0104] Where pool is the pooling function, which is generally a maximum function or a mean function.

[0105] As the end of the entire CNN, the fully connected layer is used to map the features extracted by the convolutional layer and the pooling layer to the sample label space. The fully connected layer occupies most of the parameters of the entire network.

[0106] Considering that the fully connected layer in traditional CNN limits the size and aspect ratio of the input image, most CNN models are suitable for square input images. Considering the morphological characteristics of pigs, the input is a bird's-eye view of the pig's back. If the image is converted into an image with the same length and width, it will cause deformation of the pig's body and affect the quality of the data. Therefore, this method needs to fix the original image ratio as the input of the CNN model.

[0107] When determining the network structure of the feature extraction model, based on the CNN model, the fully connected layer is replaced by an adaptive average pooling layer and a 1×1 convolution layer. The present invention uses a method combining an adaptive global average pooling layer with a convolution layer using a 1×1 convolution kernel to adapt to image inputs of any size, effectively replacing the fully connected layer, and reducing the number of parameters and calculations for the model, effectively preventing overfitting.

[0108] like Figure 6 and Figure 7 As shown, the process of extracting image features and obtaining target feature vectors by the feature extraction model of the present invention is explained in combination with a specific CNN model structure.

[0109] The CNN model consists of multiple stacked layers, an adaptive average pooling layer, and a convolutional layer. Two convolutional layers and a maximum pooling layer form a stacked unit. In the stacked unit, the convolution kernel size of the two convolutional layers is 3×3, the step size is set to 1, and the convolution kernel size of the maximum pooling layer is 2×2; a BN (BatchNormalization) layer and a LeakyReLU (Leaky Corrected Linear Unit) function are added after each convolutional layer in the stacked unit. The convolution kernel size of the last convolutional layer of the CNN model is 1×1.

[0110] First, the preprocessed two-dimensional pig top view is used as the input of the first stacking layer. After the feature extraction of two convolutional layers C1 and C2 and the data dimension reduction of one maximum pooling layer S3, the image is transformed from a single channel to a feature map with n1 channels. Then the data enters the second stacking layer, and after the feature extraction of two convolutional layers C4 and C5 and the data dimension reduction of the maximum pooling layer S6, the feature map with n2 channels is output. After the data enters the third stacking layer, the feature extraction of the convolutional layers C7 and C8 and the data dimension reduction of the maximum pooling layer S9 are output. The feature map with n3 channels is output. Then the data is reduced by the adaptive average pooling layer S10, and the image size is changed to 1×1 without changing the number of channels in the feature map. Next, the image is filtered by the convolutional layer C11, and the number of channels is t1, the number of features that need to be extracted from the pig image, and the convolution kernel size is 1×1. The convolution block is transformed to t1 channels and the size is 1×1. Finally, the CNN model outputs the feature vector.

[0111] It should be noted that the specific structure of the above model is only used as a specific example to assist in explaining the present invention. When the present invention is actually applied, the model structure can be adjusted according to actual needs, and the present invention does not limit this.

[0112] The method for detecting pig backfat thickness provided by the present invention uses a feature extraction model based on the traditional CNN model structure, and uses an adaptive global average pooling layer combined with a convolution layer using a 1×1 convolution kernel to replace a fully connected layer. The method can adapt to image input of any size and ensure that the top view of the pig is not deformed. The model reduces the number of parameters and the amount of calculation, effectively prevents overfitting, and can effectively improve the accuracy of backfat thickness detection and increase the speed of detection.

[0113] Optionally, according to the pig backfat thickness detection method provided by the present invention, the backfat thickness detection model is a support vector machine regression model whose kernel function is a Gaussian kernel function.

[0114] Specifically, Figure 7 This is a schematic diagram of the structure of the CNN-BGR-SVR backfat detection model provided by the present invention. Figure 8 The schematic diagram of the process of the pig backfat thickness detection method provided by the present invention is as follows: Figure 7 and Figure 8 As shown in the figure, the feature extraction model is a CNN model framework, and the backfat thickness detection model is a support vector machine regression model framework, which together constitute a CNN-BGR-SVR backfat detection model, that is, a pig backfat thickness detection model.

[0115] SVR (support vector regression) was proposed as an important application branch of SVM (Support Vector Machine). Different from traditional regression, the prediction is considered correct only when the predicted value is completely equal to the true value. By introducing the tolerance deviation ε to create an "interval band", when the absolute value of the difference between the predicted value and the true value is within the interval band, the prediction is considered correct and the loss is not calculated. The optimal model is found under the conditions of minimizing the loss and maximizing the interval. The optimization model is:

[0116]

[0117]

[0118] In the formula, x i is the input feature vector of the i-th sample, y i is the sample label value, ω is the normal vector of the segmentation hyperplane, b is the bias term, ω T φ(x i )+b is the linear hyperplane in high-dimensional space, ε is the insensitive loss factor, ξ i is the slack variable, C is the penalty factor.

[0119] For linearly inseparable data in the input space, it is necessary to introduce a kernel function to map low-dimensional data to a high-dimensional space, find a linearly separable hyperplane in the high-dimensional space, and transform the nonlinear problem into a linear problem. After introducing the kernel function, SVR can be rewritten as:

[0120]

[0121] In the formula, α i is the Lagrange multiplier, κ(x i ,x j ) is the kernel function.

[0122] The present invention selects Gaussian kernel function as the kernel function of SVR. Compared with linear kernel function, Gaussian kernel function can simulate better nonlinear effect; compared with polynomial kernel function, Gaussian kernel function has fewer parameters and can generally achieve the same or better accuracy as polynomial function.

[0123] The Gaussian kernel function is expressed as:

[0124]

[0125] Where σ is the width of the Gaussian kernel function.

[0126] The method for detecting pig back fat thickness provided by the present invention adopts a hybrid model of CNN and SVR as the final back fat thickness prediction model. The advantage of CNN lies in feature extraction, but the fully connected layer used for regression prediction in the traditional CNN model requires a large number of parameters. SVR, as a powerful machine learning model that has been proven to be suitable for regression prediction, has a small number of parameters but does not have the ability to extract features. The hybrid model combines the advantages of the two models to make up for their shortcomings. Compared with the method of simply using one model for detection, it can effectively improve the accuracy of model detection.

[0127] Optionally, the pig backfat thickness detection method provided by the present invention further includes: training a feature extraction model before inputting the target pig image and backfat growth rate characteristics of the pig to be detected into the pig backfat thickness detection model to determine the backfat thickness of the pig to be detected;

[0128] Train the feature extraction model, including:

[0129] The feature extraction model was trained using a sample pig image set;

[0130] Based on the target loss function, an adaptive moment estimation optimization algorithm is used to update the network parameters of the feature extraction model, and the feature extraction model is iteratively trained based on the updated network parameters until the feature extraction model converges; wherein the target loss function is a mean square error function.

[0131] Specifically, it can be understood that the CNN-BGR-SVR backfat detection model is taken as an example to illustrate the model training process of the present invention.

[0132] All samples are divided into training samples and test samples, and all samples are preprocessed. The training samples are used to train the model and adjust the model parameters; the test samples are used to test the effect of the final trained model. Figure 8 As shown in FIG. 1 , after determining the CNN-BGR-SVR model framework, the CNN-BGR-SVR model is trained using training samples.

[0133] The training samples are input into the CNN model for training, and the image features used to predict the back fat thickness of pigs are extracted. For example, in order to expand the richness of the training samples and enable the model to learn more image features, 90 frames of images of each pig sample are input into the CNN network, and finally the image features of each sample whose back fat prediction value is at the median of all back fat output values ​​are selected as the image features extracted by CNN for each sample.

[0134] The image features extracted by CNN and the backfat growth rate features (BGR) customized according to individual differences are combined as the input of the SVR model to train the SVR model. At this point, the training process of the CNN-BGR-SVR overall model is completed, and the trained CNN-BGR-SVR model is used to predict the test sample and output the final test sample backfat thickness prediction value.

[0135] When training the feature extraction model, the sample pig image set (training set) is used to train the feature extraction model; based on the target loss function, the adaptive momentum estimation (Adam) optimization algorithm with fast convergence speed and easy parameter adjustment is used to update the network parameters of the feature extraction model, and the feature extraction model is iteratively trained based on the updated network parameters until the feature extraction model converges; wherein the target loss function is the mean square error function.

[0136] It can be understood that the conditions for determining the model to stop iterative training (for example: the number of training times reaches a preset threshold, the verification set is used to determine that the verification result meets the preset conditions and the objective function meets the preset conditions, etc.) can be selected according to the actual situation. The present invention does not limit this.

[0137] It should be noted that the initial CNN model and the SVR model are both model frameworks. The hyperparameters required by the two models are optimized and determined by the Optuna hyperparameter search framework. Table 1 shows the hyperparameters that need to be searched for the model and the hyperparameter search range set by this method. The hyperparameter optimization algorithm uses the TPE (Tree-structured Parzen Estimator) optimization method.

[0138]

[0139] Table 1. Hyperparameter search range required for CNN and SVR models

[0140] This method uses an automatic hyperparameter optimization method based on Bayesian optimization. Different from the traditional grid search and random search hyperparameter search methods, Bayesian optimization determines the next hyperparameter combination to be trained by observing the training results of the selected hyperparameters. Each new experiment relies on the experience of the previous experiments, which can reduce the time and cost of model training and improve modeling efficiency.

[0141] It should be noted that the specific structure of the above model is only used as a specific example to assist in explaining the present invention. When the present invention is actually applied, the model structure can also be adjusted according to actual needs.

[0142] The method for detecting the back fat thickness of pigs provided by the present invention determines the back fat thickness of the pigs to be tested by collecting the back image of the pigs to be tested at a top-down angle, combining the back fat growth rate used to characterize the genetic characteristics of the back fat thickness of the pigs to be tested, and determining the back fat thickness of the pigs to be tested through the pig back fat thickness detection model. Using the top-down two-dimensional image as the detection basis can realize non-contact detection of back fat thickness, effectively avoid the pigs from having a stress reaction, and fully consider the genetic factors of the pigs' back fat thickness, reflecting the physical differences of individual pigs, effectively reducing the error of back fat thickness detection based on images, and improving the measurement accuracy.

[0143] In combination with specific experiments to verify the technical effect of the pig back fat thickness detection method provided by the present invention, a total of ten data sets were divided for evaluating the model effect, and the test mean and standard error of the ten test sets were used as the measurement standard for each model evaluation index.

[0144] The experiment is based on the windows 10 operating system, the programming language python 3.8.12, the experimental platform pycharm 2020.1.5, the development framework is pytorch 1.10.0, and the hardware environment is an Intel i9-10900F CPU @ 2.8GHz processor with 32GB of running memory and an NVIDIA GeForce RTX 2080Ti GPU with 11GB of video memory.

[0145] In order to verify the effectiveness of CNN's autonomous extraction of image features and the usefulness of the backfat growth rate defined in the present invention in establishing a pig backfat detection model, pig body shape characteristics (SHAPE) such as manually measured hip width, hip height, body length, and user-defined hip height-to-width ratio, body length-to-width ratio, and waist-to-hip ratio manually extracted from images were used as comparative input features of the model.

[0146] The stepwise regression method was used to select the input features of the SVR regression model, and five models were established, including a model with only image features (CNN-SVR), a model with only body shape features (SHAPE-SVR), body shape features and back fat growth rate (SHAPE-BGR-SVR), image features and body shape features (CNN-SHAPE-SVR), and image features plus body shape features and back fat growth rate (CNN-SHAPE-BGR-SVR).

[0147]

[0148]

[0149] Table 2 Test results of each feature combination model

[0150] The test results of each model are shown in Table 2. The results show that:

[0151] After comprehensive comparison of various feature combinations, the best results were obtained by selecting the image features extracted by CNN and the two BGR features as the input of the pig backfat detection model. In terms of predictive effectiveness, the MAE, RMSE, and MAPE of the CNN-BGR-SVR model were the smallest, which were 1.21 mm, 1.50 mm, and 7.57%, respectively. Compared with other models, MAE decreased by more than 6%, RMSE decreased by more than 2%, and MAPE decreased by more than 6%. In terms of model generalization, the determination coefficient R of CNN-BGR-SVR was 1.21 mm, 1.50 mm, and 7.57%, respectively. 2 It reaches 0.72, which is at least 2% higher than other models, with better fitting effect and generalization performance.

[0152] Comparing the CNN and SHAPE models, we can see that the pig backfat detection model established using CNN features has an overwhelming advantage in all evaluation indicators, including R 2 The R2 of the CNN-BGR-SVR model is improved by 900%, and the MAE, RMSE and MAPE values ​​are reduced by 43%. By comparing the CNN-BGR-SVR and SHAPE-BGR-SVR models, it can be seen that the R2 of the CNN-BGR-SVR model is improved by 929.6%, the MAE is reduced by 46.7%, the RMSE is reduced by 44.2%, and the MAPE is reduced by 46.5%. In addition, by comparing the CNN-SHAPE-SVR and SHAPE-SVR models, and the CNN-SHAPE-BGR-SVR and SHAPE-BGR-SVR models, it can be seen that adding CNN features to the input can improve the prediction accuracy and generalization ability of the model.

[0153] Comparing the CNN-SVR and CNN-BGR-SVR models, and the CNN-SHAPE-SVR and CNN-SHAPE-BGR-SVR models, we can see that the addition of backfat growth rate can improve the prediction accuracy and generalization ability of the model. Compared with the CNN-SVR model without adding this feature, the CNN-BGR-SVR model with backfat growth rate added on its basis has improved all evaluation indicators, among which R 2 The MAE increased by 2.9%, the RMSE decreased by 6.9%, the MAE decreased by 2.6%, and the MAPE decreased by 6.5%, which proved the effectiveness of the BGR feature in the modeling process; in addition, when the number of input features increased and the weight of the back fat growth rate feature decreased, the MAE and MAPE of the CNN-SHAPE-BGR-SVR model were reduced by 1.2% and 1.4% respectively compared with the CNN-SHAPE-SVR model.

[0154] In order to compare the prediction ability of different regression algorithms in detecting backfat thickness of pigs, the multivariable linear regression model (LR), ridge regression model (RR), random forest model (RF) and support vector regression model (SVR) were compared, and three backfat detection models based on CNN-BGR, namely LR, RR and RF, were established respectively.

[0155]

[0156] Table 3 Test results of each regression model

[0157] The test results of each model are shown in Table 3. The results show that: whether considering the prediction accuracy or the model generalization performance, using SVR as the final regression model can achieve the best effect. MAE, RMSE, and MAPE are 1.21mm, 1.50mm, and 7.57% respectively, which are at least reduced by 12%, 10%, and 12% compared with other models; R 2 The prediction accuracy and generalization ability of ridge regression are second to none. 2 The multiple linear regression model performed the worst.

[0158] In summary, the pig backfat thickness detection method based on two-dimensional images and backfat growth rate finally obtained R 2The mean is 0.72, the mean values ​​of MAE and RMSE are 1.21 mm and 1.50 mm respectively, and the MAPE is 7.57%, which has high accuracy and generalization ability, indicating that the CNN-BGR-SVR pig back fat detection model proposed in the present invention is capable of predicting pig back fat.

[0159] It should be noted that the verification method of the above-mentioned pig backfat thickness detection model is only for reflecting the effect of the backfat thickness detection method provided by the present invention, and is only used as a specific example to assist in explaining the present invention, and is not intended to limit the present invention.

[0160] Fig. 9 The schematic diagram of the pig backfat thickness detection system provided by the present invention is as follows: Fig. 9 As shown, the present invention also provides a pig backfat thickness detection system, comprising: a pig feature acquisition unit 901 and a pig backfat detection unit 902;

[0161] The pig feature acquisition unit 901 is used to acquire the target pig image and back fat growth rate characteristics of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; the back fat growth rate characteristics are used to represent the genetic characteristics of the pig's back fat thickness;

[0162] The pig backfat detection unit 902 is used to input the target pig image and backfat growth rate characteristics of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0163] Specifically, because the backfat thickness of pigs is affected by multiple factors such as genetics, nutrition and environment, the growth rate of backfat in different pigs is inconsistent. Backfat thickness of pigs is a medium-to-high heritability trait (h 2 =0.4~0.6), which can be stably inherited to the offspring, resulting in the difference of "easy to get fat or thin" physique of pigs. The prior art method for measuring backfat thickness of pigs does not take into account the difference of "easy to get fat or thin" physique of individuals, has certain limitations, and affects the detection accuracy of backfat thickness. Therefore, the present invention introduces the backfat growth rate (BGR) feature to indicate the genetic characteristics of pig backfat thickness.

[0164] The pig feature acquisition unit 901 is used to collect the back image of the pig to be tested at a top-down angle as the target pig image, and determine the back mark growth rate characteristics of the pig to be tested.

[0165] It is understandable that the back fat growth rate characteristic represents the influence of pig genetic factors on pig back fat growth, including all characteristics that can characterize the influence of genetics and genes on individual back fat changes, but not limited to back fat growth rate, genes that affect pig back fat changes or all genes of an individual, genes that affect individual paternal or maternal back fat changes, and the law of individual paternal and maternal back fat changes, etc. In the actual application of the present invention, the specific expression form of the back fat growth rate characteristic can be selected according to actual needs, and the present invention does not limit this.

[0166] The pig backfat detection unit 902 is used to input the target pig image and backfat growth rate characteristics of the pig to be tested obtained by the pig feature acquisition unit 901 into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested.

[0167] It is understandable that before performing backfat thickness detection based on the trained pig backfat thickness detection model, the pig backfat thickness detection model needs to be trained based on the sample pig image set and the sample backfat growth rate feature set. The specific neural network model structure and the neural network training method can be selected according to actual needs, and the present invention is not limited to this.

[0168] The pig backfat thickness detection system provided by the present invention determines the backfat thickness of the pig to be tested by collecting the back image of the pig under the top view angle, combining the backfat growth rate used to characterize the genetic characteristics of the backfat thickness of the pig to be tested, and determining the backfat thickness of the pig to be tested through the pig backfat thickness detection model. Using the top view two-dimensional image as the detection basis can realize non-contact detection of backfat thickness, effectively avoid the pig from having a stress reaction, and fully consider the genetic factors of the pig backfat thickness, reflect the physical differences of individual pigs, effectively reduce the error of backfat thickness detection based on the image, and improve the measurement accuracy.

[0169] It should be noted that the pig backfat thickness detection system provided by the present invention is used to execute the above-mentioned pig backfat thickness detection method, and its specific implementation method is consistent with the method implementation method, which will not be repeated here.

[0170] Fig.10 A schematic diagram of the physical structure of the electronic device provided by the present invention, such as Fig.10As shown, the electronic device may include: a processor 101, a communication interface 102, a memory 103 and a communication bus 104, wherein the processor 101, the communication interface 102 and the memory 103 communicate with each other through the communication bus 104. The processor 101 may call the logic instructions in the memory 103 to execute the pig back fat thickness detection method, which includes: obtaining a target pig image and a back fat growth rate feature of the pig to be detected; wherein the pig image is a back image of the pig at a top-down angle; the back fat growth rate feature is used to represent the genetic characteristics of the pig back fat thickness; the target pig image and the back fat growth rate feature of the pig to be detected are input into the pig back fat thickness detection model to determine the back fat thickness of the pig to be detected.

[0171] In addition, the logic instructions in the above-mentioned memory 103 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk.

[0172] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the pig back fat thickness detection method provided by the above methods, and the method includes: obtaining a target pig image and back fat growth rate characteristics of the pig to be tested; wherein the pig image is an image of the pig's back from a top-down angle; the back fat growth rate characteristics are used to represent the genetic characteristics of the pig's back fat thickness; the target pig image and back fat growth rate characteristics of the pig to be tested are input into a pig back fat thickness detection model to determine the back fat thickness of the pig to be tested.

[0173] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned pig back fat thickness detection method, the method comprising: obtaining a target pig image and back fat growth rate characteristics of the pig to be tested; wherein the pig image is an image of the pig's back from a top-down angle; the back fat growth rate characteristics are used to represent the genetic characteristics of the pig's back fat thickness; the target pig image and back fat growth rate characteristics of the pig to be tested are input into a pig back fat thickness detection model to determine the back fat thickness of the pig to be tested.

[0174] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0175] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting pig backfat thickness, characterized in that: include: Obtaining a target pig image and backfat growth rate characteristics of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; and the backfat growth rate characteristics are used to represent the genetic characteristics of the pig's backfat thickness; Inputting the target pig image and backfat growth rate characteristics of the pig to be tested into a pig backfat thickness detection model to determine the backfat thickness of the pig to be tested; The pig backfat thickness detection model includes: a feature extraction model and a backfat thickness detection model; the feature extraction model includes: a feature extraction layer and a feature dimension reduction layer, the feature extraction layer includes a plurality of stacked units connected in series, the stacked unit includes two convolutional layers connected in series and a maximum pooling layer, the feature dimension reduction layer includes an adaptive average pooling layer and a 1×1 convolutional layer; the backfat thickness detection model is a support vector machine regression model whose kernel function is a Gaussian kernel function; The step of inputting the target pig image and the backfat growth rate characteristics of the pig to be tested into a pig backfat thickness detection model to determine the backfat thickness of the pig to be tested specifically includes: Input the target pig image into the first stacking unit of the feature extraction model, use the output of each stacking unit as the input of the next stacking unit, extract features from the input image through two series-connected convolutional layers in each stacking unit, and perform data dimensionality reduction processing through a maximum pooling layer to obtain an initial feature map output by the last stacking unit; Inputting the initial feature map into the feature dimension reduction layer, performing data dimension reduction processing on the initial feature map through an adaptive average pooling layer and performing feature extraction through a 1×1 convolution layer to determine a target feature vector; The target feature vector and the backfat growth rate feature of the pig to be tested are input into a backfat thickness detection model to determine the backfat thickness of the pig to be tested.

2. The method for detecting pig backfat thickness according to claim 1, characterized in that: The step of obtaining the target pig image and backfat growth rate characteristics of the pig to be tested specifically includes: Raising the pigs to be tested based on preset feeding conditions; Measuring the backfat value of the pig to be tested according to a preset period; The difference between the back fat value of the pig to be tested within the preset period and the divisor of the preset period is calculated, and the divisor is used as the back fat growth rate characteristic of the pig to be tested.

3. The method for detecting pig backfat thickness according to claim 1, characterized in that: Before the step of inputting the target pig image and backfat growth rate feature of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested, the method further includes: training the feature extraction model; The training of the feature extraction model specifically includes: Training the feature extraction model using a sample pig image set; Based on the target loss function, an adaptive moment estimation optimization algorithm is used to update the network parameters of the feature extraction model, and the feature extraction model is iteratively trained based on the updated network parameters until the feature extraction model converges; wherein the target loss function is a mean square error function.

4. A pig backfat thickness detection system, characterized in that: include: Pig feature acquisition unit and pig backfat detection unit; The pig feature acquisition unit is used to acquire a target pig image and a back fat growth rate feature of the pig to be tested; wherein the pig image is a back image of the pig from a top-down angle; and the back fat growth rate feature is used to represent the genetic characteristics of the pig's back fat thickness; The pig backfat detection unit is used to input the target pig image and backfat growth rate characteristics of the pig to be tested into the pig backfat thickness detection model to determine the backfat thickness of the pig to be tested; The pig backfat thickness detection model includes: a feature extraction model and a backfat thickness detection model; the feature extraction model includes: a feature extraction layer and a feature dimension reduction layer, the feature extraction layer includes a plurality of stacked units connected in series, the stacked unit includes two convolutional layers connected in series and a maximum pooling layer, the feature dimension reduction layer includes an adaptive average pooling layer and a 1×1 convolutional layer; the backfat thickness detection model is a support vector machine regression model whose kernel function is a Gaussian kernel function; The step of inputting the target pig image and the backfat growth rate characteristics of the pig to be tested into a pig backfat thickness detection model to determine the backfat thickness of the pig to be tested specifically includes: Input the target pig image into the first stacking unit of the feature extraction model, use the output of each stacking unit as the input of the next stacking unit, extract features from the input image through two series-connected convolutional layers in each stacking unit, and perform data dimensionality reduction processing through a maximum pooling layer to obtain an initial feature map output by the last stacking unit; Inputting the initial feature map into the feature dimension reduction layer, performing data dimension reduction processing on the initial feature map through an adaptive average pooling layer and performing feature extraction through a 1×1 convolution layer to determine a target feature vector; The target feature vector and the backfat growth rate feature of the pig to be tested are input into a backfat thickness detection model to determine the backfat thickness of the pig to be tested.

5. An electronic device, characterized in that: It comprises a memory and a processor, wherein the processor and the memory communicate with each other via a bus; the memory stores program instructions executable by the processor, and the processor calls the program instructions to execute the pig back fat thickness detection method as described in any one of claims 1 to 3.

6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting pig backfat thickness as described in any one of claims 1 to 3 is implemented.