Livestock weight detection method and device, electronic equipment and storage medium

The livestock weight detection method based on multi-scale feature separation and aggregation solves the problems of high cost and complexity of traditional detection methods, and realizes low-cost, fast and accurate livestock weight detection, which is applicable to livestock in various environments and species.

CN119027400APending Publication Date: 2024-11-26SHANGHAI IFLYTEK HEGUANG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411138773.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

Traditional methods for measuring livestock weight are costly, complex to operate, and limited in application scenarios, making it difficult to meet the needs of refined management in animal husbandry.

Method used

By using multi-scale feature separation and feature aggregation based on livestock images, low-frequency basic information and high-frequency detail information are extracted. Weight detection is then performed using high- and low-frequency aggregated features, employing low-cost computer vision technology.

Benefits of technology

It enables rapid and accurate livestock weight detection, improves detection precision and stability, is applicable to livestock in different environments and of different species, reduces hardware costs, and avoids stress reactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027400A_ABST
    Figure CN119027400A_ABST
Patent Text Reader

Abstract

The invention provides a livestock weight detection method and apparatus, an electronic device and a storage medium. The method comprises the steps of determining a livestock image of a to-be-detected livestock; performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; according to the method, feature aggregation is carried out based on the multi-scale low-frequency features and the multi-scale high-frequency features, weight detection is carried out based on the high-low-frequency aggregation features obtained through feature aggregation, the weight of the to-be-detected livestock is obtained, the problems that in a traditional scheme, livestock weight detection is high in cost, complex in operation, limited in application scene and the like are solved, and the detection accuracy is improved. The livestock weight detection device realizes rapid and accurate livestock weight detection, effectively improves the precision and stability of weight detection, can be suitable for various breeding environments and various types and sizes of livestock, is low in cost and simple and convenient to operate, does not cause stress reaction to the livestock, avoids adverse effects on the growth of the livestock, and is suitable for popularization and application. And powerful support is provided for fine management of animal husbandry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a livestock weight detection method, device, electronic equipment and storage medium. Background Art

[0002] In animal husbandry, livestock weight detection is an indispensable part of breeding management. Accurate weight data is crucial for optimizing feeding strategies and monitoring health status. However, traditional weight detection methods, such as manual guidance to weighing scales or relying on visual estimation by breeders, have many drawbacks and are difficult to meet the refined management needs of the breeding industry.

[0003] With the development of computer vision and artificial intelligence technology, non-contact and automated detection methods have gradually become a research hotspot. These methods have achieved the detection of livestock weight through sensor technology, image processing technology, and machine learning algorithms. However, although these emerging technologies have shown great potential, there are still problems in practical applications such as high hardware costs, restrictions on breeding environments, and complex data processing, which need to be further optimized and improved. Summary of the invention

[0004] The present invention provides a livestock weight detection method, device, electronic device and storage medium, which are used to solve the problems of high cost, complicated process and limited application scenarios in the livestock weight detection method in the prior art, realize fast and accurate livestock weight detection, effectively improve the accuracy and stability of weight detection, can be applied to different environments, and have low cost and easy operation, providing strong support for the refined management of animal husbandry.

[0005] The present invention provides a livestock weight detection method, comprising: determining a livestock image of the livestock to be inspected; Performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; Feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected.

[0006] According to a livestock weight detection method provided by the present invention, the feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features includes: Performing multi-scale feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features to obtain low-frequency aggregated features and high-frequency aggregated features; High and low frequency features are aggregated based on the low frequency aggregation features and the high frequency aggregation features to obtain high and low frequency aggregation features.

[0007] According to a livestock weight detection method provided by the present invention, the high- and low-frequency features are aggregated based on the low-frequency aggregate features and the high-frequency aggregate features to obtain the high- and low-frequency aggregate features, including: Performing deep feature extraction on the low-frequency aggregated features and the high-frequency aggregated features respectively to obtain low-frequency deep features and high-frequency deep features; High and low frequency features are aggregated based on the low frequency deep features and the high frequency deep features to obtain high and low frequency aggregated features.

[0008] According to a livestock weight detection method provided by the present invention, the weight detection is performed based on high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected, including: Determining weighted image features based on the high and low frequency aggregate features and the livestock image; determining enhanced image features based on the weighted image features and the livestock image; Deep feature extraction is performed based on the enhanced image features, and weight detection is performed based on the deep image features obtained by the deep feature extraction to obtain the weight of the livestock to be detected.

[0009] According to a livestock weight detection method provided by the present invention, the multi-scale feature separation is performed based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, including: Performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features; the multi-scale feature separation includes multi-scale average pooling and upsampling; Based on the multi-scale low-frequency features and the livestock image, multi-scale high-frequency features are determined.

[0010] According to a livestock weight detection method provided by the present invention, the step of determining the livestock image of the livestock to be detected includes: Acquire a group image of livestock to be detected; Extracting a single livestock binary image based on the group image to obtain a livestock binary image; Based on the livestock binary image and the group image, a livestock image of the livestock to be detected is determined.

[0011] According to a livestock weight detection method provided by the present invention, multi-scale feature separation is performed based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected, including: Based on the livestock weight detection network, multi-scale feature separation is performed on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected; Wherein, the livestock weight detection network is trained based on the difference between the predicted weight and the sample weight of the sample livestock, and / or the similarity between the sample livestock image and the predicted livestock image of the sample livestock; the predicted weight and the predicted livestock image are determined by the livestock weight detection network during the training process based on the input sample livestock image.

[0012] The present invention also provides a livestock weight detection device, comprising: an image determination unit, for determining an animal image of the animal to be detected; The weight detection unit is used to perform multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; perform feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and perform weight detection based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected.

[0013] 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 livestock weight detection method as described above is implemented.

[0014] 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 livestock weight detection method as described in any one of the above is implemented.

[0015] The livestock weight detection method, device, electronic device and storage medium provided by the present invention obtain multi-scale low-frequency features and multi-scale high-frequency features through livestock image extraction to obtain rich and stable livestock information, then perform feature aggregation based on the multi-scale low-frequency features and multi-scale high-frequency features, and use the high- and low-frequency aggregated features obtained by feature aggregation to perform weight detection to obtain the weight of the livestock to be detected, thereby overcoming the problems of high cost, complex operation, and limited application scenarios of livestock weight detection in traditional solutions, achieving fast and accurate livestock weight detection, effectively improving the accuracy and stability of weight detection, being applicable to livestock of various breeding environments, categories, and sizes, and having low cost and easy operation, without causing stress response to livestock, thus avoiding adverse effects on their growth, and providing strong support for the refined management of animal husbandry. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to 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 any creative work.

[0017] Figure 1 It is a schematic flow chart of the livestock weight detection method provided by the present invention; Figure 2 is a schematic diagram of a multi-scale feature separation result provided by the present invention; Figure 3 is a schematic diagram of the multi-scale feature aggregation process provided by the present invention; Figure 4 is a schematic diagram of a weight detection process provided by the present invention; Figure 5 is a schematic diagram of the multi-scale feature separation process provided by the present invention; Figure 6 is a schematic diagram of a group image and a livestock image provided by the present invention; Figure 7 It is a schematic diagram of the framework of the network training process provided by the present invention; Figure 8 is a schematic diagram of the feature decoding process provided by the present invention; Fig. 9 It is a structural schematic diagram of the livestock weight detection device provided by the present invention; Fig.10 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0018] 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.

[0019] In animal husbandry, accurate livestock weight helps optimize feeding strategies, monitor animal health, and improve economic benefits. However, traditional livestock weight detection, such as manual guidance to weighing on a scale or relying on visual estimation by livestock farmers, has many disadvantages. The former is not only cumbersome and inefficient, but also easily causes unnecessary stress reactions to livestock, affecting their growth and welfare; the latter is highly subjective and inaccurate, making it difficult to meet the requirements of modern livestock farming for refined management.

[0020] However, with the rapid development of computer vision and artificial intelligence technology, non-contact, automated livestock weight detection has gradually become a research hotspot. These methods use sensor technology, image processing technology, and machine learning algorithms to detect livestock weight. For example, using a single or multiple cameras to capture livestock images, combining image processing technology to extract livestock contours and morphological features, and then using a trained machine learning model to estimate weight, not only improves detection efficiency, but also reduces manual intervention and errors.

[0021] In addition, the introduction of depth cameras, LiDAR and infrared cameras has further broadened the methods of weight detection. Depth cameras can obtain three-dimensional information of livestock, providing more detailed data support for weight estimation; LiDAR can generate three-dimensional point cloud data to accurately calculate the volume of livestock, thereby indirectly estimating their weight; infrared cameras have unique advantages at night or in low-light environments, making all-weather detection possible.

[0022] However, despite the great potential these technologies have shown, they still face some challenges in practical applications. For example, although depth cameras and lidar methods can achieve weight detection, they are expensive and complex to operate. At the same time, they are limited by the farming environment and have poor feasibility in practical applications. Although infrared cameras work better at night or in low-light environments, the resolution and accuracy of infrared imaging are low, and the accuracy of the detection results is worrying.

[0023] In this regard, the present invention provides a livestock weight detection method, which aims to use livestock images to extract low-frequency basic information and high-frequency detail information of different scales to obtain rich and stable feature data; based on this, feature aggregation is performed, and high- and low-frequency aggregated features obtained by feature aggregation are used to perform weight detection, so as to obtain the weight of the livestock to be detected, thereby achieving fast and accurate weight detection, and effectively improving the accuracy and stability of livestock weight detection. At the same time, since the detection process does not require additional hardware facilities, the cost is lower. In addition, it can also be applicable to different breeding environments, livestock of different types and sizes, which is more practical, and the detection process will not cause stress response to the livestock, avoiding adverse effects on their growth. Figure 1 Schematic diagram of the livestock weight detection method provided by the present invention. Figure 1 As shown, the method includes: Step 110, determining a livestock image of the livestock to be detected; Step 120: performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and performing weight detection based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected.

[0024] Specifically, taking into account the current detection methods that rely on manual labor, as well as the problems of non-contact, automated detection methods such as high cost, cumbersome operation, low efficiency, limitations on the breeding environment, and complex data processing processes, in an embodiment of the present invention, a livestock weight detection method with low cost, simple operation, strong adaptability and high accuracy is proposed. By taking into account both the low-frequency basic information and the high-frequency detail information in the image, the accuracy and stability of weight detection are effectively improved, providing support for the intelligent and automated management of animal husbandry.

[0025] It is understandable that in the actual livestock weight detection process, when using computer vision technology to detect livestock weight, the first thing that needs to be determined is the image of the livestock to be detected, that is, the image of the livestock to be detected. Since livestock in animal husbandry are mostly raised in groups or in collective enclosures, the images directly collected by the image acquisition equipment installed around the farm, breeding circle, breeding fence, etc. are mostly group images, which often contain multiple livestock. At this time, if the weight detection is directly based on this, it is not only not targeted, but also easy to confuse feature information during the detection process, resulting in inaccurate detection results and reduced detection accuracy. Therefore, after directly acquiring the image of the group, in the embodiment of the present invention, it can also be further processed to obtain an image containing only a single livestock to be detected, that is, a livestock image of the livestock to be detected.

[0026] Here, the livestock image may be one or more images, and each livestock image contains only one livestock to be detected. It should be noted that the livestock image may be an image of a single livestock separated from a group image directly acquired through an installed image acquisition device such as a camera, etc., or may be an image containing only a single livestock to be detected directly acquired through other methods such as website search, crawler crawling, network reception, etc., or an image containing only a single livestock to be detected obtained through further processing based on the image acquired in such a way, and the embodiment of the present invention does not make specific limitations. The livestock to be detected may be pigs, cattle, sheep, etc.

[0027] After obtaining the livestock image of the livestock to be detected, in an embodiment of the present invention, weight detection can be performed based on the livestock image to obtain the weight of the livestock to be detected. Specifically, multi-scale information can be obtained by extracting livestock images, such as low-frequency basic information, high-frequency detail information, etc., so as to fully reflect the characteristics of the livestock to be detected from multiple angles through multi-scale information, so as to detect its weight more accurately, that is, feature extraction can be performed based on the livestock image to obtain high-frequency and low-frequency components of different scales of the image. This process can also be understood as multi-scale feature separation of livestock images to separate information of different scales therefrom, thereby obtaining features at different scales.

[0028] Each scale contains low-frequency features (basic features) and corresponding high-frequency features (detailed features). Low-frequency features contain basic information of the image, while high-frequency features contain detailed information of the image. Figure 2 is a schematic diagram of the multi-scale feature separation result provided by the present invention, such as Figure 2 As shown in the figure, by performing multi-scale feature separation (×2, ×4 and ×8) on the livestock images of the livestock (pigs) to be detected, the basic information and detail information at scales of 2, 4 and 8 can be obtained. Based on this multi-scale and frequency dimension information, the characteristics of the livestock (pigs) to be detected can be relatively complete and comprehensive, thereby ensuring the accuracy of subsequent livestock weight detection.

[0029] Furthermore, after obtaining multi-scale low-frequency features and multi-scale high-frequency features, in an embodiment of the present invention, multi-scale feature aggregation can be performed to obtain aggregated features. Since the objects of feature aggregation here include both low-frequency features and high-frequency features, the aggregated features can not only highlight the important characteristics of the low-frequency features and the high-frequency features, but also reflect the relationship between the low-frequency features and the high-frequency features. Therefore, it can be called a high-low frequency aggregated feature. That is, by performing feature aggregation on the multi-scale low-frequency features and the multi-scale high-frequency features obtained by multi-scale feature separation, a high-low frequency aggregated feature can be obtained.

[0030] Specifically, the feature aggregation process here can be to aggregate the low-frequency features and high-frequency features at each scale, and then aggregate the aggregated multi-scale features again; it can also be to first aggregate the multi-scale low-frequency features, and aggregate the multi-scale high-frequency features, and then aggregate the aggregated low-frequency features and high-frequency features obtained in the previous step again; it can also be to directly aggregate all low-frequency features and high-frequency features once to obtain the aggregated high and low-frequency features, which is not specifically limited in the embodiments of the present invention.

[0031] After that, weight detection can be performed based on the high and low frequency features, so as to estimate the weight of the livestock to be detected through the information of the livestock to be detected reflected by the high and low frequency features, thereby obtaining the weight of the livestock to be detected. Here, weight detection based on high and low frequency aggregate features can be achieved through regression, that is, weight regression can be performed on the basis of high and low frequency aggregate features, so as to convert the features into weight through convolution, batch normalization, activation and other processing, thereby obtaining the weight of the livestock to be detected.

[0032] The livestock weight detection method provided by the present invention obtains multi-scale low-frequency features and multi-scale high-frequency features through livestock image extraction to obtain rich and stable livestock information, then performs feature aggregation based on the multi-scale low-frequency features and multi-scale high-frequency features, and uses the high- and low-frequency aggregated features obtained by feature aggregation to perform weight detection to obtain the weight of the livestock to be detected, thereby overcoming the problems of high cost, complex operation, and limited application scenarios of livestock weight detection in traditional solutions, achieving fast and accurate livestock weight detection, effectively improving the accuracy and stability of weight detection, being applicable to livestock of various breeding environments, categories, and sizes, and having low cost and easy operation, without causing stress response to livestock, thus avoiding adverse effects on their growth, and providing strong support for the refined management of animal husbandry.

[0033] Based on the above embodiment, in step 120, feature aggregation is performed based on multi-scale low-frequency features and multi-scale high-frequency features, including: Based on the multi-scale low-frequency features and the multi-scale high-frequency features, multi-scale feature aggregation is performed to obtain low-frequency aggregation features and high-frequency aggregation features; High and low frequency features are aggregated based on low frequency aggregate features and high frequency aggregate features to obtain high and low frequency aggregate features.

[0034] Specifically, in step 120, the process of performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features may specifically include: First, multi-scale feature aggregation can be performed on multi-scale low-frequency features and multi-scale high-frequency features to obtain aggregated low-frequency features and high-frequency features, i.e., low-frequency aggregate features and high-frequency aggregate features. The feature aggregation here is actually to aggregate the features in the same frequency dimension obtained by multi-scale feature separation to obtain the features of the features in the same frequency dimension after aggregation, specifically, to aggregate the low-frequency features of different scales obtained by separation to obtain low-frequency aggregate features, and to aggregate the high-frequency features of different scales obtained by separation to obtain high-frequency aggregate features.

[0035] Figure 3 is a schematic diagram of the multi-scale feature aggregation process provided by the present invention, such as Figure 3As shown, for each input (input 1, input 2, and input 3), the high-frequency features of the input first pass through two convolution modules ( Figure 3 ×2) for processing, and then concatenating C (Concat), where each convolution module includes basic convolution Conv (Convolution), batch normalization Norm (Normal) and GELU (Gaussian Error Linear Units) activation. After concatenation, the concatenated high-frequency features can be subjected to channel dimension reduction through a convolution layer with a convolution kernel of 1*1 to reduce the number of channels so that the final output channel number is consistent with a single input, thereby obtaining high-frequency aggregate features. Similarly, for each low-frequency feature of the input, it is first processed through two convolution modules and then concatenated. After that, the concatenated low-frequency features are subjected to channel dimension reduction to obtain low-frequency aggregate features.

[0036] Subsequently, the low-frequency aggregated features and high-frequency aggregated features obtained by multi-scale feature aggregation can be aggregated again to aggregate the low-frequency aggregated features and high-frequency aggregated features, thereby obtaining high-low-frequency aggregated features. Here, the high-frequency aggregated features and low-frequency aggregated features obtained in the previous step are actually aggregated again, that is, high-low-frequency feature aggregation is performed, thereby obtaining high-low-frequency aggregated features that can reflect the important characteristics of the high-frequency features and low-frequency features, and can reflect the relationship between the low-frequency features and the high-frequency features.

[0037] Here, the process of high- and low-frequency feature aggregation can be to first process the input high-frequency aggregated features through two convolution modules, and at the same time, process the input low-frequency aggregated features through two convolution modules; wherein each convolution module includes Conv, Norm and GELU activation. Then, the high-frequency aggregated features and low-frequency aggregated features output after the convolution module processing are spliced, and the channel dimension reduction is performed on the spliced ​​features to reduce the number of channels so that the final output channel number is consistent with the single input, thereby obtaining high- and low-frequency aggregated features.

[0038] Based on the above embodiment, high- and low-frequency features are aggregated based on low-frequency aggregate features and high-frequency aggregate features to obtain high- and low-frequency aggregate features, including: Perform deep feature extraction on low-frequency aggregate features and high-frequency aggregate features respectively to obtain low-frequency deep features and high-frequency deep features; High and low frequency features are aggregated based on low frequency deep features and high frequency deep features to obtain high and low frequency aggregated features.

[0039] Specifically, the process of aggregating high and low frequency features according to low frequency aggregation features and high frequency aggregation features to obtain high and low frequency aggregation features may specifically include: First, deep feature extraction can be performed on low-frequency aggregate features and high-frequency aggregate features respectively to encode deeper information in the low-frequency aggregate features and high-frequency aggregate features, thereby obtaining low-frequency deep features and high-frequency deep features; that is, deep encoding is performed on low-frequency aggregate features and high-frequency aggregate features to encode useful information related to the livestock to be detected and beneficial to livestock weight detection, and deep feature extraction of high- and low-frequency aggregate features is achieved by enhancing useful information and cross-channel information interaction, thereby obtaining low-frequency deep features and high-frequency deep features.

[0040] Here, the process of deep feature extraction for low-frequency aggregate features and high-frequency aggregate features can be implemented through a relatively efficient basic convolution module, or through VGG (Visual Geometry Group), ResNet (ResidualNetwork), Transformer high-performance encoding modules, etc., or through other modules with deep feature extraction functions, which are not specifically limited in the embodiments of the present invention. Preferably, in the embodiments of the present invention, the high-performance Transformer Block in Restormer is selected to realize the deep feature extraction of low-frequency aggregate features and high-frequency aggregate features. Among them, the Transformer Block is composed of a gated deep convolution feedforward network GDFN (Gated-Dconv Feed-ForwardNetwork) and a multi-deconvolution head transposed attention MDTA (Multi-Dconv Head Transposed Attention), wherein GDFN can control the useful information in the enhanced features, and MDTA realizes the cross-channel interactive information of the features.

[0041] Then, the low-frequency deep features and high-frequency deep features obtained by deep feature extraction can be aggregated to obtain high- and low-frequency aggregated features. Here, the process of high- and low-frequency feature aggregation can be achieved through a feature aggregation network. The structure of this feature aggregation network is similar to Figure 3 The network structure used in the multi-scale feature aggregation process shown in the figure is basically the same, only the input is different. The feature aggregation network here has only two input branches, corresponding to the low-frequency deep features and the high-frequency deep features respectively. For each input, it is first processed by two convolution modules, where each convolution module includes Conv, Norm and GELU activation; then the low-frequency deep features and high-frequency deep features output by the convolution module are spliced, and the channel dimension reduction is performed on the spliced ​​features to reduce the number of channels so that the final output channel number is consistent with the single input, thereby obtaining high- and low-frequency aggregation features.

[0042] Based on the above embodiment, in step 120, weight detection is performed based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected, including: Determining weighted image features based on high and low frequency aggregate features and livestock images; Determining enhanced image features based on the weighted image features and the livestock image; Deep feature extraction is performed based on the enhanced image features, and weight detection is performed based on the deep image features obtained by the deep feature extraction to obtain the weight of the livestock to be detected.

[0043] Specifically, in step 120, the process of performing weight detection according to the high-frequency and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected may specifically include: In order to further enhance the useful information in the livestock images and suppress irrelevant information to avoid affecting the weight detection process, in an embodiment of the present invention, an attention gating mechanism can also be introduced to convert high- and low-frequency aggregate features into attention weights through the attention gating mechanism, and use the weights to suppress irrelevant information in the livestock images while enhancing useful information.

[0044] Specifically, first, the weighted image features can be determined by high- and low-frequency aggregate features and livestock images; that is, the high- and low-frequency aggregate features are combined on the basis of the livestock images to obtain the weighted components of the attention weights of the livestock images, thereby obtaining the weighted image features. Next, the livestock images can be enhanced based on the weighted image features to enhance the useful information therein, thereby obtaining enhanced image features; here, in fact, based on the weighted components of the attention weights obtained in the previous step, the weighted components are added to the livestock images to enhance the livestock images, thereby obtaining the enhanced overall features, namely, the enhanced image features.

[0045] Among them, the enhanced image features can be determined by the following formula:

[0046] In the formula, To enhance image features, For livestock images, It is a high-low frequency aggregation feature. represents the Sigmoid activation function, Indicates that the convolution kernel is 1*1 convolution.

[0047] After that, the enhanced image features can be used to perform weight detection to obtain the weight of the livestock to be detected. Specifically, the enhanced image features can be firstly subjected to deep feature extraction to encode deeper information therein, thereby obtaining deep image features. The deep feature extraction process here can also be implemented using Transformer Block, that is, the enhanced image features can be deeply encoded through this module to obtain the overall deep features, namely, deep image features. Then, weight detection can be performed based on the deep image features obtained by deep encoding, so as to predict the weight of the livestock to be detected by weight regression.

[0048] Figure 4 is a schematic diagram of the weight detection process provided by the present invention, such as Figure 4 As shown in the figure, the input deep image features can be processed in sequence through a convolution Conv, batch normalization Norm, GELU activation, adaptive average pooling AvgPool (Average Pooling), and a second convolution Conv, and finally the weight output, that is, the weight of the livestock to be tested, can be obtained. Among them, the input and output channels of the first convolution are the same, the convolution kernel size is 1*1, and the number of output channels is 1.

[0049] In the embodiment of the present invention, the livestock images are adaptively enhanced using the attention gate, which can effectively enhance the useful information therein and suppress irrelevant information, so that in the subsequent weight regression, not only can more attention be paid to the valuable information, but irrelevant information can be ignored, thereby improving the accuracy and stability of weight detection, and can be applied to livestock in different environments, different scales and different types, and has good feasibility and universality.

[0050] Based on the above embodiment, in step 120, multi-scale feature separation is performed based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, including: Multi-scale feature separation is performed based on livestock images to obtain multi-scale low-frequency features; multi-scale feature separation includes multi-scale average pooling and upsampling; Based on the multi-scale low-frequency features and livestock images, multi-scale high-frequency features are determined.

[0051] Specifically, in step 120, the process of performing multi-scale feature separation according to the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features may specifically include the following steps: First, livestock images can be used for multi-scale feature separation to obtain multi-scale low-frequency features; that is, multi-scale high- and low-frequency features are obtained by separating livestock images of the livestock to be detected. Here, the multi-scale feature separation process can be achieved through multi-scale average pooling and upsampling.

[0052] Figure 5 is a schematic diagram of the multi-scale feature separation process provided by the present invention, such as Figure 5 As shown in FIG. 1 , for the input livestock image, multi-scale average pooling and upsampling can be performed to obtain the low-frequency basic information of the livestock image at different scales, thereby obtaining multi-scale low-frequency features. Here, the process of determining the low-frequency features can be expressed as:

[0053] In the formula, is a low frequency feature, for livestock images; is the scale factor, which defaults to 2, 4, and 8, representing feature extraction at scales of 2, 4, and 8, respectively; is average pooling; For upsampling, bilinear interpolation is used for upsampling in the embodiment of the present invention.

[0054] Then, the corresponding high-frequency features can be determined based on the multi-scale low-frequency features obtained in the previous step, that is, the multi-scale high-frequency features can be obtained based on the multi-scale low-frequency features combined with the livestock images. Here, the difference method can be used to subtract the livestock images from the low-frequency features to obtain high-frequency detail information, thereby obtaining multi-scale high-frequency features. Here, the process of determining the high-frequency features can be expressed as:

[0055] In the formula, It is a high-frequency feature, which can be obtained by differentiating the livestock image and the low-frequency feature.

[0056] Based on the above embodiment, step 110 includes: Acquire a group image of livestock to be detected; Extracting a single livestock binary image based on the group image to obtain a livestock binary image; Based on the livestock binary image and the group image, a livestock image of the livestock to be detected is determined.

[0057] Specifically, in step 110, the process of determining the livestock image of the livestock to be detected may include: First, a group image of livestock can be obtained, that is, an image containing multiple livestock to be detected or a group of livestock to be detected, which is referred to as a group image of livestock to be detected. The group image can be directly acquired by an image acquisition device set around a breeding farm, breeding pen, breeding pen, etc. of the livestock to be detected, or can be obtained by other means, which is not specifically limited in the embodiment of the present invention.

[0058] Next, a single livestock mask can be extracted from the group image to obtain a binary image of a single livestock, that is, a livestock binary image; here, specifically, a pre-trained livestock image segmentation network can be used to perform image segmentation on the group image to extract a binary image of a single livestock.

[0059] Subsequently, the livestock binary image and the group image can be used to determine the livestock image of the livestock to be detected. That is, based on the livestock binary image, the livestock image of the livestock to be detected can be obtained by segmenting the group image.

[0060] Figure 6 is a schematic diagram of a group image and a livestock image provided by the present invention, such as Figure 6 As shown in the figure, after obtaining the group image, the YOLOv8 (You Only Look Once version 8) segmentation network can be used to extract the mask of a single livestock to obtain a livestock binary image, and then the obtained livestock binary image is multiplied with the livestock image to obtain the livestock image of the single livestock to be detected.

[0061] Based on the above embodiment, step 120 includes: Based on the livestock weight detection network, multi-scale feature separation is performed on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, feature aggregation is performed based on the multi-scale low-frequency features and multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected; The livestock weight detection network is trained based on the difference between the predicted weight and the sample weight of the sample livestock, and / or the similarity between the sample livestock image and the predicted livestock image of the sample livestock; the predicted weight and the predicted livestock image are determined by the livestock weight detection network during the training process based on the input sample livestock image.

[0062] Specifically, in step 120, the process of weight detection based on livestock images can be implemented through a livestock weight detection network. That is, the livestock images can be input into the livestock weight detection network, and the network performs weight detection and outputs the weight of the livestock to be detected. Specifically, when performing the detection, the livestock images can be firstly subjected to multi-scale feature separation to obtain multi-scale low-frequency features and multi-scale high-frequency features, and then feature aggregation can be performed based on the multi-scale low-frequency features and multi-scale high-frequency features to obtain high- and low-frequency aggregation features, and then weight detection can be performed based on the high- and low-frequency aggregation features to obtain the weight of the livestock to be detected.

[0063] Among them, the process of multi-scale feature separation, feature aggregation, and weight detection has been described in detail above and will not be repeated here.

[0064] It should be noted that before inputting livestock images into the livestock weight detection network, the livestock weight detection network can also be pre-trained, that is, livestock images of sample livestock, that is, sample livestock images, and their corresponding sample weights can be used to train the livestock weight detection network.

[0065] Figure 7 It is a schematic diagram of the framework of the network training process provided by the present invention, such as Figure 7 As shown, the training process of the network may specifically include: first, obtaining sample livestock images and sample weights. The sample livestock images and sample weights here can be collected in advance, for example, livestock images marked with livestock weights are crawled from public websites as sample livestock images and sample weights, or livestock images are directly collected by field image acquisition equipment when the livestock weight is known, as sample livestock images, or obtained by other means, which are not specifically limited in the embodiment of the present invention. Then, the sample livestock images can be processed by the livestock state detection network in the training process to predict the weight of the sample livestock through multi-scale feature separation, feature aggregation and weight regression, thereby obtaining the predicted livestock weight output by the network, that is, the predicted weight. The multi-scale feature separation, feature aggregation, and weight regression processes are consistent with the corresponding steps in the above application process, so the specific implementation steps of this part of the processing process will not be described in detail.

[0066] It is worth noting that during the network training process, after obtaining the high- and low-frequency aggregated features corresponding to the sample livestock image through feature aggregation, while performing weight regression, in an embodiment of the present invention, feature decoding is also performed to decode the features into an image, thereby obtaining a predicted livestock image. Figure 8 is a schematic diagram of the feature decoding process provided by the present invention, such as Figure 8 As shown in the figure, during the training process, in order to improve the detection performance of the network and ensure the accuracy of livestock weight detection in application, the features can also be focused on the livestock to restore the original input livestock image, so as to verify the network performance by comparing the original input with the current output. That is, the high- and low-frequency aggregated features corresponding to the input sample livestock image can be decoded into the form of a binary image, thereby obtaining a single-channel image with the same size as the input sample livestock image.

[0067] Furthermore, after the decoding restoration and weight regression are completed, in an embodiment of the present invention, the loss of the network during the training process can be determined accordingly. That is, the loss of the network in feature extraction and decoding restoration can be determined according to the predicted livestock image output by the livestock state detection network during the training process, and the sample livestock image, which is called the restoration loss; specifically, the restoration loss can be determined by measuring the similarity between the sample livestock image and the predicted livestock image. Alternatively, the loss of the network in feature extraction and weight regression can be determined according to the predicted weight output by the livestock state detection network during the training process, and the sample weight, which is called the prediction loss; specifically, the prediction loss can be determined by measuring the difference between the predicted weight and the sample weight. Alternatively, the overall loss of the network can be determined by measuring the similarity between the sample livestock image and the predicted livestock image, and the difference between the predicted weight and the sample weight.

[0068] After that, the parameters of the livestock weight detection network in the training process can be iterated according to the calculated loss to adjust the parameters of the network so that the predicted livestock image output by the adjusted network can be as close as possible to the sample livestock image, and the output predicted weight can be as close as possible to the sample weight, and finally a trained livestock weight detection network can be obtained.

[0069] Preferably, in the embodiment of the present invention, the prediction loss can be measured by the mean square error (MSE) loss, and the specific calculation formula is as follows:

[0070] In the formula, To predict the loss, is the number of sample livestock or sample livestock images, Indicates Sample weight of sampled livestock, Indicates The predicted weights of the sample animals.

[0071] The restoration loss can be measured by Dice loss, and the specific calculation formula is as follows:

[0072] In the formula, To restore the losses, To represent a sample livestock image, It means predicting livestock images.

[0073] The overall loss of the network can be calculated by the following formula:

[0074] In the formula, For the overall loss, and are the weights of prediction loss and restoration loss, respectively, and are hyperparameters. In the embodiment of the present invention, during the network training process, and .

[0075] Specifically, the training is divided into two steps, namely, the weight regression part training and the other part training.

[0076] The livestock weight detection device provided by the present invention is described below. The livestock weight detection device described below and the livestock weight detection method described above can be referred to each other.

[0077] Fig. 9 Schematic diagram of the structure of the livestock weight detection device provided by the present invention. Fig. 9 As shown, the device comprises: An image determination unit 910 is used to determine an animal image of the animal to be detected; The weight detection unit 920 is used to perform multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; perform feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and perform weight detection based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected.

[0078] The livestock weight detection device provided by the present invention obtains multi-scale low-frequency features and multi-scale high-frequency features through livestock image extraction to obtain rich and stable livestock information, then performs feature aggregation based on the multi-scale low-frequency features and multi-scale high-frequency features, and uses the high- and low-frequency aggregated features obtained by feature aggregation to perform weight detection to obtain the weight of the livestock to be detected, thereby overcoming the problems of high cost, complex operation, and limited application scenarios of livestock weight detection in traditional solutions, achieving fast and accurate livestock weight detection, effectively improving the accuracy and stability of weight detection, being applicable to livestock of various breeding environments, categories, and sizes, and having low cost and easy operation, without causing stress response to livestock, thus avoiding adverse effects on their growth, and providing strong support for the refined management of animal husbandry.

[0079] Based on the above embodiment, the weight detection unit 920 is used for: Performing multi-scale feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features to obtain low-frequency aggregated features and high-frequency aggregated features; High and low frequency features are aggregated based on the low frequency aggregation features and the high frequency aggregation features to obtain high and low frequency aggregation features.

[0080] Based on the above embodiment, the weight detection unit 920 is used for: Performing deep feature extraction on the low-frequency aggregated features and the high-frequency aggregated features respectively to obtain low-frequency deep features and high-frequency deep features; High and low frequency features are aggregated based on the low frequency deep features and the high frequency deep features to obtain high and low frequency aggregated features.

[0081] Based on the above embodiment, the weight detection unit 920 is used for: Determining weighted image features based on the high and low frequency aggregate features and the livestock image; determining enhanced image features based on the weighted image features and the livestock image; Deep feature extraction is performed based on the enhanced image features, and weight detection is performed based on the deep image features obtained by the deep feature extraction to obtain the weight of the livestock to be detected.

[0082] Based on the above embodiment, the weight detection unit 920 is used for: Performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features; the multi-scale feature separation includes multi-scale average pooling and upsampling; Based on the multi-scale low-frequency features and the livestock image, multi-scale high-frequency features are determined.

[0083] Based on the above embodiment, the image determination unit 910 is used to: Acquire a group image of livestock to be detected; Extracting a single livestock binary image based on the group image to obtain a livestock binary image; Based on the livestock binary image and the group image, a livestock image of the livestock to be detected is determined.

[0084] Based on the above embodiment, the weight detection unit 920 is used for: Based on the livestock weight detection network, multi-scale feature separation is performed on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected; Wherein, the livestock weight detection network is trained based on the difference between the predicted weight and the sample weight of the sample livestock, and / or the similarity between the sample livestock image and the predicted livestock image of the sample livestock; the predicted weight and the predicted livestock image are determined by the livestock weight detection network during the training process based on the input sample livestock image.

[0085] Fig.10An example of a physical structure diagram of an electronic device is shown in FIG. Fig.10 As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030 and a communication bus 1040, wherein the processor 1010, the communication interface 1020 and the memory 1030 communicate with each other through the communication bus 1040. The processor 1010 may call the logic instructions in the memory 1030 to execute the livestock weight detection method, which includes: determining the livestock image of the livestock to be detected; performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and performing weight detection based on the high-low frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected.

[0086] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and 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 method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0087] 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 livestock weight detection method provided by the above methods, and the method includes: determining a livestock image of the livestock to be detected; performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and performing weight detection based on the high- and low-frequency aggregated features obtained by the feature aggregation to obtain the weight of the livestock to be detected.

[0088] 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 livestock weight detection method provided by the above-mentioned methods, the method comprising: determining a livestock image of the livestock to be detected; performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and performing weight detection based on the high- and low-frequency aggregated features obtained by the feature aggregation to obtain the weight of the livestock to be detected.

[0089] 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 displayed as units may or may not be physical units, that is, 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. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0090] 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, 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 described in each embodiment or some parts of the embodiments.

[0091] 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 livestock weight, characterized in that: include: determining a livestock image of the livestock to be inspected; Performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; Feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected.

2. The livestock weight detection method according to claim 1, characterized in that: The performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features includes: Performing multi-scale feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features to obtain low-frequency aggregated features and high-frequency aggregated features; High and low frequency features are aggregated based on the low frequency aggregation features and the high frequency aggregation features to obtain high and low frequency aggregation features.

3. The livestock weight detection method according to claim 2, characterized in that: The step of aggregating high and low frequency features based on the low frequency aggregate features and the high frequency aggregate features to obtain high and low frequency aggregate features includes: Performing deep feature extraction on the low-frequency aggregated features and the high-frequency aggregated features respectively to obtain low-frequency deep features and high-frequency deep features; High and low frequency features are aggregated based on the low frequency deep features and the high frequency deep features to obtain high and low frequency aggregated features.

4. The livestock weight detection method according to any one of claims 1 to 3, characterized in that: The weight detection is performed based on the high and low frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected, including: Determining weighted image features based on the high and low frequency aggregate features and the livestock image; determining enhanced image features based on the weighted image features and the livestock image; Deep feature extraction is performed based on the enhanced image features, and weight detection is performed based on the deep image features obtained by the deep feature extraction to obtain the weight of the livestock to be detected.

5. The livestock weight detection method according to any one of claims 1 to 3, characterized in that: The multi-scale feature separation is performed based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, including: Performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features; the multi-scale feature separation includes multi-scale average pooling and upsampling; Based on the multi-scale low-frequency features and the livestock image, multi-scale high-frequency features are determined.

6. The livestock weight detection method according to any one of claims 1 to 3, characterized in that: The step of determining the livestock image of the livestock to be detected comprises: Acquire a group image of livestock to be inspected; Extracting a single livestock binary image based on the group image to obtain a livestock binary image; Based on the livestock binary image and the group image, a livestock image of the livestock to be detected is determined.

7. The livestock weight detection method according to any one of claims 1 to 3, characterized in that: The method of performing multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; performing feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and performing weight detection based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected includes: Based on the livestock weight detection network, multi-scale feature separation is performed on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features, feature aggregation is performed based on the multi-scale low-frequency features and the multi-scale high-frequency features, and weight detection is performed based on the high- and low-frequency aggregated features obtained by feature aggregation to obtain the weight of the livestock to be detected; Wherein, the livestock weight detection network is trained based on the difference between the predicted weight and the sample weight of the sample livestock, and / or the similarity between the sample livestock image and the predicted livestock image of the sample livestock; the predicted weight and the predicted livestock image are determined by the livestock weight detection network during the training process based on the input sample livestock image.

8. A livestock weight detection device, characterized in that: include: an image determination unit, for determining an animal image of the animal to be detected; The weight detection unit is used to perform multi-scale feature separation based on the livestock image to obtain multi-scale low-frequency features and multi-scale high-frequency features; perform feature aggregation based on the multi-scale low-frequency features and the multi-scale high-frequency features, and perform weight detection based on the high- and low-frequency aggregation features obtained by feature aggregation to obtain the weight of the livestock to be detected.

9. 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 computer program, the livestock weight detection method according to any one of claims 1 to 7 is implemented.

10. 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 livestock weight detection method according to any one of claims 1 to 7 is implemented.