Intelligent evaluation method and system for pig cleanliness based on pig house inspection robot

Through the pig house inspection robot combined with image repair and deep learning models, the problems of lighting changes and environmental adaptability in pig cleanliness assessment are solved, automated and accurate cleanliness assessment is achieved, and pig house management efficiency is improved.

CN120412031BActive Publication Date: 2025-08-29NAT CENT OF TECH INNOVATON FOR PIGNS +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510863408.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-08-29
Estimated Expiration
2045-06-25

AI Technical Summary

Technical Problem

The prior art has problems such as sensitivity to light change, poor environmental adaptability and insufficient algorithm robustness in pig cleanliness assessment, resulting in a decrease in false positive detection and classification accuracy, which is difficult to apply in real breeding scenarios.

Method used

The intelligent evaluation method based on pig house inspection robot is adopted to enhance image diversity through image repair, geometric deformation, photometric perturbation and occlusion simulation processing, combined with object detection and texture synthesis technology, eliminate hair occlusion and pollutant coverage interference, and use deep learning models for cleanliness score.

Benefits of technology

Automatic and accurate pig cleanliness assessment is achieved, the accuracy and stability of the model is improved, the demand for manual inspection is reduced, and the sanitation management efficiency of the pig house environment is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120412031B_ABST
    Figure CN120412031B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing and analysis technology, and specifically to a method and system for intelligently evaluating the cleanliness of pigs based on a pig house inspection robot. This application obtains historical pig images of each pig in the pig house area; repairs each historical pig image to obtain each target pig image; trains an initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; inputs each current pig image obtained into the target cleanliness scoring model to obtain a cleanliness score corresponding to each current pig image; and obtains the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image. In this way, the cleanliness of the pigs in the pig house area can be automatically evaluated, replacing manual inspections, saving time and effort, and being more convenient.
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 analysis, and in particular to a method and system for intelligently evaluating the cleanliness of pigs based on a pig house inspection robot. Background Art

[0002] With the global livestock industry facing the long-term threat of African swine fever, pig farming is accelerating its transition toward high-density, enclosed facilities. While enclosed piggeries can effectively prevent the spread of pathogens, the limited space exacerbates the problem of manure accumulation. Pigs exposed to this filthy environment are prone to skin inflammation, respiratory diseases, and even public health risks. Furthermore, the increasing adoption of animal welfare practices is placing higher demands on pig cleanliness.

[0003] Currently, the evaluation of pig surface cleanliness mainly adopts the traditional visual evaluation method, which relies on manual observation and is time-consuming and labor-intensive.

[0004] Traditional techniques rely on single image processing techniques, such as using HSV (Hue, Saturation, Value) color space threshold segmentation to extract suspected stain areas, then combining support vector machines (SVM) and histogram of oriented gradients (HOG) features to classify cleanliness levels. While these methods have partially replaced manual judgment, they still have significant limitations in practical applications, primarily in environmental adaptability and algorithm robustness. More critically, traditional color threshold-based segmentation algorithms are highly sensitive to lighting variations, easily misclassifying contaminants such as shadows and water stains on the pig's surface as fecal stains, resulting in false positive detections. Traditional algorithms struggle to process image features in complex scenes, as the texture of pig hair can obscure stain edges, causing threshold segmentation failures. Furthermore, hand-crafted features like HOG lack discriminative power for heterogeneous stains like mucus and mud, resulting in significantly lower classification accuracy as stain morphology changes. These technical bottlenecks severely restrict the practical application of cleanliness assessment systems in real-world farming scenarios. Summary of the Invention

[0005] In response to the shortcomings of the existing technology, the present invention proposes an intelligent pig cleanliness evaluation method and system based on a pig house inspection robot to improve the convenience of obtaining pig cleanliness.

[0006] In a first aspect, the present invention provides an intelligent pig cleanliness evaluation method based on a pig house inspection robot, comprising: obtaining historical pig images of each pig in the pig house area; repairing each historical pig image to obtain each target pig image; training an initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; inputting each current pig image obtained into the target cleanliness scoring model to obtain a cleanliness score corresponding to each current pig image; and obtaining a current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image.

[0007] In one embodiment, the step of obtaining historical pig images of each pig in the pig house area includes: collecting historical pig house area images based on a pig house inspection robot, wherein the historical pig house area images include pigs; preprocessing the historical pig house area images to obtain preprocessed historical pig house area images; and segmenting the preprocessed historical pig house area images to obtain historical pig images.

[0008] In one embodiment, the step of preprocessing the historical pig house area image to obtain the preprocessed historical pig house area image includes: performing geometric deformation processing on the historical pig house area image to obtain the geometrically deformed historical pig house area image; performing photometric perturbation processing on the geometrically deformed historical pig house area image to obtain the photometrically disturbed historical pig house area image; performing occlusion simulation processing on the photometrically disturbed historical pig house area image to obtain the preprocessed historical pig house area image.

[0009] In one embodiment, the step of performing photometric perturbation processing on the geometrically deformed historical pigsty area image to obtain the photometrically perturbated historical pigsty area image includes: performing offset processing on the RGB channels in the geometrically deformed historical pigsty area image based on a preset offset of the RGB channels to obtain the offset RGB channels; and obtaining the photometrically perturbated historical pigsty area image based on the offset RGB channels.

[0010] In one embodiment, the step of performing repair processing on each historical pig image to obtain each target pig image includes: in response to the presence of a patch area in the historical pig image, performing cutout processing on the patch area in the historical pig image to obtain the cutout historical pig image; performing texture synthesis processing on the cutout area of ​​the cutout historical pig image to obtain the target pig image.

[0011] In one embodiment, the step of performing repair processing on each historical pig image to obtain each target pig image further includes: in response to the presence of a pollutant-covered area in the historical pig image, performing mask covering processing on the pollutant-covered area in the historical pig image to obtain the mask-covered historical pig image; and performing texture reconstruction processing on the mask-covered area of ​​the mask-covered historical pig image to obtain the target pig image.

[0012] In one embodiment, the step of training the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model includes: obtaining an actual cleanliness score value of each target pig image; training the initial cleanliness scoring model based on each target pig image and the actual cleanliness score value corresponding to each target pig image to obtain a trained initial cleanliness scoring model; obtaining the accuracy of the trained initial cleanliness scoring model; and in response to the accuracy of the trained initial cleanliness scoring model being greater than a preset accuracy threshold, determining the trained initial cleanliness scoring model as the target cleanliness scoring model.

[0013] In one embodiment, the step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the absence of a plaque area in the current pig image, obtaining the total score between the cleanliness scores corresponding to each current pig image; and determining the ratio between the total score and the number of pigs in each current pig image as the current pig cleanliness score of the pig house area.

[0014] In one embodiment, the step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the presence of a plaque area in the current pig image, determining the plaque category according to the area of ​​the plaque area; and obtaining the current pig cleanliness score of the pig house area according to the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image.

[0015] In a second aspect, the present invention provides an intelligent pig cleanliness evaluation system based on a pig house inspection robot, characterized in that it includes: an image acquisition module for acquiring historical pig images of each pig in the pig house area; an abnormal image processing module for repairing each historical pig image to obtain each target pig image; a model training module for training an initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; a cleanliness score acquisition module for inputting each acquired current pig image into the target cleanliness scoring model to obtain a cleanliness score corresponding to each current pig image; a current pig cleanliness score acquisition module for obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image.

[0016] It can be seen from the above technical solution that the beneficial technical effects of the present invention are as follows:

[0017] It can automatically evaluate the cleanliness of pigs in the pig house area, replacing manual inspections, saving time and effort and being more convenient.

[0018] The cleanliness score is obtained through the target cleanliness scoring model. On the one hand, it can be quantified according to the degree of dirtiness of the pig's body surface through the cleanliness score, providing a classification standard for the cleanliness of the pig's body surface. On the other hand, compared with relying on manual evaluation, the model is more accurate and stable. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for the specific embodiments or the description of the prior art. Similar elements or parts are generally identified by similar reference numerals throughout the drawings. Elements or parts in the drawings are not necessarily drawn to scale.

[0020] Figure 1 This is a flow chart of an exemplary embodiment of a method for intelligently evaluating the cleanliness of pigs based on a pig house inspection robot, as shown in the present application;

[0021] Figure 2 is a schematic diagram of an exemplary embodiment of a piggery area image shown in the present application;

[0022] Figure 3 is a schematic diagram of an exemplary embodiment of adjusting the image size of a target pig image shown in the present application;

[0023] Figure 4 is a schematic diagram of an exemplary embodiment of a confusion matrix shown in this application;

[0024] Figure 5 is a schematic structural diagram of an exemplary embodiment of a CEN module shown in this application;

[0025] Figure 6 is a structural diagram of an exemplary embodiment of External attention shown in this application;

[0026] Figure 7 This is a block diagram of an exemplary embodiment of an intelligent pig cleanliness evaluation system based on a pig house inspection robot shown in the present application;

[0027] Figure 8 is a structural diagram of an embodiment of an electronic device shown in this application;

[0028] Figure 9 It is a structural diagram of an embodiment of a computer-readable storage medium shown in this application. DETAILED DESCRIPTION

[0029] The following embodiments of the technical solution of the present invention will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention and are therefore only examples and are not intended to limit the scope of protection of the present invention.

[0030] It should be noted that, unless otherwise specified, the technical or scientific terms used in this application should have the common meaning understood by those skilled in the art to which the present invention belongs. The terms "first," "second," and the like in the description and claims of the embodiments of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate to facilitate the implementation of the embodiments of the present disclosure described herein. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions. Unless otherwise specified, the term "plurality" means two or more. In the embodiments of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B means: A or B. The term "and / or" describes an association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B. The term "corresponding" can refer to an association relationship or a binding relationship. A and B corresponding means that there is an association relationship or a binding relationship between A and B.

[0031] First, it's important to note that with the global livestock industry facing the long-term threat of African swine fever, pig farming is accelerating its transition toward high-density, enclosed facilities. While enclosed piggeries can effectively prevent the spread of pathogens, spatial limitations exacerbate the problem of manure accumulation. Pigs exposed to this filthy environment for extended periods are prone to skin inflammation, respiratory illnesses, and even public health risks. Furthermore, the increasing adoption of animal welfare practices is placing higher demands on piggery environmental cleanliness. Currently, traditional visual assessment methods are primarily used to evaluate pig surface cleanliness, relying on manual observation and being time-consuming and labor-intensive.

[0032] Based on this, the present application provides a method and system for intelligently evaluating the cleanliness of pigs based on a pig house inspection robot, which improves the convenience of obtaining the cleanliness of pigs. The execution subject of an intelligent evaluation method for the cleanliness of pigs based on a pig house inspection robot can be a terminal device or a server or other processing device, wherein the terminal device can be a computer, a mobile device, a terminal, a computing device, a vehicle-mounted device, etc. The execution subject of the intelligent evaluation method for the cleanliness of pigs based on a pig house inspection robot can also be an intelligent evaluation device for the cleanliness of pigs based on a pig house inspection robot. In some possible implementations, the intelligent evaluation method for the cleanliness of pigs based on a pig house inspection robot can be implemented by a processor calling computer-readable instructions stored in a memory. The execution subject of the intelligent evaluation method for the cleanliness of pigs based on a pig house inspection robot can also be a big data cluster. A big data cluster is a computer system architecture formed by multiple computers connected through a network. The big data cluster can be deployed on a private cloud built with K8S (Kubernetes, a container orchestration engine).

[0033] Combine Figure 1 As shown, this embodiment provides an intelligent pig cleanliness evaluation method based on a pig house inspection robot, comprising:

[0034] Step S110: Acquire historical pig images of each pig in the pig house area.

[0035] The pig house area refers to the area where pigs are raised.

[0036] Historical pig images refer to images containing pigs at historical moments.

[0037] The intelligent pig cleanliness evaluation device obtains historical pig images of each pig in the piggery area. Specifically, the intelligent pig cleanliness evaluation device uses a camera to capture images of the piggery area to obtain the historical pig images. The camera can be a visible light camera or a still camera.

[0038] Step S120: Perform restoration processing on each historical pig image to obtain each target pig image.

[0039] The intelligent pig cleanliness assessment device performs repair processing on each historical pig image to obtain each target pig image. Specifically, the intelligent pig cleanliness assessment device performs one or more of removing noise from each historical pig image, repairing scratches or damaged portions in each historical pig image, and filling in missing areas in each historical pig image.

[0040] Step S130: training the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model.

[0041] The intelligent pig cleanliness assessment device trains an initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model. Specifically, the intelligent pig cleanliness assessment device scores each target pig image to obtain a historical cleanliness score. The historical cleanliness score corresponding to each target pig image is used as a label for each target pig image. Each target pig image and its corresponding label are then input into the initial cleanliness scoring model for machine learning to obtain a target cleanliness scoring model.

[0042] Step S140: Input the acquired current pig images into the target cleanliness scoring model to obtain the cleanliness scores corresponding to the current pig images.

[0043] The current live pig image refers to the image containing the current live pig in the current pig house area.

[0044] The intelligent pig cleanliness evaluation device inputs the acquired current pig images into the target cleanliness scoring model, obtains the model output result, and uses the model output result as the cleanliness score corresponding to each current pig image.

[0045] The intelligent pig cleanliness assessment device obtains images of each current pig. As an example, the intelligent pig cleanliness assessment device uses a pig house inspection robot to collect images of each pig in the current pig house area to obtain images of each current pig. As another example, the intelligent pig cleanliness assessment device uses a pig house inspection robot to collect images of the current pig house area, wherein the images of the current pig house area include pigs; preprocesses the images of the current pig house area to obtain preprocessed images of the current pig house area; and segmentes the preprocessed images of the current pig house area to obtain images of each current pig.

[0046] In one embodiment, a track is installed above the piggery area, on which a piggery inspection robot is mounted. The intelligent pig cleanliness assessment device uses the inspection robot to periodically capture images of the current piggery area. For example, the inspection robot captures an image of the current piggery area from directly above the piggery area, facing the live pigs, every 10 seconds for one minute to obtain an image of the current piggery area.

[0047] It should be noted that the specific steps of preprocessing the current pigsty area image to obtain the preprocessed current pigsty area image; and segmenting the preprocessed current pigsty area image to obtain the current live pig images can be referred to the specific steps of preprocessing the historical pigsty area image to obtain the preprocessed historical pigsty area image; and segmenting the preprocessed historical pigsty area image to obtain the historical live pig images. These steps will not be repeated here.

[0048] Step S150: obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image.

[0049] Optionally, the step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the absence of a plaque area in the current pig image, obtaining the total score between the cleanliness scores corresponding to each current pig image; and determining the ratio between the total score and the number of pigs in each current pig image as the current pig cleanliness score of the pig house area.

[0050] For example, the cleanliness score corresponding to each current pig image and the current pig cleanliness score satisfy the following formula:

[0051]

[0052] In the above formula, represents the current pig cleanliness score, n represents the number of pigs in the pig house area, Characterizes the cleanliness score of the i-th pig.

[0053] As can be seen, by acquiring historical images of each pig in the piggery area; repairing each historical image to obtain each target pig image; training the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; inputting each current pig image into the target cleanliness scoring model to obtain the cleanliness score corresponding to each current pig image; and obtaining the current pig cleanliness score of the piggery area based on the cleanliness score corresponding to each current pig image. Thus, by using the target cleanliness scoring model to score the cleanliness of each current pig image, compared to the traditional method of manually checking piggery hygiene using monitoring equipment, there is no need for manual inspection, which saves manpower while enabling timely detection of dirty pigs, improving convenience, and at the same time contributing to improving pig welfare.

[0054] Optionally, the step of obtaining historical pig images of each pig in the pig house area includes: collecting historical pig house area images based on a pig house inspection robot, the historical pig house area images including pigs; preprocessing the historical pig house area images to obtain preprocessed historical pig house area images; and segmenting the preprocessed historical pig house area images to obtain historical pig images.

[0055] In one embodiment, a track is installed above the piggery area, and a piggery inspection robot is mounted on the track. The intelligent pig cleanliness assessment device uses the piggery inspection robot to collect historical images of the piggery area at intervals within a preset time period. For example, the piggery inspection robot captures an image frame from directly above the piggery area every 30 minutes from 06:00 to 18:00 daily to obtain historical images of the piggery area.

[0056] Optionally, the step of preprocessing the historical pig house area image to obtain the preprocessed historical pig house area image includes: performing geometric deformation processing on the historical pig house area image to obtain the geometrically deformed historical pig house area image; performing photometric perturbation processing on the geometrically deformed historical pig house area image to obtain the photometrically disturbed historical pig house area image; performing occlusion simulation processing on the photometrically disturbed historical pig house area image to obtain the preprocessed historical pig house area image.

[0057] In one embodiment, the intelligent pig cleanliness assessment device simulates pig muscle tremors in historical pigsty area images through elastic deformation and randomly rotates the pigs in the historical pigsty area images, thereby geometrically deforming the historical pigsty area images and obtaining a geometrically deformed historical pigsty area image. Geometric deformation of the historical pigsty area images helps enhance posture robustness.

[0058] Optionally, the step of performing photometric perturbation processing on the geometrically deformed historical pigsty area image to obtain the photometrically perturbated historical pigsty area image includes: offsetting the RGB channels in the geometrically deformed historical pigsty area image based on preset offsets for the RGB channels to obtain offset RGB channels; and obtaining the photometrically perturbated historical pigsty area image based on the offset RGB channels. The preset offsets are determined based on the light color temperature. This allows for independent offsetting of the RGB channels to simulate different light color temperatures, thereby increasing image diversity.

[0059] For example, the preset offset and the offset RGB channels satisfy the following formula:

[0060]

[0061]

[0062]

[0063] in, Respectively represent the R, G, and B channels after offset, 、 、 Respectively represent the preset offset of R, G, and B channels, clamp ( x , a , b ) characterization will x Restricted to [ a , b ] range.

[0064] Optionally, the step of performing occlusion simulation processing on the photometrically perturbed historical pigsty region image to obtain a preprocessed historical pigsty region image includes: adding random elliptical spots to the photometrically perturbed historical pigsty region image to obtain the preprocessed historical pigsty region image. Occlusion simulation processing increases image diversity, which helps improve the accuracy of model training.

[0065] Optionally, the step of segmenting the pre-processed historical pig house area image to obtain each historical live pig image includes: performing resolution unification processing on the pre-processed historical pig house area image to obtain the historical pig house area image with unified resolution, and inputting the historical pig house area image with unified resolution into a preset image segmentation model to obtain each historical live pig image.

[0066] In one embodiment, the intelligent pig cleanliness evaluation device changes the image resolution of the pre-processed historical piggery area image to 640×640 size, such as Figure 2 As shown, the preset image segmentation model is then input to obtain the mask coordinates of each pig in the historical pig house area image, and each historical pig image is cropped from the historical pig house area image according to the mask coordinates of each pig.

[0067] Optionally, the steps of performing repair processing on each historical pig image to obtain each target pig image include: in response to the presence of patch areas in the historical pig images, performing cutout processing on the patch areas in the historical pig images to obtain the cutout historical pig images; and performing texture synthesis processing on the cutout areas of the cutout historical pig images to obtain the target pig images.

[0068] The patchy areas may be naturally occurring patches of hair color on the pig's body surface.

[0069] In one embodiment, the intelligent pig cleanliness assessment device determines whether plaque areas exist in historical pig images. If so, it locates the plaque areas using a preset object detection model, obtains the bounding box coordinates of the plaque areas, and then subtracts the plaque areas from the historical pig images according to the bounding box coordinates to obtain a cutout historical pig image. Then, based on a preset generative adversarial network (GAN) image restoration model, texture synthesis is performed on the cutout areas in the cutout historical pig images to generate a pig background image free of plaque interference, i.e., the target pig image. This restoration of the plaque areas through cutout and texture synthesis facilitates effective feature extraction in the presence of complex interference.

[0070] Optionally, the step of performing repair processing on each historical pig image to obtain each target pig image also includes: in response to the existence of a pollutant-covered area in the historical pig image, performing mask covering processing on the pollutant-covered area in the historical pig image to obtain the historical pig image after mask covering processing; performing texture reconstruction processing on the mask-covered area of ​​the historical pig image after mask covering processing to obtain the target pig image.

[0071] The pollutant-covered area refers to the area where pollutants such as feces and mud are covered by pig hair, which is highly hidden and difficult to identify.

[0072] In one embodiment, an intelligent pig cleanliness assessment device determines whether contaminant-covered areas exist in historical pig images. If so, it locates abnormal areas based on a preset morphological feature-spatial frequency joint detection algorithm to obtain the contaminant-covered areas. For example, the intelligent pig cleanliness assessment device uses a preset convolutional neural network (CNN) to extract the spatial frequency characteristics of pig hair texture in the target pig image. Regions with high-frequency texture abrupt changes in spatial frequency characteristics are identified as areas of hair lift caused by contaminant attachment, thus obtaining the contaminant-covered areas. A preset region growing algorithm is then used to perform connected domain analysis on the contaminant-covered areas to generate a mask of the hair regions covering the contaminants. Finally, a preset Generative Adversarial Network (GAN) model is used to reconstruct the clean pig texture of the masked areas to obtain the target pig image. By masking and reconstructing the contaminant-covered areas, the device eliminates interference caused by hair occlusion on subsequent stain detection. The training data for the preset GAN model consists of sample images of dirty pigs and those after the contaminants have been removed.

[0073] It's important to note that traditional techniques rely on single image processing techniques, such as using HSV (Hue, Saturation, Value) color space threshold segmentation to extract suspected stain areas, then combining support vector machines (SVMs) and histograms of oriented gradients (HOGs) for cleanliness classification. While these methods have partially replaced manual judgment, they still have significant limitations in practical applications. Their main drawbacks lie in environmental adaptability and algorithm robustness. First, traditional color threshold-based segmentation algorithms are highly sensitive to lighting variations, making it easy for interfering factors like shadows and water stains on the pig's surface to be misclassified as fecal stains, resulting in false positive detections. Second, traditional algorithms struggle to handle complex image features: pig hair texture can obscure stain edges, causing threshold segmentation failures. Furthermore, hand-crafted features like HOGs lack discriminative power for heterogeneous stains like mucus and mud, resulting in significantly lower classification accuracy as stain morphology changes. These technical bottlenecks severely restrict the practical application of cleanliness assessment systems in real-world farming scenarios.

[0074] This application enhances image diversity by geometrically deforming historical piggery area images, independently offsetting RGB channels to simulate different lighting color temperatures, and occlusion simulation. By cutting out and synthesizing textures in patchy areas, patchy areas can be repaired, which helps improve effective feature extraction under complex interference. By masking and reconstructing textures in pollutant-covered areas, the interference of hair occlusion on subsequent stain detection is eliminated, thereby improving model accuracy and solving the problem of accurately classifying the degree of contamination of pigs in complex environments.

[0075] Optionally, the step of training the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model includes: obtaining the actual cleanliness score value of each target pig image; training the initial cleanliness scoring model based on each target pig image and the actual cleanliness score value corresponding to each target pig image to obtain a trained initial cleanliness scoring model; obtaining the accuracy of the trained initial cleanliness scoring model; and in response to the accuracy of the trained initial cleanliness scoring model being greater than a preset accuracy threshold, determining the trained initial cleanliness scoring model as the target cleanliness scoring model.

[0076] Optionally, the step of obtaining the actual cleanliness score of each target pig image includes: in response to the presence of a plaque area in the target pig image, obtaining a plaque category based on the area of ​​the plaque area; determining a corresponding plaque area score from a preset plaque score mapping table based on the plaque category corresponding to each target pig image, obtaining the pollution shape and pollution area ratio in each target pig image, and determining a corresponding alternative cleanliness score from a preset pollution score mapping table based on the pollution shape and pollution area ratio, wherein the preset plaque score mapping table includes a correspondence between a preset pollution shape, a preset pollution area range and a preset cleanliness score; obtaining a third product term between the plaque area ratio value in the target pig image and the plaque area score, obtaining a fourth product term between the difference between the preset quantity threshold and the plaque area ratio value and the alternative cleanliness score; and determining the sum of the third product term and the fourth product term as the actual cleanliness score corresponding to the target pig image.

[0077] Optionally, the step of determining the plaque category based on the area of ​​the plaque region includes: obtaining the ratio between the area of ​​the plaque region and the area of ​​the pig region in the corresponding target pig image to obtain a plaque region ratio value; and determining the corresponding plaque category based on the interval range of the plaque region ratio value.

[0078] It should be noted that the specific steps for obtaining the patch area score of the target pig image can refer to obtaining the patch area score of the current pig area, and will not be repeated here.

[0079] The contaminated area ratio is the ratio between the area of ​​the contaminated area and the area of ​​the pigs in the target pig image.

[0080]

[0081] Table 1 is an example table of the preset patch score mapping table. As shown in Table 1, if the pollution shape is point-shaped and the proportion of point-shaped pollution area is between 10% and 50%, the corresponding category is light pollution, and the corresponding cleanliness score is 4 points; if the pollution shape is point-shaped and the proportion of point-shaped pollution area exceeds 50%, the corresponding category is moderate pollution, and the corresponding cleanliness score is 3 points; if the pollution shape is continuous and the proportion of continuous pollution area is between 10% and 50%, the corresponding category is heavy pollution, and the corresponding cleanliness score is 2 points.

[0082] Optionally, the step of training the initial cleanliness scoring model based on each target pig image and the actual cleanliness score value corresponding to each target pig image to obtain the trained initial cleanliness scoring model includes: formatting each target pig image to obtain each format-processed target pig image; grouping each format-processed target pig image and the corresponding actual cleanliness score value into a data set; selecting a training set from the data set to train the initial cleanliness scoring model to obtain the trained initial cleanliness scoring model.

[0083] Optionally, the step of performing format processing on each target pig image to obtain each target pig image after format processing includes: normalizing the pixels of each target pig image to obtain each normalized target pig image; performing background processing on each normalized target pig image to obtain each background-processed target pig image; performing expansion processing on each background-processed target pig image to obtain each expanded target pig image; and resizing each expanded target pig image to obtain each format-processed target pig image.

[0084] In one embodiment, the intelligent evaluation device for pig cleanliness normalizes the pixels of each target pig image, and then adjusts the non-pig area in each normalized target pig image to black, that is, the pixel value is set to zero; according to the minimum circumscribed matrix of each target pig image, the boundary is expanded by 10% as the classification input area to obtain each expanded target pig image; finally, based on the long side length of the expanded target pig image, the expanded target pig image is expanded into a square by supplementing a black background in the short side direction, that is, an image with a pixel value set to 0. For example, if the expanded target pig image is a horizontal version, that is, the long side is the width, then the black pixel area is supplemented symmetrically on the upper and lower sides in the height direction; if Figure 3 As shown in the left figure, if it is a vertical version, that is, the long side is the height, then the black pixel area is symmetrically added on the left and right sides in the width direction, and finally the image appears in a square shape.

[0085] Optionally, the step of obtaining the accuracy of the trained initial cleanliness scoring model includes: selecting a validation set from the data set, inputting images in the validation set into the trained initial cleanliness scoring model, and obtaining a cleanliness score prediction value; if the cleanliness score prediction value is the same as the actual cleanliness score value corresponding to the input image, the verification result is correct, otherwise the verification result is incorrect; and calculating the ratio between the number of correct verification results and the total number of verification results to obtain the accuracy of the trained initial cleanliness scoring model.

[0086] In one embodiment, the dataset contains 28,115 images, which are divided into a training set and a validation set in a ratio of 8:2. The accuracy of the trained initial cleanliness scoring model is obtained by the following formula:

[0087]

[0088] in, Represents the accuracy of the initial cleanliness score model after training. TP represents the sample with the actual cleanliness score value of A being correctly predicted as A, FP represents the sample with the actual cleanliness score value not being A being incorrectly predicted as A, FN represents the sample with the actual cleanliness score value of A being incorrectly predicted as other, and TN represents the sample with the actual cleanliness score value being other being correctly predicted as other.

[0089] In one embodiment, the initial cleanliness scoring model is trained based on each target pig image and the actual cleanliness score value corresponding to each target pig image. The training results are plotted as a confusion matrix. The training accuracy is 91%. The confusion matrix of the training results is as follows: Figure 4 shown.

[0090] Optionally, the target cleanliness score model includes a CNE (Conventional Neural Evolution) module. Figure 5 As shown, the CNE module includes a sequentially connected convolution module, an external attention mechanism module, and a third convolution layer. The convolution module includes a sequentially connected first convolution layer with a window size of 7×7 and an input feature map channel number of 96, and a second convolution layer with a window size of 1×1 and an input feature map channel number of 384. External attention is an external attention mechanism module, and the window size of the third convolution layer is 1×1 and the number of input feature map channels is 96. Compared with general models that only focus on the information of the current input data during training, the target cleanliness scoring model of the present application can focus on the correlation between different samples, thereby improving the model accuracy.

[0091] Combine Figure 6 As shown, External attention includes: feature is the input feature layer, Query is the query vector of the input feature, and Norm is the normalization processing layer. and There are two memory units and output is the output. Among them, the external attention mechanism module uses and Two memory units learn the characteristics of the entire dataset, enabling the model to take into account the global important information of the data and reduce overfitting of model training.

[0092] For example, the input feature map , the calculation process of the external attention mechanism module is as follows:

[0093]

[0094]

[0095] In the above formula, Characterization i elements and matrices M No. j Similarity between rows, M is a learnable parameter independent of the input, which will serve as the memory of the entire training set, A Representation is an attention map derived from the learned dataset-level prior knowledge, N Represents the number of pixels in the image, d Characterize feature dimensions.

[0096] Optionally, the step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the presence of a plaque area in the current pig image, determining the plaque category according to the area of ​​the plaque area; and obtaining the current pig cleanliness score of the pig house area according to the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image.

[0097] Optionally, the step of determining the plaque category based on the area of ​​the plaque region includes: obtaining the ratio between the area of ​​the plaque region and the area of ​​the pig region in the corresponding current pig image to obtain a plaque region ratio value; and determining the corresponding plaque category based on the interval range of the plaque region ratio value.

[0098] Optionally, the step of obtaining the current pig cleanliness score of the pig house area according to the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image includes: determining the corresponding plaque area score from a preset plaque score mapping table according to the plaque category corresponding to each current pig image, the preset plaque score mapping table including the correspondence between the plaque category and the plaque area score; obtaining a first product term between the plaque area ratio value in the current pig image and the plaque area score, obtaining a second product term between the difference between the preset quantity threshold and the plaque area ratio value and the cleanliness score; determining the sum of the first product term and the second product term as the target cleanliness score corresponding to the current pig image; and taking the average value of the target cleanliness score corresponding to the current pig image with plaque area and the cleanliness score corresponding to the current pig image without plaque area as the current pig cleanliness score of the pig house area.

[0099] For example, the plaque area ratio value, the plaque area score, and the cleanliness score satisfy the following formula:

[0100]

[0101] In the above formula, Characterize the plaque area score, Characterizes the cleanliness score of the current pig image with the mask removing the plaque area, Characterizes the proportion of the plaque area to the total area of ​​the pig image, Represents the target cleanliness score corresponding to the current pig image.

[0102]

[0103] Table 2 is an example table of the preset plaque score mapping table. As shown in Table 2, if the contaminated area is less than 20%, the corresponding plaque category is basically clean, and the corresponding plaque area score is 5 points; if the contaminated area is between 20% and 50%, the corresponding plaque category is moderately polluted, and the corresponding plaque area score is 3 points; if the contaminated area accounts for more than 50%, the corresponding plaque category is severely polluted, and the corresponding plaque area score is 1 point.

[0104] Combine Figure 7 As shown, this embodiment provides a pig cleanliness intelligent evaluation system based on a pig house inspection robot, including an image acquisition module 710, an abnormal image processing module 720, a model training module 730, a cleanliness score acquisition module 740, and a current pig cleanliness score acquisition module 750. Specifically:

[0105] Image acquisition module 710, for acquiring historical pig images of each pig in the pig house area;

[0106] The abnormal image processing module 720 is used to perform repair processing on each historical pig image to obtain each target pig image;

[0107] A model training module 730 is used to train the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model;

[0108] The cleanliness score acquisition module 740 is used to input the acquired current pig images into the target cleanliness score model to obtain the cleanliness score corresponding to each current pig image;

[0109] The current pig cleanliness score acquisition module 750 is used to obtain the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image.

[0110] This embodiment provides a pig cleanliness intelligent evaluation system based on a pig house inspection robot. The system obtains historical pig images of each pig in the pig house area; repairs each historical pig image to obtain each target pig image; trains an initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; inputs each current pig image obtained into the target cleanliness scoring model to obtain the cleanliness score corresponding to each current pig image; and obtains the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image. Thus, by using the target cleanliness scoring model to score the cleanliness of each current pig image, compared with the traditional method of manually checking the hygiene of the pig house using monitoring equipment, there is no need for human inspection, which saves manpower while being able to detect dirty pigs in a timely manner, improving convenience, and at the same time helping to improve pig welfare.

[0111] In order to realize the above-mentioned embodiment of the intelligent evaluation method of pig cleanliness based on the pig house inspection robot, this application proposes another electronic device, please refer to Figure 8 , Figure 8 It is a structural diagram of an embodiment of an electronic device provided by this application.

[0112] The electronic device 800 includes a memory 801 and a processor 802 , wherein the memory 801 and the processor 802 are coupled.

[0113] The memory 801 is used to store program data, and the processor 802 is used to execute the program data to implement the intelligent pig cleanliness evaluation method based on the pig house inspection robot of the above embodiment.

[0114] In this embodiment, the processor 802 may also be referred to as a CPU (Central Processing Unit). The processor 802 may be an integrated circuit chip with signal processing capabilities. The processor 802 may also be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or the processor 802 may be any conventional processor.

[0115] This application also provides a computer-readable storage medium, such as Figure 9 As shown, the computer-readable storage medium 900 is used to store program data 901. When the program data 901 is executed by the processor, it is used to implement the intelligent evaluation method for pig cleanliness based on the pig house inspection robot in the method embodiment of the present application.

[0116] The methods involved in the embodiments of the intelligent pig cleanliness evaluation method based on a pig house inspection robot in this application, when implemented as software functional units and sold or used as independent products, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of this application, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the various embodiments of the method of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0117] 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 or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention.

Claims

1. An intelligent evaluation method for pig cleanliness based on a pig house inspection robot, characterized in that: include: Obtain historical pig images of each pig in the pig house area; Perform restoration processing on each historical pig image to obtain each target pig image; The initial cleanliness scoring model is trained based on each target pig image to obtain a target cleanliness scoring model; Inputting each current pig image obtained into the target cleanliness scoring model to obtain a cleanliness score corresponding to each current pig image; Obtaining a current pig cleanliness score for the piggery area based on the cleanliness score corresponding to each current pig image; The step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the presence of a plaque area in the current pig image, determining the plaque category according to the area of ​​the plaque area; obtaining the current pig cleanliness score of the pig house area according to the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image; The step of obtaining the current pig cleanliness score of the pig house area based on the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image includes: determining the corresponding plaque area score from a preset plaque score mapping table according to the plaque category corresponding to each current pig image, wherein the preset plaque score mapping table includes the correspondence between the plaque category and the plaque area score; obtaining a first product term between the plaque area ratio value in the current pig image and the plaque area score, and obtaining a second product term between the difference between a preset quantity threshold and the plaque area ratio value and the cleanliness score; determining the sum of the first product term and the second product term as the target cleanliness score corresponding to the current pig image; and taking the average value of the target cleanliness score corresponding to the current pig image with plaque area and the cleanliness score corresponding to the current pig image without plaque area as the current pig cleanliness score of the pig house area.

2. The method according to claim 1, characterized in that The step of obtaining historical pig images of each pig in the pig house area includes: Collecting historical piggery area images based on the piggery inspection robot, wherein the historical piggery area images include live pigs; Preprocessing the historical pigsty area image to obtain a preprocessed historical pigsty area image; The pre-processed historical piggery area images are segmented to obtain historical live pig images.

3. The method according to claim 2, characterized in that The step of preprocessing the historical pigsty area image to obtain the preprocessed historical pigsty area image comprises: Performing geometric deformation processing on the historical piggery area image to obtain a geometrically deformed historical piggery area image; Performing photometric perturbation processing on the geometrically deformed historical pigsty area image to obtain a photometrically perturbation processed historical pigsty area image; The historical pigsty area image after the photometric disturbance processing is subjected to occlusion simulation processing to obtain the pre-processed historical pigsty area image.

4. The method according to claim 3, characterized in that The step of performing photometric perturbation processing on the geometrically deformed historical pigsty area image to obtain the photometrically perturbation processed historical pigsty area image comprises: Performing an offset process on the RGB channels in the geometrically deformed historical piggery area image based on a preset offset of the RGB channels to obtain the offset RGB channels; The historical pigsty area image after the photometric disturbance processing is obtained based on the offset RGB channels.

5. The method according to claim 1, wherein The step of performing restoration processing on each historical pig image to obtain each target pig image includes: In response to the presence of a patch region in the historical pig image, performing a cutout process on the patch region in the historical pig image to obtain a cutout historical pig image; Texture synthesis processing is performed on the cutout region of the cutout historical pig image to obtain the target pig image.

6. The method according to claim 1, characterized in that The step of performing restoration processing on each historical pig image to obtain each target pig image further includes: In response to the presence of a pollutant-covered area in the historical pig image, performing mask covering processing on the pollutant-covered area in the historical pig image to obtain a mask-covered historical pig image; Texture reconstruction is performed on the mask-covered area of ​​the historical pig image after the mask-covering process to obtain the target pig image.

7. The method according to claim 1, characterized in that The step of training the initial cleanliness scoring model based on each target pig image to obtain the target cleanliness scoring model includes: Obtain the actual cleanliness score value of each target pig image; The initial cleanliness scoring model is trained based on each target pig image and the actual cleanliness score value corresponding to each target pig image to obtain a trained initial cleanliness scoring model; Get the accuracy of the initial cleanliness scoring model after training; In response to the accuracy of the trained initial cleanliness scoring model being greater than a preset accuracy threshold, the trained initial cleanliness scoring model is determined as the target cleanliness scoring model.

8. The method according to claim 1, characterized in that The step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image comprises: In response to the absence of a plaque area in the current pig image, obtaining a total score among the cleanliness scores corresponding to the current pig images; The ratio between the total score and the number of pigs in each current pig image is determined as the current pig cleanliness score of the pig house area.

9. An intelligent pig cleanliness evaluation system based on a pig house inspection robot, characterized in that: include: An image acquisition module is used to obtain historical pig images of each pig in the pig house area; The abnormal image processing module is used to repair each historical pig image to obtain each target pig image; A model training module is used to train the initial cleanliness scoring model based on each target pig image to obtain a target cleanliness scoring model; A cleanliness score acquisition module is used to input each acquired current pig image into the target cleanliness score model to obtain a cleanliness score corresponding to each current pig image; A current pig cleanliness score acquisition module is used to obtain the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image; The step of obtaining the current pig cleanliness score of the pig house area based on the cleanliness score corresponding to each current pig image includes: in response to the presence of a plaque area in the current pig image, determining the plaque category according to the area of ​​the plaque area; obtaining the current pig cleanliness score of the pig house area according to the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image; The step of obtaining the current pig cleanliness score of the pig house area based on the plaque category corresponding to each current pig image and the cleanliness score corresponding to each current pig image includes: determining the corresponding plaque area score from a preset plaque score mapping table according to the plaque category corresponding to each current pig image, wherein the preset plaque score mapping table includes the correspondence between the plaque category and the plaque area score; obtaining a first product term between the plaque area ratio value in the current pig image and the plaque area score, and obtaining a second product term between the difference between a preset quantity threshold and the plaque area ratio value and the cleanliness score; determining the sum of the first product term and the second product term as the target cleanliness score corresponding to the current pig image; and taking the average value of the target cleanliness score corresponding to the current pig image with plaque area and the cleanliness score corresponding to the current pig image without plaque area as the current pig cleanliness score of the pig house area.

Citation Information

Patent Citations

  • Dairy cow cleanliness automatic scoring method and system, storage medium and equipment

    CN114627505A

  • Intelligent evaluation system for hog house ground cleanliness

    CN209514689U