Cattle target detection method and equipment based on RCNN
By introducing dilated deformable convolution and feature pyramid into RCNN, the problem of low detection accuracy and occlusion in cattle target detection is solved, efficient cattle feature extraction and management is achieved, and the efficiency of cattle farm management is improved.
Patent Information
- Application Number
- CN202111078288.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-09-15
AI Technical Summary
The existing technology has low detection accuracy, poor real-time performance and occlusion problems in cattle target detection. It is difficult to deal with the complex background and dense environment between cattle groups, which affects the efficiency of cattle farm management.
The cattle herd target detection method based on RCNN is used to build an improved neural network target detection model by adding dilated deformable convolutions to the feature extraction backbone network and combining the feature pyramid to deeply fuse the feature information of each layer to reduce occlusion interference. and enhance feature extraction capabilities.
It improves the accuracy and spatial resolution of cattle detection, enhances the distinction between cattle and background, enables accurate inventory and real-time visual monitoring of cattle numbers, and improves cattle farm management efficiency.
Smart Images

Figure CN113780193B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a cattle target detection method and device based on an expansion-deformable convolution-cascade RCNN network (Expansion-Deformable Convolutional Networks-Cascade Recurrent Convolutional Neural Networks, E-DCN-Cascade RCNN). Background Art
[0002] In the existing technology, in recent years, as the animal husbandry industry has developed towards scale, informatization and refinement, intensive cattle farms will gradually replace small-scale farming models such as individual farming. In large-scale cattle farms, in order to achieve refined management of individual cattle and track the health status of each cattle, it is necessary to build and improve the quality traceability system, and the key lies in the identification of individual cattle. The premise of identity identification is to perform target detection on the cattle herd, and then perform individual cattle identification when the target detection has a high enough accuracy.
[0003] At present, target detection tasks are mainly divided into traditional target detection and deep learning target detection. Traditional target detection is mainly Histogram of Oriented Gradient (HOG) + Support Vector Machine (SVM). The descriptor generation process in HOG takes a long time, resulting in slow speed, poor real-time performance, and difficulty in handling occlusion problems between cattle. In recent years, with the development of deep learning, target detection performance has been continuously optimized and improved. Researchers use Recurrent Convolutional Neural Networks (RCNN) for target detection and have achieved good results. However, since each candidate area generated by the selective search algorithm must perform forward propagation of the convolutional network (ConvNet), the detection speed is very slow. Some people proposed to use Fast RCNN to extract features from images first and then select candidate regions, thus avoiding multiple convolutions and having a higher detection speed than RCNN. Later, researchers used Faster RCNN for target detection. Since Faster RCNN uses region proposal networks (RPN) instead of the original selection search algorithm, it has a certain improvement in comprehensive performance compared to Fast RCNN, especially in terms of detection speed. In animal husbandry, the above algorithms are rarely used for cattle detection. The reason is that the cattle target detection is complicated due to the large size of cattle, the relatively dense cattle, the severe occlusion, and the cattle body is very similar to the background of the cattle shed, without a relatively high degree of distinction, which brings certain difficulties to the detection. The above detection method does not take into account that the background is relatively close to the detection target, resulting in poor detection performance and affecting the efficiency of cattle management.
[0004] Therefore, how to improve the detection model's target feature extraction capability and reduce background noise interference to ensure the accuracy of cattle target detection is a direction that researchers in this field need to study. Summary of the invention
[0005] One purpose of the present application is to provide a cattle target detection method and device based on RCNN to solve the problem in the prior art of how to improve the accuracy of cattle target detection, visualize and monitor the cattle situation in real time, and thus achieve efficient management of cattle farms.
[0006] According to one aspect of the present application, a method for detecting cattle targets based on RCNN is provided, comprising:
[0007] Get the current herd image;
[0008] Constructing a neural network target detection model, including a feature extraction backbone network, a feature pyramid, and a cascade detector, adding an expanded deformable convolution to the feature extraction backbone network, and combining the feature pyramid to deeply fuse feature information of each layer to obtain an improved neural network target detection model;
[0009] The acquired current cattle herd image is input into the improved neural network target detection model to detect the target object to be detected to obtain a detection result.
[0010] Furthermore, in the above cattle target detection method, before constructing the neural network target detection model, the method further includes:
[0011] Acquire at least two cattle herd training images, and mark the position of each cattle in each of the cattle herd training images to obtain a cattle herd data set;
[0012] The cattle herd data set is divided into a cattle herd training set and a cattle herd test set according to a preset ratio.
[0013] Furthermore, in the above cattle target detection method, the dilated deformable convolution is added to the feature extraction backbone network, and the feature information of each layer is deeply fused in combination with the feature pyramid to obtain an improved neural network target detection model, including:
[0014] The cattle herd training set is made into the COCO data set format and input into the feature extraction backbone network. In the 3rd, 4th and 5th convolutional layers, the original feature map outputted by each layer is passed through the deformable-expanded convolutional layer to obtain the cattle herd initial feature set corresponding to conv2_x, conv3_x, conv4_x and conv5_x;
[0015] After the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, a cattle herd feature atlas is obtained;
[0016] The optimal intersection-over-union ratio threshold of the cascade detector is determined, and the cattle herd feature atlas is input into the region candidate network for detection using the cascade detector to obtain an improved neural network target detection model.
[0017] Furthermore, in the above cattle target detection method, the cattle training set is made into the COCO data set format and input into the feature extraction backbone network. In the 3rd, 4th and 5th convolutional layers, the original feature map output by each layer is passed through the deformable-expanded convolutional layer to obtain the cattle initial feature map set corresponding to conv2_x, conv3_x, conv4_x and conv5_x, including:
[0018] Adding offsets to the convolutions with dilation rates r=1 and r=2 respectively forms a first deformable convolution kernel and a second deformable convolution kernel;
[0019] The first deformable convolution kernel and the second deformable convolution kernel are respectively convolved with the original feature map output by each of the third, fourth and fifth convolution layers, and then a 1×1 convolution kernel is used to perform a dimensionality reduction operation to obtain an initial feature map of the herd of cattle of the same size as the original feature map;
[0020] The feature map output by the conv2_x layer and all the initial feature maps of the herd output by conv3_x, conv4_x, and conv5_x are taken as the initial feature map set of the herd.
[0021] Furthermore, in the above cattle target detection method, after the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, a cattle feature atlas is obtained, including:
[0022] For the initial feature atlas of the cattle group, doubly sample the cattle body feature maps from a higher pyramid level according to a top-down path;
[0023] By laterally connecting and fusing the cow body feature maps of the same spatial size from the top-down path, a cow herd feature atlas is obtained.
[0024] Furthermore, in the above cattle target detection method, the optimal intersection-over-union ratio threshold of the cascade detector is determined, the cattle feature atlas is input into the region candidate network and the cascade detector is used for detection to obtain an improved neural network target detection model, including:
[0025] The cascade detector includes a first detector, a second detector, and a third detector, each of which includes a region of interest matching, a fully connected layer, a frame regression, and a classification score, and determines an optimal intersection-over-union ratio threshold of the first detector, an optimal intersection-over-union ratio threshold of the second detector, and an optimal intersection-over-union ratio threshold of the third detector, wherein the optimal intersection-over-union ratio threshold increases step by step;
[0026] Inputting the cattle herd feature atlas into the first detector, performing candidate target region sampling and frame regression in the first detector to obtain a first candidate frame and a first classification score;
[0027] Inputting the cattle herd feature atlas and the first candidate box and the first classification score corresponding thereto into a second detector, and obtaining a second candidate box and a second classification score in the second detector by resampling the candidate target area and performing frame regression;
[0028] The cattle herd feature atlas and its corresponding second candidate box and second classification score are input into a third detector, and a third candidate box and a third classification score are obtained in the third detector through candidate target area resampling and border regression as the final detection result.
[0029] Furthermore, in the above cattle target detection method, after inputting the acquired current cattle image into the improved neural network target detection model to detect the target object to be detected and obtain the detection result, it also includes:
[0030] The location information of each target object to be detected and the total number of cattle are displayed.
[0031] According to another aspect of the present application, a computer-readable medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are processed and executed, the processor can implement the robot behavior decision method as described above.
[0032] According to another aspect of the present application, a cattle target detection device based on RCNN is also provided, the device comprising:
[0033] one or more processors;
[0034] A computer readable medium for storing one or more computer readable instructions,
[0035] When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the above-mentioned robot flexible behavior decision method. Compared with the prior art, the present application obtains the current cattle herd image; constructs a neural network target detection model, including a feature extraction backbone network, a feature pyramid and a cascade detector, adds an expansion deformable convolution to the feature extraction backbone network, and combines the feature pyramid to deeply fuse the feature information of each layer to obtain an improved neural network target detection model; inputs the obtained current cattle herd image into the neural network target detection model to detect the target object to be detected to obtain the detection result. That is, the deformable convolution can fit the convolution area around the cattle body, reduce the interference of occlusion on the cattle body features, and put more weight on the cattle body features, increase the contrast with the cattle shed background information, and combine the feature pyramid to deeply fuse the feature information, so as to obtain feature information of different ranges, enhance the cattle body features of the occluded cattle herd, and improve the spatial resolution, thereby improving the accuracy of cattle herd detection, ensuring the efficiency of cattle farm management, accurately counting the number of cattle herds, and monitoring the number of cattle herds in real time through visualization means. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0037] Figure 1 A schematic diagram showing a process of a cattle target detection method based on RCNN according to one aspect of the present application is shown;
[0038] Figure 2 A cattle herd training image captured from a monitoring device in an embodiment of a cattle herd target detection method based on RCNN according to one aspect of the present application is shown;
[0039] Figure 3 A network structure diagram of an improved neural network target detection model of a cattle target detection method based on RCNN according to one aspect of the present application is shown;
[0040] Figure 4 A deformable-dilated convolution fusion structure diagram with dilation rates r=1 and r=2 in an embodiment of a cattle target detection method based on RCNN according to one aspect of the present application is shown;
[0041] Figure 5 A detection effect diagram of an embodiment of a cattle target detection method based on RCNN according to one aspect of the present application is shown.
[0042] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0043] The present application is described in further detail below in conjunction with the accompanying drawings.
[0044] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (such as a central processing unit (CPU), an input / output interface, a network interface and a memory.
[0045] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0046] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, Phase-Change RAM (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of random access memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0047] Figure 1 A flow chart of a cattle target detection method based on RCNN according to one aspect of the present application is shown. The method is applicable to various livestock detection and visual management, and may be, but is not limited to, cattle target detection and visual management. The method includes step S1, step S2 and step S3, which specifically include:
[0048] Step S1, obtaining the current cattle herd image;
[0049] Step S2, constructing a neural network target detection model, including a feature extraction backbone network, a feature pyramid, and a cascade detector, adding an expanded deformable convolution to the feature extraction backbone network, and combining the feature pyramid to deeply fuse the feature information of each layer to obtain an improved neural network target detection model;
[0050] Step S3, inputting the acquired current cattle herd image into the improved neural network target detection model to detect the target object to be detected to obtain a detection result.
[0051] In the above steps S1 to S3, the current cattle herd image is first obtained; then, a neural network target detection model is constructed, including a feature extraction backbone network, a feature pyramid, and a cascade detector, an expansion deformable convolution is added to the feature extraction backbone network, and the feature information of each layer is deeply fused in combination with the feature pyramid to obtain an improved neural network target detection model; finally, the obtained current cattle herd image is input into the neural network target detection model to detect the target object to be detected to obtain a detection result. That is, the deformable convolution can fit the convolution area around the cattle body, reduce the interference of occlusion on the cattle body features, and put more weight on the cattle body features, increase the contrast with the cattle shed background information, which is conducive to the extraction of cattle body features, and at the same time, the deep fusion of feature information in combination with the feature pyramid can obtain feature information of different ranges, enhance the cattle body features of the occluded cattle herd, and improve the spatial resolution, thereby improving the accuracy of cattle herd detection, ensuring the efficiency of cattle farm management, accurately counting the number of cattle herds, and monitoring the number of cattle herds in real time through visualization means.
[0052] For example, the current cattle herd image P of the cattle farm is collected by placing a video surveillance device on the top of the cattle shed. A neural network target detection model M is constructed, including a feature extraction backbone network, a feature pyramid, and a cascade detector. An expansion deformable convolution is added to the feature extraction backbone network, and the feature information of each layer is deeply fused in combination with the feature pyramid to obtain an improved neural network target detection model M'. Then, the acquired current cattle herd image P is input into the improved neural network target detection model M' to detect the target object to be detected to obtain the detection result, which improves the distinction between the cattle body and the cattle shed background, overcomes the mutual occlusion between the cattle bodies and the resulting missed detection problem, thereby enhancing the detection accuracy and realizing visual monitoring and management of the cattle farm.
[0053] Following the above embodiment, the method further includes:
[0054] Acquire at least two cattle herd training images, and mark the position of each cattle in each of the cattle herd training images to obtain a cattle herd data set;
[0055] The cattle herd data set is divided into a cattle herd training set and a cattle herd test set according to a preset ratio for model training.
[0056] For example, a herd of cattle training image is captured from a monitoring device installed on the top of a cowshed. The image size is 1280×720. Figure 2 As shown. Use annotation software to annotate the cattle in the cattle farm to obtain cattle labels and cattle position coordinates. A total of 1200 images are annotated as a data set, of which 1000 are training sets and 200 are test sets. This facilitates the subsequent steps to improve and train the neural network target detection model.
[0057] Following the above embodiment, in step S2, an expanded deformable convolution is added to the feature extraction backbone network, and the feature information of each layer is deeply fused in combination with the feature pyramid to obtain an improved neural network target detection model, including:
[0058] The cattle training set is made into the COCO dataset format and input into the feature extraction backbone network. In the 3rd, 4th and 5th convolutional layers, the original feature maps output by each layer are subjected to the deformable-expanded convolutional layer to obtain the cattle initial feature sets corresponding to conv2_x, conv3_x, conv4_x and conv5_x. Here, the feature extraction backbone network E-DCN-Resnet101 is mainly composed of five parts, including a convolution block conv1 and four residual blocks conv2_x, conv3_x, conv4_x and conv5_x, and the number of the four residual blocks is 3, 4, 23 and 3 respectively. Among them, conv1 contains 1 7×7 convolution layer, 1 maximum pooling layer, 1 ReLU activation function layer and 1 BN layer (batch normalization layer). Conv2_x contains 2 1×1 convolution layers, a 3×3 convolution layer, 3 ReLU activation function layers and a BN layer. conv3_x, conv4_x, and conv5_x contain two 1×1 convolutional layers, two 3×3 E-DCN layers, three ReLU activation function layers, and a BN layer, respectively.
[0059] After the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, a cattle herd feature atlas is obtained;
[0060] The optimal intersection-over-union ratio threshold of the cascade detector is determined, and the cattle herd feature atlas is input into the region candidate network for detection using the cascade detector to obtain an improved neural network target detection model.
[0061] For example, in order to improve the receptive field of cow body features, obtain information of different ranges and sizes of the cow body, and obtain the spatial perception of cow body features, after E-DCN-Resnet101 extracts features, deformable-dilated convolution is used in conv3_x, conv4_x, and conv5_x of the feature extraction backbone network. Before and after use, the corresponding feature map size (C×W×H) is kept unchanged, which is 128×28×28, 256×14×14, and 512×7×7, respectively. The output of the last layer of conv2_x, conv3_x, conv4_x, and conv5_x is used as the initial feature set of the herd {F2, F3, F4, F5} of the feature pyramid; after the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, the herd feature atlas {P2, P3, P4, P5} is obtained; the optimal intersection-over-union ratio threshold of the cascade detector is determined, and the herd feature atlas is input into the region candidate network and detected using the cascade detector to obtain the improved neural network target detection model M', as shown in Figure 3 The network structure diagram of the improved neural network target detection model is shown.
[0062] Following the above embodiment, the cattle training set is made into the COCO data set format and input into the feature extraction backbone network. In the 3rd, 4th and 5th convolutional layers, the original feature map output by each layer is subjected to a deformable-expanded convolutional layer to obtain the cattle initial feature map set corresponding to conv2_x, conv3_x, conv4_x and conv5_x, including:
[0063] The convolutions with dilation rates r=1 and r=2 are offset respectively to form the first deformable convolution kernel C1 and the second deformable convolution kernel C2; the present invention selects the deformable-dilated convolutions with dilation rates r=1 and r=2 as the optimal dilation rate values, which can obtain feature information in different ranges, increase the receptive field, and overcome the problem of reduced spatial resolution. Here, Figure 4 As shown in the figure, for a standard convolution kernel K1 with a size of 3×3 and a dilation rate of r=1, a regular grid R is used to sample the input feature map, and then the sampled values are weighted and summed. Define R={(-1,-1), (-1,0),..., (0,1), (1,1)}, representing the nine positions of the convolution kernel. For each position of the input feature image, the following convolution operation is performed, and the weighted sum is expressed as:
[0064]
[0065] Among them, P n is each position of the convolution kernel. For a 3×3 convolution kernel, there are 9 positions in total. The value range of n is 1, 2, 3...9, which corresponds to the 9 positions in R. w is the convolution kernel, and x is the feature map.
[0066] In order to make the convolution area fit the cow body and make the cow body and the cowshed background more distinguishable, a deformable convolution is introduced based on the standard convolution principle, and the deformable convolution kernel is C1. An offset is added to the original convolution sampling, and the weighted summation result y′(P 0 ) is adjusted to:
[0067]
[0068] Among them, {ΔP n |n=1,...,N,N=|R|}, where the offset ΔP n It is not necessarily an integer pixel, it is likely to be a decimal. Here we use the bilinear interpolation method to round it up:
[0069] x(p)=∑ q max(0, 1-|q x -p x |)·max(0,1-|q y -p y |)·x(q) (3)
[0070] In formula (3), p = P 0 +P n +ΔP n is an arbitrary position; q represents the spatial position of all integers on the feature map.
[0071] After obtaining the feature map x(p) after deformable convolution, E-DCN first adds an offset to the convolution kernels with dilation rate r=1 and dilation rate r=2 to form deformable convolution kernels K1 and K2. This offset is learned in the subsequent back propagation, and the specific shape of the convolution area is aggregated to the shape of the cow body.
[0072] The first deformable convolution kernel and the second deformable convolution kernel are respectively convolved with the original feature maps output by each of the 3rd, 4th and 5th convolution layers and fused, and then a 1×1 convolution kernel is used to perform a dimensionality reduction operation to obtain an initial feature map of the herd of cattle of the same size as the original feature map; K1 and K2 are respectively convolved with a feature map of size C×W×H to obtain two feature maps of size 2C×W×H. 1 (p)( Figure 4 F1) and x 2 (p)( Figure 4 F2), change x 1 (p) and x 2(p) After the concat method is used to fuse, a feature of size 4C×W×H is obtained. Then, a 1×1 convolution kernel is used for dimensionality reduction to obtain a feature of size C×W×H to ensure that the fused feature matches the feature obtained by the subsequent convolution operation. The final fused feature Q can be expressed by formula (4):
[0073] Q=f 1×1 (C cancat (x 1 (p)*G dcn (K 1 )+x 2 (p)*G dcn (K 2 ))) (4)
[0074] Where x 1 (p) and x 2 (p) are the features obtained by deformable convolution kernels with expansion rate r = 1 and r = 2, respectively. K1 and K2 are 3×3 convolution kernels with r = 1 and r = 2, respectively. G dcn (·) represents a deformable convolution operation, * represents a convolution operation, C concat (·) represents the concat operation, f 1×1 (·) indicates the use of a 1×1 convolution kernel to change the number of feature channels.
[0075] The feature map output by the conv2_x layer and all the initial feature maps of the herd output by conv3_x, conv4_x, and conv5_x are taken as the initial feature map set of the herd {F2, F3, F4, F5}.
[0076] Following the above embodiment, in the above method, after the feature information of each layer is subjected to multi-scale fusion at different levels through the feature pyramid, a cattle herd feature atlas is obtained, including:
[0077] For the initial feature atlas of the cattle group, doubly sample the cattle body feature maps from a higher pyramid level according to a top-down path;
[0078] By laterally connecting and fusing the cow body feature maps of the same spatial size from the top-down path, a cow herd feature atlas is obtained.
[0079] For example, after the backbone network E-DCN-Resnet101 extracts features, the output of the last layer of the backbone network is used as the initial feature set of the cattle group {F2, F3, F4, F5} of the feature pyramid. According to the top-down path, the spatially coarse but semantically robust cattle body feature map is doubled upsampled from the higher pyramid level to obtain higher resolution features. These cattle body features are then enhanced by horizontally connecting the top-down path. Each horizontal connection fuses the cattle body feature maps of the same spatial size from the top-down path to obtain a cattle group feature map set {P2, P3, P4, P5} with multi-layer perception, and inputs it into the RPN for classification and bounding box regression.
[0080] Following the above embodiment, in the above method, the optimal intersection-over-union ratio threshold of the cascade detector is determined, the cattle herd feature atlas is input into the region candidate network and the cascade detector is used for detection to obtain an improved neural network target detection model, including:
[0081] The cascade detector includes a first detector, a second detector, and a third detector, each of which includes a region of interest matching, a fully connected layer, a frame regression, and a classification score, and determines an optimal intersection-over-union ratio threshold of the first detector, an optimal intersection-over-union ratio threshold of the second detector, and an optimal intersection-over-union ratio threshold of the third detector, wherein the optimal intersection-over-union ratio threshold increases step by step;
[0082] Inputting the cattle herd feature atlas into the first detector, performing candidate target region sampling and frame regression in the first detector to obtain a first candidate frame and a first classification score;
[0083] Inputting the cattle herd feature atlas and the first candidate box and the first classification score corresponding thereto into a second detector, and obtaining a second candidate box and a second classification score in the second detector by resampling the candidate target area and performing frame regression;
[0084] The cattle herd feature atlas and its corresponding second candidate box and second classification score are input into a third detector, and a third candidate box and a third classification score are obtained in the third detector through candidate target area resampling and border regression as the final detection result.
[0085] For example, the cattle feature atlas enters the cascade detector after entering the RPN. In the detection stage, the cascade detector is used for inspection. Three detectors are used, each of which contains ROI Align (region of interest matching), fully connected layer FC, classification score C and frame regression B. During detection, the candidate target area is resampled by the frame regression B output by the previous detector, that is, the candidate target area is resampled by the frame regression B output by the previous detector during detection, that is, the candidate frame output by the previous regression network is used as the input of the next detector to continue regression. According to the characteristics of the cattle body, the optimal intersection-over-union thresholds of the first detector, the second detector, and the third detector are obtained from a large amount of experimental data from 0.5 to 0.6 and then to 0.7, respectively. The intersection-over-union (IOU) threshold is gradually cascaded to improve with better accuracy. Specifically, when IOU is set to 0.5, candidate box B1 and classification score C1 are obtained through regression in ROI Align1. Then, the IOU threshold is increased to 0.6 and B1 is input into ROI Align2 for regression to obtain the updated candidate box B2 and classification score C2. Finally, IOU is increased to 0.7 and B1 is input into ROI Align3 for regression to obtain the final candidate box B3 and classification score C3, which ultimately improves the cattle detection effect. By cascading the output of such detectors, the accuracy of each detector is improved a little bit, which is used as the input of the next higher accuracy, and the accuracy of the network output is gradually further improved.
[0086] Following the above embodiment, in the detection method, after the step S3 inputs the acquired current cattle herd image into the neural network target detection model to detect the target object to be detected and obtains the detection result, it also includes:
[0087] Display the location information of each target object to be detected and the total number of cattle, such as Figure 4 As shown, it is conducive to the visual supervision of cattle farms, improving the efficiency of cattle farm management, and accurately counting the number of cattle. Figure 5 shown.
[0088] Following the above embodiment, during the back propagation process, the loss function of the network in the present invention is the sum of the classification loss and the regression loss, and its expression is as follows:
[0089]
[0090] Where i is the anchor frame sequence; p i is the confidence that the i-th anchor box contains a cow; is the true value of whether the i-th anchor box contains a cow. If it contains a cow, then is 1, otherwise it is 0; t iIt is the four coordinate parameters for predicting the i-th anchor box; N represents the real coordinate parameters corresponding to the i-th anchor box containing the cow; cls is the total number of samples in a batch, N reg is the total number of anchor boxes, and λ is the balance ratio parameter for classification and regression.
[0091] In formula (5), L cls is the classification loss, and its expression is:
[0092]
[0093] In formula (5), L reg is Smooth L1 Loss, and its expression is:
[0094]
[0095] In formula (7), S is the smooth function, and its expression is:
[0096]
[0097] In summary, the present application obtains the current cattle image; constructs a neural network target detection model, including a feature extraction backbone network, a feature pyramid and a cascade detector, adds an expansion deformable convolution to the feature extraction backbone network, and combines the feature pyramid to deeply fuse the feature information of each layer to obtain an improved neural network target detection model; the obtained current cattle image is input into the neural network target detection model to detect the target object to be detected to obtain the detection result. That is, the deformable convolution can fit the convolution area around the cattle body, reduce the interference of occlusion on the cattle body features, and put more weight on the cattle body features, increase the contrast with the cattle shed background information, and combine the feature pyramid to deeply fuse the feature information, so as to obtain feature information of different ranges, enhance the cattle body features of the occluded cattle, and improve the spatial resolution, thereby improving the accuracy of cattle herd detection, ensuring the efficiency of cattle farm management, accurately counting the number of cattle herds, and monitoring the number of cattle herds in real time through visualization means.
[0098] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0099] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present application, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments according to the present application.
[0100] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A cattle target detection method based on RCNN, RCNN is a regional convolutional neural network, characterized in that: The method comprises: Get the current herd image; A neural network target detection model is constructed, including a feature extraction backbone network, a feature pyramid, and a cascade detector. An expanded deformable convolution is added to the feature extraction backbone network, and the feature information of each layer is deeply fused in combination with the feature pyramid to obtain an improved neural network target detection model, including: The cattle training set is made into the COCO data set format and input into the feature extraction backbone network. The 2nd, 3rd, 4th and 5th convolutional layers in the feature extraction backbone network respectively include 3 conv2_x, 4 conv3_x, 23 conv4_x and 3 conv5_x, conv2_x includes 2 1×1 convolutional layers, 1 3×3 convolutional layer, 3 ReLU activation function layers and BN layers, conv3_x, conv4_x, conv5_x respectively include 2 1×1 convolutional layers, 2 3×3 E-DCN layers, 3 ReLU activation function layers and BN layers; in the 3rd, 4th and 5th convolutional layers, the original feature map output by each layer is passed through the deformable-expanded convolutional layer to obtain the cattle initial feature set corresponding to conv2_x, conv3_x, conv4_x and conv5_x, including: The convolutions with expansion rates r=1 and r=2 are offset respectively to form the first deformable convolution kernel and the second deformable convolution kernel; the first deformable convolution kernel and the second deformable convolution kernel are respectively convolved with the original feature maps output by each of the 3rd, 4th and 5th convolution layers and fused, and then a 1×1 convolution kernel is used to perform a dimensionality reduction operation to obtain an initial feature map of the herd of cattle of the same size as the original feature map; the feature map output by the conv2_x layer and all the initial feature maps of the herd of cattle output by conv3_x, conv4_x and conv5_x are used as the initial feature map set of the herd of cattle, The final fused feature map Q can be expressed by the formula: Q=f 1×1 (C concat (x1(p)*G dcn (K1)+x2(p)*G dcn (K2))) Where x1(p) and x2(p) are the features obtained by deformable convolution kernels with dilation rate r=1 and r=2, respectively. K1 and K2 are 3×3 convolution kernels with r=1 and r=2, respectively. G dcn (·) represents a deformable convolution operation, * represents a convolution operation, C concat (·) represents the concat operation, f 1×1 (·) indicates the use of 1×1 convolution kernel convolution operation, which is used to change the number of feature channels; The acquired current cattle herd image is input into the improved neural network target detection model to detect the target object to be detected to obtain a detection result.
2. The method according to claim 1, characterized in that Before constructing the neural network target detection model, the following steps are also included: Acquire at least two cattle training images, and mark the position of each cattle in each of the cattle training images to obtain a cattle data set; The cattle herd data set is divided into a cattle herd training set and a cattle herd test set according to a preset ratio.
3. The method according to claim 2, characterized in that The improved neural network target detection model is obtained by adding an expanded deformable convolution to the feature extraction backbone network and combining the feature pyramid to deeply fuse the feature information of each layer, including: After the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, a cattle herd feature atlas is obtained; The optimal intersection-over-union ratio threshold of the cascade detector is determined, and the cattle herd feature atlas is input into the region candidate network for detection using the cascade detector to obtain an improved neural network target detection model.
4. The method according to claim 3, characterized in that After the feature pyramid performs multi-scale fusion of the feature information of each layer at different levels, a cattle herd feature atlas is obtained, including: After the feature extraction backbone network extracts features, the last layer outputs of conv2_x, conv3_x, conv4_x, and conv5_x are used as the initial feature set {F2, F3, F4, F5} of the cattle herd of features pyramid, and the cattle body feature map is double-upsampled from a higher pyramid level according to a top-down path for the initial feature set of the cattle herd; The cow body feature maps of the same spatial size from the top-down path are fused through lateral connections between the feature maps.
5. The method according to claim 4, characterized in that The step of determining the optimal intersection-over-union ratio threshold of the cascade detector, inputting the herd feature atlas into the region candidate network and using the cascade detector for detection to obtain an improved neural network target detection model includes: The cascade detector includes a first detector, a second detector, and a third detector, each detector includes a region of interest matching, a fully connected layer, a frame regression, and a classification score, and determines an optimal intersection-and-union threshold of the first detector, an optimal intersection-and-union threshold of the second detector, and an optimal intersection-and-union threshold of the third detector, wherein the optimal intersection-and-union threshold of the first detector is less than the optimal intersection-and-union threshold of the second detector, and the optimal intersection-and-union threshold of the second detector is less than the optimal intersection-and-union threshold of the third detector; Inputting the cattle herd feature atlas into the first detector, performing candidate target region sampling and frame regression in the first detector to obtain a first candidate frame and a first classification score; Inputting the cattle herd feature atlas and the first candidate box and the first classification score corresponding thereto into a second detector, and obtaining a second candidate box and a second classification score in the second detector by resampling the candidate target area and performing frame regression; The cattle herd feature atlas and its corresponding second candidate box and second classification score are input into a third detector, and a third candidate box and a third classification score are obtained in the third detector through candidate target area resampling and border regression as the final detection result.
6. The method according to any one of claims 1 to 5, characterized in that After inputting the acquired current cattle herd image into the improved neural network target detection model to detect the target object to be detected and obtain the detection result, the method further includes: The location information of each target object to be detected and the total number of cattle are displayed.
7. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to enable the processor to implement the method according to any one of claims 1 to 6.
8. A cattle target detection device based on RCNN, RCNN is a regional convolutional neural network, characterized in that: The equipment includes: one or more processors; A computer readable medium for storing one or more computer readable instructions, When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
