A system and method for detecting small objects in complex scenes based on mask attention and contextual feature optimization.

JP2026167574APending Publication Date: 2026-10-14HANGZHOU VOCATIONAL & TECHN COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2026051232
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-03-31
Filing Date
2026-03-25
Publication Date
2026-10-14

Smart Images

  • Figure 2026167574000014
    Figure 2026167574000014
  • Figure 2026167574000015
    Figure 2026167574000015
  • Figure 2026167574000016
    Figure 2026167574000016
Patent Text Reader

Abstract

This invention provides a small object detection system and method in complex scenes based on mask attention and context feature optimization. [Solution] The system includes a backbone network with an integrated mask attention mechanism that takes the original image as input, filters out redundant background information using a mask mechanism, and outputs a multiscale feature map; a context-aware enhanced feature refining encoder that performs multi-branch processing on the multiscale feature map and finally generates a multiscale fused feature sequence by weighted fusion; and a deformable Transformer decoder that takes the multiscale fused feature sequence as input, processes it using cross-attention and self-attention modules, constructs an object query, and generates detection results including bounding box coordinates, class labels, and confidence scores.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] This application relates to the technical field of image object detection, and more particularly to a system and method for detecting small objects in complex scenes based on mask attention and context feature optimization. [Background technology]

[0002] In the field of small object detection, small objects significantly impact detection accuracy due to their small size and frequent occlusion. Small objects typically have a low pixel occupancy rate. This means that the space occupied by the small object in the image is extremely limited, and the extractable feature information is relatively scarce. Furthermore, small objects are susceptible to interference from background noise, and complex background environments can obscure the true features of the object, making detection even more difficult.

[0003] For small object detection tasks, conventional convolutional neural networks (CNNs) struggle to capture global contextual information due to their limited receptive fields. Contextual information helps the model better understand the relationship between an object and its surrounding environment, thereby enabling more accurate object identification. Therefore, contextual information is particularly important for small object detection. However, the local receptive fields of CNNs limit their ability to integrate this global information. As a result, models are prone to losing important contextual cues when processing complex scenes.

[0004] Furthermore, to address this constraint, a Transformer-based end-to-end detector called DETR has been proposed. However, conventional deformable DETR detectors are clearly insufficient even when processing extremely small objects. While deformable DETR enhances the model's ability to adapt to object deformation by incorporating a deformable attention mechanism, when processing extremely small objects that occupy only a few pixels, the design of its sampling points and offsets may not adequately capture the object's characteristic information. Because the visible portion of extremely small objects in an image is very small, conventional sampling strategies may fail to cover the key region of the object, potentially reducing the detection effectiveness. [Overview of the project] [Problems that the invention aims to solve]

[0005] This invention provides a small object detection system and method in complex scenes based on mask attention and context feature optimization, thereby solving the problem of conventional convolutional neural networks (CNNs) having limited receptive fields and difficulty in capturing global contextual information. Conventional Deformable Deformable Detectors (DETRs) cannot achieve sufficient detection effectiveness for extremely small objects (e.g., those occupying only a few pixels). [Means for solving the problem]

[0006] The object detection system in complex scenes based on mask attention and context feature optimization provided herein is A ResNet50 backbone network with an integrated mask attention mechanism takes the original image as input, filters out redundant background information using a mask mechanism, and outputs a refined multiscale feature map. A context-aware enhanced feature refining encoder performs a multi-branch process on the aforementioned multi-scale feature map, including capturing local details by small-scale convolution, expanding the receptive field by multi-scale convolution, and capturing global information by deformable attention, and finally generates a multi-scale fused feature sequence by weighted fusion. The system includes a deformable Transformer decoder that receives the multiscale fused feature sequence as input, processes it using cross-attention and self-attention modules, constructs an object query, and generates a detection result that includes bounding box coordinates, a class label, and a confidence score.

[0007] Furthermore, the configuration of the ResNet50 backbone network integrating the aforementioned mask attention mechanism is as follows: An input feature processing module that processes multiscale feature maps through standard convolutional layers to obtain initial feature mappings, A feature segmentation module divides the initial feature mapping into three parts along the channel direction for mask generation and attention weight calculation, A mask generation module processes a portion of the partitioned initial feature mapping using convolutional layers and a sigmoid activation function to generate a mask, An attention weight module that utilizes the self-attention mechanism to calculate an attention matrix using the other two partitioned parts of the initial feature mapping, selectively enhances them using a mask, and obtains a modulated attention matrix. The system includes a feature enhancement and residual connection module that combines the modulated attention matrix with the original image and outputs a multiscale feature map containing refined global context information and important information from the original input through convolutional transformation and residual connection.

[0008] Furthermore, the context-aware enhanced feature refining encoder is A small-scale convolution branch performs a single-layer convolution on a multiscale feature map to capture the texture and fine-grained information of an object and generate local detail features. a multi-scale convolution combination branch that expands the receptive field of a multi-scale feature map through 3×3 convolution, then performs channel reorganization and feature compression using 1×1 convolution to generate global context features, a deformable attention branch that adaptively captures features of objects of different scales in the multi-scale feature map based on dynamic sampling offsets and attention weights to generate adaptive global features, and a multi-branch feature fusion module that performs weighted fusion of local detailed features, global context features, and adaptive global features using learnable weights, applies linear transformation and an activation function, and outputs a final multi-scale fused feature sequence.

[0009] Further, the deformable Transformer decoder includes a cross-attention module that integrates the multi-scale features output by the encoder and the object queries of the decoder to obtain adaptively enhanced fine-grained features, and a self-attention module that performs global relationship modeling processing on the object queries of the decoder to obtain consistent and mutually exclusive detection box prediction results.

[0010] Further, the deformable Transformer decoder further includes a preprocessing module that performs position encoding and flattening on the multi-scale fused feature sequence to form a feature vector.

[0011] The present application further proposes a small object detection method in complex scenes based on mask attention and context feature optimization using the above system. The method comprises: step S1: inputting an original image into a ResNet50 backbone network integrated with a mask attention mechanism, and extracting a multi-scale feature map, step S2 of inputting the multi-scale feature map output by the backbone network into a context-aware enhanced feature refinement encoder to obtain a multi-scale fused feature sequence; and step S3 of inputting the multi-scale fused feature sequence into a Transformer decoder, generating an object query through a cross-attention module and a self-attention module, and outputting a prediction result.

[0012] Further, the step S1 specifically includes: step S11 of processing an original image through a convolution layer to obtain an initial feature map; step S11 of processing an original image through a convolution layer to obtain an initial feature map; dividing the initial feature map along a channel dimension into three branches, which are a query branch F Q , a key branch F K , and a mask generation branch F M step S12; performing a convolution operation on F M to generate an initial mask M, restricting mask values to the interval [0, 1] through a Sigmoid activation function, calculating a similarity through a dot product of F and F Q , normalizing the similarity after scaling by Softmax to obtain an attention matrix A, step S13; K step S13 of calculating a similarity by the dot product of F and F, normalizing the similarity after scaling by Softmax to obtain an attention matrix A; step S14 of performing mask modulation by calculating an element-wise product of the mask M and the attention matrix, so as to suppress the response of a background region; performing weighted summation using the modulated attention matrix A' and the corresponding value feature F V , performing convolution enhancement on the weighted summation result to obtain an enhanced feature F refine , step S15; adding the enhanced feature F refine and the original image, performing activation by ReLU, and outputting an optimized multi-scale feature map, step S16.

[0013] Furthermore, step S2 specifically means, Step S21 involves processing a multiscale feature map using three parallel branches: a small-scale convolutional branch, a multiscale convolutional combinational branch, and a deformable attention branch, thereby obtaining three branch features. Step S22 involves weighted fusion of the three branch features using learnable weights, The process includes step S23, which involves performing fully connected layer mapping on the fusion result to generate a final multiscale fusion feature sequence.

[0014] Furthermore, step S3 specifically means, Step S31 initializes the object query feature vector based on pre-set learnable parameters, Step S32 involves using a deformable cross-attention module to interact with object queries and multiscale fused features of an encoder, dynamically sampling and weighting key regions to generate initial detection boxes and class predictions. Step S33 involves using a deformable self-attention module to model spatial and semantic dependencies between object queries, suppressing redundant predictions and improving global consistency of detection boxes. The process includes step S34, which maps the optimized object query to the final discovery result via a feedforward network. Beneficial effects achieved through this application The object detection system in complex scenes based on mask attention and context feature optimization described in this application significantly improves the detection performance of objects in complex scenes by integrating multiple novel modules. First, this system uses a ResNet50 backbone network with an integrated mask attention mechanism. This network effectively filters out redundant background information through the mask mechanism and enhances the global context modeling function, allowing the network to focus on the target area and ignore irrelevant background noise. This significantly improves the quality of feature extraction and detection accuracy.

[0015] Furthermore, this system incorporates a context-aware enhanced feature refining encoder (CAEFRE) that achieves effective fusion of multi-scale features through multi-branch processing. Specifically, CAEFRE combines small-scale convolutional layers, relatively large-scale feature extraction branches, and deformable attention branches to simultaneously capture local details of small objects and relatively large-scale contextual information. This fusion strategy not only improves the adaptability of the model to objects of different sizes but also significantly improves the accuracy of small object detection.

[0016] Finally, this system utilizes a deformable Transformer decoder, which further enhances overall detection performance through an adaptive focus and sampling mechanism. The deformable Transformer decoder can perform adaptive focus and sampling on objects of different scales while maintaining the completeness of global information, thereby enabling the model to more accurately pinpoint the location of objects. [Brief explanation of the drawing]

[0017] [Figure 1] This is a schematic diagram of the system configuration of the present invention. [Figure 2] This figure shows the backbone network architecture of the present invention. [Figure 3] This figure shows the mask-sensitive image processing method of the present invention. [Figure 4] This figure shows the architecture of the context-aware feature enhancement encoder of the present invention. [Figure 5] This is a flowchart of the method described in this application. [Figure 6] This is a flowchart of the S1 substep of the present invention. [Figure 7] This is a flowchart of the S2 substep of the present invention. [Figure 8] This is a flowchart of the S3 substep of the present application. The drawings are for illustrative purposes only and should not be understood as limiting the present application. Some components of the drawings are omitted, enlarged, or reduced in order to better illustrate this embodiment, but do not represent the actual size of the product. Those skilled in the art will understand that some well-known components and their descriptions in the drawings are omittable. Identical or similar reference numerals correspond to identical or similar components. Terms used to describe positional relationships in the drawings are for illustrative purposes only and should not be understood as limiting the present application. [Modes for carrying out the invention]

[0018] Furthermore, the embodiments and technical features described herein may be combined with each other, provided they do not contradict each other. The detailed descriptions in the specific embodiments should be understood as explaining the spirit of this application and should not be considered as unduly limiting this application.

[0019] To further clarify the purpose, technical solutions, and advantages of the embodiments of this application, the specific technical solutions of this application will be described in more detail below, with reference to the drawings in the embodiments. The following embodiments are for illustrative purposes only and are not intended to limit the scope of this application.

[0020] As shown in Figure 1, the object detection system in complex scenes based on mask attention and context feature optimization provided by this embodiment is A ResNet50 backbone network with an integrated Mask Attention mechanism takes the original image as input, filters out redundant background information using a masking mechanism, and outputs a refined multiscale feature map. A context-aware enhanced feature refining encoder (CAEFRE) performs a multi-branch process on the aforementioned multi-scale feature map, including capturing local details by small-scale convolution, expanding the receptive field by multi-scale convolution, and capturing global information by deformable attention, and finally generates a multi-scale fused feature sequence by weighted fusion. The system includes a deformable Transformer decoder that receives the multiscale fused feature sequence as input, processes it using cross-attention and self-attention modules, constructs an object query, and generates a detection result that includes bounding box coordinates, a class label, and a confidence score.

[0021] To enhance the backbone network's global image feature extraction capabilities, this embodiment integrates Mask Attention as a core component into the backbone network. This component not only improves the backbone network's ability to capture global information but also allows for the filtering and removal of redundant pixel data through a masking mechanism.

[0022] As shown in Figure 5, the method for detecting small targets in complex scenes based on mask attention and context feature optimization using the above system is: Step S1 involves inputting the original image into a ResNet50 backbone network with an integrated mask attention mechanism and extracting a multiscale feature map. Step S2 involves inputting the multiscale feature map output by the backbone network into a context-aware enhanced feature refining encoder to obtain a multiscale fused feature sequence. The process includes step S3, which involves inputting the multiscale fused feature sequence into a Transformer decoder, generating object queries using a cross-attention module and a self-attention module, and outputting prediction results.

[0023] Specifically, this embodiment uses ResNet50 as the base backbone network architecture and improves its basic block. As shown in Figure 2, the input data is processed by a convolutional layer and then split into three independent input sources, which are fed to a Mask Attention module. After internal processing by the Mask Attention module, a convolution operation is performed again, followed by residual connection (summation) with the original input, and finally the output is generated via a ReLU activation function.

[0024] As shown in Figure 6, in the improved ResNet50 basic block, a convolution operation is first performed on the input feature X to obtain the initial feature mapping shown below.

number

[0025] Next, F is divided into three parts along the channel direction, and each part is F Q F K and F M Let's assume that F Q and F K These function as a query and a key, respectively, and are used in the subsequent calculation of attention weights. M This is used to generate a mask M, selectively highlight features, and remove redundant information through filtering.

[0026] (1) Mask generation F M Using this, a specially designed convolutional layer generates a mask M with pixel-level control capabilities, as shown below.

number

[0027] Of these, Conv mask This is a 1x1 or 3x3 convolution operation. σ() is a sigmoid activation function that maps the output values ​​to the interval [0,1]. This mask then functions to filter out redundant background by modulating attention weights so that the response values ​​in the relevant regions approach 0 if the input features do not contain the object to be detected.

[0028] (2) Calculation of attention weight F Q F K Based on this, the attention matrix A shown below is calculated using a mechanism similar to self-attention.

number

[0029] Of these, d is the scaling factor (usually the number of channels after division) at which the dot product value is too large and the gradient is guaranteed to vanish. Note that F here Q and F K The specific array method varies depending on the implementation details, and similarity can be calculated in a two-dimensional or flattened format.

[0030] Next, the generated mask M is applied to the attention matrix as follows to achieve selective emphasis.

number

[0031] Here,

number

[0032] (3) Feature enhancement and residual connection within the module Modulated attention matrix A' and corresponding value feature F V (Usually, F K By performing weighted combinations using (which can be constructed using either or by directly using part of the information of the original feature F), the following attention-enhanced feature F is obtained. att Obtain it.

number

[0033] Of these, "·" represents a weighted sum operation (which can be interpreted as matrix multiplication or position-based weighted aggregation).

[0034] Next, in order to further refine the feature representation, F att Apply a convolution transformation once to it.

number

[0035] Finally, the mask attention module and the features after the convolutional transformation are residual-connected to the original input X, and the ReLU activation function is applied as follows to obtain the final output.

number

[0036] Such residual connections allow the network to retain the original information even after new modules are introduced, effectively mitigating the vanishing gradient problem and promoting learning stability.

[0037] Figure 3 illustrates the principle of Mask Attention in image processing. After extracting the input feature data, Mask Attention is used to selectively enhance the image features. If the input features do not contain the object to be detected, the mask mechanism effectively optimizes the feature extraction and dimensionality reduction processes by removing irrelevant data.

[0038] To improve the performance of small object detection, this embodiment combines a deformable attention mechanism with convolutional layers. Small-scale convolutional layers extract local features of minute pixel objects. Furthermore, the high sensitivity of the convolutional layers to texture information enhances the capture of texture features in the input image. In addition, the deformable attention mechanism enhances the stability of the model by ensuring feature integrity of objects at different scales.

[0039] As shown in Figure 4, image features extracted by the backbone network and neck module are processed in parallel by three information extraction branches: a small-scale convolutional branch, a relatively large-scale feature extraction branch, and a deformable attention branch. In this system, single-layer convolutional layers capture small-pixel features, combinations of 3x3 and 1x1 convolutions enhance the ability to capture relatively large-scale features, and the deformable attention component ensures optimal performance in the large-pixel region. Finally, the information from these three branches is aggregated to generate a new image feature sequence, which is then sent to the decoder.

[0040] As shown in Figure 7, the specific technical details are as follows.

[0041] (1) Three information extraction branches 1. Small-scale convolution branch This branch is primarily used to capture the local texture and detailed information of small objects. Given an input feature map f, a single-layer convolution operation is performed to obtain local features as follows.

number

[0042] Of these, F s (x,y) represents the features of the small-scale convolutional branch output at position (x,y) and is primarily used to capture local details. x and y represent the spatial coordinates of a pixel point in the feature map. i and j represent the offsets in the convolutional kernel, i.e., the row (i) and column (j) indices relative to the current pixel position. K s (i,j) are the weights of the small-scale convolution kernel (1×1) at offset (i,j). s This is the bias term, σ R (·) is the ReLU activation function.

[0043] 2. Relatively large-scale feature extraction branch To obtain a wider range of contextual information, this branch employs a combination strategy of first performing a 3x3 convolution, followed by a 1x1 convolution.

[0044] First, we expand the receptive field using a 3x3 convolution as shown below.

number

[0045] Next, channel reconstruction and feature compression are performed using 1x1 convolution as follows.

number

[0046] Of these, F 3×3 F is an intermediate feature obtained after a 3x3 convolution operation. lThis is a feature of the large-scale branch output obtained after channel tuning by 1x1 convolution, and is used to integrate richer contextual information. 3×3 and b 3×3 These represent the weights and bias terms of the 3x3 convolution kernel, respectively. 1×1 and b 1×1 These represent the weights and bias terms of a 1x1 convolution kernel, respectively.

[0047] This combination not only expands the receptive field of features but also effectively integrates contextual information and can complement global features that cannot be captured by a single local convolution.

[0048] 3. Deformable attention branch To adaptively capture object features within a large-scale domain, we utilize the deformable attention mechanism in Deformable DETR. For each query position q, its output is defined as follows:

number

[0049] Of these, F d (q) is the output feature of a deformable attention branch at query position q, capturing global information using dynamic sampling. N is the number of attention heads. K is the number of sampling points within each head. A qmk This represents the attention weight of the corresponding sampling point (usually normalized by softmax). W m Δp is a linear mapping matrix. qmk x() is the learned sampling offset, allowing the module to dynamically adjust the sampling position. x() represents the feature sampled at the offset position.

[0050] This branch allows the model to adaptively focus on and sample objects at different scales while maintaining the completeness of global information.

[0051] (2) Multibranch feature fusion The outputs of the three branches mentioned above are each F s (Small-scale features), F l (Characteristics of relatively large scale), and F d (Deformable attention features) are used, and a weighted fusion strategy is employed to generate the final feature representation as follows.

number

[0052] Of these, α, β, and γ are learnable fusion weights, and are usually normalized by softmax to ensure a reasonable contribution of each branch to the fusion result. fusion is the linear transformation matrix after fusion. b is the bias term.

[0053] As shown in Figure 8, in this embodiment, the design of the deformable Transformer decoder is based on the Deformable DETR framework and combines dynamic sampling offset and a multiscale feature alignment mechanism. The specific implementation procedure is as follows.

[0054] 1. Initialize object queries The decoder initializes a set of learnable object query parameters (Object Queries). Each query is a high-dimensional embedding vector (e.g., dimension d=256) representing abstract location and class information of a potential object.

[0055] The query count is typically pre-set to a fixed value (e.g., 100 or 300) that covers the maximum number of objects that may exist in an image.

[0056] In the initial stages, queries are independent of input features, and their expressive power is gradually optimized through training.

[0057] 2. Deformable Cross-Attention Module The multiscale fused feature sequence output by the encoder (features generated by CAEFRE) and the object query input are fed into the cross-attention module. Each object query generates reference point coordinates (e.g., center point x,y) through linear mapping and uses them as the initial point of interest.

[0058] Each query predicts multiple sets of dynamic offsets and their corresponding attention weights. Based on each offset, multiscale features are sparsely sampled around the reference point, and weighted aggregate results are calculated.

[0059] Attention weights are used to suppress responses from non-symmetric regions and to emphasize local features of small objects. Intermediate features related to object position and class are generated, including initial detected box coordinates and class confidence.

[0060] 3. Deformable Self-Attention Module The self-attention module acts on object query features through dynamic neighbor constraints to ensure that each query pays attention only to other queries that are spatially close (e.g., within a Euclidean distance threshold). Each query predicts a self-attention sampling offset, sparse the interaction range, and reduces redundant computations.

[0061] It models spatial exclusivity between queries (e.g., avoiding overlapping detection boxes) and semantic relationships (e.g., class co-occurrence) to output optimized object query features.

[0062] The above-mentioned examples of the present application are for illustrative purposes only and do not indicate any preference for any particular example. These are merely preferred examples of the present application and do not limit the scope of protection. For the same reasons, any homogeneous structures or homogeneous flow conversions, or any direct or indirect applications to other related technical fields, made using the contents of the specification and drawings of the present application are included within the scope of protection of the patent of the present application.

Claims

1. A small object detection system in complex scenes based on mask attention and context feature optimization, The ResNet50 backbone network, which integrates a masking attention mechanism, takes the original image as input, filters out redundant background information using a masking mechanism, and outputs a refined multiscale feature map. A context-aware enhanced feature refining encoder performs a multi-branch process on the aforementioned multi-scale feature map, including capturing local details by small-scale convolution, expanding the receptive field by multi-scale convolution, and capturing global information by deformable attention, and finally generates a multi-scale fused feature sequence by weighted fusion. A transformable transformer decoder receives the multiscale fused feature sequence as input, processes it using cross-attention and self-attention modules, constructs an object query, and generates detection results including bounding box coordinates, class labels, and confidence scores. A small object detection system in complex scenes based on mask attention and context feature optimization, including the above.

2. The configuration of the ResNet50 backbone network, which integrates the aforementioned masked attention mechanism, is as follows: An input feature processing module that processes multiscale feature maps through standard convolutional layers to obtain initial feature mappings, A feature segmentation module divides the initial feature mapping into three parts along the channel direction for mask generation and attention weight calculation, A mask generation module processes a portion of the partitioned initial feature mapping using a convolutional layer and a sigmoid activation function to generate a mask, An attention weight module that utilizes the self-attention mechanism to calculate an attention matrix using the other two partitioned parts of the initial feature mapping, selectively enhances them using a mask, and obtains a modulated attention matrix. The module includes a feature enhancement and residual connection module that combines the modulated attention matrix with the original image and outputs a multiscale feature map containing refined global context information and important information from the original input through convolutional transformation and residual connection, A small object detection system in a complex scene based on mask attention and context feature optimization as described in claim 1.

3. The aforementioned context-aware feature enhancement encoder is A small-scale convolution branch is formed by performing a single-layer convolution operation on the aforementioned multiscale feature map to capture the texture and fine-grained information of the object and generate local detail features. A multiscale convolutional combination branch expands the receptive field of the aforementioned multiscale feature map using a 3x3 convolution, and then performs channel reorganization and feature compression using a 1x1 convolution to generate global context features, A deformable attention branch that adaptively captures the features of objects at different scales within the multiscale feature map and generates adaptive global features based on dynamic sampling offsets and attention weights, This includes a multi-branch feature fusion module that weights local detail features, global context features, and adaptive global features using learnable weights, applies linear transformations and activation functions, and outputs a final multi-scale fused feature sequence. A small object detection system in a complex scene based on mask attention and context feature optimization as described in claim 1.

4. The aforementioned deformable Transformer decoder is A cross-attention module that integrates the multiscale features output by the encoder and the object query of the decoder to obtain adaptively enhanced fine-grained features, The decoder includes a self-attention module that performs global relationship modeling on the object query and obtains consistent and mutually exclusive detection box prediction results. A small object detection system in a complex scene based on mask attention and context feature optimization as described in claim 1.

5. The aforementioned deformable Transformer decoder is The preprocessing module further includes performing position encoding and flattening on the multiscale fused feature sequence to form a feature vector, A small object detection system in a complex scene based on mask attention and context feature optimization as described in claim 3.

6. A method for detecting small objects in a complex scene based on mask attention and context feature optimization, using the system described in any one of claims 1 to 5, Step S1 involves inputting the original image into a ResNet50 backbone network that integrates a mask attention mechanism and extracting a multiscale feature map. Step S2 involves inputting the multiscale feature map output by the backbone network into a context-aware enhanced feature refining encoder to obtain a multiscale fused feature sequence. Step S3 involves inputting the multiscale fused feature sequence into the Transformer decoder, generating object queries using the cross-attention module and the self-attention module, and outputting the prediction results. A method for detecting small objects in complex scenes, including mask attention and context feature optimization.

7. Step S1 is, Step S11 involves processing the original image through a convolutional layer to obtain an initial feature mapping, Initial feature mapping along the channel dimension, query branch F Q , Key Branch F K , and mask generation branch F M Step S12 divides it into three branches, F M A convolution operation is performed on the result to generate an initial mask M, and the mask value is restricted to the interval [0,1] using the Sigmoid activation function, F Q and F K Step S13 involves calculating the similarity using the dot product, scaling it, and then normalizing it using Softmax to obtain the attention matrix A. Step S14 involves calculating the element-wise product of the mask M and the attention matrix to perform mask modulation and suppress the response in the background region. Modulated attention matrix A' and corresponding value feature F V A weighted sum is performed using and, convolution enhancement is performed on the result of the weighted sum, and the enhanced features F are obtained. refine Step S15 to obtain, Enhanced feature F refine step S16 of adding the original image, activating the sum with ReLU, and outputting an optimized multi-scale feature map. A method for detecting small objects in a complex scene based on mask attention and context feature optimization as described in claim 6.

8. The aforementioned step S2 is, Step S21 involves processing a multiscale feature map using three parallel branches: a small-scale convolutional branch, a multiscale convolutional combinational branch, and a deformable attention branch, thereby obtaining three branch features. Step S22 involves weighted fusion of the three branch features using learnable weights, The process includes step S23, which involves performing fully connected layer mapping on the fusion result to generate a final multiscale fusion feature sequence. A method for detecting small objects in a complex scene based on mask attention and context feature optimization as described in claim 6.

9. Step S3 is, Step S31 initializes the object query feature vector based on pre-set learnable parameters, Step S32 involves using a deformable cross-attention module to interact with object queries and multiscale fused features of an encoder, dynamically sampling and weighting key regions to generate initial detection boxes and class predictions. Step S33 involves using a deformable self-attention module to model spatial and semantic dependencies between object queries, thereby suppressing redundant predictions and improving the global consistency of the detection box. The process includes step S34, which maps the optimized object query to the final discovery result via a feedforward network. A method for detecting small objects in a complex scene based on mask attention and context feature optimization as described in claim 6.