Method and system for monitoring large-scale pig farms based on data analysis
By processing and analyzing image data from pig farms, and using target area localization and transfer learning models to identify diarrheal substances, the uncertainty problem in existing technologies for disease monitoring in pig farms has been solved, achieving higher prediction accuracy and efficiency.
Patent Information
- Application Number
- CN202510135011.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-02-07
AI Technical Summary
Existing methods for disease control in pig farms have uncertainties in the monitoring and analysis results of some diseases with diarrhea symptoms, and their accuracy needs to be improved.
By acquiring raw image data from pig farms, denoising, resizing, and image enhancement are performed. A target region localization model is used to identify the tail and rump of pigs and the ground area of pig pens. Combined with a target transfer learning model, the probability value of diarrheal substances is output.
It improves the accuracy of predicting common diseases in pig farms, helps farm managers to detect health problems in a timely manner, and enhances monitoring efficiency and accuracy.
Smart Images

Figure CN120032314B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of pig farming monitoring technology, and in particular to a monitoring method and system for large-scale pig farms based on data analysis. Background Technology
[0002] In large-scale pig farming, disease prevention and control has always been a thorny problem. Due to the high density of pigs, the difficulty of disease prevention and control increases. Furthermore, with the expansion of farming scale, the increase in industrialization and automation, the demand for farm workers in pig farming is decreasing. Therefore, in related technologies, predictive analysis of the dynamic behavior of pigs is used to determine whether there are signs of disease in the current pig herd. This method plays a certain role in disease prevention and control in pig farming by collecting and analyzing continuous pig movements.
[0003] In actual pig farming, it has been found that a common symptom is diarrhea in some common pig diseases, such as porcine colibacillosis, porcine leptospirosis, transmissible gastroenteritis, rotavirus infection, swine dysentery, porcine Klebsiella pneumoniae infection, porcine clostridial infection, porcine epidemic diarrhea (PED), and even some piglet yellow scours. When pigs have diarrhea, due to their habits and the fact that the diarrhea is watery, obvious diarrheal material will be left on the tail and rump of the pigs and on the ground of the farm within a short period of time after the diarrhea.
[0004] Existing methods for analyzing pig behavior have limitations. Due to the uncertainty and continuity of pig behavior, they require the analysis of large amounts of historical data, and many behaviors cannot be fully considered. Furthermore, analysis of collected time-series data is necessary. Therefore, the accuracy of predictions based on this method for the aforementioned common diseases needs improvement. Summary of the Invention
[0005] This application aims to address the problem that existing methods for disease prevention and control in pig farms have uncertain monitoring and analysis results for some diseases with diarrheal symptoms, i.e., the accuracy needs to be improved. Based on this, this application proposes a monitoring method and system for large-scale pig farms based on data analysis.
[0006] Firstly, this application provides a monitoring method for large-scale pig farms based on data analysis, including:
[0007] The original image data of the pig farm is acquired, and the original image data is subjected to denoising processing, resizing and image enhancement processing to obtain target image data for representing the real-time pig farming site.
[0008] The target image data is input into a preset target area positioning model to output a bounding area image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump region in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground region in the target image.
[0009] Based on the selected region image and the coordinate frame data, non-ROI regions in the target image data are removed to obtain a first feature map and a second feature map.
[0010] The first feature map and the second feature map are input into a preset target transfer learning model, and the output is a judgment probability value used to characterize the diarrheal substances in the corresponding monitoring area of the pig farm.
[0011] In some possible implementations, acquiring raw image data of a pig farm and performing denoising, resizing, and image enhancement processing on the raw image data to obtain target image data characterizing a real-time pig farm site includes:
[0012] Create a corresponding Gaussian filter, perform a convolution operation between the Gaussian filter and the original image data, update the pixel value of each pixel in the original image data, and obtain the denoised image data.
[0013] The denoised image data is cropped to obtain standard image data;
[0014] The standard image data is subjected to histogram equalization and linear transformation processing to enhance its brightness and obtain the target image data.
[0015] In some possible implementations, the step of acquiring raw image data of a pig farm and performing denoising, resizing, and image enhancement processing on the raw image data to obtain target image data for characterizing a real-time pig farm site further includes:
[0016] The functional expression of the Gaussian filter is:
[0017]
[0018] In the formula, This represents the standard deviation of a Gaussian distribution. The spatial coordinates of the Gaussian filter kernel function;
[0019] The function expression for the linear transformation process is:
[0020]
[0021] In the formula, Represents the brightness value of a pixel in an image. Indicates grayscale level as The frequency of pixel occurrence, The total number of images, This is the image contrast scaling factor. This represents the brightness offset of the image.
[0022] In some possible implementations, the creation of the target region localization model, which involves inputting the target image data into a preset target region localization model to output a bounding box image and coordinate frame data, includes:
[0023] Historical image data of pig farms are acquired, the historical image data is preprocessed, and the preprocessed historical image dataset is divided into a first training set and a first validation set. The preprocessing includes selecting and labeling the ground of the pigpen and the tail and buttocks of the pigs in the historical image data to obtain labeled image data.
[0024] Build an initial region localization model, and input the first training set into the initial region localization model for training iteration;
[0025] After each training cycle, the first validation set is input into the iterated initial region localization model to determine whether overfitting has occurred and to adjust the hyperparameters of the initial region localization model based on the output results, thereby obtaining the target region localization model.
[0026] In some possible implementations, the step of building an initial region localization model and inputting the first training set into the initial region localization model for training iterations specifically includes:
[0027] The SimAM module is embedded into the C2f structure of the Backbone module of the YOLOv8 basic model to form the C2f_SimAM module, replacing the fourth and sixth layer C2f modules of the Backbone module; and
[0028] The EffectiveSE module is embedded into the C2f structure in the Neck module of the YOLOv8 base model to form the C2f_EffectiveSE module, which replaces the fifteenth and eighteenth layer C2f modules of the YOLOv8 base model Neck module. This optimizes the YOLOv8 base model's inspection of irregular edges and low-contrast images, resulting in the initial region localization model.
[0029] In some possible implementations, the step of building an initial region localization model and inputting the first training set into the initial region localization model for training iterations further includes:
[0030] A loss function is created to measure the difference between the predicted probability distribution output by the initial region localization model and the true label. The expression for the loss function is as follows:
[0031]
[0032] In the formula, This represents the true label of the i-th pixel. This represents the predicted probability of the i-th pixel. If the pixel is not selected, the predicted probability is 0. This represents the total number of pixels in the image.
[0033] In some possible implementations, the creation of the target transfer learning model, which involves inputting the first feature map and the second feature map into a preset target transfer learning model and outputting a probability value representing the diarrheal substance in the corresponding monitoring area of the pig farm, includes:
[0034] Obtain feature map data with non-ROI regions removed, and divide the feature map data into a second training set and a second validation set. The feature map data is used to characterize the feature map of the pigpen floor area with diarrheal material and the tail and rump area of pigs.
[0035] Create an initial transfer learning model, which includes freezing the low and mid convolutional layers in the pre-trained base model network structure and adding a custom classification layer before the fully connected layers;
[0036] The second training set is input into the initial transfer learning model to perform transfer learning training iterations of the model;
[0037] The second validation set is input into the iterated initial transfer learning model to determine whether overfitting has occurred and to adjust the parameters of the initial transfer learning model based on the output results, thereby obtaining the target transfer learning model.
[0038] Compared with the prior art, the technical solution provided in this application has at least the following beneficial effects or advantages:
[0039] This application proposes a method distinct from analyzing swine behavior and actions. By leveraging common physiological phenomena associated with some common diseases and neural network models, it aims to more accurately predict common swine diseases in large-scale farms. Specifically, it performs denoising, resizing, and image enhancement processing on the collected raw image data. For dimly lit environments in large-scale swine farms, it further removes noise and enhances key features to improve the model's target detection accuracy. A target region localization model is constructed to identify the location of the swine's tail and rump area, as well as the pigpen floor area and its coordinates, from the target image. Based on the selected region image and coordinate data, the region of interest is cropped. By removing irrelevant areas, the image quality of the target region is enhanced, background noise is removed, and the efficiency and accuracy of subsequent model analysis are improved. The extracted feature maps are input into a target transfer learning model, which further analyzes the image to identify the presence of diarrheal material in the corresponding areas, thereby assisting farm managers in timely detection of swine health problems.
[0040] Secondly, this application provides a monitoring system for large-scale pig farms based on data analysis, comprising:
[0041] The acquisition module is configured to acquire raw image data of a pig farm, and perform denoising, resizing, and image enhancement processing on the raw image data to obtain target image data that characterizes the real-time pig farming site.
[0042] The region positioning module is configured to input the target image data into a preset target region positioning model to output a selected region image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump region in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground region in the target image.
[0043] The region selection module is configured to remove non-ROI regions from the target image data based on the selected region image and the coordinate frame data, to obtain a first feature map and a second feature map;
[0044] The determination module is configured to input the first feature map and the second feature map into a preset target transfer learning model, and output a judgment probability value for characterizing diarrheal substances in the corresponding monitoring area of the pig farm.
[0045] Thirdly, this application also provides an electronic device, comprising:
[0046] At least one processor; and
[0047] A memory communicatively connected to the at least one processor; wherein,
[0048] The memory stores instructions that can be executed by the at least one processor, which enables the at least one processor to perform the steps of the data analysis-based monitoring method for large-scale pig farms provided in the first aspect above.
[0049] Fourthly, this application also provides a computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, implement the steps of the data analysis-based monitoring method for large-scale pig farms provided in the first aspect.
[0050] It is understood that the beneficial effects of the technical solutions provided in the second, third and fourth aspects above can be found in the relevant descriptions in the first aspect above, and will not be repeated here.
[0051] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0052] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is a data transmission flowchart illustrating a data analysis-based monitoring method for large-scale pig farms according to an embodiment of this application.
[0054] Figure 2 This is a flowchart illustrating a data analysis-based monitoring method for large-scale pig farms according to embodiments of this application;
[0055] Figure 3 This is a block diagram of a monitoring system for a large-scale pig farm based on data analysis, as shown in an embodiment of this application.
[0056] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0057] The embodiments of this application are described in detail below. The embodiments described with reference to the accompanying drawings are exemplary. It should be understood that the specific embodiments described herein are merely for explaining this application and are not intended to limit this application.
[0058] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0059] In large-scale pig farming, the existing technology for systematic assessment of large-scale pig farms, DMBSENH, is characterized by its completeness, comprehensiveness, and systematic approach. It divides the pig farm into seven structures: data, management, breed, safety, environment, nutrition, and health. It uses three methods—on-site inquiries, record review, and on-site observation—to identify existing problems and control characteristics based on the current state and ideal conditions of the pig farm. In data assessment, data is the most economical and direct method for evaluating pig farm management. Data can reflect the management status of a pig farm, and gaps can be identified from the data to find the reasons for these gaps on-site.
[0060] The significance of management assessment includes: operational management assessment: whether the pig farm can survive and achieve sustainable development; team management assessment: assessment of personnel quality, team composition, team execution, key positions, etc.; the significance of breed assessment includes: different breeds have different production performances, and under different environmental conditions and health conditions, the optimal production performance of a breed may not be achieved. Whether a breed can achieve optimal production performance in the pig farm environment requires breed assessment.
[0061] The significance of a safety assessment includes: While biosecurity is never 100%, every pig farm has certain critical points. Problems at these critical points can lead to disease outbreaks or unstable production. Production safety is a prerequisite for ensuring pig farm profits; safety issues can cause significant economic losses to pig farm operations and management. The significance of an environmental assessment includes: the macro-environment (location, climate, surrounding pig farms, sanitation); and the micro-environment (temperature, humidity, density, ventilation and air quality, ammonia concentration, availability of feed troughs and waterers, and whether monitoring has been implemented).
[0062] The significance of nutritional assessment includes: Nutrition is a crucial aspect affecting pig farms, encompassing a wide range of factors such as nutrient ratios, production processes, nutrient composition and components, and feed intake. All of these influence a pig farm's health and production performance. Health assessment includes: laboratory testing results from the pig farm: antibody levels, pathogen prevalence, drug resistance spectrum; immunization program and assessment for the pig herd (reviewing immunization records); health management program and assessment for the pig herd (reviewing medication records); and on-site assessment of the pig herd's health status (clinical symptoms, necropsy lesions).
[0063] However, whether it is a safety assessment, health assessment or other assessment, disease monitoring and assessment are indispensable. Based on this, the inventors propose a monitoring method and system for large-scale pig farms based on data analysis. The monitoring method and system will be described below through several embodiments.
[0064] Please see Figure 1 and Figure 2 , Figure 1 The data transmission flowchart of the monitoring method for large-scale pig farms based on data analysis provided in this embodiment is shown. Figure 2 A flowchart illustrating the data analysis-based monitoring method for large-scale pig farms provided in this embodiment is shown.
[0065] like Figure 1 and Figure 2 As shown, this embodiment provides a monitoring method for large-scale pig farms based on data analysis, including:
[0066] Step S100: Obtain the original image data of the pig farm, and perform denoising, resizing and image enhancement processing on the original image data to obtain target image data for representing the real-time pig farming site;
[0067] In this step, it should be noted that the raw image data can be continuously collected using camera models installed in the pig farm. The pig pens in the pig farm can be arranged in a single pen or a group housing type. The camera models can be set up for each pig pen, and the specific selection can be made according to actual needs. Since current pig farms are often indoor farms, and their indoor lighting is mainly provided by additional light sources, the collected images often have a lot of noise. After acquiring the raw image data, the raw image data is subjected to noise reduction, size adjustment, and image enhancement processing.
[0068] Optional, such as Figure 1 As shown, in this embodiment, the data transmission process can be as follows: after the camera model collects image data of the pigs being monitored in the pig farm, it is transmitted in real time to the server in the corresponding control room via wired connection. The server has data processing capabilities and is connected to the control host. The control host can display reminders based on the data processing results of the server. It is understood that the data transmission can also be wireless, and the specific choice can be made according to actual needs.
[0069] In some embodiments, for the acquired raw image data, a corresponding Gaussian filter can be created, and the Gaussian filter can be convolved with the raw image data to update the pixel value of each pixel in the raw image data, thus obtaining denoised image data. Specifically, when the mean of a certain channel... When the mean is large (i.e., the channel contains more high-frequency information), the filter's enhancement effect will be weakened to prevent over-amplification of existing high-frequency components. Conversely, when the mean is small, the filter will enhance the high-frequency part of the channel more strongly to ensure that more detailed information is captured.
[0070] The functional expression for the Gaussian filter is:
[0071]
[0072] In the formula, This represents the standard deviation of a Gaussian distribution. These are the spatial coordinates of the Gaussian filter kernel function.
[0073] The process of performing a convolution operation on the original image data is as follows:
[0074]
[0075] In the formula, Represents the original image data. The image data is denoised, and * indicates a convolution operation. This convolution process highlights high-frequency information in the image data while suppressing redundant low-frequency components and noise. This processing enables subsequent models to better capture edge and texture details during image recognition. In particular, for diarrheal material, due to its presence on the ground or the edges of pig tails and buttocks, which are uncertain and indistinct, and the low brightness of the acquired image environment, denoising with a Gaussian filter can further improve the recognition accuracy of subsequent models.
[0076] Optionally, resizing is mainly achieved by cropping the denoised image data to obtain standard image data, that is, scaling the width and height of the image to a specified size. Since the size of the input image usually needs to be fixed when using deep learning network models, and since resizing is a common existing technology, the specific resizing can be selected according to actual needs, and no restrictions are imposed here.
[0077] Optionally, due to the limited environment of pig farms, the brightness of the acquired images is low. Therefore, image enhancement processing is required. Specifically, histogram equalization and linear transformation processing are performed on the standard image data to enhance the brightness of the standard image data and obtain the target image data. The histogram equalization process can be as follows: convert the standard image data into grayscale data, calculate the frequency of occurrence of each grayscale level to obtain a histogram, further accumulate the frequency of each grayscale level to obtain the cumulative distribution function (CDF), and then map each grayscale value to a new grayscale value. Based on the mapping formula, the grayscale value of each pixel is replaced with the new grayscale value to obtain the histogram-equalized image. In this way, the contrast of the image can be enhanced.
[0078] Furthermore, the image brightness and contrast are adjusted linearly to improve the visual effect. Linear transformation processing involves applying a linear transformation to the pixel values. The function expression for linear transformation processing is:
[0079]
[0080] In the formula, Represents the brightness value of a pixel in an image. Indicates grayscale level as The frequency of pixel occurrence, The total number of images, This is the image contrast scaling factor. This represents the brightness offset of the image.
[0081] It is understandable that image data can be normalized or standardized before input. Normalization is a common technique in related fields, and the specific process will not be elaborated here.
[0082] Step S200: Input the target image data into the preset target area positioning model to output the selected area image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump area in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground area in the target image.
[0083] In this step, it should be noted that the collected images of the farm contain a large number of different scenes. Through observation in actual pig farming, it has been found that diarrhea is a common symptom in some common pig diseases. Because of the pigs' habits and the fact that their diarrhea is watery, noticeable diarrheal material is left on the pig's tail and rump and on the farm floor shortly after diarrhea. Therefore, to improve the accuracy of prediction, a target area localization model can be used to process the target image data to output the selected area image and corresponding coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame represents the location information of the pig's tail and rump area in the target image, and the second coordinate frame represents the location information of the corresponding pigpen floor area in the target image.
[0084] It should also be noted that the target area localization model is mainly used to select the pig's tail and rump region in the image and the corresponding ground region and obtain the corresponding positional relationship data. This facilitates the initial removal of non-ROI regions, resulting in more accurate and simplified image data, and improving the accuracy of subsequent model data processing.
[0085] In some embodiments, the target region localization model can be built based on the YOLOv8 base model. To improve the accuracy of predictions, the YOLOv8 base model needs to be improved and trained, which may include the following steps:
[0086] Step S210: Obtain historical image data of pig farms, preprocess the historical image data, and divide the preprocessed historical image dataset into a first training set and a first validation set. The preprocessing includes selecting and labeling the ground of the pigpen and the tail and rump of the pigs in the historical image data to obtain labeled image data.
[0087] In this step, the historical image data can be images of pig pens under the same conditions in a pig farm. In order to improve the accuracy of model prediction, since historical image data may contain a lot of noise or have different image sizes, it can be preprocessed. Preprocessing may include image scaling and cropping, image smoothing, and image format conversion. The specific preprocessing can be selected according to actual needs and is not limited here.
[0088] Optionally, to facilitate model training, it is necessary to select and label the ground of the pigpen and the tail and rump of pigs in the historical image data to obtain labeled image data. For example, the X-AnyLAbeling image annotation tool can be used to annotate the defect targets in the collected image data and build a sample database to facilitate subsequent model training and optimization. Of course, other annotation tools can also be used to accurately annotate the photos.
[0089] Optionally, to facilitate subsequent model training and optimization, the preprocessed image dataset needs to be divided into a training set and a validation set. Preferably, the image dataset can be divided into a 70% first training set and a 30% first validation set for subsequent model training and performance verification.
[0090] Step S220: Build an initial region localization model and input the first training set into the initial region localization model for training iteration;
[0091] In this step, the initial region localization model is built based on the YOLOv8 base model. To improve the recognition of irregular edges and low contrast in the pigpen floor and pig tail and rump areas of the corresponding farm, a corresponding attention mechanism is embedded into the YOLOv8 base model to enhance feature extraction, fusion, and detection capabilities. Specifically, the SimAM module is embedded into the C2f structure of the Backbone module of the YOLOv8 base model to form the C2f_SimAM module, replacing the fourth and sixth layers of the C2f module in the Backbone module; and the EffectiveSE module is embedded into the C2f structure of the Neck module of the YOLOv8 base model to form the C2f_EffectiveSE module, replacing the fifteenth and eighteenth layers of the C2f module in the Neck module of the YOLOv8 base model. This optimizes the YOLOv8 base model's inspection of irregular edges and low-contrast images, resulting in the initial region localization model.
[0092] It should be noted that, in order to handle the complex relationship between the pigpen floor and the tail and rump region of the pigs in the corresponding farm and the global feature information, the C2f_EffectiveSE module, combined with the EffectiveSE attention mechanism, first performs channel convolution expansion on the features, and then completes feature fusion and output through global average pooling and channel feature adjustment. By embedding the SimAM module in the 4th and 6th layers of the backbone, and the EffectiveSE module in the 15th and 18th layers of the neck, an improved YOLOv8 model structure is formed. This model performs feature processing and fusion at different levels for the complex characteristics of the pigpen floor and the tail and rump region of the pigs in the farm, thereby optimizing and adjusting the overall architecture.
[0093] Optionally, to quantify the error or gap between the model output and the true value, the model aims to minimize the value of the loss function through training. The smaller the value of the loss function, the closer the model's prediction is to the actual label, and the better its performance. A loss function can be created to measure the difference between the initial region localization model's output prediction probability distribution and the true label, where the loss function expression is:
[0094]
[0095] In the formula, This represents the true label of the i-th pixel. This represents the predicted probability of the i-th pixel. If the pixel is not selected, the predicted probability is 0. This represents the total number of pixels in the image.
[0096] Step S230: After each training cycle, input the first validation set into the iterated initial region localization model to determine whether overfitting has occurred and adjust the hyperparameters of the initial region localization model based on the output results, so as to obtain the target region localization model.
[0097] In this step, after each training cycle, the first validation set is input into the iterated initial region localization model. The validation set can be used to prevent overfitting during training. To adjust the hyperparameters of the initial region localization model, appropriate learning rate, batch size, regularization strength, and optimization algorithm can be selected and adjusted to improve the training effect and prediction accuracy of the model. Of course, the adjustment of hyperparameters is an existing technical means, and the specific process will not be elaborated here.
[0098] Step S300: Based on the selected region image and the coordinate frame data, remove the non-ROI regions from the target image data to obtain the first feature map and the second feature map;
[0099] In this step, the selected area image and coordinate frame data obtained in step S200 can be used to manually or automatically select the ROI (Region of Interest) of the pig's tail and rump region and the corresponding ground region. After removing the non-ROI regions, feature map data samples are obtained. The feature map data samples are extracted by cropping from the selected pig tail and rump region and the corresponding ground region in the image. Since it is necessary to select the pig tail and rump region and the corresponding ground region in the image, a first feature map and a second feature map of the corresponding ground region can be obtained to represent the pig tail and rump region.
[0100] Step S400: Input the first feature map and the second feature map into the preset target transfer learning model, and output the judgment probability value used to characterize the diarrheal substances in the corresponding monitoring area of the pig farm.
[0101] It should be noted that transfer learning accelerates model training and improves performance by applying the learning results (models and features) from one domain to another. For the target transfer learning model, in this step, it is used to identify diarrheal substances from the extracted first and second feature maps. Since the first and second feature maps further narrow the scope and complexity of feature recognition, and transfer learning reduces the amount of labeled data required for training, it can utilize existing large-scale datasets (such as ImageNet) for feature extraction of pre-trained models without having to retrain from scratch. Good prediction results can be obtained with only a small amount of labeled data.
[0102] In some embodiments, the process of creating a target transfer learning model may include the following steps:
[0103] Step S410: Obtain feature map data of non-ROI regions, divide the feature map data into a second training set and a second validation set, and use the feature map data to characterize the feature map of the pigpen floor area with diarrheal material and the tail and buttock area of the pig.
[0104] In this step, the feature map data for removing non-ROI regions can be obtained through the target region localization model. For example, some historical image data carrying diarrheal material can be processed by the target region localization model to output feature map data for the pigpen ground area and the pig tail and rump area with diarrheal material. The feature map data can be divided into a second training set and a second validation set. The second training set can contain 70% of the data, and the second validation set can contain 30% of the data. Of course, these data can also be preprocessed. For example, preprocessing can include size adjustment or normalization, depending on the actual needs.
[0105] Step S420: Create an initial transfer learning model, which includes freezing the low and mid convolutional layers in the pre-trained base model network structure and adding a custom classification layer before the fully connected layers;
[0106] In this step, the initial transfer learning model utilizes an existing pre-trained network model, such as one of ResNet, InceptionV3, or VGG16. The low- and mid-level convolutional layers in the pre-trained network are frozen to preserve the features learned from the large-scale dataset. Only the high-level parts of the network, particularly the fully connected layers, are trained. Custom classification layers are added before the fully connected layers to classify the output category of the task (e.g., whether it contains diarrheal material). The fully connected layers may include an activation function (such as ReLU or Sigmoid) to add non-linearity.
[0107] Step S430: Input the second training set into the initial transfer learning model to perform transfer learning training iterations of the model;
[0108] In this step, only the parameters of the high-level classification layer are updated during training. Through batch training, the classification layer of the model is gradually optimized so that it can adapt to the recognition of diarrheal areas until the training loss converges and the initial transfer learning model training iteration is completed.
[0109] Step S440: Input the second validation set into the iterated initial transfer learning model to determine whether overfitting has occurred and adjust the parameters of the initial transfer learning model based on the output results, so as to obtain the target transfer learning model.
[0110] In this step, the model is checked for overfitting by inputting the iterated initial transfer learning model into the second validation set, and the model parameters are adjusted appropriately. For example, regularization, data augmentation, or adjusting the learning rate can be used to avoid or reduce overfitting and adjust the parameters of the initial transfer learning model.
[0111] In the above method steps, the collected raw image data undergoes denoising, resizing, and image enhancement processing. For some dimly lit environments in large-scale pig farms, noise is further removed and key features are enhanced to improve the accuracy of target detection. A target region localization model is built to identify the location of the pig's tail and rump area, as well as the image and coordinate information of the pigpen floor area from the target image. Based on the selected region image and coordinate frame data, the region of interest is cropped. By removing irrelevant areas, the image quality of the target region is enhanced, background noise is removed, and the efficiency and accuracy of subsequent model analysis are improved. The extracted feature map is input into the target transfer learning model, and the model further analyzes the image to accurately identify whether there is diarrhea in the corresponding area, thereby assisting farm managers in timely detection of pig health problems in the farm.
[0112] Please see Figure 3 , Figure 3 This diagram illustrates a structural block diagram of a data analysis-based monitoring system 200 for large-scale pig farms provided in this embodiment. In this embodiment, the data analysis-based monitoring system 200 for large-scale pig farms includes modules for performing... Figures 1-2 The steps in the corresponding embodiments. Please refer to the details. Figures 1-2 as well as Figures 1-2 The relevant descriptions in the corresponding embodiments are shown below. For ease of explanation, only the parts relevant to this embodiment are shown. See also... Figure 3 The data analysis-based monitoring system for large-scale pig farms includes:
[0113] The acquisition module 210 is configured to acquire raw image data of a pig farm, and perform denoising, resizing and image enhancement processing on the raw image data to obtain target image data for representing the real-time pig farm site.
[0114] The region positioning module 220 is configured to input the target image data into a preset target region positioning model to output a selected region image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump region in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground region in the target image.
[0115] The region selection module 230 is configured to remove non-ROI regions from the target image data based on the selected region image and the coordinate frame data, to obtain a first feature map and a second feature map;
[0116] The determination module 240 is configured to input the first feature map and the second feature map into a preset target transfer learning model, and output a judgment probability value for characterizing the diarrheal substance in the corresponding monitoring area of the pig farm.
[0117] The beneficial effects of the above embodiments compared with related technologies are as follows: By performing denoising, resizing, and image enhancement processing on the collected raw image data, noise in the images is further removed and key features are enhanced in some dimly lit environments in large-scale pig farms, so as to improve the accuracy of the model in target detection. By constructing a target region localization model, the location of the pig's tail and rump area and the image and coordinate information of the pigpen ground area are identified from the target image. Based on the selected area image and coordinate frame data, the region of interest is cropped. By removing irrelevant areas, the image quality of the target area is enhanced, background noise is removed, and the efficiency and accuracy of subsequent model analysis are improved. The extracted feature map is input into the target transfer learning model, and the model further analyzes the image to accurately identify whether there is diarrhea in the corresponding area, thereby assisting farm managers in timely detection of pig health problems in the farm.
[0118] It should be understood that, Figure 3 The block diagram of the data analysis-based monitoring system 200 for large-scale pig farms shown below illustrates how each module performs [the necessary functions]. Figures 1-2 The steps in the corresponding embodiments, and for Figures 1-2 The steps in the corresponding embodiments have been explained in detail in the above embodiments. Please refer to them for details. Figures 1-2 as well as Figures 1-2 The relevant descriptions in the corresponding embodiments will not be repeated here.
[0119] Please see Figure 4 , Figure 4 A structural block diagram of an electronic device provided in this embodiment is shown. The server 500 of this electronic device includes a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501, such as a program for a data analysis-based monitoring method for large-scale pig farms. When the processor 501 executes the computer program 503, it implements the steps of the data analysis-based monitoring method for large-scale pig farms in the above embodiments, for example... Figure 1 Steps S100 to S500 in the corresponding embodiment. Alternatively, the processor 501 executes the computer program 503 to implement the above. Figure 3The functions of each module in the corresponding embodiments, for example, Figure 3 For details on the functions of the modules shown (e.g., module 210), please refer to [link / reference]. Figure 3 The relevant descriptions in the corresponding embodiments are not repeated here.
[0120] For example, computer program 503 can be divided into one or more units, one or more units are stored in memory 502 and executed by processor 501 to complete the technical solution provided in the above embodiments. One or more units can be a series of computer program instruction segments capable of performing a specific function, which are used to describe the execution process of computer program 503 in server 500.
[0121] The electronic device may include, but is not limited to, a processor 501 and a memory 502. Those skilled in the art will understand that... Figure 4 This is merely an example of server 500 in an electronic device and does not constitute a limitation on server 500. It may include more or fewer components than shown, or combine certain components, or different components. For example, a turntable terminal device may also include input / output terminal devices, network access terminal devices, buses, etc.
[0122] The processor 501 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0123] The memory 502 can be an internal storage unit of the server 500, such as the server 500's hard drive or memory. The memory 502 can also be an external storage terminal device of the server 500, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the server 500. Furthermore, the memory 502 can include both internal storage units and external storage terminal devices of the server 500. The memory 502 is used to store computer programs and other programs and data required by the turntable terminal device. The memory 502 can also be used to temporarily store data that has been output or will be output.
[0124] In some embodiments, a computer-readable storage medium is also provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data analysis-based monitoring method for large-scale pig farms as described in the above embodiments.
[0125] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0126] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be non-volatile or volatile. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0127] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects and not to describe a particular order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, it may include a series of steps or units, or optionally, steps or units not listed, or other steps or units inherent to these processes, methods, products, or devices.
[0128] The accompanying drawings show only the portions relevant to this application, not all of them. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations may be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process may correspond to a method, function, procedure, subroutine, subprogram, etc.
[0129] The terms “component,” “module,” “system,” “unit,” etc., used in this specification are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a unit can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, a thread of execution, a program, and / or distributed between two or more computers. Furthermore, these units can be executed from various computer-readable media on which various data structures are stored. Units can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from a second unit interacting with another unit between a local system, a distributed system, and / or a network; for example, the Internet interacting with other systems via signals).
[0130] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example.
[0131] Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The reference to "embodiment" herein means that a specific feature, structure, or characteristic described in connection with an embodiment can be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily indicate the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0132] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
[0133] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
Claims
1. A monitoring method for large-scale pig farms based on data analysis, characterized in that, include: The original image data of the pig farm is acquired, and the original image data is subjected to denoising processing, resizing and image enhancement processing to obtain target image data for representing the real-time pig farming site. The target image data is input into a preset target area positioning model to output a bounding area image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump region in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground region in the target image. Based on the selected region image and the coordinate frame data, non-ROI regions in the target image data are removed to obtain a first feature map and a second feature map. The first feature map and the second feature map are input into a preset target transfer learning model, and the output is a judgment probability value used to characterize the diarrheal substances in the corresponding monitoring area of the pig farm.
2. The monitoring method for large-scale pig farms based on data analysis according to claim 1, characterized in that, The process of acquiring raw image data from a pig farm and performing denoising, resizing, and image enhancement processing on the raw image data to obtain target image data representing the real-time pig farm site includes: Create a corresponding Gaussian filter, perform a convolution operation between the Gaussian filter and the original image data, update the pixel value of each pixel in the original image data, and obtain the denoised image data. The denoised image data is cropped to obtain standard image data; The standard image data is subjected to histogram equalization and linear transformation processing to enhance its brightness and obtain the target image data.
3. The monitoring method for large-scale pig farms based on data analysis according to claim 2, characterized in that, The process of acquiring raw image data from a pig farm and performing denoising, resizing, and image enhancement processing on the raw image data to obtain target image data representing the real-time pig farm site further includes: The functional expression of the Gaussian filter is: In the formula, This represents the standard deviation of a Gaussian distribution. The spatial coordinates of the Gaussian filter kernel function; The function expression for the linear transformation process is: In the formula, Represents the brightness value of a pixel in an image. Indicates grayscale level as The frequency of pixel occurrence, The total number of images, This is the image contrast scaling factor. This represents the brightness offset of the image.
4. The monitoring method for large-scale pig farms based on data analysis according to claim 1, characterized in that, The process of inputting the target image data into a preset target region localization model to output a bounding box image and coordinate frame data includes the following steps: Historical image data of pig farms are acquired, the historical image data is preprocessed, and the preprocessed historical image dataset is divided into a first training set and a first validation set. The preprocessing includes selecting and labeling the ground of the pigpen and the tail and buttocks of the pigs in the historical image data to obtain labeled image data. Build an initial region localization model, and input the first training set into the initial region localization model for training iteration; After each training cycle, the first validation set is input into the iterated initial region localization model to determine whether overfitting has occurred and to adjust the hyperparameters of the initial region localization model based on the output results, thereby obtaining the target region localization model.
5. A monitoring method for large-scale pig farms based on data analysis according to claim 4, characterized in that, The process of building an initial region localization model and inputting the first training set into the initial region localization model for training iterations specifically includes: The SimAM module is embedded into the C2f structure of the Backbone module of the YOLOv8 basic model to form the C2f_SimAM module, replacing the fourth and sixth layer C2f modules of the Backbone module; and The EffectiveSE module is embedded into the C2f structure in the Neck module of the YOLOv8 base model to form the C2f_EffectiveSE module, which replaces the fifteenth and eighteenth layer C2f modules of the YOLOv8 base model Neck module. This optimizes the YOLOv8 base model's inspection of irregular edges and low-contrast images, resulting in the initial region localization model.
6. The monitoring method for large-scale pig farms based on data analysis according to claim 4, characterized in that, The step of building an initial region localization model and inputting the first training set into the initial region localization model for training iterations further includes: A loss function is created to measure the difference between the predicted probability distribution output by the initial region localization model and the true label. The expression for the loss function is as follows: In the formula, This represents the true label of the i-th pixel. This represents the predicted probability of the i-th pixel. If the pixel is not selected, the predicted probability is 0. This represents the total number of pixels in the image.
7. The monitoring method for large-scale pig farms based on data analysis according to claim 1, characterized in that, The creation of the target transfer learning model, which involves inputting the first feature map and the second feature map into a preset target transfer learning model and outputting a probability value representing the diarrheal substance in the corresponding monitoring area of the pig farm, includes: Obtain feature map data with non-ROI regions removed, and divide the feature map data into a second training set and a second validation set. The feature map data is used to characterize the feature map of the pigpen floor area with diarrheal material and the tail and rump area of pigs. Create an initial transfer learning model, which includes freezing the low and mid convolutional layers in the pre-trained base model network structure and adding a custom classification layer before the fully connected layers; The second training set is input into the initial transfer learning model to perform transfer learning training iterations of the model; The second validation set is input into the iterated initial transfer learning model to determine whether overfitting has occurred and to adjust the parameters of the initial transfer learning model based on the output results, thereby obtaining the target transfer learning model.
8. A monitoring system for large-scale pig farms based on data analysis, characterized in that, include: The acquisition module is configured to acquire raw image data of a pig farm, and perform denoising, resizing, and image enhancement processing on the raw image data to obtain target image data that characterizes the real-time pig farming site. The region positioning module is configured to input the target image data into a preset target region positioning model to output a selected region image and coordinate frame data. The coordinate frame data includes a first coordinate frame and a second coordinate frame. The first coordinate frame is used to represent the location information of the pig tail and rump region in the target image, and the second coordinate frame is used to represent the location information of the corresponding pigpen ground region in the target image. The region selection module is configured to remove non-ROI regions from the target image data based on the selected region image and the coordinate frame data, to obtain a first feature map and a second feature map; The diarrheal substance identification module is configured to input the first feature map and the second feature map into a preset target transfer learning model, and output a judgment probability value for characterizing the diarrheal substance in the corresponding monitoring area within the pig farm.
9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the steps of a data analysis-based monitoring method for large-scale pig farms according to any one of claims 1-7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the steps of the monitoring method for large-scale pig farms based on data analysis, as described in any one of claims 1-7.
Citation Information
Patent Citations
Animal illness state monitoring system and method
CN111310596A
Recognition device for animal diarrhea
CN116682147A