Pig behavior identification method and system based on multi-modal features
By integrating RGB and skeletal modal features in the pig behavior recognition model and using a bidirectionally connected network structure, the problem of insufficient recognition accuracy and robustness in the existing technology is solved, and more efficient pig behavior recognition is achieved.
Patent Information
- Application Number
- CN202410736621.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing pig behavior recognition technology is limited to single modal data, making it difficult to accurately identify pig behavior in complex environments, and is easily affected by background noise, resulting in insufficient recognition accuracy and robustness.
A pig behavior recognition method based on multi-modal features is adopted. By introducing a bidirectionally connected first tributary network and a second tributary network into the pig behavior recognition model, the RGB modal features and skeletal modal features are integrated to improve the recognition accuracy and robustness. The specific implementation includes extracting and mapping bone key points of pig images into heat maps, and combining SlowOnly network and PoseC3D network for feature extraction and fusion.
It effectively improves the accuracy and robustness of pig behavior recognition, can better resist light and background changes, makes up for the shortcomings of single modal feature recognition, and improves recognition efficiency.
Smart Images

Figure CN118587629A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pig posture behavior recognition, and in particular to a pig behavior recognition method and system based on multimodal features. Background Art
[0002] As the demand for pig farming in my country grows, the industry is transforming towards automation and intelligent monitoring. Animal behavior is a common indicator for evaluating animal health and welfare. Poor environment and health conditions can cause abnormal behavior. In a farm environment, tracking and monitoring the posture and behavior of pigs is crucial to ensure their health and production efficiency. Traditional manual monitoring methods have the disadvantages of high labor costs, untimely response, and subjective judgments that can easily lead to misjudgments.
[0003] At present, the main monitoring technology based on computer vision is used to monitor the behavior of pigs in the breeding process, which provides a new direction for the development of modern large-scale breeding technology. For example, the pig action recognition method based on RGB images analyzes and obtains information about pig actions from RGB images or videos, which is easily interfered by the background noise of the video image; another example is the recognition method based on skeleton features, which locates key points and skeleton structures through computer vision technology, can capture more subtle motion changes, and has stronger robustness to complex environments and occlusion between multiple pigs, but lacks appearance feature information of pigs and breeding environments, and is affected to a certain extent by background environmental information, making it difficult to distinguish similar pig behaviors. In addition, this type of pig behavior monitoring method is often limited by the limitations of single modality data. Summary of the invention
[0004] The embodiment of the present invention provides a pig behavior recognition method and system based on multimodal features, which utilizes the bidirectional connection between the first tributary network and the second tributary network in the pig behavior recognition model to achieve the complementarity and efficient fusion of RGB modal features and bone modal features, so as to improve the recognition accuracy and efficiency of pig behavior.
[0005] In order to solve the above technical problems, an embodiment of the present invention provides a pig behavior recognition method based on multimodal features, comprising:
[0006] Based on the video data of the first pig to be identified, obtaining a plurality of first pig images;
[0007] Inputting all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output first pig behavior recognition information corresponding to the first pig video data;
[0008] Among them, the output of the N+1th residual network layer in the first tributary network is connected to the input of the N+1th residual network layer in the second tributary network, and the output of the Nth residual network layer in the second tributary network is connected to the input of the N+2th residual network layer in the first tributary network, N≥1.
[0009] An embodiment of the present invention is implemented to perform multimodal feature extraction on pig images and identify pig behavior in a pig behavior recognition model, which includes a first tributary network and a second tributary network, and the output of the N+1th residual network layer in the first tributary network in the pig behavior recognition model is connected to the input of the N+1th residual network layer in the second tributary network, and the output of the Nth residual network layer in the second tributary network is connected to the input of the N+2th residual network layer in the first tributary network, so as to achieve a bidirectional connection between the first tributary network and the second tributary network in the pig behavior recognition model, so as to efficiently fuse the features of the two modalities, RGB modal features and skeletal modal features, promote information complementarity between the first tributary network and the second tributary network, thereby improving the extraction accuracy of RGB modal features and skeletal modal features. In addition, based on the first pig video data to be identified, several first pig images are obtained, and then all the first pig images are input into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each first pig image to obtain RGB modal features and skeleton modal features, and fuse the RGB modal features and the skeleton modal features to obtain the corresponding first pig behavior recognition information, which can utilize the advantage of skeleton data having strong robustness to changes in light and background, effectively make up for the shortcomings of RGB video images in pig behavior recognition modeling, and further improve the accuracy and robustness of pig behavior recognition.
[0010] As a preferred solution, the first branch network is a SlowOnly network, and the second branch network is a PoseC3D network; all the first pig images are input into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data, specifically:
[0011] Extracting skeleton key points from each of the first pig images to obtain a plurality of two-dimensional skeleton key points corresponding to each of the first pig images, and then mapping the plurality of two-dimensional skeleton key points corresponding to each of the first pig images into a two-dimensional heat map corresponding to each of the first pig images;
[0012] According to the order of frame times corresponding to the first pig images in the first pig video data, stacking the two-dimensional heat maps corresponding to all the first pig images in sequence to form a three-dimensional heat map sequence corresponding to the first pig video data;
[0013] All the first pig images are input into the SlowOnly network so that the SlowOnly network captures spatial detail features of all the first pig images and outputs RGB modal features, and the three-dimensional heat map sequence is input into the PoseC3D network so that the PoseC3D network extracts pig bone features and outputs bone modal features.
[0014] A preferred solution for implementing the embodiment of the present invention is not to use the original skeletal key point coordinates or skeletal graph of the image as the input of the PoseC3D network, but to map multiple two-dimensional skeletal key points extracted from the first pig image into a two-dimensional heat map, and then stack the two-dimensional heat maps at different times along the time dimension to form a three-dimensional heat map sequence as the input of the PoseC3D network, which can increase the robustness of the pig behavior recognition model.
[0015] As a preferred solution, the SlowOnly network includes two two-dimensional convolutional layers, M three-dimensional convolutional layers, a first global average pooling layer and a first fully connected layer, and the two-dimensional convolutional layer and the three-dimensional convolutional layer are both residual network layers; all the first pig images are input into the SlowOnly network, so that the SlowOnly network captures spatial detail features of all the first pig images and outputs RGB modal features, specifically:
[0016] Inputting all the first pig images into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network iteratively extract the detail features of each of the first pig images, and obtaining a first feature map corresponding to the first pig image;
[0017] Iteratively process the first feature map, and input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolutional layer in the SlowOnly network during the Mth iterative process, so that the Mth three-dimensional convolutional layer in the SlowOnly network fuses the spatial information, time information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map;
[0018] The first global average pooling layer and the first fully connected layer are used in sequence to perform global average pooling and fully connected operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
[0019] According to a preferred solution for implementing the embodiment of the present invention, the SlowOnly network uses a lower frame sampling rate but high-resolution input to better capture the spatial detail features of the RGB image. Compared with a single frame input, the SlowOnly network gradually encodes the timing information in a sparse sampling and gradual dimensionality increase manner, effectively learning the data feature distribution of the video data, making the learned RGB modal features more representative in time.
[0020] As a preferred solution, the PoseC3D network includes M+1 residual network layers, a second global average pooling layer, and a second fully connected layer; the three-dimensional heat map sequence is input into the PoseC3D network so that the PoseC3D network extracts pig bone features and outputs bone modal features, specifically:
[0021] Inputting the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map;
[0022] Iteratively process the fourth feature map, and input the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network to the M+1th residual network layer in the PoseC3D network during the Mth iteration, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map;
[0023] The second global average pooling layer and the second fully connected layer are used in sequence to perform global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data.
[0024] According to the preferred solution of the embodiment of the present invention, compared with the typical ST-GCN network, the PoseC3D network is less sensitive to bone data noise and can further promote the fusion of bone modal features with other modal features.
[0025] As a preferred solution, the pig behavior recognition model is obtained by:
[0026] Acquire multiple second pig video data, and continuously acquire a plurality of second pig images from each of the second pig video data according to a preset video frame acquisition frequency, and then pre-process each of the second pig images to obtain a plurality of third pig images corresponding to each of the second pig video data; wherein the pre-processing includes image data cleaning, size cropping, and filtering and denoising processing;
[0027] Performing posture key point recognition and annotation on each of the third pig images, and dividing a plurality of pig skeleton structure recognition areas in each of the third pig images according to the annotation results, and then analyzing the pig behavior category of each of the third pig images based on the plurality of pig skeleton structure recognition areas corresponding to each of the third pig images, so as to serve as the second pig behavior recognition information corresponding to each of the third pig images;
[0028] A plurality of third pig images corresponding to a plurality of second pig video data and second pig behavior identification information corresponding to each of the third pig images are used as a pig behavior estimation data set, and a pre-constructed initial recognition model is trained based on the pig behavior estimation data set to obtain the pig behavior recognition model.
[0029] A preferred scheme for implementing the embodiment of the present invention is to obtain a plurality of third pig images corresponding to each second pig video data based on a plurality of second pig video data, and then perform posture key point recognition and annotation on each third pig image to obtain the pig behavior category of each third pig image, thereby constructing a pig behavior estimation data set, and then use the pig behavior estimation data set to implement training of the initial recognition model to improve the recognition accuracy of the pig behavior recognition model.
[0030] As a preferred solution, the method of obtaining a plurality of first pig images based on the first pig video data to be identified is specifically as follows:
[0031] Shooting a scene to be identified including pigs in real time to obtain first video data of the pigs to be identified, and then continuously acquiring a plurality of fourth pig images from the first video data of the pigs to be identified according to a preset video frame acquisition frequency;
[0032] Preprocessing is performed on each of the fourth pig images to obtain a first pig image corresponding to each of the fourth pig images; wherein the preprocessing includes image data cleaning, size cropping, and filtering and denoising processing.
[0033] The preferred solution of the embodiment of the present invention is to shoot the scene to be identified containing the pigs in real time to obtain the first video data of the pigs to be identified, and then collect the fourth pig images at several consecutive moments from the first video data of the pigs to be identified, so as to facilitate the subsequent analysis of the changes in the posture and behavior of the pigs over a period of time, thereby accurately determining the first pig behavior identification information corresponding to the first pig video data. In addition, the pre-processing of image data cleaning, size cropping and filtering and denoising of each fourth pig image can remove redundant data, unify the size of the model input data and reduce the interference of the background noise of the video image, so as to improve the processing efficiency of the model.
[0034] In order to solve the same technical problem, an embodiment of the present invention further provides a pig behavior recognition system based on multimodal features, comprising:
[0035] An image acquisition module, used for acquiring a plurality of first pig images based on the first pig video data to be identified;
[0036] A behavior recognition module is used to input all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data; wherein the output of the N+1th residual network layer in the first branch network is connected to the input of the N+1th residual network layer in the second branch network, and the output of the Nth residual network layer in the second branch network is connected to the input of the N+2th residual network layer in the first branch network, and N≥1.
[0037] As a preferred solution, the first branch network is a SlowOnly network, and the second branch network is a PoseC3D network; the behavior recognition module specifically includes:
[0038] A key point extraction unit is used to extract skeleton key points from each of the first pig images to obtain a plurality of two-dimensional skeleton key points corresponding to each of the first pig images, and then map the plurality of two-dimensional skeleton key points corresponding to each of the first pig images into a two-dimensional heat map corresponding to each of the first pig images;
[0039] a heat map stacking unit, configured to sequentially stack the two-dimensional heat maps corresponding to all the first pig images in the order of frame times corresponding to the first pig images in the first pig video data, to form a three-dimensional heat map sequence corresponding to the first pig video data;
[0040] A spatial detail feature capturing unit, used for inputting all the first pig images into the SlowOnly network, so that the SlowOnly network captures the spatial detail features of all the first pig images and outputs RGB modal features;
[0041] The pig bone feature extraction unit is used to input the three-dimensional heat map sequence into the PoseC3D network, so that the PoseC3D network extracts pig bone features and outputs bone modal features.
[0042] As a preferred solution, the SlowOnly network includes two two-dimensional convolutional layers, M three-dimensional convolutional layers, a first global average pooling layer and a first fully connected layer, and the two-dimensional convolutional layer and the three-dimensional convolutional layer are both residual network layers; the spatial detail feature capture unit specifically includes:
[0043] a detail feature extraction subunit, configured to input all the first pig images into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network iteratively extract detail features of each of the first pig images, and obtain a first feature map corresponding to the first pig image;
[0044] A first feature fusion subunit is used to iteratively process the first feature map, and input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolutional layer in the SlowOnly network during the Mth iterative processing, so that the Mth three-dimensional convolutional layer in the SlowOnly network fuses the spatial information, time information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map;
[0045] The first pooling operation subunit is used to sequentially use the first global average pooling layer and the first fully connected layer to perform global average pooling and full connection operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
[0046] As a preferred solution, the PoseC3D network includes M+1 residual network layers, a second global average pooling layer, and a second fully connected layer; the pig bone feature extraction unit specifically includes:
[0047] A bone feature extraction subunit, used for inputting the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts the pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map;
[0048] The second feature fusion subunit is used to iteratively process the fourth feature map, and input the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network to the M+1th residual network layer in the PoseC3D network during the M-th iterative processing, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map;
[0049] The second pooling operation subunit is used to use the second global average pooling layer and the second fully connected layer in sequence to perform global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 : A schematic diagram of a flow chart of a pig behavior recognition method based on multimodal features provided in the first embodiment of the present invention;
[0051] Figure 2 : A schematic diagram of the structure of the SlowOnly network provided in the first embodiment of the present invention;
[0052] Figure 3 : A schematic diagram of the structure of a pig behavior recognition model provided in Example 1 of the present invention;
[0053] Figure 4 : A structural diagram of a pig behavior recognition system based on multimodal features provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] Embodiment one:
[0056] Please refer to Figure 1, a pig behavior recognition method based on multimodal features provided by an embodiment of the present invention, the method includes steps S1 to S2, each step is specifically as follows:
[0057] Step S1, acquiring a plurality of first pig images based on the first pig video data to be identified.
[0058] As a preferred solution, step S1 includes step S11 to step S12, and each step is specifically as follows:
[0059] Step S11, shooting the scene to be identified including the pigs in real time to obtain the first video data of the pigs to be identified, and then continuously acquiring a plurality of fourth pig images from the first video data of the pigs to be identified according to a preset video frame acquisition frequency.
[0060] Step S12, pre-processing each fourth pig image to obtain a first pig image corresponding to each fourth pig image.
[0061] Among them, preprocessing includes image data cleaning, size cropping and filtering and denoising.
[0062] Step S2, input all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each first pig image, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data.
[0063] Among them, the output of the N+1th residual network layer in the first tributary network is connected to the input of the N+1th residual network layer in the second tributary network, and the output of the Nth residual network layer in the second tributary network is connected to the input of the N+2th residual network layer in the first tributary network, N≥1.
[0064] It should be noted that the first branch network and the second branch network in the pig behavior recognition model are parallel and bidirectionally connected.
[0065] As a preferred solution, the first branch network is a SlowOnly network, the second branch network is a PoseC3D network, and step S2 includes steps S21 to S24, each of which is as follows:
[0066] Step S21, extracting skeleton key points from each first pig image to obtain a plurality of two-dimensional skeleton key points corresponding to each first pig image, and then mapping the plurality of two-dimensional skeleton key points corresponding to each first pig image into a two-dimensional heat map corresponding to each first pig image.
[0067] Step S22, stacking the two-dimensional heat maps corresponding to all the first pig images in sequence according to the order of the frame times corresponding to the first pig images in the first pig video data, to form a three-dimensional heat map sequence corresponding to the first pig video data.
[0068] In step S23, all the first pig images are input into the SlowOnly network, so that the SlowOnly network captures the spatial detail features of all the first pig images and outputs the RGB modal features, and at the same time, the three-dimensional heat map sequence is input into the PoseC3D network, so that the PoseC3D network extracts the pig bone features and outputs the bone modal features.
[0069] Step S24, fusing the RGB modal features and the bone modal features so that the pig behavior recognition model outputs first pig behavior recognition information corresponding to the first pig video data.
[0070] As a preferred option, please refer to Figure 2 , the SlowOnly network includes two 2D convolutional layers, M 3D convolutional layers, the first global average pooling layer, and the first fully connected layer. Both the 2D convolutional layer and the 3D convolutional layer are residual network layers. The PoseC3D network includes M+1 residual network layers, the second global average pooling layer, and the second fully connected layer. As an example, M is equal to 2. Please refer to Figure 2 , the two two-dimensional convolutional layers in the SlowOnly network are SlowOnlyResNetLayer1 and SlowOnlyResNetLayer2, the two three-dimensional convolutional layers in the SlowOnly network are SlowOnly ResNet Layer3 and SlowOnly ResNet Layer4, the first global average pooling layer in the SlowOnly network is the SlowOnly global average pooling layer, the first fully connected layer in the SlowOnly network is the SlowOnly fully connected layer, the residual network layers in the PoseC3D network are PoseC3D ResNet Layer2, PoseC3D ResNet Layer3 and PoseC3D ResNet Layer4, the second global average pooling layer in the PoseC3D network is the PoseC3D global average pooling layer, and the second fully connected layer in the PoseC3D network is the PoseC3D fully connected layer. Step S23 includes an RGB modality feature acquisition process and a skeletal modality feature acquisition process, and these two processes are performed simultaneously. The RGB modality feature acquisition process includes steps S231 to S233, and the bone modality feature acquisition process includes steps S234 to S236. The specific steps are as follows:
[0071] Step S231, please refer to Figure 2 and Figure 3 , all the first pig images are input into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network, namely, SlowOnly ResNet Layer1 and SlowOnly ResNetLayer2, iteratively extract the detail features of each first pig image to obtain the first feature map corresponding to the first pig image.
[0072] In this embodiment, the size of the first pig image is 64×8×56×56, and the size of the first feature map is 256×8×56×56.
[0073] Step S232, please refer to Figure 2 and Figure 3 , iteratively process the first feature map, and in the Mth iterative process, input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolutional layer in the SlowOnly network, so that the Mth three-dimensional convolutional layer in the SlowOnly network fuses the spatial information, temporal information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map.
[0074] In this embodiment, please refer to Figure 2 and Figure 3After passing through SlowOnly ResNetLayer1 and SlowOnly ResNet Layer2 in the SlowOnly network, SlowOnly ResNet Layer2 outputs the first feature map corresponding to the first pig image, and then in the first iterative processing, the first feature map output by SlowOnly ResNet Layer2 and the output result of the first residual network layer in the PoseC3D network, PoseC3D ResNet Layer2, are jointly input into the next three-dimensional convolutional layer in the SlowOnly network, SlowOnly ResNet Layer3, to fuse the spatial information, temporal information and pig bone features and output the spatiotemporal feature information, and generate a new first feature map based on the current spatiotemporal feature information, and then in the second iterative processing, the current first feature map and the output result of the second residual network layer in the PoseC3D network, PoseC3D ResNet Layer3, are jointly input into the next three-dimensional convolutional layer in the SlowOnly network, SlowOnly ResNet Layer 4, to fuse the spatial information, temporal information and pig bone features again and output new spatiotemporal feature information, so as to update the first feature map again based on the current spatiotemporal feature information. Since the current number of iterations is updated to 3 in the next iteration, which is obviously greater than 2, the iteration is terminated and the current first feature map is used as the second feature map. The size of the second feature map is 2048×8×7×7.
[0075] Step S233, using the first global average pooling layer and the first fully connected layer in sequence, performs global average pooling and full connection operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
[0076] Step S234: input the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map.
[0077] Step S235, iteratively process the fourth feature map. In the Mth iterative process, the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network are input to the M+1th residual network layer in the PoseC3D network, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map.
[0078] Step S236, using the second global average pooling layer and the second fully connected layer in sequence, performing global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data.
[0079] In this embodiment, please refer to Figure 3 , the output of SlowOnly ResNet Layer2 in the SlowOnly network is connected to the input of PoseC3D ResNet Layer3 in the PoseC3D network, the output of SlowOnlyResNet Layer3 in the SlowOnly network is connected to the input of PoseC3D ResNet Layer4 in the PoseC3D network, the output of PoseC3D ResNet Layer2 in the PoseC3D network is connected to the input of SlowOnly ResNet Layer3 in the SlowOnly network, and the output of PoseC3D ResNet Layer3 in the PoseC3D network is connected to the input of SlowOnlyResNet Layer4 in the SlowOnly network, so that the early fusion of the features of the two modalities can be achieved in the early feature extraction stage of the pig behavior recognition model. Compared with the unidirectional horizontal connection, the bidirectional connection can enable the entire fusion model to better learn the spatiotemporal features of different modalities, so that the SlowOnly network and the PoseC3D network can complement each other's information. In addition, after the SlowOnly network extracts the RGB modal features and the PoseC3D network extracts the skeleton modal features, the RGB modal features and the skeleton modal features are fused, that is, the late fusion of the RGB modal features and the skeleton modal features is achieved.
[0080] As a preferred solution, a method for pig behavior recognition based on multimodal features provided in an embodiment of the present invention further includes a process for obtaining a pig behavior recognition model, the process including steps S01 to S03, each of which is specifically as follows:
[0081] Step S01, obtaining a plurality of second pig video data, and continuously collecting a plurality of second pig images from each second pig video data according to a preset video frame acquisition frequency, and then preprocessing each second pig image to obtain a plurality of third pig images corresponding to each second pig video data; wherein the preprocessing includes image data cleaning, size cropping and filtering and denoising processing.
[0082] Step S02, use the labeling software LabelMe tool to identify and label the posture key points of each third pig image, and according to the labeling results, divide the pig body into multiple pig skeleton structure identification areas in each third pig image - 5 areas of head, limbs, back, chest and tail, and then analyze the pig behavior category of each third pig image based on the multiple pig skeleton structure identification areas corresponding to each third pig image, as the second pig behavior identification information corresponding to each third pig image.
[0083] In this embodiment, 20 key points can be marked for each target pig according to preset requirements.
[0084] Step S03, taking a plurality of third pig images corresponding to a plurality of second pig video data and the second pig behavior recognition information corresponding to each third pig image as a pig behavior estimation data set, and training a pre-constructed initial recognition model based on the pig behavior estimation data set to obtain a pig behavior recognition model.
[0085] It should be noted that before training the feature fusion model, this embodiment first pre-trains the two tributary networks respectively, and uses the weights obtained by the training to initialize the feature fusion model, thereby accelerating the convergence speed of the model during feature fusion.
[0086] Please refer to Figure 4 , is a schematic diagram of the structure of a pig behavior recognition system based on multimodal features provided by an embodiment of the present invention, the system includes an image acquisition module M1 and a behavior recognition module M2, and the specific details of each module are as follows:
[0087] An image acquisition module M1 is used to acquire a plurality of first pig images based on the first pig video data to be identified;
[0088] The behavior recognition module M2 is used to input all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each first pig image, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data; wherein, the output of the N+1th residual network layer in the first branch network is connected to the input of the N+1th residual network layer in the second branch network, and the output of the Nth residual network layer in the second branch network is connected to the input of the N+2th residual network layer in the first branch network, and N≥1.
[0089] As a preferred solution, the first branch network is a SlowOnly network, and the second branch network is a PoseC3D network; the behavior recognition module M2 specifically includes a key point extraction unit 21, a heat map stacking unit 22, a spatial detail feature capture unit 23 and a pig bone feature extraction unit 24, and each unit is specifically as follows:
[0090] A key point extraction unit 21 is used to extract skeleton key points from each first pig image to obtain a plurality of two-dimensional skeleton key points corresponding to each first pig image, and then map the plurality of two-dimensional skeleton key points corresponding to each first pig image into a two-dimensional heat map corresponding to each first pig image;
[0091] The heat map stacking unit 22 is used to stack the two-dimensional heat maps corresponding to all the first pig images in sequence according to the order of the frame times corresponding to the first pig images in the first pig video data, so as to form a three-dimensional heat map sequence corresponding to the first pig video data;
[0092] A spatial detail feature capturing unit 23, used for inputting all first pig images into the SlowOnly network, so that the SlowOnly network captures spatial detail features of all first pig images and outputs RGB modal features;
[0093] The pig bone feature extraction unit 24 is used to input the three-dimensional heat map sequence into the PoseC3D network, so that the PoseC3D network extracts pig bone features and outputs bone modal features.
[0094] As a preferred solution, the SlowOnly network includes two two-dimensional convolutional layers, M three-dimensional convolutional layers, a first global average pooling layer and a first fully connected layer, and both the two-dimensional convolutional layer and the three-dimensional convolutional layer are residual network layers; the spatial detail feature capture unit 23 specifically includes a detail feature extraction subunit 231, a first feature fusion subunit 232 and a first pooling operation subunit 233, and each subunit is specifically as follows:
[0095] A detail feature extraction subunit 231 is used to input all first pig images into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network iteratively extract detail features of each first pig image to obtain a first feature map corresponding to the first pig image;
[0096] The first feature fusion subunit 232 is used to iteratively process the first feature map, and input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolution layer in the SlowOnly network during the Mth iterative processing, so that the Mth three-dimensional convolution layer in the SlowOnly network fuses the spatial information, time information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map;
[0097] The first pooling operation subunit 233 is used to sequentially use the first global average pooling layer and the first fully connected layer to perform global average pooling and full connection operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
[0098] As a preferred solution, the PoseC3D network includes M+1 residual network layers, a second global average pooling layer, and a second fully connected layer; the pig bone feature extraction unit 24 specifically includes a bone feature extraction subunit 241, a second feature fusion subunit 242, and a second pooling operation subunit 243, and each subunit is specifically as follows:
[0099] The bone feature extraction subunit 241 is used to input the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts the pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map;
[0100] The second feature fusion subunit 242 is used to iteratively process the fourth feature map, and input the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network to the M+1th residual network layer in the PoseC3D network during the Mth iteration, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map;
[0101] The second pooling operation subunit 243 is used to sequentially use the second global average pooling layer and the second fully connected layer to perform global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data.
[0102] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0103] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0104] The present invention provides a pig behavior recognition method and system based on multimodal features, which is a pig behavior recognition model for extracting multimodal features from pig images and identifying pig behaviors. The model includes a first tributary network and a second tributary network, and the output of the N+1th residual network layer in the first tributary network in the pig behavior recognition model is connected to the input of the N+1th residual network layer in the second tributary network, and the output of the Nth residual network layer in the second tributary network is connected to the input of the N+2th residual network layer in the first tributary network, so as to realize a bidirectional connection between the first tributary network and the second tributary network in the pig behavior recognition model, so as to efficiently fuse the features of the two modalities, RGB modal features and skeletal modal features, promote information complementarity between the first tributary network and the second tributary network, and thus improve the extraction accuracy of the RGB modal features and the skeletal modal features. In addition, based on the first pig video data to be identified, several first pig images are obtained, and then all the first pig images are input into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each first pig image to obtain RGB modal features and skeleton modal features, and fuse the RGB modal features and the skeleton modal features to obtain the corresponding first pig behavior recognition information, which can utilize the advantage of skeleton data having strong robustness to changes in light and background, effectively make up for the shortcomings of RGB video images in pig behavior recognition modeling, and further improve the accuracy and robustness of pig behavior recognition.
[0105] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A pig behavior recognition method based on multimodal features, It is characterized in that include: Based on the video data of the first pig to be identified, obtaining a plurality of first pig images; Inputting all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output first pig behavior recognition information corresponding to the first pig video data; Among them, the output of the N+1th residual network layer in the first tributary network is connected to the input of the N+1th residual network layer in the second tributary network, and the output of the Nth residual network layer in the second tributary network is connected to the input of the N+2th residual network layer in the first tributary network, N≥1.
2. A pig behavior recognition method based on multimodal features as claimed in claim 1, It is characterized in that The first branch network is a SlowOnly network, and the second branch network is a PoseC3D network; all the first pig images are input into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data, specifically: Extracting skeleton key points from each of the first pig images to obtain a plurality of two-dimensional skeleton key points corresponding to each of the first pig images, and then mapping the plurality of two-dimensional skeleton key points corresponding to each of the first pig images into a two-dimensional heat map corresponding to each of the first pig images; According to the order of frame times corresponding to the first pig images in the first pig video data, stacking the two-dimensional heat maps corresponding to all the first pig images in sequence to form a three-dimensional heat map sequence corresponding to the first pig video data; All the first pig images are input into the SlowOnly network so that the SlowOnly network captures spatial detail features of all the first pig images and outputs RGB modal features, and the three-dimensional heat map sequence is input into the PoseC3D network so that the PoseC3D network extracts pig bone features and outputs bone modal features.
3. A pig behavior recognition method based on multimodal features as claimed in claim 2, It is characterized in that The SlowOnly network includes two two-dimensional convolutional layers, M three-dimensional convolutional layers, a first global average pooling layer and a first fully connected layer, wherein the two-dimensional convolutional layer and the three-dimensional convolutional layer are both residual network layers; inputting all the first pig images into the SlowOnly network so that the SlowOnly network captures spatial detail features of all the first pig images and outputs RGB modality features, specifically: Inputting all the first pig images into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network iteratively extract the detail features of each of the first pig images, and obtaining a first feature map corresponding to the first pig image; Iteratively process the first feature map, and input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolutional layer in the SlowOnly network during the Mth iterative process, so that the Mth three-dimensional convolutional layer in the SlowOnly network fuses the spatial information, time information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map; The first global average pooling layer and the first fully connected layer are used in sequence to perform global average pooling and fully connected operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
4. A method for pig behavior recognition based on multimodal features as claimed in claim 3, It is characterized in that The PoseC3D network includes M+1 residual network layers, a second global average pooling layer, and a second fully connected layer; the three-dimensional heat map sequence is input into the PoseC3D network so that the PoseC3D network extracts pig bone features and outputs bone modal features, specifically: Inputting the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map; Iteratively process the fourth feature map, and input the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network to the M+1th residual network layer in the PoseC3D network during the Mth iteration, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map; The second global average pooling layer and the second fully connected layer are used in sequence to perform global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data.
5. A pig behavior recognition method based on multimodal features as claimed in any one of claims 1 to 4, It is characterized in that The pig behavior recognition model is obtained by: Acquire multiple second pig video data, and continuously acquire a plurality of second pig images from each of the second pig video data according to a preset video frame acquisition frequency, and then pre-process each of the second pig images to obtain a plurality of third pig images corresponding to each of the second pig video data; wherein the pre-processing includes image data cleaning, size cropping, and filtering and denoising processing; Performing posture key point recognition and annotation on each of the third pig images, and dividing a plurality of pig skeleton structure recognition areas in each of the third pig images according to the annotation results, and then analyzing the pig behavior category of each of the third pig images based on the plurality of pig skeleton structure recognition areas corresponding to each of the third pig images, so as to serve as the second pig behavior recognition information corresponding to each of the third pig images; A plurality of third pig images corresponding to a plurality of second pig video data and second pig behavior identification information corresponding to each of the third pig images are used as a pig behavior estimation data set, and a pre-constructed initial recognition model is trained based on the pig behavior estimation data set to obtain the pig behavior recognition model.
6. A method for pig behavior recognition based on multimodal features as claimed in claim 1, It is characterized in that The step of obtaining a plurality of first pig images based on the first pig video data to be identified is specifically as follows: Shooting a scene to be identified including pigs in real time to obtain first video data of the pigs to be identified, and then continuously acquiring a plurality of fourth pig images from the first video data of the pigs to be identified according to a preset video frame acquisition frequency; Preprocessing is performed on each of the fourth pig images to obtain a first pig image corresponding to each of the fourth pig images; wherein the preprocessing includes image data cleaning, size cropping, and filtering and denoising processing.
7. A pig behavior recognition system based on multimodal features, It is characterized in that include: An image acquisition module, used for acquiring a plurality of first pig images based on the first pig video data to be identified; A behavior recognition module is used to input all the first pig images into a preset pig behavior recognition model, so that the first branch network and the second branch network in the pig behavior recognition model respectively perform multimodal feature extraction on each of the first pig images, obtain RGB modal features and bone modal features, and fuse the RGB modal features and the bone modal features to output the first pig behavior recognition information corresponding to the first pig video data; wherein the output of the N+1th residual network layer in the first branch network is connected to the input of the N+1th residual network layer in the second branch network, and the output of the Nth residual network layer in the second branch network is connected to the input of the N+2th residual network layer in the first branch network, and N≥1.
8. A pig behavior recognition system based on multimodal features as claimed in claim 7, It is characterized in that The first branch network is a SlowOnly network, and the second branch network is a PoseC3D network; the behavior recognition module specifically includes: A key point extraction unit is used to extract skeleton key points from each of the first pig images to obtain a plurality of two-dimensional skeleton key points corresponding to each of the first pig images, and then map the plurality of two-dimensional skeleton key points corresponding to each of the first pig images into a two-dimensional heat map corresponding to each of the first pig images; a heat map stacking unit, configured to sequentially stack the two-dimensional heat maps corresponding to all the first pig images in the order of frame times corresponding to the first pig images in the first pig video data, to form a three-dimensional heat map sequence corresponding to the first pig video data; A spatial detail feature capturing unit, used for inputting all the first pig images into the SlowOnly network, so that the SlowOnly network captures the spatial detail features of all the first pig images and outputs RGB modal features; The pig bone feature extraction unit is used to input the three-dimensional heat map sequence into the PoseC3D network, so that the PoseC3D network extracts pig bone features and outputs bone modal features.
9. A pig behavior recognition system based on multimodal features as claimed in claim 8, It is characterized in that The SlowOnly network includes two two-dimensional convolutional layers, M three-dimensional convolutional layers, a first global average pooling layer and a first fully connected layer, wherein both the two-dimensional convolutional layer and the three-dimensional convolutional layer are residual network layers; the spatial detail feature capture unit specifically includes: a detail feature extraction subunit, configured to input all the first pig images into the SlowOnly network, so that the two two-dimensional convolutional layers in the SlowOnly network iteratively extract detail features of each of the first pig images, and obtain a first feature map corresponding to the first pig image; A first feature fusion subunit is used to iteratively process the first feature map, and input the current first feature map and the output result of the Mth residual network layer in the PoseC3D network to the Mth three-dimensional convolutional layer in the SlowOnly network during the Mth iterative processing, so that the Mth three-dimensional convolutional layer in the SlowOnly network fuses the spatial information, time information and pig bone features of the current first feature map and outputs the spatiotemporal feature information, and generates a new first feature map based on the current spatiotemporal feature information, until the current number of iterations is greater than M, then the current first feature map is used as the second feature map; The first pooling operation subunit is used to sequentially use the first global average pooling layer and the first fully connected layer to perform global average pooling and full connection operations on the second feature map to obtain a third feature map corresponding to the second feature map as the RGB modal feature corresponding to the first pig video data.
10. A pig behavior recognition system based on multimodal features as claimed in claim 9, It is characterized in that The PoseC3D network includes M+1 residual network layers, a second global average pooling layer, and a second fully connected layer; the pig bone feature extraction unit specifically includes: A bone feature extraction subunit, used for inputting the three-dimensional heat map sequence into the PoseC3D network, so that the first residual network layer in the PoseC3D network extracts the pig bone features from the three-dimensional heat map sequence and outputs a fourth feature map; The second feature fusion subunit is used to iteratively process the fourth feature map, and input the current fourth feature map and the output result of the M+1th three-dimensional convolutional layer in the SlowOnly network to the M+1th residual network layer in the PoseC3D network during the M-th iterative processing, so that the M+1th residual network layer in the PoseC3D network performs pig bone feature extraction and spatiotemporal feature fusion on the current fourth feature map and outputs a new fourth feature map, until the current number of iterations is greater than M, then the current fourth feature map is used as the fifth feature map; The second pooling operation subunit is used to use the second global average pooling layer and the second fully connected layer in sequence to perform global average pooling and full connection operations on the fifth feature map to obtain a sixth feature map corresponding to the fifth feature map as the skeletal modal feature corresponding to the first pig video data.
Citation Information
Patent Citations
Video-based pig behavior recognition system and method
CN113763429A
