Safe real-time detection method in complex scene based on multi-scale feature fusion

By improving the lightweight backbone feature extraction network and the adaptive feature fusion network, and combining deep separable convolution and multi-scale context aggregation, the accuracy and real-time performance issues of multi-scale target detection in complex scenarios are solved, and efficient security detection is achieved.

CN121811331AInactive Publication Date: 2026-04-07GUANGZHOU RENHE SHICHUANG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-02
Publication Date
2026-04-07
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing deep learning object detection models struggle to adaptively fuse multi-scale contextual information in complex scenarios, leading to excessive computational load or decreased detection accuracy. They perform poorly, especially in recognizing small-sized objects, making it difficult to meet real-time response requirements.

Method used

An improved lightweight backbone feature extraction network and an adaptive feature fusion network are adopted. The network combines depthwise separable convolution, channel attention mechanism and multi-scale context aggregation. It integrates features at different levels through adaptive gating fusion mechanism, and introduces knowledge distillation and structured pruning optimization to dynamically adjust the computation strategy to adapt to complex scenarios.

Benefits of technology

It significantly improves the detection accuracy and robustness of multi-scale targets in complex scenarios, reduces computational complexity, meets real-time requirements, and enhances the generalization ability under different lighting, weather, and occlusion conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121811331A_ABST
    Figure CN121811331A_ABST
Patent Text Reader

Abstract

The invention discloses a safety real-time detection method in a complex scene based on multi-scale feature fusion, and relates to the technical field of safety detection, and the method comprises the steps: S1, obtaining a to-be-detected complex scene image; s2, extracting multi-scale initial feature maps with different semantic information and spatial details; s3, inputting the initial feature maps of the plurality of scales into an adaptive feature fusion network; s4, inputting the enhanced feature pyramid into a lightweight decoupling detection head, and executing target classification and bounding box regression in parallel; and S5, based on the category and position information, generating and outputting a final security detection result. The method has the advantages that semantic and detail features of different levels are effectively integrated through a self-adaptive gating fusion mechanism and multi-scale context aggregation, and the detection precision and robustness of the model on a multi-scale target in a complex scene are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of security detection technology, specifically to a real-time security detection method for complex scenarios based on multi-scale feature fusion. Background Technology

[0002] With the rapid development of computer vision technology, deep learning-based object detection methods have been widely applied in safety-critical fields such as security monitoring and autonomous driving. However, complex real-world scenarios often present challenges such as significant differences in target scale, variable lighting conditions, severe occlusion, and cluttered backgrounds, which place extremely high demands on the robustness and accuracy of detection algorithms. While many existing high-performance detection models have improved multi-scale target recognition capabilities by constructing complex deep networks and feature pyramid structures, their massive computational load makes it difficult to meet the urgent need for real-time response in practical applications. On the other hand, some lightweight models, although ensuring processing speed, often experience a significant decrease in detection accuracy, especially in the perception of small-sized targets, when faced with the aforementioned complex factors.

[0003] Specifically, in terms of feature fusion strategies, existing methods mostly employ simple top-down or bidirectional feature pyramid networks for multi-scale feature aggregation. However, this fixed fusion approach struggles to adaptively balance the feature contributions of different levels and scenarios, easily leading to information redundancy or confusion. While improving the model's adaptability to complex scenarios, it introduces additional computational overhead. Therefore, designing a security detection method that can adaptively fuse multi-scale contextual information, effectively cope with complex environmental interference, and maintain efficient inference speed within limited hardware and time budgets has become a pressing technical problem in this field. Summary of the Invention

[0004] To address the aforementioned technical issues, this technical solution provides a real-time security detection method for complex scenarios based on multi-scale feature fusion, solving at least one of the technical problems mentioned in the background section.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: Real-time security detection methods for complex scenarios based on multi-scale feature fusion include: S1. Obtain the image of the complex scene to be detected; S2. Input the image into the improved lightweight backbone feature extraction network to extract initial feature maps at multiple scales with different semantic information and spatial details; S3. Input the initial feature maps of the multiple scales into the adaptive feature fusion network. The adaptive feature fusion network includes a bidirectional feature fusion path and a multi-scale context aggregation module to generate an enhanced feature pyramid rich in multi-scale context information. S4. Input the enhanced feature pyramid into a lightweight decoupled detection head, perform target classification and bounding box regression in parallel, and output the category and location information of security-related targets in the complex scene image; S5. Based on the category and location information, generate and output the final security detection result.

[0006] Preferably, the improved lightweight backbone feature extraction network is constructed in the following manner: A lightweight backbone network is built based on depthwise separable convolutions, and deformable convolutional layers are embedded in it to enhance the network's ability to model the geometric deformation of the target. A channel attention mechanism module is introduced after multiple stages of the backbone network. This module adaptively recalibrates the weights of each feature channel by modeling the dependencies between channels in order to focus on key features. A feature pyramid structure is connected after the backbone network. Through top-down and horizontal connections, deep semantic features and shallow detail features are fused to form initial feature maps at multiple scales.

[0007] Preferably, in step S3, the adaptive feature fusion network generates the enhanced feature map through the following steps: In the bidirectional feature fusion path, for two adjacent feature scales, the high-level feature map is first upsampled and then aligned with the number of channels using a 1×1 convolution. At the same time, the low-level feature map is subjected to a 3×3 depthwise separable convolution to enhance its feature representation. The processed high-level and low-level feature maps are concatenated and input into a gating fusion unit, which adaptively fuses feature information from different scales through learnable weight parameters. The multi-scale context aggregation module adopts a hollow spatial pyramid pooling structure, which contains multiple parallel convolutional branches with different void ratios to capture contextual information in multiple receptive fields, and further fuses the outputs of each branch with the output of the gated fusion unit.

[0008] Preferably, in step S4, the lightweight decoupled detection head includes a classification subnetwork and a regression subnetwork, and adopts the following optimization strategy: The classification subnetwork and the regression subnetwork share the input from the enhanced feature pyramid, but are subsequently processed using independent lightweight convolutional layers to optimize the classification and localization tasks respectively. The prior box sizes obtained from the training set using the K-means++ clustering algorithm are combined with a dynamic label assignment strategy to match the most suitable prior box for the target. The classification subnetwork uses VarifocalLoss as the loss function to balance positive and negative samples and hard samples, while the regression subnetwork uses CompleteIoULoss to improve the localization accuracy of the bounding box and assign higher loss weights to small targets.

[0009] Preferably, the method further includes a real-time optimization step, which is implemented during the training and inference phases, and specifically includes: After the model training phase is completed, a structured pruning algorithm based on channel importance is applied to remove redundant feature channels in the backbone feature extraction network and the adaptive feature fusion network. The improved lightweight backbone feature extraction network is trained using a knowledge distillation technique and a more accurate teacher model to improve its performance. During the model deployment phase, mixed-precision inference and inference engine optimization are used to convert model weights to FP16 precision and perform layer fusion and automatic kernel tuning to improve inference speed.

[0010] Preferably, the method further includes a complex scene adaptation mechanism, which specifically includes: In the data preprocessing during the model training phase, physical simulation enhancement is applied, which includes dynamically rendering fog, rain, and snow weather of different concentrations onto the training images, as well as adding motion blur and simulating changes in illumination. During the model inference phase, the input image is first analyzed by a lightweight scene complexity evaluation module. The analysis includes calculating image entropy, edge density, and preliminary target density. Based on the score output by the scene complexity assessment module, the detection mode is dynamically switched: when the score is higher than the threshold, the enhancement mode containing the entire adaptive feature fusion network is enabled; when the score is lower than the threshold, the fast detection mode that bypasses part of the fusion layer is enabled.

[0011] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention effectively integrates semantic and detailed features at different levels through an adaptive gating fusion mechanism and multi-scale context aggregation, significantly improving the model's detection accuracy and robustness for multi-scale targets, especially small targets, in complex scenarios. By introducing lightweight and optimization strategies such as depthwise separable convolution, knowledge distillation, structured pruning, and dynamic inference, it significantly reduces computational complexity and the number of model parameters while maintaining high accuracy, achieving a balance between accuracy and speed and meeting the real-time requirements of applications such as security monitoring. Furthermore, by combining physical simulation data augmentation and scene adaptation mechanisms, the method's generalization ability under different lighting, weather, and occlusion conditions is further enhanced, making it more practical and easier to deploy in real-world complex environments. Attached Figure Description

[0012] Figure 1 This is a flowchart of the real-time security detection method for complex scenarios based on multi-scale feature fusion proposed in this invention. Figure 2 This is an architecture diagram of the electronic devices in this solution; Figure 3 This is a schematic diagram of the computer-readable storage medium structure in this scheme.

[0013] The numbers on the map are: 500 - Electronic device; 501 - Bus; 502 - CPU; 503 - ROM; 504 - RAM; 505 - Communication port; 506 - Input / output component; 507 - Hard disk; 508 - User interface; 600 - Computer-readable storage medium. Detailed Implementation

[0014] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.

[0015] Reference Figure 1 As shown, a real-time security detection method for complex scenarios based on multi-scale feature fusion includes: S1. Acquire complex scene images to be detected. Obtain raw image data to be analyzed from image sensors, video streams, or storage devices. These images usually come from real-world scenes such as security cameras, vehicle vision systems, or drone aerial photography. Their "complexity" is reflected in challenges such as uneven lighting, severe weather (rain, snow, fog), dense targets, varying scales, and partial occlusion, providing uncompressed raw pixel information input for subsequent processing. S2. The image is input into an improved lightweight backbone feature extraction network to extract initial feature maps at multiple scales with different semantic information and spatial details. The improved lightweight backbone network embeds deformable convolution and channel attention mechanisms into a standard lightweight architecture (such as MobileNet), which can enhance the ability to capture target deformation and key features while controlling the amount of computation. Through its hierarchical structure, the network naturally outputs feature maps with different spatial resolutions (such as 1 / 4, 1 / 8, 1 / 16, and 1 / 32 downsampling). The deep feature maps are rich in semantic information, which is conducive to the identification of large targets, while the shallow feature maps have clear spatial details, which is conducive to the localization of small targets, thus forming the initial multi-scale feature representation basis. S3. Initial feature maps at multiple scales are input into an adaptive feature fusion network. This network includes a bidirectional feature fusion path and a multi-scale context aggregation module to generate an enhanced feature pyramid rich in multi-scale contextual information. Instead of simply concatenating or adding features, the adaptive feature fusion network promotes cross-scale information flow through bidirectional paths (top-down and bottom-up) and introduces learnable gating weights to adaptively adjust the fusion contribution of features at each scale. The multi-scale context aggregation module (such as ASPP) captures global and local contexts from different receptive fields through a parallel multi-branch structure, ultimately outputting an enhanced feature pyramid where each layer incorporates contextual information from other scales, significantly improving the model's adaptability to scale differences and complex backgrounds. S4. The enhanced feature pyramid is input into a lightweight decoupled detection head, which performs target classification and bounding box regression in parallel, and outputs the category and location information of safety-related targets in complex scene images. The lightweight decoupled detection head adopts a structure that separates classification and regression branches to avoid task conflicts, and is constructed using lightweight operations such as depthwise separable convolution. It receives the output of each layer of the enhanced feature pyramid and presets anchor boxes of different sizes for each layer. The target category probability is predicted through the classification branch, and the anchor box position is refined through the regression branch. In this process, loss functions (such as VarifocalLoss and CIoULoss) specifically designed for class imbalance and bounding box optimization are adopted, and higher weights are assigned to small targets, so as to directly output high-precision detection results containing class confidence and accurate coordinates while ensuring speed. S5. Based on category and location information, generate and output the final safety detection result. Post-process the original output of the detection head, including applying a non-maximum suppression algorithm to remove redundant overlapping detection boxes and filtering reliable results according to the confidence threshold. The final output is structured data, which may include target bounding box coordinates, category labels, and confidence scores. It can be provided to upper-level applications such as monitoring systems and autonomous driving decision modules in a visual form (such as drawing boxes and labels on the original image) or in the form of a data interface, completing the real-time conversion from image to understandable safety information.

[0016] Specifically, the improved lightweight backbone feature extraction network is constructed in the following way: A lightweight backbone network is built based on depthwise separable convolutions, and deformable convolutional layers are embedded in it to enhance the network's ability to model the geometric deformation of the target. A channel attention mechanism module is introduced after multiple stages of the backbone network. This module adaptively recalibrates the weights of each feature channel by modeling the dependencies between channels in order to focus on key features. A feature pyramid structure is connected after the backbone network. Through top-down and horizontal connections, deep semantic features and shallow detail features are fused to form initial feature maps at multiple scales.

[0017] The specific construction and training implementation methods are as follows: The lightweight backbone network is built upon the inverse residual structure of MobileNetV3-large, replacing all standard convolutions with depthwise separable convolutions to significantly reduce the number of model parameters and computational cost. To enhance the network's ability to model target deformation, pose changes, and partial occlusion, a deformable convolutional layer is embedded after stages 3 and 5 of the backbone network (i.e., layers processing features with medium receptive fields). This deformable convolutional layer adds a parallel offset learning branch to the standard convolution operation, and its kernel sampling position can be dynamically adjusted according to the content of the input features, thereby adaptively focusing on key regions of irregularly shaped targets. To improve feature representation and suppress irrelevant background noise, an efficient channel attention mechanism module is embedded after the outputs of stages 2, 4, and 6 of the backbone network. The specific implementation of this module is as follows: For the input feature map, the spatial dimension is first compressed using global average pooling to generate channel description vectors; then, a bottleneck structure containing two fully connected layers is used, and the Sigmoid function is activated to generate weight coefficients for each channel (with values ​​ranging from 0 to 1); finally, the weight coefficients are multiplied with the original input feature map channel by channel to complete the recalibration of the feature channels. This process enables the network to automatically strengthen feature channels relevant to the target and weaken irrelevant or interfering channels. The final output of the above backbone network (denoted as C5) is used as the source of deep semantic features. A top-down feature pyramid network (FPN) is constructed: After 1×1 convolutional dimensionality reduction of the C5 feature map, it is upsampled by 2 and fused element-wise with the output feature map (C4) from the 4th stage of the backbone network to obtain the fused feature P4; similarly, P4 is upsampled and fused with C3 to obtain P3. Simultaneously, to enrich the semantic information at the bottom layer of the feature pyramid, a bottom-up enhancement path is added: P3 is downsampled using a 3×3 convolution with a stride of 2 and fused with P4 to generate an enhanced P4; this process can continue to propagate upwards. Finally, P3, P4, P5, and P6, directly derived from C5, together constitute initial feature maps at multiple scales (e.g., corresponding to 1 / 8, 1 / 16, 1 / 32, and 1 / 64 downsampling of the input image). During training, this backbone network is jointly trained end-to-end with subsequent modules, employing a stochastic gradient descent optimizer and a cosine annealing learning rate scheduling strategy for optimization.

[0018] The adaptive feature fusion network generates enhanced feature maps through the following steps: In the bidirectional feature fusion path, for two adjacent feature scales, the high-level feature map is first upsampled and then aligned with the number of channels using a 1×1 convolution. At the same time, the low-level feature map is subjected to a 3×3 depthwise separable convolution to enhance its feature representation. The processed high-level and low-level feature maps are concatenated and input into a gating fusion unit, which adaptively fuses feature information from different scales through learnable weight parameters. The multi-scale context aggregation module adopts a hollow spatial pyramid pooling structure, which contains multiple parallel convolutional branches with different void ratios to capture contextual information in multiple receptive fields, and further fuses the outputs of each branch with the output of the gated fusion unit.

[0019] It should be noted that the input to this network consists of initial feature maps of different scales from the backbone network, denoted as {P3, P4, P5, P6}, with their spatial dimensions halved at each level. Taking the fusion process from P5 to P4 as an example in the bidirectional feature fusion path: First, the high-level feature map P5 is upsampled by a factor of 2 to make its spatial dimensions consistent with P4. Then, an independent 1×1 convolutional layer is used to uniformly adjust its channel count to a preset intermediate channel count (e.g., 256 dimensions). Simultaneously, a 3×3 depthwise separable convolution is applied to the low-level feature map P4 for feature enhancement and smoothing, and its output channel count is also adjusted to 256 dimensions. Next, the two processed feature maps are concatenated along the channel dimension to obtain a 512-dimensional pre-fusion feature. This concatenated feature is then fed into a gated fusion unit. This unit specifically consists of a global average pooling layer, two fully connected layers (with ReLU activation in between), and a sigmoid activation function. First, it obtains the global representation of each channel through global average pooling. Then, it learns and outputs a weight vector (with a value range of 0-1) with the same number of input concatenated feature channels through a fully connected layer. This weight vector is multiplied channel-by-channel with the original concatenated features to achieve adaptive weighted fusion of feature information from P4 (details) and P5 (semantics), outputting a preliminary fused feature F4. The preliminary fused feature F4 is fed into a multi-scale context aggregation module. This module adopts a dilated spatial pyramid pooling structure, containing four parallel branches: a 1×1 standard convolution branch, three dilated convolution branches using 3×3 convolutions with dilation rates set to 1, 2, and 4 respectively, and a global average pooling branch. The output channel count of all branches is set to 64 dimensions. Each branch processes F4 separately to capture multi-scale information from local details to global context. Finally, the output features of all five branches are concatenated along the channel dimension, and then dimensionality reduction and integration are performed through a 1×1 convolution to output the final enhanced feature map P4'. This process is repeated for each layer of the feature pyramid, ultimately generating a set of enhanced feature maps {P3', P4', P5', P6'} with highly rich contextual information, for use by subsequent detection heads.

[0020] The lightweight decoupled detection head includes a classification subnet and a regression subnet, and employs the following optimization strategies: The classification subnetwork and the regression subnetwork share input from the augmented feature pyramid, but are subsequently processed using separate lightweight convolutional layers to optimize the classification and localization tasks respectively. The prior box sizes obtained from the training set using the K-means++ clustering algorithm are combined with a dynamic label assignment strategy to match the most suitable prior box for the target. The classification subnet uses VarifocalLoss as the loss function to balance positive and negative samples and hard samples, while the regression subnet uses CompleteIoULoss to improve the localization accuracy of the bounding box and assign higher loss weights to small targets.

[0021] The specific construction, training, and workflow are as follows: The input to the detection head is the enhanced feature pyramid {P3', P4', P5', P6'} output by the adaptive feature fusion network. For the feature map of any layer (e.g., P4'), it is first pre-processed through a shared lightweight basic convolutional module, which consists of a 1×1 pointwise convolution and a 3×3 depthwise separable convolution, designed to perform preliminary feature transformation and integration. Subsequently, the feature stream is split into two parallel independent sub-networks: a classification sub-network and a regression sub-network.

[0022] The classification subnetwork consists of two cascaded 3×3 depthwise separable convolutional layers. The last convolutional layer has K×A output channels, where K is the total number of target categories to be detected and A is the number of anchor boxes preset for this feature layer. This subnetwork outputs the position of each anchor box and the original classification confidence score for each category.

[0023] The regression subnet and the classification subnet have symmetrical structures. Both are composed of two cascaded 3×3 depth-separable convolutional layers. The output channel number of the last convolutional layer is 4×A, which corresponds to the prediction of the four coordinate offsets of each anchor box (the offset of the center point relative to the preset prior box and the scaling of the width and height).

[0024] In terms of prior box design, before model training, the K-means++ clustering algorithm is first run on all ground truth labeled boxes in the training set. For the four different levels of the feature pyramid (P3' to P6'), clustering is performed independently, generating a set of prior boxes that best match the target size of the receptive field for each level. For example, level P3' (high resolution) might yield a set of small-sized prior boxes, while level P6' (low resolution) might yield a set of large-sized prior boxes. During training, a dynamic label allocation strategy (such as ATSS or SimOTA) is used. Based on comprehensive metrics such as the IoU between the predicted and ground truth boxes and the distance to the center points, several best-matching positive sample anchor boxes are dynamically selected for each ground truth target during training, rather than being statically fixed.

[0025] Regarding the loss function, the total loss is a weighted sum of the classification loss and the regression loss. The classification loss uses Variational Loss (VFL): for positive anchor boxes, VFL weights the standard binary cross-entropy loss with a learnable IoU-aware weight, enabling it to simultaneously learn classification scores and localization quality (IoU) estimates; for a large number of negative samples, a version with reduced weights is used to automatically balance positive and negative samples as well as easy and difficult samples. The regression loss uses CompleteIoULoss (CIoU), which comprehensively considers overlapping area, center distance, and aspect ratio to provide more accurate gradient directions. Furthermore, to improve the accuracy of small object detection, a weight coefficient is assigned to the target bounding box based on its area when calculating the regression loss; the smaller the target's area, the larger its weight coefficient (e.g., inversely proportional to the square root of the area), allowing small targets to contribute more to the total regression loss and driving the model to optimize the localization accuracy of small targets. Finally, the parameters of the entire network are jointly optimized through backpropagation.

[0026] In some preferred embodiments, the method further includes a real-time optimization step, which is implemented during the training and inference phases, and specifically includes: After the model training phase, a structured pruning algorithm based on channel importance is applied to remove redundant feature channels in the backbone feature extraction network and the adaptive feature fusion network. We employ knowledge distillation techniques to guide the training of an improved lightweight backbone feature extraction network using a more accurate teacher model, thereby enhancing its performance. During the model deployment phase, mixed-precision inference and inference engine optimization are used to convert model weights to FP16 precision and perform layer fusion and automatic kernel tuning to improve inference speed.

[0027] In specific applications, the above real-time optimization steps are as follows: During the training phase, the model is first refined using knowledge distillation. A deeper and more accurate model (such as ResNet50-FPN) pre-trained on the same dataset is selected as the teacher model. When training the student network (i.e., the improved lightweight backbone network of this invention), in addition to using the target detection loss function of the task itself, a distillation loss is introduced. Specifically, the feature maps output by the feature fusion network and the classification and regression outputs of the final detection head are aligned between the teacher and student models. By calculating the mean squared error loss between feature maps and the KL divergence loss between predicted outputs, a joint distillation loss function is constructed to guide the student network to mimic the teacher network's more powerful feature extraction and inference capabilities, thereby improving performance without significantly increasing its computational complexity. After training, a structured pruning algorithm based on channel L1 norm is applied: for the convolutional layers in the backbone network and the fusion network (especially the pointwise convolutional part of depthwise separable convolution), the average L1 norm of the output feature channel weights is calculated, which is used as a measure of channel importance; a global pruning ratio (e.g., 30%) is set, and the channels with the lowest importance and their connected input / output channels are removed; after pruning, the model is fine-tuned for a short period of time to recover the accuracy lost due to pruning, and finally a lighter and more compact network model is obtained.

[0028] During the deployment and inference phases, the final model, after training, distillation, and pruning, is transformed and accelerated using a deep learning inference optimization framework (such as NVIDIA's TensorRT). First, the model weights are converted from FP32 precision during training to FP16 half-precision to reduce memory usage and leverage GPU Tensor Cores for faster computation. Next, automatic layer fusion optimization is enabled in the inference engine, such as fusing convolutional layers, batch normalization layers, and activation function layers into a single GPU kernel to significantly reduce kernel startup overhead and memory read / write operations. Simultaneously, for different GPU hardware platforms, the inference engine's kernel auto-tuner dynamically selects or generates the fastest kernel from numerous pre-compiled, efficient kernel implementations for key computational layers in the model (such as convolutions of specific sizes) in real-time. Finally, this highly optimized inference engine is packaged and deployed, enabling it to perform real-time security detection tasks with higher throughput and lower latency on edge computing devices or servers.

[0029] In some preferred embodiments, the above method further includes a complex scene adaptation mechanism, which specifically includes: In the data preprocessing stage of model training, physical simulation enhancement is applied, which includes dynamically rendering different concentrations of fog, rain, and snow on the training images, as well as adding motion blur and simulating changes in lighting. During the model inference phase, the input image is first analyzed by a lightweight scene complexity evaluation module. The analysis includes calculating image entropy, edge density, and preliminary target density. Based on the score output by the scene complexity assessment module, the detection mode is dynamically switched: when the score is higher than the threshold, the enhancement mode containing the entire adaptive feature fusion network is enabled; when the score is lower than the threshold, the fast detection mode that bypasses some fusion layers is enabled.

[0030] In specific applications, the aforementioned complex scenario adaptation mechanism is as follows: During the model training phase, the data preprocessing workflow integrates a physical simulation enhancement module. This module dynamically applies various physical perturbations to the input images with preset probabilities during training each batch of data. For weather simulation, an image dehazing model based on dark channel priors is used to generate fog effects of different concentrations (e.g., visibility between 50 and 200 meters), and a particle system is used to simulate raindrops, snowflakes, and their cumulative effects adhering to the lens. Motion blur is simulated by applying a linear motion blur kernel along random directions. Illumination changes are achieved by adjusting the image's brightness and contrast and simulating the illumination effects of point light sources (such as car headlights and searchlights). All these enhancement parameters are randomly sampled within preset ranges to ensure the model is fully trained in a very broad synthetic environment, thereby learning robust feature representations that transcend the limited distribution of real-world data.

[0031] During the model inference phase, a lightweight scene complexity evaluation module is deployed. Before the full detection network runs, this module first performs a rapid analysis of a single-frame input image: calculating the Shannon entropy of the image to assess texture richness and information content; extracting edges using the Sobel operator and calculating edge pixel density to assess structural complexity; and performing a preliminary scan using an extremely lightweight pre-trained face or general object detector (such as a single-layer convolutional network) to estimate the coarse density of objects in the image. After normalizing these three metrics (image entropy, edge density, and object density), a comprehensive scene complexity score between 0 and 1 is output through a learnable small fully connected layer or a linearly weighted combination.

[0032] Based on this score, the system implements a dynamic inference strategy. A configurable threshold T is set (e.g., T=0.6). When the score is greater than T, it is determined to be a "complex scene," and the system activates "enhanced detection mode," which calls the complete network process including all adaptive feature fusion layers and multi-scale context aggregation modules to maximize detection accuracy. When the score is less than or equal to T, it is determined to be a "simple / normal scene," and the system activates "fast detection mode." In this mode, some computationally expensive components are bypassed; for example, the multi-scale context aggregation module in the adaptive feature fusion network is skipped, or a shallower feature pyramid is used for prediction. Mode switching is implemented through conditional judgment logic, ensuring that the system can make an optimal trade-off between accuracy and speed based on the actual input content, thereby maintaining high efficiency in complex and ever-changing real-world deployment environments.

[0033] Furthermore, the method according to the embodiments of this application can also be achieved by means of... Figure 2 The architecture of the electronic device shown is used to implement this. For example... Figure 2 As shown, the electronic device 500 may include a bus 501, one or more CPUs 502, ROM 503, RAM 504, a communication port 505 connected to a network, an input / output component 506, a hard disk 507, etc. The storage device in the electronic device 500, such as ROM 503 or hard disk 507, may store the real-time security detection method for complex scenes based on multi-scale feature fusion provided in this application. The electronic device 500 may also include a user interface 508. Of course, Figure 2 The architecture shown is merely exemplary and can be omitted as needed when implementing different devices. Figure 2 One or more components in the illustrated electronic device.

[0034] Figure 3 This is a schematic diagram of a computer-readable storage medium structure provided in one embodiment of this application. Figure 3 The diagram illustrates a computer-readable storage medium 600 according to one embodiment of this application. The computer-readable storage medium 600 stores computer-readable instructions. When executed by a processor, the computer-readable instructions can perform the real-time security detection method for complex scenes based on multi-scale feature fusion, as described above with reference to the accompanying drawings, according to an embodiment of this application. The computer-readable storage medium 600 includes, but is not limited to, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.

[0035] In summary, the advantages of this invention are: by using an adaptive gating fusion mechanism and multi-scale context aggregation, it effectively integrates semantic and detailed features at different levels, significantly improving the model's detection accuracy and robustness for multi-scale targets in complex scenes.

[0036] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.

Claims

1. A real-time security detection method for complex scenes based on multi-scale feature fusion, characterized in that, include: S1. Obtain the image of the complex scene to be detected; S2. Input the image into the improved lightweight backbone feature extraction network to extract initial feature maps at multiple scales with different semantic information and spatial details; S3. Input the initial feature maps of the multiple scales into the adaptive feature fusion network. The adaptive feature fusion network includes a bidirectional feature fusion path and a multi-scale context aggregation module to generate an enhanced feature pyramid rich in multi-scale context information. S4. Input the enhanced feature pyramid into a lightweight decoupled detection head, perform target classification and bounding box regression in parallel, and output the category and location information of security-related targets in the complex scene image; S5. Based on the category and location information, generate and output the final security detection result.

2. The real-time security detection method for complex scenes based on multi-scale feature fusion according to claim 1, characterized in that, The improved lightweight backbone feature extraction network is constructed in the following way: A lightweight backbone network is built based on depthwise separable convolutions, and deformable convolutional layers are embedded in it to enhance the network's ability to model the geometric deformation of the target. A channel attention mechanism module is introduced after multiple stages of the backbone network. This module adaptively recalibrates the weights of each feature channel by modeling the dependencies between channels in order to focus on key features. A feature pyramid structure is connected after the backbone network. Through top-down and horizontal connections, deep semantic features and shallow detail features are fused to form initial feature maps at multiple scales.

3. The real-time security detection method for complex scenes based on multi-scale feature fusion according to claim 2, characterized in that, In step S3, the adaptive feature fusion network generates enhanced feature maps through the following steps: In the bidirectional feature fusion path, for two adjacent feature scales, the high-level feature map is first upsampled and then aligned with the number of channels using a 1×1 convolution. At the same time, the low-level feature map is subjected to a 3×3 depthwise separable convolution to enhance its feature representation. The processed high-level and low-level feature maps are concatenated and input into a gating fusion unit, which adaptively fuses feature information from different scales through learnable weight parameters. The multi-scale context aggregation module adopts a hollow spatial pyramid pooling structure, which contains multiple parallel convolutional branches with different void ratios to capture contextual information in multiple receptive fields, and further fuses the outputs of each branch with the output of the gated fusion unit.

4. The real-time security detection method for complex scenes based on multi-scale feature fusion according to claim 3, characterized in that, In step S4, the lightweight decoupled detection head includes a classification subnetwork and a regression subnetwork, and adopts the following optimization strategy: The classification subnetwork and the regression subnetwork share the input from the enhanced feature pyramid, but are subsequently processed using independent lightweight convolutional layers to optimize the classification and localization tasks respectively. The prior box sizes obtained from the training set using the K-means++ clustering algorithm are combined with a dynamic label assignment strategy to match the most suitable prior box for the target. The classification subnetwork uses VarifocalLoss as the loss function to balance positive and negative samples and hard samples, while the regression subnetwork uses CompleteIoULoss to improve the localization accuracy of the bounding box and assign higher loss weights to small targets.

5. The real-time security detection method for complex scenes based on multi-scale feature fusion according to claim 4, characterized in that, It also includes real-time optimization steps, which are implemented during the training and inference phases, and specifically include: After the model training phase is completed, a structured pruning algorithm based on channel importance is applied to remove redundant feature channels in the backbone feature extraction network and the adaptive feature fusion network. The improved lightweight backbone feature extraction network is trained using a knowledge distillation technique and a more accurate teacher model to improve its performance. During the model deployment phase, mixed-precision inference and inference engine optimization are used to convert model weights to FP16 precision and perform layer fusion and automatic kernel tuning to improve inference speed.

6. The real-time security detection method for complex scenes based on multi-scale feature fusion according to claim 5, characterized in that, It also includes a complex scene adaptation mechanism, which specifically includes: In the data preprocessing during the model training phase, physical simulation enhancement is applied, which includes dynamically rendering fog, rain, and snow weather of different concentrations onto the training images, as well as adding motion blur and simulating changes in illumination. During the model inference phase, the input image is first analyzed by a lightweight scene complexity evaluation module. The analysis includes calculating image entropy, edge density, and preliminary target density. Based on the score output by the scene complexity assessment module, the detection mode is dynamically switched: when the score is higher than the threshold, the enhancement mode containing the entire adaptive feature fusion network is enabled; when the score is lower than the threshold, the fast detection mode that bypasses part of the fusion layer is enabled.

7. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the real-time security detection method for complex scenes based on multi-scale feature fusion as described in any one of claims 1-6.

8. A computer-readable storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by a processor, they implement the real-time security detection method for complex scenarios based on multi-scale feature fusion as described in any one of claims 1-6.

Citation Information

Cited By

  • Mask detection method and device

    CN122089738A

  • Unmanned aerial vehicle small target lightweight detection method and system applied to complex scene

    CN122313341A

  • Vehicle visual recognition method and system based on multi-scale feature fusion

    CN122368964A