Object detection method and device based on multi-scale context perception
By introducing a multi-level feature fusion mechanism and context-aware module in the object detection model, the problem of poor performance in complex scenarios and small object detection is solved, and higher detection accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411864141.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Existing object detection models perform poorly when dealing with complex scenarios and small targets, making it difficult to effectively integrate multi-scale features and utilize contextual information.
Using a multi-level feature fusion mechanism and context-aware module, an object detection model based on multi-scale context-awareness is constructed, including a multi-scale segmentation encoding module, a multi-scale context-aware decoding module, a gated multi-scale feature fusion module and a prediction module.
It significantly improves the accuracy and robustness of object detection in complex scenarios, enhances the ability to identify small targets, and provides more efficient and reliable solutions.
Smart Images

Figure CN119313889B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision, and in particular relates to a target detection method and device based on multi-scale context perception. Background Art
[0002] In the field of modern computer vision, object detection is a basic and crucial task. It is widely used in many key fields such as intelligent monitoring, autonomous driving, medical image analysis, and drone navigation. Traditional object detection methods usually rely on hand-designed feature extractors and classifiers, such as methods that combine oriented gradient histogram features with support vector machine classifiers. Although such methods perform well when dealing with simple scenes, they often perform poorly when facing complex environments or small object detection. With the development of deep learning technology, object detection methods based on deep neural networks have gradually become mainstream. These methods have made significant progress in accuracy and speed by leveraging powerful representation learning capabilities. Nevertheless, existing object detection models still face some challenges, especially when dealing with objects with multi-scale variations. In practical applications, objects of different sizes may coexist in the same image, which puts higher requirements on the detection algorithm, requiring the ability to capture large-scale information and local details in the global view at the same time. In addition, contextual information is also crucial for correctly identifying objects. It not only helps to distinguish objects from backgrounds, but also helps to identify objects with similar appearances. Therefore, it is particularly urgent to develop a detection method that can effectively integrate multi-scale features and make full use of contextual information.
[0003] The target detection method based on multi-scale context perception proposed in the present invention is designed to address the above-mentioned problems. By introducing a multi-level feature fusion mechanism and a context perception module, the method aims to enhance the detection accuracy and robustness of small targets in complex scenes, thereby providing a more efficient and reliable solution for practical application scenarios. This method is particularly suitable for fields that require precise target positioning and identification, such as refined agricultural management, urban traffic monitoring, etc., and provides solid technical support for promoting the further development of intelligent systems. Summary of the invention
[0004] In order to solve the above problems, the present invention provides a target detection method and device based on multi-scale context perception.
[0005] In order to achieve the above object, the present invention is implemented through the following technical solutions:
[0006] In a first aspect, the present invention provides a method for object detection based on multi-scale context perception, comprising the following steps:
[0007] S1. Obtain the target detection dataset and divide the dataset into a training set and a test set;
[0008] S2. Construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter The multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network; the multi-scale context-aware object detection model is trained using images in the training set;
[0009] S3. Optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model;
[0010] S4. Input the images in the test set into the trained model to obtain the target detection results.
[0011] Furthermore, in step S2, the multi-scale segmentation encoding module is specifically:
[0012] Images in the training set The image feature encoder is used to extract features and obtain global image features. , the formula is as follows:
[0013] ,
[0014] in, represents the image feature encoder;
[0015] Three segmentation scale parameters are predefined, including the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter ; The first segmentation scale parameter Set to 4×4, by using a convolution layer with a convolution kernel size of 4×4, a stride of 4, and a number of convolution kernels of 768; the second segmentation scale parameter Set to 8×8, by using a convolution layer with a convolution kernel size of 8×8, a stride of 8, and a number of convolution kernels of 768; the third segmentation scale parameter Set to 16×16, using a convolutional layer with a kernel size of 16×16, a stride of 16, and a kernel number of 768; images in the training set After the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter Processed, we get feature , feature as well as feature , the formula is as follows:
[0016] ,
[0017] ,
[0018] ,
[0019] in, It represents a convolutional layer with a kernel size of 4×4, a stride of 4, and 768 kernels. It represents a convolutional layer with a kernel size of 8×8, a stride of 8, and 768 kernels. It represents a convolutional layer with a kernel size of 16×16, a stride of 16, and 768 kernels.
[0020] Further, in step S2, the multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, specifically:
[0021] Global image features and feature After the multi-scale context-aware decoding module, Context-aware representation , the process is as follows:
[0022] The dual context-aware decoding layer includes a left_to_right context-aware decoding unit and an up_to_down context-aware decoding unit; in the left_to_right context-aware decoding unit, the global image features are used to decode the right feature Decode and predict, and get the left context perception representation based on the left context feature , the formula is as follows:
[0023]
[0024] in, Indicates that through feature Middle From left to right, The left feature above is obtained by summing the features of the columns. Representation based on global image features and left above feature The decoded position coordinates are (i, j) and the left context perception representation is: represents the left_to_right context-aware decoding unit, express feature The vertical index range is , Represents images in the training set In the vertical direction, the first segment scale parameter The number of blocks after segmentation, where is an image Height, express feature Horizontal index, range: , Represents images in the training set In the horizontal direction, the first segmentation scale parameter The number of blocks after segmentation, where is an image The width of the image is: In the up_to_down context-aware decoding unit, the global image features are used right feature Decode and predict, and get the up context perception representation based on the up context features , the formula is as follows:
[0025]
[0026] in, Indicates that through feature Middle From top to bottom in the column The up feature above is obtained by summing the features of the rows. Representation based on global image features and up the above features The decoded position coordinates are (i, j) up context perception representation, represents up_to_down context-aware decoding unit; represents left context-aware And up above perception representation By adding features, we can get Above Perception Representation ;
[0027] The dual context-aware decoding layer includes a right_to_left context-aware decoding unit and a down_to_up context-aware decoding unit; in the right_to_left context-aware decoding unit, the global image feature is used to right feature Decode and predict, and obtain the right context perception representation based on the right context features , the formula is as follows:
[0028]
[0029] in, Indicates that through feature No. From right to left in the row The right context feature is obtained by summing the features of the columns. Representation based on global image features and right context features The decoded position coordinates are (i, j) and the perceptual representation of the right context is: represents the right_to_left context-aware decoding unit; in the down_to_up context-aware decoding unit, the global image features are used right feature Decode and predict, and get the down context perception representation based on the down context features , the formula is as follows:
[0030]
[0031] in, Express feature No. From bottom to top in the column The down context features are obtained by summing up the features of the rows. Representation based on global image features and down context features Decoding obtains the down context perception representation with position coordinates (i, j), represents the down_to_up context perception decoding unit; represents the right context perception and down context-aware representation By adding features, we can get Context-aware representation ;
[0032] based on Above Perception Representation and Context-aware representation After the feature aggregation operation is performed through the dual context-aware aggregation layer, we get Context-aware representation ;
[0033] Similarly, after the above process, the global image features and feature After the context-aware decoding module, Context-aware representation ; Global image features and feature After the context-aware decoding module, Context-aware representation .
[0034] Furthermore, in step S2, the gated multi-scale feature fusion module is specifically:
[0035] Gated Cell Building Blocks: Context-aware Representations for Each Scale Design a gating unit , , the gating unit Including fully connected layers and sigmoid activation functions, gated units The formula is as follows:
[0036] ,
[0037] in, represents the sigmoid activation function, represents the learnable weight parameters in the gating unit building block, represents a bitwise multiplication operation, represents the bias term;
[0038] Gated Fusion Unit: Context-aware representation of each scale With the corresponding gate control unit Multiply them to get the weighted feature representation, and sum all the weighted feature representations to get the final multi-scale context-aware representation , the formula is as follows:
[0039] ,
[0040] in, represents element-wise multiplication, Represents the learnable weight parameters in the gated fusion unit.
[0041] Further, in step S2, the prediction module is specifically: the prediction module includes a classification head network and a regression head network; the final multi-scale context-aware representation After the classification head network is used for classification prediction, the target category is obtained , the formula is as follows:
[0042] ,
[0043] in, represents the activation function in the classification head network, represents the multiplication operation, represents the learnable weight parameters in the classification head network, Represents the bias term in the classification head network; the final multi-scale context-aware representation After regression prediction is performed through the regression head network, the target position is obtained , the formula is as follows:
[0044] ,
[0045] in, represents the learnable weight parameters of the regression head network, Represents the bias term of the regression head network.
[0046] Furthermore, step S3 is specifically as follows: the model is trained and optimized using the Adam optimizer through the classification loss function and the regression loss function. Using cross entropy loss, regression loss Using smooth L1 loss function Smooth L1 Loss, the total loss function for: .
[0047] In a second aspect, the present invention provides a target detection device based on multi-scale context perception, comprising:
[0048] Data acquisition unit: used to acquire target detection data;
[0049] Model construction unit: used to construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter , the multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network;
[0050] Model training unit: used to train and optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model;
[0051] Target detection unit: used to input the image to be detected into the trained model to obtain the target detection result.
[0052] In a third aspect, the present invention provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the target detection method based on multi-scale context perception described in the first aspect is executed.
[0053] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the target detection method based on multi-scale context perception described in the first aspect is executed.
[0054] The advantages of the present invention are:
[0055] The present invention proposes a target detection method based on multi-scale context perception, which significantly improves the accuracy and robustness of target detection in complex scenarios through innovative multi-scale segmentation coding, multi-scale context-aware decoding, and gated multi-scale feature fusion. By combining multi-scale segmentation coding with context-aware decoding, the present invention can more finely capture the contextual relationship between target information and its surrounding environment at different scales, thereby enhancing the model's ability to recognize small targets. The method of combining global image features with multi-scale features allows the algorithm to focus not only on the target itself, but also consider the overall characteristics of its environment. The present invention not only advances research progress in the field of computer vision in theory, but also provides strong technical support for related industries at the practical application level, greatly promoting the development and development of intelligent systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0057] Figure 1 is a flow chart of the steps of the method of the present invention;
[0058] Figure 2 It is a visualization effect diagram of the method of the present invention. DETAILED DESCRIPTION
[0059] 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.
[0060] Example 1
[0061] In this embodiment, Figure 1 As shown, the present invention provides a target detection method based on multi-scale context perception, and the specific steps include:
[0062] S1. Obtain the target detection dataset and divide the dataset into a training set and a test set;
[0063] S2. Construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter The multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network; the multi-scale context-aware object detection model is trained using images in the training set;
[0064] Specifically, in the multi-scale segmentation encoding module, the images in the training set The image feature encoder is used to extract features and obtain global image features. , the formula is as follows:
[0065] ,
[0066] in, represents the image feature encoder;
[0067] Three segmentation scale parameters are predefined, including the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter ; The first segmentation scale parameter Set to 4×4, by using a convolution layer with a convolution kernel size of 4×4, a stride of 4, and a number of convolution kernels of 768; the second segmentation scale parameter Set to 8×8, by using a convolution layer with a convolution kernel size of 8×8, a stride of 8, and a number of convolution kernels of 768; the third segmentation scale parameter Set to 16×16, using a convolutional layer with a kernel size of 16×16, a stride of 16, and a kernel number of 768; images in the training set After the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter Processed, we get feature , feature as well as feature , the formula is as follows:
[0068] ,
[0069] ,
[0070] ,
[0071] in, It represents a convolutional layer with a kernel size of 4×4, a stride of 4, and 768 kernels. It represents a convolutional layer with a kernel size of 8×8, a stride of 8, and 768 kernels. It represents a convolutional layer with a kernel size of 16×16, a stride of 16, and 768 kernels.
[0072] Specifically, in the multi-scale context-aware decoding module, the global image features and feature After the multi-scale context-aware decoding module, Context-aware representation , the process is as follows:
[0073] The dual context-aware decoding layer includes a left_to_right context-aware decoding unit and an up_to_down context-aware decoding unit; in the left_to_right context-aware decoding unit, the global image features are used to decode the right feature Decode and predict, and get the left context perception representation based on the left context feature , the formula is as follows:
[0074]
[0075] in, Indicates that through feature Middle From left to right, The left feature above is obtained by summing the features of the columns. Representation based on global image features and left above feature The decoded position coordinates are (i, j) and the left context perception representation is: represents the left_to_right context-aware decoding unit, express feature The vertical index range is , Represents images in the training set In the vertical direction, the first segment scale parameter The number of blocks after segmentation, where is an image Height, express feature Horizontal index, range: , Represents images in the training set In the horizontal direction, the first segmentation scale parameter The number of blocks after segmentation, where is an image The width of the image is: In the up_to_down context-aware decoding unit, the global image features are used right feature Decode and predict, and get the up context perception representation based on the up context features , the formula is as follows:
[0076]
[0077] in, Indicates that through feature Middle From top to bottom in the column The up feature above is obtained by summing the features of the rows. Representation based on global image features and up the above features The decoded position coordinates are (i, j) up context perception representation, represents up_to_down context-aware decoding unit; represents left context-aware And up above perception representation By adding features, we can get Above Perception Representation ;
[0078] The dual context-aware decoding layer includes a right_to_left context-aware decoding unit and a down_to_up context-aware decoding unit; in the right_to_left context-aware decoding unit, the global image feature is used to right feature Decode and predict, and obtain the right context perception representation based on the right context features , the formula is as follows:
[0079]
[0080] in, Indicates that through feature No. From right to left in the row The right context feature is obtained by summing the features of the columns. Representation based on global image features and right context features The decoded position coordinates are (i, j) and the perceptual representation of the right context is: represents the right_to_left context-aware decoding unit; in the down_to_up context-aware decoding unit, the global image features are used right feature Decode and predict, and get the down context perception representation based on the down context features , the formula is as follows:
[0081] in, Express feature No. From bottom to top in the column The down context features are obtained by summing up the features of the rows. Representation based on global image features and down context features Decoding obtains the down context perception representation with position coordinates (i, j), represents the down_to_up context perception decoding unit; represents the right context perception and down context-aware representation By adding features, we can get Context-aware representation ;
[0082] based on Above Perception Representation and Context-aware representation After the feature aggregation operation is performed through the dual context-aware aggregation layer, we get Context-aware representation ;
[0083] Similarly, after the above process, the global image features and feature After the context-aware decoding module, Context-aware representation ; Global image features and feature After the context-aware decoding module, Context-aware representation .
[0084] Specifically, in the gated multi-scale feature fusion module,
[0085] Gated Cell Building Blocks: Context-aware Representations for Each Scale Design a gating unit , , the gating unit Including fully connected layers and sigmoid activation functions, gated units The formula is as follows:
[0086] ,
[0087] in, represents the sigmoid activation function, represents the learnable weight parameters in the gating unit building block, represents a bitwise multiplication operation, represents the bias term;
[0088] Gated Fusion Unit: Context-aware representation of each scale With the corresponding gate control unit Multiply them to get the weighted feature representation, and sum all the weighted feature representations to get the final multi-scale context-aware representation , the formula is as follows:
[0089] ,
[0090] in, represents element-wise multiplication, Represents the learnable weight parameters in the gated fusion unit.
[0091] Specifically, in the prediction module, the final multi-scale context-aware representation After the classification head network is used for classification prediction, the target category is obtained , the formula is as follows:
[0092] ,
[0093] in, represents the activation function in the classification head network, represents the multiplication operation, represents the learnable weight parameters in the classification head network, Represents the bias term in the classification head network; the final multi-scale context-aware representation After regression prediction is performed through the regression head network, the target position is obtained , the formula is as follows:
[0094] ,
[0095] in, represents the learnable weight parameters of the regression head network, Represents the bias term of the regression head network.
[0096] S3. Optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model;
[0097] Specifically, the Adam optimizer is used to train and optimize the model through the classification loss function and regression loss function. Using cross entropy loss, regression loss Using smooth L1 loss function Smooth L1 Loss, the total loss function for: .
[0098] S4. Input the images in the test set into the trained model to obtain the target detection results.
[0099] Example 2
[0100] In this embodiment, the DOTA dataset, a publicly available target detection dataset, is downloaded from the Internet. The DOTA dataset is a commonly used dataset for remote sensing aerial image detection, containing 2806 aerial images, with a size of approximately 4k×4k, and 15 categories with a total of 188,282 instances. The characteristics of this dataset are large variability in image scale, dense target objects, and random directions. The method of the present invention is experimentally compared with the prior art RIDet on the DOTA dataset, as shown in Table 1.
[0101] Table 1 Experimental comparison of the method of the present invention and the deep learning model RIDet on the DOTA dataset
[0102]
[0103] As shown in Table 1, the average detection accuracy of the method of the present invention reaches 80.91%, which is significantly higher than the deep learning model RIDet, indicating that the target detection model of the present invention has better detection performance and stronger robustness.
[0104] Figure 2 This is a visualization result diagram of the test of the method of the present invention on the DOTA dataset. The effectiveness of the method of the present invention is Figure 2 This has been fully verified in the image comparison in . In the input image, the target objects have large size differences, different categories, and complex backgrounds, but in the output image processed by the method of the present invention, all types of target objects are accurately detected and labeled with category and location information. Whether it is a larger target (such as an airplane) or a smaller target (such as a car), the model can accurately identify it without obvious missed detection or false detection, which fully demonstrates the efficiency and robustness of the method of the present invention in the target detection task. In summary, the method of the present invention can accurately detect various types of targets in the image, especially when facing complex scenes and small target detection, the method of the present invention shows obvious advantages and has broad application prospects and practical value.
[0105] Example 3
[0106] This embodiment provides a target detection device based on multi-scale context perception, including:
[0107] Data acquisition unit: used to acquire target detection data;
[0108] Model construction unit: used to construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter , the multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network;
[0109] Model training unit: used to train and optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model;
[0110] Target detection unit: used to input the image to be detected into the trained model to obtain the target detection result.
[0111] Example 4
[0112] This embodiment provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, a target detection method based on multi-scale context perception is performed.
[0113] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0114] Example 5
[0115] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, a method for object detection based on multi-scale context perception is executed.
[0116] Storage media include: USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks, and other media that can store programs.
[0117] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A target detection method based on multi-scale context perception, characterized in that: The following steps are involved: S1. Obtain the target detection dataset and divide the dataset into a training set and a test set; S2. Construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter The multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network; the multi-scale context-aware object detection model is trained using images in the training set; The multi-scale context-aware decoding module is specifically: Global image features and feature After the multi-scale context-aware decoding module, Context-aware representation , the process is as follows: The dual context-aware decoding layer includes a left_to_right context-aware decoding unit and an up_to_down context-aware decoding unit; in the left_to_right context-aware decoding unit, the global image feature is used to decode the image. right feature Decode and predict, and get the left context perception representation based on the left context feature , the formula is as follows: in, Indicates that through feature Middle From left to right, The left feature above is obtained by summing the features of the columns. Representation based on global image features and left above feature The decoded position coordinates are (i, j) and the left context perception representation is: represents the left_to_right context-aware decoding unit, express feature The vertical index range is , Represents images in the training set In the vertical direction, the first segment scale parameter The number of blocks after segmentation, where is an image Height, express feature Horizontal index, range: , Represents images in the training set In the horizontal direction, the first segmentation scale parameter The number of blocks after segmentation, where is an image The width of the image is: In the up_to_down context-aware decoding unit, the global image features are used right feature Decode and predict, and get the up context perception representation based on the up context features , the formula is as follows: in, Indicates that through feature Middle From top to bottom in the column The up feature is obtained by summing up the features of the rows. Representation based on global image features and up the above features The decoded position coordinates are (i, j) up context perception representation, represents up_to_down context-aware decoding unit; represents left context-aware And up above perception representation By adding features, we can get Above Perception Representation ; The dual context-aware decoding layer includes a right_to_left context-aware decoding unit and a down_to_up context-aware decoding unit; in the right_to_left context-aware decoding unit, the global image feature is used to right feature Decode and predict, and obtain the right context perception representation based on the right context features , the formula is as follows: in, Indicates that through feature No. From right to left in the row The right context feature is obtained by summing the features of the columns. Representation based on global image features and right context features The decoded position coordinates are (i, j) and the perceptual representation of the right context is: represents the right_to_left context-aware decoding unit; in the down_to_up context-aware decoding unit, the global image features are used right feature Decode and predict, and get the down context perception representation based on the down context features , the formula is as follows: in, Express feature No. From bottom to top in the column The down context features are obtained by summing up the features of the rows. Representation based on global image features and down context features Decoding obtains the down context perception representation with position coordinates (i, j), represents the down_to_up context perception decoding unit; represents the right context perception and down context-aware representation By adding features, we can get Context-aware representation ; based on Above Perception Representation and Context-aware representation After the feature aggregation operation is performed through the dual context-aware aggregation layer, we get Context-aware representation ; Similarly, after the above process, the global image features and feature After the context-aware decoding module, Context-aware representation ; Global image features and feature After the context-aware decoding module, Context-aware representation ; S3. Optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model; S4. Input the images in the test set into the trained model to obtain the target detection results.
2. The object detection method based on multi-scale context perception according to claim 1 is characterized in that: In step S2, the multi-scale segmentation encoding module is specifically: Images in the training set The image feature encoder is used to extract features and obtain global image features. , the formula is as follows: , in, represents the image feature encoder; Three segmentation scale parameters are predefined, including the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter ; The first segmentation scale parameter Set to 4×4, by using a convolution layer with a convolution kernel size of 4×4, a stride of 4, and a number of convolution kernels of 768; the second segmentation scale parameter Set to 8×8, by using a convolution layer with a convolution kernel size of 8×8, a stride of 8, and a number of convolution kernels of 768; the third segmentation scale parameter Set to 16×16, using a convolutional layer with a kernel size of 16×16, a stride of 16, and a kernel number of 768; images in the training set After the first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter Processed, we get feature , feature as well as feature , the formula is as follows: , , , in, It represents a convolutional layer with a kernel size of 4×4, a stride of 4, and 768 kernels. It represents a convolutional layer with a kernel size of 8×8, a stride of 8, and 768 kernels. It represents a convolutional layer with a kernel size of 16×16, a stride of 16, and 768 kernels.
3. The target detection method based on multi-scale context perception according to claim 2 is characterized in that: In step S2, the gated multi-scale feature fusion module is specifically: Gated Cell Building Blocks: Context-aware Representations for Each Scale Design a gating unit , , the gating unit Including fully connected layers and sigmoid activation functions, gated units The formula is as follows: , in, represents the sigmoid activation function, represents the learnable weight parameters in the gating unit building block, represents a bitwise multiplication operation, represents the bias term; Gated Fusion Unit: Context-aware representation of each scale With the corresponding gate control unit Multiply them to get the weighted feature representation, and sum all the weighted feature representations to get the final multi-scale context-aware representation , the formula is as follows: , in, represents element-wise multiplication, Represents the learnable weight parameters in the gated fusion unit.
4. The multi-scale context-aware target detection method according to claim 3, characterized in that: In step S2, the prediction module is specifically: The prediction module includes a classification head network and a regression head network; the final multi-scale context-aware representation After the classification head network is used for classification prediction, the target category is obtained , the formula is as follows: , in, represents the activation function in the classification head network, represents the multiplication operation, represents the learnable weight parameters in the classification head network, Represents the bias term in the classification head network; the final multi-scale context-aware representation After regression prediction is performed through the regression head network, the target position is obtained , the formula is as follows: , in, represents the learnable weight parameters of the regression head network, Represents the bias term of the regression head network.
5. The target detection method based on multi-scale context perception according to claim 4 is characterized in that: Step S3 is specifically as follows: The model is trained and optimized using the Adam optimizer through the classification loss function and regression loss function. Using cross entropy loss, regression loss Using smooth L1 loss function Smooth L1 Loss, the total loss function for: .
6. A target detection device based on multi-scale context perception, executing the steps of the target detection method based on multi-scale context perception as claimed in claim 1, characterized in that: include: Data acquisition unit: used to acquire target detection data; Model construction unit: used to construct a target detection model based on multi-scale context perception, the model includes a multi-scale segmentation encoding module, a multi-scale context perception decoding module, a gated multi-scale feature fusion module and a prediction module; the multi-scale segmentation encoding module includes an image feature encoder, a first segmentation scale parameter , the second segmentation scale parameter And the third segmentation scale parameter , the multi-scale context-aware decoding module includes a dual context-aware decoding layer, a dual context-aware decoding layer and a dual context-aware aggregation layer, the gated multi-scale feature fusion module includes a gated unit construction unit and a gated fusion unit, and the prediction module includes a classification head network and a regression head network; Model training unit: used to train and optimize the multi-scale context-aware object detection model through the loss function to obtain a trained model; Target detection unit: used to input the image to be detected into the trained model to obtain the target detection result.
7. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the target detection method based on multi-scale context perception as described in any one of claims 1 to 5 is executed.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the object detection method based on multi-scale context perception as described in any one of claims 1 to 5 is executed.
Citation Information
Patent Citations
Image semantic segmentation method fusing space detail context and multi-scale interaction
CN118230323A
Classroom behavior recognition method and device based on multi-scale expansion residual attention perception
CN119131908A