Method and device for detecting abalone seedlings using horizontal cross-scale fusion query matrix
Through the horizontal cross-scale fusion query matrix detection method, combined with deep learning technology, the problem of low detection accuracy and speed in a dense environment of abalone seedlings is solved, efficient detection of densely occluded abalone seedlings is achieved, and detection accuracy and speed are improved.
Patent Information
- Application Number
- CN202411080516.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-08-08
AI Technical Summary
In the intensive breeding environment of abalone seedlings, it is difficult for existing detection technology to accurately count densely obscured small targets, resulting in low detection accuracy and speed.
The horizontal cross-scale fusion query matrix detection method is adopted. By establishing abalone seedling data set and using the fusion cross-scale query matrix algorithm, combined with the backbone network, feature pyramid FPN module and DGAM module, the calculation amount is reduced and the detection accuracy is improved.
It significantly improves the detection accuracy and speed of abalone seedlings under dense occlusion. It can effectively detect dense and mutually occluded young abalone, reduces the workload of manual annotation, and improves the detection accuracy and speed.
Smart Images

Figure CN118609170B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method and a special device for detecting abalone seedlings by utilizing a horizontal cross-scale fusion query matrix, and belongs to the technical field of computer vision. Background Art
[0002] In the cultivation of abalone, the number of abalone seedlings required is strictly controlled, because the density of abalone seedlings is high, which causes insufficient bait and slow growth of young abalone, affecting production efficiency. In order to monitor the number of abalone seedlings, those skilled in the art apply convolutional neural networks to abalone seedling detection and counting to improve the accuracy and speed of detection. However, since the number of cultivated abalone seedlings is relatively large and dense, the abalone seedlings will be blocked from each other. When detecting abalone seedlings, the abalone seedlings themselves are relatively small, resulting in a low accuracy of detection. Therefore, how to improve the accuracy of detection becomes an important topic. Summary of the invention
[0003] In order to improve the accuracy of abalone seedling detection, a method for detecting abalone seedlings using a horizontal cross-scale fusion query matrix is provided, and a corresponding special device is also provided. A data set preparation method that is more suitable for densely occluded small targets is proposed, which can be widely used in the preparation of data sets in breeding processes such as seedlings with smaller targets, can significantly reduce the workload of manual annotation, and more different occlusions can be generated. The position distribution of the detection target on the image is consistent with the actual situation; secondly, using the synthetic young abalone data set, a new matrix is obtained by using the fusion cross-scale query matrix, which improves the speed and accuracy of detection. By detecting the young abalone in the picture, the position of the young abalone in the picture can be directly marked to determine the number of abalone seedlings.
[0004] The present invention solves the above technical problems through the following technical solutions:
[0005] A method for detecting abalone seedlings using a horizontal cross-scale fusion query matrix comprises establishing an abalone seedling data set, dividing the abalone seedling data set into a test set and a training set, wherein the training set is input into a horizontal cross-scale query matrix fusion abalone seedling detection algorithm, wherein the horizontal cross-scale query matrix fusion abalone seedling detection algorithm comprises: establishing a model, training the model;
[0006] The model is established, including a backbone network for performing preliminary feature extraction on an input image, the backbone network extracts image feature information from multiple scales, and transmits the information to a feature pyramid FPN module, the image information of different scales extracted by the backbone network is transmitted to the FPN module of the corresponding level, a DGAM module is set corresponding to the FPN module of each level, and after the DGAM module further processes the image information, the processed information is input into the HEAD module for information processing, and the detection result is output;
[0007] The DGAM module extracts image information through two 3x3 dilated convolutions, and the DGAM module enhances the ability to extract image information through two 3x3 dilated convolutions;
[0008] Each FPN module that extracts information at a large scale also transmits image information to the FPN module below that extracts information at a small scale.
[0009] Furthermore, the backbone network outputs a multi-scale feature map. When the size of the input image is H×W, the size of the FPN feature is ; represents the pyramid level, equal ,The detection head consists of four 3×3 convolutional layers, and the obtained feature pyramid covers different degrees of resolution and semantic information.
[0010] Further, the DGAM module is:
[0011] Given a feature, the intermediate feature and output features The definition of is:
[0012]
[0013] The query input is , the corresponding stride is , output heat map , l represents the number of layers, o represents a center coordinate located at ( , ), if the size of o is less than the specified threshold, then its center coordinates are at the corresponding position in the output image The GT on the GT is set to 1, otherwise it is set to 0; calculate the minimum distance between each feature position The formula is:
[0014] ;
[0015] The ground truth query score is defined as :
[0016]
[0017] In getting After that, the corresponding Will be assigned to the next level To guide the detection position, The key value queried is ;
[0018] After obtaining the query value of the corresponding position, the query values of the corresponding positions of the upper and lower layers are merged to finally obtain the corrected corresponding query value:
[0019] ;
[0020] Next, in In , the head and the query value for the next layer are calculated according to the position of the key value. This process is implemented through sparse matrices, which greatly saves the amount of calculation. The query head is treated as a binary classification problem, and focal loss is used as the loss function. The total loss calculation of the model is expressed as:
[0021] ;
[0022] in represents focal loss, represents the categorical result, and Represents the category result of the corresponding real box, Indicates smooth loss, represents the detection box regression result, and represents the bounding box of the corresponding ground-truth box, represents the query score result, and Represents the query result of the corresponding ground-truth box.
[0023] Furthermore, the training model is as follows: the model is established, and then pictures are imported into the model for training. After each round of training, the pictures in the validation set are input into the trained neural network to calculate the prediction accuracy of the model; the training process is iterated 4000 times to update the parameters; the above training process is repeated until the model converges, and the model with the highest accuracy on the validation set during the training process is saved as the final model.
[0024] Furthermore, the final model is tested as follows: the final model is used to predict the results, and the non-maximum suppression algorithm is further run on the predicted bounding boxes in the image to remove duplicate bounding boxes and retain more accurate predicted bounding boxes. The images in the test set are input into the trained model to verify the generalization ability of the model.
[0025] Furthermore, the establishment of the abalone seedling data set is achieved in the following manner: dense young abalone pictures are collected, and then the labelme annotation tool is used to manually annotate the data set, and the annotated data set is subjected to the copy-paste data enhancement method, that is, the instance corresponding to the mask part is cut out from one image, and then pasted into another image. The two images are scaled 1:1, and the instances are also scaled 1:1 to synthesize the occluded dense young abalone pictures, which are copied and synthesized into the format of the coco data set, and finally the data set is divided into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0026] In order to better implement the above technical solution, the inventors have also designed a special device, specifically:
[0027] A special device for the method of detecting abalone seedlings using a horizontal cross-scale fusion query matrix is characterized in that the device includes a frame, a top plate is installed on the top of the frame, and a support plate is installed on the middle and lower parts of the frame through a frame beam; a camera is installed on the lower plate surface of the top plate; and an abalone tray is placed on the upper surface of the support plate.
[0028] The above device shoots abalone in an abalone tray by a camera, the camera is fixedly installed below the top plate in a fixed installation manner, the abalone tray is placed on a support plate, the support plate can be installed on four columns of the frame in a sliding installation manner, the support plate can be a perforated plate, and by adjusting the spacing between the support plate and the top plate, it is suitable for abalone trays of different sizes. In addition, in order to ensure the position of the abalone tray, a positioning code can be set on the support plate, that is, corresponding numbers are marked on the sides of different hole positions, and a positioning protrusion is set on the bottom surface of the abalone tray, and the positioning protrusion can be stuck in the hole of the support plate.
[0029] The beneficial effects of the above technical solution are:
[0030] In view of the problem of low detection accuracy and detection speed of abalone seedlings under dense occlusion, the present invention proposes a horizontal cross-scale fusion query matrix abalone seedling detection method to perform real-time detection of abalone seedlings under dense occlusion. We image the abalone seedlings through a camera to obtain image information and reduce artificial damage to the abalone seedlings; a horizontal fusion query matrix is proposed to reduce the calculation amount of the algorithm while improving the detection speed. The fused query matrix contains a higher proportion of more accurate abalone seedling location information, which is more conducive to improving the detection accuracy. By improving the fusion method of the query matrix, the target detection algorithm can effectively and quickly detect dense and mutually occluded young abalone, improve the detection accuracy and have a faster detection speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A flow chart for designing a horizontal cross-scale fusion query matrix abalone seedling detection algorithm based on deep learning is provided for this application;
[0032] Figure 2 This is the picture detection flow chart;
[0033] Figure 3 This is a schematic diagram of the Head module structure;
[0034] Figure 4 It is a schematic diagram of the DGAM module structure;
[0035] Figure 5 It is a schematic diagram of the CSQ module structure;
[0036] Figure 6 It is a rendering of the abalone seedling detection algorithm based on horizontal cross-scale fusion query matrix based on deep learning described in this application;
[0037] Figure 7 It is a labeled graph of a data set of abalone seedling detection algorithm based on deep learning and horizontal cross-scale fusion query matrix described in this application;
[0038] Figure 8 This is the effect diagram of the RCNN (CE ASC) algorithm;
[0039] Fig. 9 It is a labeled graph of a data set of abalone seedling detection algorithm based on horizontal cross-scale fusion query matrix based on deep learning described in this application;
[0040] Fig.10 It is a front view of the special device involved in this application;
[0041] Fig.11 It is a three-dimensional diagram of the special device involved in this application.
[0042] Figure numerals: 1. frame, 2. top plate, 3. camera, 4. abalone tray, 5. support plate. DETAILED DESCRIPTION
[0043] The following embodiments, in conjunction with the accompanying drawings, are only intended to illustrate the technical solutions described in the claims and are not intended to limit the protection scope of the claims.
[0044] Combined with Figure 1-5 , the technical solution of this application is described as follows.
[0045] A deep learning-based horizontal cross-scale fusion query matrix abalone seedling detection algorithm, the technical solution of the present invention includes the following contents:
[0046] Create a young abalone dataset:
[0047] We collected pictures of densely packed juvenile abalone, and then used the labelme annotation tool to manually annotate the dataset. We then used the copy-paste data augmentation method to extract the instance corresponding to the masked part from one image and paste it into another image. The two images were scaled 1:1, and the instances were also scaled 1:1 to synthesize the occluded dense juvenile abalone images. After copying and synthesizing, the images were converted into the format of the coco dataset. Finally, the dataset was divided into training set, validation set, and test set in a ratio of 8:1:1.
[0048] Fusion cross-scale query matrix module:
[0049] Sparse query accelerated inference is now commonly used in the design of FPN-based detectors. Small objects are often detected from low-resolution feature maps, and small targets are not obvious in low-resolution feature maps. Therefore, we first predict the rough position of the small target on the coarse feature map, and then recalculate the corresponding position on the feature map based on this position. This approach can be regarded as a query process. The rough position is used as the query basis to detect the high-resolution features of the small target and calculate the query value.
[0050] Figure 2-3 Schematic diagram of the framework for horizontal cross-scale fusion query matrix.
[0051] Building the model:
[0052] Figure 2 In this paper, C3-C5 is the backbone network and P3-P5 is the FPN network.
[0053] Use a backbone network with FPN to output multi-scale feature maps. When the size of the input image is H×W, the size of the FPN feature is Here, l represents the pyramid level, and in a typical FPN implementation, equal , the detection head consists of four 3×3 convolutional layers. The feature pyramid obtained by this method covers different degrees of resolution and semantic information.
[0054] When the image is input into the backbone network, features at different levels are extracted. C3, C4 and C5 extract features at three different levels. The scale of features extracted by C5 is the largest, and the scale of features extracted by C3 is the smallest. The features extracted by C3-C5 are input into the FPN network.
[0055] FPN receives features at different levels and then outputs features at different scales; for example, features extracted by C3 are input to P3, features extracted by C4 are input to P4, and features extracted by C5 are input to P5; at the same time, after the features extracted by the large-scale level are processed by the corresponding FPN module, the processed scale features are also transmitted to the adjacent small-scale FPN module, for example, the scale features output by P5 are input to P4, and the scale features output by P4 are input to P3. The benefits of this operation are: low-level features have less semantic information, but the target position is accurate; high-level features have richer semantic information, but the target position is relatively rough; high-level features with low resolution and high semantic information are connected to low-level features with high resolution and low semantic information from top to bottom, so that features at all scales have rich semantic information.
[0056] DGAM module:
[0057] DGAM module: receives the features output by FPN modules at different levels, filters them, and processes them using dilated convolution; the DGAM module focuses on basic features and suppresses unnecessary features, thereby improving the model's ability to extract features. The details are as follows.
[0058] The calculation process of DGAM is as follows Figure 2-4 As shown, given a feature , then the intermediate feature and output features The definition of is:
[0059] ,
[0060] and are the channel and spatial attention maps, respectively.
[0061] The DGAM module designed in this application is different from the conventional GAM in that two 3x3 dilated convolutions are inserted in the middle; using dilated convolutions, unnecessary features are suppressed, thereby improving the model's ability to extract features;
[0062] CSQ Modules:
[0063] The query input is , the corresponding stride is , output heat map , l represents the number of layers, o represents a center coordinate located at ( , ), if the size of o is less than the specified threshold, then its center coordinates are at the corresponding position in the output image The GT on is set to 1, otherwise it is set to 0. Calculate the minimum distance between each feature position The formula is
[0064] ,
[0065] and , x and y represent coordinates, 0 represents point 0, l represents layer l, which means the x and y coordinates of point 0 on layer l;
[0066] The query score of the ground truth is defined as
[0067] ,
[0068] In getting After that, the corresponding Will be assigned to the next level To guide the detection position, The key value queried is .
[0069] After obtaining the query value of the corresponding position, the query values of the corresponding positions of the upper and lower layers are merged to finally obtain the corrected corresponding query value.
[0070]
[0071] Next, in The head and the query value for the next layer are calculated based on the position of the key value. This process is implemented through sparse matrices, which greatly saves the amount of calculation. The query head is treated as a binary classification problem, using focal loss as the loss function. The total loss calculation of the model is expressed as
[0072]
[0073] in represents focal loss, represents the categorical result, and Represents the category result of the corresponding real box, Indicates smooth loss, represents the detection box regression result, and represents the bounding box of the corresponding ground-truth box, represents the query score result, and Represents the query result of the corresponding ground-truth box.
[0074] like Figure 5As shown, the input is Qi-1, Qi, Qi+1; the result is the adjusted query matrix, which achieves the purpose of simplifying the processing: that is, reducing the number of operations by querying. Originally, 5x5=25 elements need to be calculated. After querying, only 3 colored elements need to be calculated, and the remaining white elements are not calculated, thereby reducing the number of calculations.
[0075] Qi-1, Qi, Qi+1, represent the query matrix of the corresponding layer. This query matrix is initially 0 and then updated once in each iteration. Our iteration (also called training number) is 4000 times. The query matrix of the i-th layer in the k-th training comes from the query matrix of the i-th layer in the k-1-th training, and is updated after the iteration is completed.
[0076] Assume that the layer c4, p4 is i, then i+1 is the layer c5, p5 above, and i-1 is the layer c3, p3 below. Then Qi-1 represents the query matrix updated in the k-1th training in the head of the layer c3, p3. Similarly, Qi+1 represents the query matrix updated in the k-1th training in the head of the layer c5, p5; when i is the top layer c5, p5, there is no more upper layer, then i+1 is 0, and only i, i-1 are valid in the csq calculation; similarly, when i is the bottom layer c3, p3, there is no more lower layer, then i-1 is 0, and only i, i+1 are valid in the csq calculation; the input features (after DGAM processing) and the adjusted query matrix in csq are operated on each other, and the result is that only the area after the query is operated.
[0077] like Figure 3 As mentioned above, the Head module is used to process the input features and make predictions, which uses the csq module. Input: features filtered by DGAM + csq query matrix; Output:
[0078] (1) Classification results, that is, labels;
[0079] (2) Regression result, that is, the predicted location box;
[0080] (3) Query matrix;
[0081] (1) and (2) are the prediction results, including the predicted label and predicted position, while (3) is only saved and used during the training process.
[0082] Training the model
[0083] Initialize the constructed model, then import images into the model for training. After each round of training, input the images in the validation set into the trained neural network to calculate the prediction accuracy of the model. The training process is iterated 4000 times (update parameters). Repeat the above training process until the model converges, and save the model with the highest accuracy on the validation set during the training process. (Save parameters)
[0084] Testing the Model
[0085] Use the final model to predict the results, and further run the non-maximum suppression algorithm on the predicted bounding boxes in the image to remove duplicate bounding boxes and retain more accurate predicted bounding boxes. Input the images in the test set into the trained model to verify the generalization ability of the model.
[0086]
[0087] Table 1. Experimental data comparing other target detection algorithms with the method described in this application
[0088] In order to verify the performance of this method, other target detection algorithms are compared with the method described in this application, namely RetinaNet, querydet, CEASC and cross scale query (the detection method of this application). In the same abalone seedling training set, the same environment and the same parameters are used. Taking Retinanet as the benchmark, the AP, AP50, AP75 and FPS of the above algorithms are compared. The test results show that the results in AP are 10.051%, 16.705%, 17.9% and 19.488% respectively, the results of AP50 are 25.9%, 29.5%, 26.4% and 30.6% respectively, and the results of AP75 are 4.401%, 16.883%, 21.6% and 22.884% respectively. In terms of detection speed FPS, the results are 13.12, 21.4, 25.0 and 8.6 respectively. Through the comparison of the above data, it can be seen that the algorithm proposed in this application has a certain degree of efficiency.
[0089] Combination Figure 6-9 , the figure of the abalone seedling detection algorithm based on deep learning and horizontal cross-scale fusion query matrix provided by this application contains 200 to 300 abalone seedlings. From the number of detections, the algorithm of this application can detect more than 85% of the targets, while other algorithms can only detect less than 20%. It can be seen that the algorithm of this application can complete the detection of dense small targets. On the other hand, the detection frames of this application have overlapping areas, which means that the algorithm of this application can detect parts that are occluded from each other, which other algorithms can hardly complete.
[0090] At the same time, in order to achieve better imaging, combined with Figure 10-11The present application also designs a special device for taking abalone pictures for use in the method of detecting abalone seedlings using a horizontal cross-scale fusion query matrix described in the present application:
[0091] Specifically, the device includes a frame 1, a top plate 2 is installed on the top of the frame 1, a support plate 5 is installed on the middle and lower part of the frame 1 through a frame beam; a camera 3 is installed on the lower plate surface of the top plate 2; and an abalone tray 4 is placed on the upper surface of the support plate 5. In order to facilitate movement, a pulley can also be set at the bottom.
[0092] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting abalone seedlings using a horizontal cross-scale fusion query matrix, comprising establishing an abalone seedling dataset, dividing the abalone seedling dataset into a test set and a training set, characterized in that: The training set is input into a horizontal cross-scale query matrix fusion abalone seedling detection algorithm, wherein the horizontal cross-scale query matrix fusion abalone seedling detection algorithm specifically comprises: establishing a model and training a model; The model is established, including a backbone network for performing preliminary feature extraction on an input image, the backbone network extracts image feature information from multiple scales, and transmits the information to a feature pyramid FPN module, the image information of different scales extracted by the backbone network is transmitted to the FPN module of the corresponding level, a DGAM module is set corresponding to the FPN module of each level, and after the DGAM module further processes the image information, the processed information is input into the HEAD module for information processing, and the detection result is output; The backbone network outputs a multi-scale feature map. When the size of the input image is H×W, the size of the FPN feature is ; represents the pyramid level, equal ,The detection head consists of four 3×3 convolutional layers, and the obtained feature pyramid covers different degrees of resolution and semantic information; The DGAM module extracts image information through two 3x3 dilated convolutions; The DGAM module is: Given a feature , then the intermediate feature and output features The definition of is: , The query input is , the corresponding stride is , output heat map , o represents a center coordinate located at ( , ), if the size of o is less than the specified threshold, then its center coordinates are at the corresponding position in the output image The GT on the GT is set to 1, otherwise it is set to 0; calculate the minimum distance between each feature position The formula is: ; The ground truth query score is defined as : , In getting After that, the corresponding Will be assigned to the next level To guide the detection position, The key value queried is ; After obtaining the query value of the corresponding position, the query values of the corresponding positions of the upper and lower layers are merged to finally obtain the corrected corresponding query value: ; Next, in In , the head and the query value for the next layer are calculated according to the position of the key value. This process is implemented through sparse matrices, which greatly saves the amount of calculation. The query head is treated as a binary classification problem, and focal loss is used as the loss function. The total loss calculation of the model is expressed as: ; in represents focal loss, represents the categorical result, and Represents the category result of the corresponding real box, Indicates smooth loss, represents the detection box regression result, and represents the bounding box of the corresponding ground-truth box, represents the query score result, and Represents the query result of the corresponding ground-truth box Each FPN module that extracts information at a large scale also transmits image information to the FPN module below that extracts information at a small scale.
2. The method for detecting abalone seedlings using a lateral cross-scale fusion query matrix according to claim 1, characterized in that: The training model is as follows: the model is established, and then pictures are imported into the model for training. After each round of training, the pictures in the validation set are input into the trained neural network to calculate the prediction accuracy of the model; The training process was iterated 4000 times to update the parameters; the above training process was repeated until the model converged, and the model with the highest accuracy on the validation set during the training process was saved as the final model.
3. The method for detecting abalone seedlings using a lateral cross-scale fusion query matrix according to claim 1, characterized in that, The final model is tested as follows: the final model is used to predict the results, and the non-maximum suppression algorithm is further run on the predicted bounding boxes in the image to remove duplicate bounding boxes and retain more accurate predicted bounding boxes; the images in the test set are input into the trained model to verify the generalization ability of the model.
4. The method for detecting abalone seedlings using a lateral cross-scale fusion query matrix according to claim 1, characterized in that: The establishment of the abalone seedling data set is achieved in the following way: collecting pictures of dense young abalone, then manually annotating the data set using the labelme annotation tool, and using the copy-paste data enhancement method to extract the instance corresponding to the mask part from one image, and then paste it into another image. The two images are scaled 1:1, and the instances are also scaled 1:1 to synthesize the occluded dense young abalone pictures. After copying and synthesizing, they are converted into the format of the coco data set, and finally the data set is divided into a training set, a validation set and a test set in a ratio of 8:1:
1.
5. A special device for the method of detecting abalone seedlings using a horizontal cross-scale fusion query matrix according to claim 1, characterized in that: The device comprises a frame (1), a top plate (2) is installed on the top of the frame (1), and a support plate (5) is installed on the middle and lower part of the frame (1) via a frame beam; a camera (3) is installed on the lower plate surface of the top plate (2); and an abalone tray (4) is placed on the upper surface of the support plate (5).
Citation Information
Patent Citations
Information query method and device, electronic equipment and storage medium
CN111054079A
Safety helmet wearing detection method based on global attention
CN114463677A
SAR image aircraft target detection method based on joint attention mechanism
CN115410102A
Method for detecting abalones in nursery period by utilizing knowledge distillation network to intensively shield
CN116109827A
Remote sensing image target detection method based on foreground attention network
CN116543315A
