A precision feeding system for lactating sows based on feeding behavior

By using magnetic navigation robots and target detection models in lactating sow farming, automated monitoring and precise control of sows' feeding behavior and remaining feed in the trough are achieved, solving the shortcomings of manual inspections and improving farming efficiency and animal health.

CN117617133BActive Publication Date: 2025-09-12NANJING AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311634297.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-30
Publication Date
2025-09-12
Estimated Expiration
2043-11-30

AI Technical Summary

Technical Problem

In the existing technology, the monitoring of feeding behavior of lactating sows relies on manual inspections, which has problems such as strong subjectivity, low accuracy, and waste of human resources. It is difficult to achieve precise feeding, which affects the production efficiency of pig farms.

Method used

A magnetic navigation robot equipped with an RGB camera is used to obtain feeding behavior data, build a target detection model, and combine it with the feed trough residual feed detection model. Data analysis is performed through a cloud server, and after optimization, a precise feeding strategy is formed. The feed amount is controlled by an electronic valve to achieve automatic adjustment.

Benefits of technology

It improves the automation level of lactating sow management, reduces the workload of manual inspections, promptly detects abnormal feeding, reduces feed waste, and improves the health of sows and piglets, in line with the concept of welfare farming.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117617133B_ABST
    Figure CN117617133B_ABST
Patent Text Reader

Abstract

This invention discloses a feeding behavior-based precision feeding system for lactating sows. Lactating sows are used as the research subjects, and a magnetic navigation robot is used as the motion platform. By using an RGB camera to acquire feeding behavior data of lactating sows, a model of abnormal feeding behavior of lactating sows based on a target detection algorithm is constructed and optimized. This model is then deployed to a cloud server platform to detect the feeding behavior of lactating sows and the remaining feed in the trough, ultimately forming a precise feeding strategy. This system provides effective support for precise pig management and promotes the intelligentization of breeding equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to image processing technology, deep learning technology, wireless network communication technology and sensor technology, and specifically to a precise feeding system for lactating sows based on feeding behavior. Background Art

[0002] Currently, my country's livestock farming sector is still in its developmental stages due to insufficient automation and informatization. Driven by the domestic economic situation and public demand, livestock and poultry farming operations are accelerating their transition from semi-automated to automated and intelligent farming methods. The production management of lactating sows is a crucial component of pig farm management, and their health directly impacts the farm's production efficiency. The feed intake of lactating sows largely determines the growth and health of their piglets. By observing the feeding behavior of lactating sows, analyzing their feeding patterns, and promptly and accurately identifying sows with abnormal feeding patterns, and adjusting feed amounts in real time, we can effectively reduce feed waste and improve farming efficiency.

[0003] Feed intake among lactating sows varies significantly due to factors such as hormone levels, environmental conditions, and feeding practices. In large-scale farms, farrowing rooms often utilize automated feeding lines for automated feeding, while regular manual inspections monitor sows' feeding habits. Before feeding, managers typically observe the sows' posture and the amount of feed remaining in the trough. Based on comprehensive information such as environmental and individual information, they determine whether the sows are exhibiting abnormal feeding behavior and adjust the current feed intake accordingly. However, manual judgment by managers is subject to high subjectivity, low accuracy, and a waste of human resources. Summary of the Invention

[0004] Based on the problems existing in the background technology, this invention uses lactating sows as the research object and a magnetic navigation robot as the motion platform. By using an RGB camera to acquire feeding behavior data of lactating sows, this invention constructs a model of abnormal feeding behavior of lactating sows based on a target detection algorithm. This model is optimized and deployed to a cloud server platform to detect feeding behavior and residual feed in troughs of lactating sows, ultimately forming a precise feeding strategy. This provides effective support for precise pig management and promotes the intelligentization of breeding equipment.

[0005] Technical solution:

[0006] A lactating sow precision feeding system based on feeding behavior includes a local image acquisition device, a local control device, and a cloud server model operation center, wherein:

[0007] The local image acquisition device includes: a camera, an inspection robot and a network module. The camera and the inspection robot collect local images and send them to the cloud server model operation center through the network module;

[0008] The cloud server model operation center deploys a lactating sow feeding behavior detection model, a feed trough residual detection model, and a lactating sow feeding system model, and connects them to a local image acquisition device and a local control device respectively. The local image is used as input data for the lactating sow feeding behavior detection model. The output data of the lactating sow feeding behavior detection model is judged, and the residual information is input into the feed trough residual detection model for residual feed quantification. The outputs of the lactating sow feeding behavior detection model and the feed trough residual detection model are finally input into the lactating sow feeding system model for operation, and the operation results are fed back to the local control device as local control instructions.

[0009] The local control device includes: a receiving instruction module, a main control module and an electronic valve. The receiving instruction module receives the local control instructions issued by the cloud server model operation center. The signal output end of the receiving instruction module is connected to the main control module, and the main control module is connected to the electronic valve to execute specific control commands.

[0010] Specifically, the local image acquisition device also includes a magnetic track and a telescopic bracket. The magnetic track is used for the inspection robot to walk; the telescopic bracket is installed 1.7 meters above the inspection robot track, and the camera is fixed on the telescopic bracket. By adjusting the position of the telescopic bracket, the collection picture can achieve the best collection effect.

[0011] Specifically, the electronic valve is set at each column under the automatic material line, and the main control module adjusts the rotation angle of the electronic valve through the switching time of the relay to control the material discharge amount.

[0012] Specifically, the steps for obtaining the lactating sow feeding behavior detection model are as follows:

[0013] Step 1: Establish a data acquisition system to collect data and obtain actual data;

[0014] Step 2: Data cleaning: For the actual data collected, we manually removed blurry images and images of pigs eating, deleting useless and interfering data from the actual operation. However, we retained data of some piglets playing and eating in the trough to improve the robustness of the model under actual operation.

[0015] Step 3: Use labeling software to label the lactating sow's posture and the remaining food in the trough in the picture;

[0016] Step 4: Dataset division and production;

[0017] Step 5: Network model training to obtain the target detection model.

[0018] Specifically, the specific steps for training the lactating sow feeding behavior detection model network model include:

[0019] S5-1. Set network hyperparameters, including Epoch, Batchsize, initial learning rate, initial impulse, and weight decay coefficient according to the data set and hardware conditions.

[0020] S5-2. The prepared data set is put into the yolov5s network with set training parameters to train the lactating sow posture and trough residual material detection model;

[0021] S5-3. After the training is completed, the weighted model with the best detection effect is selected as the target detection model based on the comprehensive evaluation of Precision and Recall.

[0022] More preferably, the specific steps of training the lactating sow feeding behavior detection model network model also include:

[0023] S5-4. Optimization of the target detection model, specifically including:

[0024] A. In the added channel attention module, the parallel pooling of avg&max for polling loses less information than single pooling; the expression of the channel attention mechanism module is as follows:

[0025]

[0026] In the formula, for the input F, average pooling and maximum pooling are performed to aggregate spatial information, and two C-dimensional pooling feature maps are obtained, F avg and F max , F avg and F max Send it to the multi-layer perceptron MLP containing one hidden layer, add the corresponding elements of the two channel attention maps obtained by MLP, activate them, and get the final channel attention map M c (F);

[0027] B. The spatial attention mechanism takes the feature map output by the channel attention module as input, then performs pooling, channel splicing, and finally performs convolution operations to obtain the generated feature map. The expression of the spatial attention mechanism module is as follows:

[0028]

[0029] In the formula, for F, first perform maximum pooling and average pooling along the channel direction to obtain two two-dimensional F and F avg and F max , the attributes are all 1×H×W, and the two Fs are spliced ​​together to get the spliced and Use a convolutional layer of size 7x7 to generate a spatial attention map Ms (F).

[0030] Specifically, the steps of establishing the trough residual material detection model include:

[0031] Step 1: Classify the output results of the lactating sow feeding behavior detection system into three categories: standing with feed, standing without feed, lying with feed, and lying without feed. Eliminate the data without feed and retain the remaining data for further processing.

[0032] Step 2: Pick out the image with excess material and obtain the coordinates of the trough detection frame [x min ,y min ],[x max ,y max ], extract the detection frame coordinates and intercept the image in the frame to obtain the standardized image of the residual material trough;

[0033] Step 3: Cut out the residual material by limiting the RGB range of the standardized image of the residual material trough to display pixels. The RGB range is [95,150], [40,90], [40,110].

[0034] Step 4: Use morphological operations such as dilation and erosion to connect adjacent black pixels;

[0035] Step 5: Perform color enhancement on the processed image, turning all pixels except white pixels into black pixels;

[0036] Step 6: The image is now processed into a black residual area and a white background area. The area ratio is calculated by calculating the ratio of the number of black pixels to the total number of black pixels. The formula is as follows:

[0037]

[0038] Where S represents the area ratio used to quantify the remaining material in the trough, N B Represents the number of black pixels, N W Represents the number of white pixels.

[0039] Specifically, the steps of establishing the lactating sow precision feeding system include:

[0040] Step 1: Based on the on-site investigation of the breeding house, the lactating sow feeding behavior detection system is divided into four levels of feeding behavior from high to low, set as variable n, corresponding to standing without feed: n = 1; standing with feed: n = 2; lying without feed: n = 3; lying with feed: n = 4;

[0041] Step 2: Calculate the remaining feed amount information output by the feed trough remaining feed detection system and the feeding behavior information to construct the feeding desire calculation formula:

[0042]

[0043] Where n is the feeding behavior variable, S is the proportion of residual feed area, A is the quantitative value of feeding desire, k and h are constant terms, and t is the number of tests;

[0044] Step 3: After normalizing the quantitative value of feeding desire A, it is combined with the environmental information, diet composition, lactation stage, and feeding amount data in the database as input information, and the piglet weaning weight, feed savings, and actual feeding amount data are used as output information; a multi-layer feedforward neural network BP based on the error back propagation algorithm is used to construct a correlation model between input and output. The neurons in each layer are fully connected to the neurons in the next layer to form a directed graph structure; the input is processed through a series of weights and activation functions to finally generate the output.

[0045] More optimally, in Step 3, by continuously iterating weights and optimizing activation function parameters, the neural network learns how to map from input to output through training data; this learning process includes forward propagation and backpropagation: forward propagation is used to calculate the network output, while backpropagation is used to update weights to reduce the error between the network prediction and the actual value; and a genetic algorithm is introduced for optimization; different instructions are sent to the local control device according to the output value, and the purpose of increasing or decreasing the feeding amount is achieved by controlling the opening and closing of the electronic valve to achieve precise feeding; finally, the actual feeding amount is sent to the local control device through the network; the local control device can control the discharge amount by controlling the opening and closing time of the electronic valve and the opening rotation angle through the feeding amount instruction.

[0046] Better yet, in Step 3, for any input, the input value range needs to be scaled to between (0, 1). The specific calculation formula is as follows:

[0047]

[0048] Where A min is the minimum value of the output result, A max In order to maximize the output result, the output result A is normalized so that the range of the output result R is scaled to between (0,1), which is convenient for multi-layer feedforward neural network BP training.

[0049] Beneficial effects of the present invention

[0050] (1) Pig houses with automatic feeding lines still require manual inspection before feeding. The precision feeding system for lactating sows improves the overall level of automation and effectively reduces the workload of pig farm staff.

[0051] (2) Through data analysis and visualization, we can fully understand the feeding behavior of each lactating sow, promptly notice certain diseases that cause abnormal feeding behavior, and promote the healthy growth of lactating sows.

[0052] (3) By adjusting the feeding amount automatically and timely according to the abnormal feeding behavior of pigs, the waste of feed is reduced and the excessive deterioration of feed residues is prevented, which affects the health of pigs. This is in line with the concept of welfare farming.

[0053] (4) The feeding behavior of lactating sows largely determines the growth of piglets. The lactating sow feeding behavior monitoring system can increase the milk production of lactating sows and improve the health of piglets. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 This is the system structure diagram of the present invention

[0055] Figure 2 This is the on-site inspection diagram of the present invention

[0056] Figure 3 This is the frame diagram of the trough target detection in the embodiment

[0057] Figure 4 Figure 2 is a diagram of a feeding system for lactating sows in the embodiment.

[0058] Figure 5 This is a live map of the delivery room in the embodiment

[0059] Figure 6 Grayscale image of the trough obtained in the embodiment

[0060] Figure 7 The residual material pixel map obtained in the embodiment

[0061] Figure 8 The results of the corrosion and expansion operations in the embodiment are shown in FIG.

[0062] Figure 9 Schematic diagram of image enhancement in the embodiment

[0063] Figure 10 Figure 2 is a diagram of a local control device in an embodiment.

[0064] Figure 11 The overall technical roadmap in the embodiment DETAILED DESCRIPTION

[0065] The present invention will be further described below with reference to the embodiments, but the scope of protection of the present invention is not limited thereto:

[0066] This patented "Lactating Sow Precision Feeding System Based on Feeding Behavior" primarily comprises a data acquisition component, a network transmission component, a data storage component, a data analysis component, a data visualization component, and a local control component. The data acquisition component primarily utilizes a magnetic navigation robot equipped with an RGB camera, which captures images of lactating sows' feeding behavior by tilting and shooting from the farrowing crate. The network transmission component is divided into an image transmission component and an environmental information transmission component. The image transmission component uses a wireless camera to transmit wirelessly via a wireless router. The environmental information component includes the pen number and temperature and humidity information of the lactating sows collected. This information is uploaded to a cloud server using a Raspberry Pi 4B via socket communication. The data storage component primarily utilizes MySQL for data storage, with a cloud server or other hardware device serving as the data storage medium. The data analysis component, using the cloud server as a model platform, processes the pig feeding data uploaded by the wireless camera and feeds the results back to the local control component. The data visualization module primarily utilizes the cloud server as the primary computing device, coded in HTML, to access and visualize data within the database. The local control component processes the image results on the cloud server to respond locally to different feeding behaviors. The main system structure diagram is as follows Figure 1 As shown, on-site inspection is as follows Figure 2 shown.

[0067] Feeding behavior detection model for lactating sows

[0068] The lactating sow feeding behavior detection system mainly includes the construction, optimization and deployment of the lactating sow feeding behavior detection model and the feed trough residual material target detection model. The lactating sow feeding behavior detection model and the feed trough residual material target detection model mainly establish the data set and network training model; after the training is completed, the weight model with the best detection effect is selected based on the comprehensive evaluation of Precision and Recall. The optimization method of the network structure is to add a channel attention module (CAM) and a spatial attention module (SAM), respectively adding channel and spatial attention modules. The overall structure of the convolutional attention mechanism module (CBAM) is as follows Figure 3 As shown in the figure. Adding the attention module can save parameters and computing power, and ensure that it can be integrated into the existing network architecture as a plug-and-play module. By using a serial sequence combination of channel first and space second, we can obtain the optimized lactating sow feeding behavior detection model and feed trough residual target detection model. Finally, the system environment and model running environment are configured on the cloud server. Pytorch1.8.1 deep learning framework, the experimental platform processor model is A CoreTM i9-10900k processor, an NVIDIA GTX3090 graphics card with 24GB of memory, and a deep learning environment with Python 3.9, CUDA 11.1, and OpenCV 4.5.1 configured on the Ubuntu 20.04 operating system. The optimized weight model was configured and run on a cloud server.

[0069] Construction of trough residual material detection model

[0070] The feed trough residual feed detection system primarily uses the output of the lactating sow feeding behavior detection system as input to further detect the amount of residual feed. The results of the lactating sow feeding behavior detection model are divided into several sections: standing with feed, standing without feed, lying with feed, and lying without feed. The data without feed is discarded, and the residual feed data is retained for further processing. The residual feed image is picked out, and the coordinates of the feed trough detection frame are obtained based on the detection results. The image within the coordinates is intercepted to obtain a standardized image. Due to the color difference between the feed trough and the feed, the standardized image is converted to a grayscale image. By adjusting the RGB threshold, the residual feed pixel points in the feed trough are segmented and processed to obtain a complete residual feed outline. The area percentage is calculated. The larger the percentage, the more residual feed.

[0071] Feeding system model for lactating sows

[0072] Combine Figure 4 The construction of the lactating sow feeding system model includes analyzing the input lactating sow feeding behavior image information based on the deployed lactating sow feeding behavior and feed trough residual feed target detection model, dividing the lactating sow feeding behavior monitoring system into four levels of feeding desire from high to low according to the relevant expert suggestions and on-site inspection of the breeding house, and calculating the residual feed amount information output by the feed trough residual feed detection system and the feeding behavior information to construct a feeding desire calculation formula.

[0073] The output is combined with database data on sow breed, environmental information, diet composition, lactation stage, and feed amount as input, while output includes data on piglet weaning weight, feed savings, and actual feed amount. A multi-layer feedforward neural network (BP) based on the back propagation algorithm is used to model the relationship between input and output. Neurons in each layer are fully connected to those in the next layer, forming a directed graph. The input is processed through a series of weights and activation functions to ultimately generate an output. By continuously iterating weights and optimizing activation function parameters, the neural network learns how to map input to output using training data. This learning process involves forward propagation and backpropagation. Forward propagation calculates the network output, while backpropagation updates the weights to reduce the error between the network's prediction and the actual value. Genetic algorithms are also introduced for optimization to better align with actual production, resulting in a continuously improving precision feeding system suitable for different sows.

[0074] The lactating sow precision feeding system of the present invention mainly includes:

[0075] (1) Data collection: RGB wireless camera is used as the main equipment to obtain the feeding behavior images of lactating sows by tilting and shooting the sow's farrowing bed.

[0076] (2) Detection of lactating sow feeding behavior and residual feed in the trough: The acquired video data is extracted and filtered, and the dataset is expanded using data enhancement methods such as horizontal flipping, Gaussian noise, and blurring to reduce the risk of model overfitting and improve the generalization performance of the model. Using the prepared lactating sow feeding behavior dataset, a lactating sow feeding behavior detection model and a residual feed in the trough target detection model are established using the Yolov5s network model.

[0077] (3) Model optimization and deployment: By adding channel and spatial attention modules, we optimized the target detection model for lactating sows’ feeding posture and trough residual feed. We wrote an inference script to load the model, detect the image, and output the results. We used OpenCV to read the camera video stream for model calculation.

[0078] (4) The output of the lactating sow feeding behavior monitoring system is used as input information to further detect the amount of residual feed. The images with residual feed are selected, and the feed trough detection frame coordinates are obtained based on the detection results to obtain a standardized image.

[0079] (5) Processing of feed trough image information: Due to the color difference between the feed trough and the feed, the standardized image is converted into a grayscale image. By adjusting the RGB threshold, the pixels of the residual material in the feed trough are segmented and processed to obtain a complete residual material contour map. The area ratio is calculated. The larger the ratio, the more residual material there is.

[0080] (6) Create a lactating sow feeding information database: store the sow breed, environmental information, diet composition, lactation stage, feeding amount, piglet weaning weight, feeding amount and other data of each lactating sow in the database as parameter information of the multi-layer feedforward neural network (BP).

[0081] (7) Construction and deployment of the feeding system model for lactating sows: The remaining feed information output by the feed trough remaining feed detection system is calculated with the feeding behavior information to construct a feeding desire calculation formula. The output results and the environmental information, diet composition, lactation stage, feeding amount and other data in the database are used as input information, and the piglet weaning weight, feed savings, actual feeding amount and other data are used as output information. A multi-layer feedforward neural network (BP) based on the error back propagation algorithm is used to construct the association model between input and output, and a genetic algorithm is introduced for optimization to make it more in line with actual production, forming a continuously improved precision feeding system suitable for different sows. Finally, the actual feeding amount is sent to the local control device through the network.

[0082] (8) Establishment of local control device: The actual feeding amount is sent to the local control device through the network module by deploying the lactating sow feeding system model on the cloud server. After receiving the information, the local main control unit sends instructions to the electronic valve according to the feeding amount information. By controlling the opening and closing time and the opening rotation angle of the electronic valve, the feeding amount can be controlled. The appetite of the lactating sow is judged according to the feeding behavior information of the lactating sow, and the rotation size of the valve is controlled to realize the automatic adjustment of the feeding amount.

[0083] (9) Establishment of feeding behavior monitoring system for lactating sows: The monitoring model is completed by deployment, with RGB camera as data acquisition device, cloud server as computing core, wireless router as network transmission device, MySQL as database, cloud server as data storage device, HTML as data visualization language, and electronic valve as local control, to establish feeding behavior monitoring system for lactating sows.

[0084] The specific implementation process is as follows.

[0085] Data acquisition equipment installation

[0086] Step 1: Select Hikvision DS-2DE2204IW-D3 / W / XM as the camera

[0087] Step 2: Install the camera 1.7m above the magnetic navigation robot using a telescopic bracket at a distance of 0.3m-0.8m.

[0088] Step 3: Place the camera in the same local area network as the wireless router, and adjust the position of the telescopic bracket through the screen to achieve the best acquisition effect.

[0089] Step 4: Install the data collection equipment in the farrowing room and start collecting data 20 minutes before each feeding. The robot moves along the magnetic strip and automatically stops for one minute in front of each lactating sow's stall. The camera is started to collect data and obtain the video data of feeding behavior, such as Figure 5The video collection period is from the third to the twenty-fourth day after the sows give birth, and the data of two days due to loss of appetite of some sows after giving birth are discarded.

[0090] Feeding behavior detection of lactating sows

[0091] The construction of the lactating sow feeding behavior detection model mainly involves establishing a data set and a network training model. The steps for establishing the data set are as follows:

[0092] Step 1: Data cleaning: Filter images of lactating sows feeding in stalls. Images must be clear and unobstructed. For the actual data collected, manually remove blurry images and images of pigs eating. Remove any useless or interfering data from actual operations. However, retain data showing some piglets playing and eating in the trough to improve the robustness of the model under actual operation.

[0093] Step 2: Data augmentation: Use data augmentation methods such as horizontal flipping, Gaussian noise, and blurring to expand the dataset to reduce the risk of model overfitting and improve the generalization performance of the model.

[0094] Step 3: Use labelImg software to label the lactating sow’s posture and the remaining food in the trough in the picture.

[0095] Step 4: Finally, the label files of lactating sows’ posture and trough residual material are prepared and divided into training set, test set and validation set in the ratio of 8:1:1.

[0096] The steps for network model training are:

[0097] Step 1: Set the network hyperparameters, mainly setting Epoch, Batchsize, initial learning rate, initial impulse, and weight decay coefficient according to the data set and hardware equipment.

[0098] Step 2: Put the prepared data set into the yolov5s network with set training parameters to train the lactating sow posture and trough residual food detection model.

[0099] Step 3: After training is completed, the weight model with the best detection effect is selected based on the comprehensive evaluation of Precision and Recall.

[0100] Model optimization and deployment

[0101] If the detection model is not optimized, it will affect the final discrimination result. The network optimization steps are as follows:

[0102] Step 1: In the channel attention module, the parallel pooling of avg & max is used for polling, which loses less information than single pooling. The expression of the channel attention mechanism module is as follows:

[0103]

[0104] In the formula, for the input F, average pooling and maximum pooling are performed to aggregate spatial information, and two C-dimensional pooling feature maps are obtained, F avg and F max , F avg and F max Send it to the multi-layer perceptron MLP containing one hidden layer, add the corresponding elements of the two channel attention maps obtained by MLP, activate them, and get the final channel attention map M c (F).

[0105] Step 2: The spatial attention mechanism takes the feature map output by the channel attention module as input, then performs pooling, channel splicing, and finally performs convolution and other operations to finally obtain the generated feature map. The expression of the spatial attention mechanism module is as follows:

[0106]

[0107] In the formula, for F, first perform maximum pooling and average pooling along the channel direction to obtain two two-dimensional F and F avg and F max , the attributes are all 1×H×W, and the two Fs are spliced ​​together to get the spliced and Use a convolutional layer of size 7x7 to generate a spatial attention map M s (F).

[0108] With the introduction of CBAM, features cover more parts of the object to be identified, and the probability of ultimately identifying the object is also higher. The addition of channels and spatial attention modules saves computing power and parameters.

[0109] Construction of trough residual material detection system

[0110] Step 1: Analyze the output results of the lactating sow feeding behavior monitoring system. The results are standing with feed, standing without feed, lying with feed, and lying without feed. Eliminate the data without feed and retain the remaining data for further processing.

[0111] Step 2: Pick out the image with excess material and obtain the coordinates of the trough detection frame [x min ,y min ],[x max ,y max], extract the detection frame coordinates and intercept the image inside the frame to obtain the standardized image of the remaining material trough as shown in Figure 6 As shown in the figure, since the camera angle and shooting location are fixed, the occlusion position of the railing will never change and can be ignored.

[0112] Step 3: Due to the obvious color difference between the trough body and the feed, the standardized image of the residual trough is cut out by limiting the RGB range of the display pixels. Figure 7 As shown, the RGB range is [95,150], [40,90], [40,110].

[0113] Step 4: Use morphological operations, dilation and erosion, to connect adjacent black pixels such as Figure 8 As shown in the figure, morphological operations can be used to dilate or shrink specific areas in an image, helping to connect scattered points. Using an erosion-then-dilution strategy helps connect adjacent black pixels within the image without enlarging the outer pixels, making the trough remaining material represented by the black pixels in the image closer to the actual value.

[0114] Step 5: Perform color enhancement on the processed image, turning all white pixels into black pixels. Figure 9 As shown, it is convenient to calculate the area.

[0115] Step 6: Now the image is processed into a black residual area and a white background area. The area ratio is calculated by calculating the ratio of the number of black pixels to the total number of black pixels. The formula is as follows:

[0116]

[0117] In the formula, S represents the area ratio, N B Represents the number of black pixels, N W Represents the number of white pixels. The larger the area S is, the more actual remaining feed there is.

[0118] Construction and deployment of lactating sow feeding system model

[0119] Step 1: Based on the advice of relevant experts and on-site inspections of breeding houses, the feeding behavior monitoring system of lactating sows is divided into four levels of feeding behavior from high to low, set as variable n, corresponding to standing without feed: n=1; standing with feed: n=2; lying without feed: n=3; lying with feed: n=4.

[0120] Step 2: Calculate the remaining feed amount information output by the feed trough remaining feed detection system and the feeding behavior information. Construct the feeding desire calculation formula:

[0121]

[0122] Where n is the feeding behavior variable, S is the remaining feed area, A is the quantitative value of feeding desire, k and h are constants, and t is the number of tests. The smaller A is, the higher the feeding desire is.

[0123] Step 3: For any input, the input value range needs to be scaled to between (0, 1). The specific calculation formula is as follows:

[0124]

[0125] Where A min is the minimum value of the output result, A max In order to maximize the output result, the output result A is normalized so that the range of the output result R is scaled to between (0,1) to facilitate the training of the multi-layer feedforward neural network (BP).

[0126] The results are combined with environmental information, diet composition, lactation stage, feeding amount and other data in the database as input information.

[0127] Data such as piglet weaning weight, feed savings, and actual feed amounts are used as output information. A multi-layer feedforward neural network (BP) based on the back propagation algorithm is used to construct a correlation model between input and output. A genetic algorithm is introduced for optimization to better align with actual production, forming a continuously improving precision feeding system suitable for different sows. The actual feed amount is transmitted to a local control device via the network.

[0128] Local control device establishment

[0129] like Figure 10 As shown, the following steps are included:

[0130] Step 1: The lactating sow feeding system model deployed on the cloud server sends the actual feeding amount to the local control device via the network module. Step 2: The local controller uses an STM32 microcontroller and a network serial port server to receive instructions from the cloud server.

[0131] Step 3: The STM32 controls the DC relay to realize the rotation angle and switch of the electronic valve.

[0132] Step 4: Replace the manual valves at each column under the automatic material line with electronic valves. The rotation angle of the electronic valves can be adjusted by the switching time of the relay to control the amount of material discharged. Figure 10 As shown:

[0133] System establishment

[0134] By deploying the monitoring model, we have established a precise feeding system for lactating sows, using RGB cameras and magnetic navigation robots as data acquisition devices, cloud servers as computing cores, wireless routers as network transmission devices, MySQL as databases, cloud servers as data storage devices, HTML as data visualization language, and electronic valves as local control. The overall technical roadmap is as follows: Figure 11 shown.

[0135] Step 1: Establish a data acquisition system to collect data and obtain actual data.

[0136] Step 2: Data cleaning. For the actual data collected, we manually remove blurred images and pictures of pigs eating, and delete the useless and interfering data in the actual operation. However, we retain the data of some piglets playing and eating in the trough to improve the robustness of the model under actual operation.

[0137] Step 3: Use label making software to create image labels.

[0138] Step 4: Dataset division and production.

[0139] Step 5: Model network selection, considering the target detection network model based on comprehensive running speed, accuracy and model complexity.

[0140] Step 6: Use the collected data set to train the target detection model by selecting a good deep learning network.

[0141] Step 7: Optimize the model and deploy it on the server.

[0142] Step 8: Establish a local control device to receive server instructions.

[0143] Step 9: The overall system is completed.

[0144] The specific embodiments described herein are merely illustrative of the spirit of the present invention. Persons skilled in the art may make various modifications, additions, or substitutions to the described specific embodiments without departing from the spirit of the present invention or exceeding the scope of the appended claims.

Claims

1. A precise feeding system for lactating sows based on feeding behavior, characterized in that It includes a local image acquisition device, a local control device and a cloud server model operation center, among which: The local image acquisition device includes: a camera, an inspection robot and a network module. The camera and the inspection robot collect local images and send them to the cloud server model operation center through the network module; The cloud server model operation center deploys a lactating sow feeding behavior detection model, a feed trough residual detection model, and a lactating sow feeding system model, and connects them to a local image acquisition device and a local control device respectively. The local image is used as input data for the lactating sow feeding behavior detection model. The output data of the lactating sow feeding behavior detection model is judged, and the residual information is input into the feed trough residual detection model for residual feed quantification. The outputs of the lactating sow feeding behavior detection model and the feed trough residual detection model are finally input into the lactating sow feeding system model for operation, and the operation results are fed back to the local control device as local control instructions. The steps of establishing the trough residual material detection model include: Step 1: Classify the output results of the lactating sow feeding behavior detection model into standing with feed, standing without feed, lying with feed, and lying without feed, and retain the remaining feed data for further processing; Step 2: Pick out the image with excess material and obtain the coordinates of the trough detection frame [x min ,y min ],[x max ,y max ], extract the detection frame coordinates and intercept the image in the frame to obtain the standardized image of the residual material trough; Step 3: Cut out the residual material by limiting the RGB range of the standardized image of the residual material trough to display pixels. The RGB range is [95,150], [40,90], [40,110]. Step 4: Use morphological operations such as dilation and erosion to connect adjacent black pixels; Step 5: Perform color enhancement on the processed image, turning all pixels except white pixels into black pixels; Step 6: The image is now processed into a black residual area and a white background area. The area ratio is calculated by calculating the ratio of the number of black pixels to the total number of black pixels. The formula is as follows: Where S represents the area ratio used to quantify the remaining material in the trough, N B Represents the number of black pixels, N W Represents the number of white pixels; The local control device includes: a receiving instruction module, a main control module and an electronic valve. The receiving instruction module receives the local control instructions issued by the cloud server model operation center. The signal output end of the receiving instruction module is connected to the main control module, and the main control module is connected to the electronic valve to execute specific control commands.

2. The system according to claim 1, characterized in that The local image acquisition device also includes a magnetic track and a telescopic bracket. The magnetic track is used for the inspection robot to walk; the telescopic bracket is installed 1.7 meters above the inspection robot track, and the camera is fixed on the telescopic bracket. By adjusting the position of the telescopic bracket, the collection picture can achieve the best collection effect.

3. The system according to claim 1, characterized in that The electronic valve is set at each column under the automatic material line, and the main control module adjusts the rotation angle of the electronic valve through the switching time of the relay to control the material discharge amount.

4. The system according to claim 1, characterized in that The steps for obtaining the lactating sow feeding behavior detection model are as follows: Step 1: Establish a data acquisition system to collect data and obtain actual data; Step 2: Data cleaning: For the actual data collected, we manually removed blurry images and images of pigs eating, deleting useless and interfering data from the actual operation. However, we retained data of some piglets playing and eating in the trough to improve the robustness of the model under actual operation. Step 3: Use labeling software to label the lactating sow's posture and the remaining food in the trough in the picture; Step 4: Dataset division and production; Step 5: Network model training to obtain the target detection model.

5. The system according to claim 4, characterized in that The specific steps of training the network model for lactating sow feeding behavior detection model include: S5-1. Set network hyperparameters, including Epoch, Batchsize, initial learning rate, initial impulse, and weight decay coefficient according to the data set and hardware conditions. S5-2. The prepared data set is put into the yolov5s network with set training parameters to train the lactating sow posture and trough residual material detection model; S5-3. After the training is completed, the weighted model with the best detection effect is selected as the target detection model based on the comprehensive evaluation of Precision and Recall.

6. The system according to claim 5, characterized in that The specific steps of the lactating sow feeding behavior detection model network training also include: S5-4. Optimization of the target detection model, specifically including: A. In the channel attention mechanism module, the parallel pooling of avg&max for polling loses less information than single pooling. The expression of the channel attention mechanism module is as follows: In the formula, for the input F, average pooling and maximum pooling are performed to aggregate spatial information, and two C-dimensional pooling feature maps are obtained, F avg and F max , F avg and F max Send it to the multi-layer perceptron MLP containing one hidden layer, add the corresponding elements of the two channel attention maps obtained by MLP, activate them, and get the final channel attention map M c (F); B. The spatial attention mechanism module takes the feature map output by the channel attention mechanism module as input, then performs pooling, channel splicing, and finally performs convolution operations to finally obtain the generated feature map; the expression of the spatial attention mechanism module is as follows: In the formula, for F, first perform maximum pooling and average pooling along the channel direction to obtain two two-dimensional F and F avg and F max , the attributes are all 1×H×W, and the two Fs are spliced ​​together to get the spliced and Use a convolutional layer of size 7x7 to generate a spatial attention map M s (F).

7. The system according to claim 1, characterized in that The steps of establishing the lactating sow precision feeding system include: Step 1: Based on the field investigation of the breeding house, the lactating sow feeding behavior detection model is divided into four levels of feeding behavior from high to low, set as variable n, corresponding to standing without feed: n = 1; standing with feed: n = 2; lying without feed: n = 3; lying with feed: n = 4; Step 2: Calculate the remaining feed amount information output by the feed trough remaining feed detection system and the feeding behavior information to construct the feeding desire calculation formula: Where n is the feeding behavior variable, S is the proportion of residual feed area, A is the quantitative value of feeding desire, k and h are constant terms, and t is the number of tests; Step 3: After normalizing the quantitative value of feeding desire A, it is combined with the environmental information, diet composition, lactation stage, and feeding amount data in the database as input information, and the piglet weaning weight, feed savings, and actual feeding amount data are used as output information; a multi-layer feedforward neural network BP based on the error back propagation algorithm is used to construct a correlation model between input and output. The neurons in each layer are fully connected to the neurons in the next layer to form a directed graph structure; the input is processed through a series of weights and activation functions to finally generate the output.

8. The system according to claim 7, characterized in that In Step 3, by continuously iterating weights and optimizing the parameters of the activation function, the neural network learns how to map from input to output through training data; This learning process includes forward propagation and backpropagation: forward propagation is used to calculate the network output, while backpropagation is used to update the weights to reduce the error between the network prediction and the actual value; and a genetic algorithm is introduced for optimization; different instructions are sent to the local control device according to the output value, and the purpose of increasing or decreasing the feeding amount is achieved by controlling the opening and closing of the electronic valve to achieve precise feeding; finally, the actual feeding amount is sent to the local control device through the network; the local control device can control the discharge amount by controlling the opening and closing time of the electronic valve and the opening rotation angle through the feeding amount instruction.

9. The system according to claim 7, characterized in that In Step 3, for any input, the input value range needs to be scaled to between (0, 1). The specific calculation formula is as follows: Where A min is the minimum value of the output result, A max In order to maximize the output result, the output result A is normalized so that the range of the output result R is scaled to between (0,1), which is convenient for multi-layer feedforward neural network BP training.

Citation Information

Patent Citations

  • Dynamic feedback breeding method and system for pigs

    CN112602667A

  • YOLOv5-based cattle individual ingestion behavior tracking method

    CN116597490A