A method, device, and storage medium for real-time cell detection based on an improved YOLOv12.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]有鉴于此,本发明的目的在于提供基于改进YOLOv12的细胞实时检测方法、装置及存储介质,旨在解决现有技术在处理成像式流式细胞仪图像时,因多尺度特征融合不足和对微小目标特征表达不充分,导致的在细胞密集、重叠等复杂场景下检测精度低、漏检率高的问题
本申请通过在现有的YOLOv12模型的骨干网络中设置注意力增强模块AFE,该模块结合通道注意力与空间注意力机制,采用自适应压缩与空间信息聚合策略,有效增强模型对微小细胞、模糊边缘等关键特征的表征能力;并在颈部网络中,在目标节点上使用注意力融合模块A2C2f(高级注意力级联特征融合)替代原标准C3k2模块,同时优化了底层特征与高层特征的融合路径,实现了对特征提取和多尺度特征融合的协同优化;这种结构能够增强模型对微小、模糊目标的特征提取能力,并提升多尺度特征的融合效率,从而显著提升在细胞密集、重叠等复杂场景下的检测精度和召回率,有效降低漏检率,此外,本申请的技术方案在提升检测性能的同时,能够保持较低的计算复杂度,满足成像式流式细胞分析等场景对实时性的要求。
Smart Images

Figure CN121685440B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and biomedical image processing technology, specifically to a method, apparatus, and storage medium for real-time cell detection based on an improved YOLOv12. Background Technology
[0002] Imaging flow cytometry can capture high-resolution microscopic images in real time under dynamic conditions of high-speed cell flow, which has important application value in biomedical research and clinical diagnosis. However, using computer vision technology to detect targets in such images faces unique challenges. For example, cellular targets are usually small in scale and densely distributed, and due to high-speed movement, they are often accompanied by motion blur, irregular shapes, and even overlapping. In addition, high-throughput applications require detection algorithms to have high-efficiency real-time processing capabilities.
[0003] To improve detection performance, some existing deep learning-based object detection methods, such as convolutional neural network-based models, have attempted to introduce attention mechanisms into the backbone network of the model. These mechanisms employ cascaded channel attention and spatial attention operations to enhance the network's ability to extract key features, thereby improving object recognition. However, these methods typically only enhance the feature extraction stage and do not perform targeted collaborative optimization of the subsequent multi-scale feature fusion network.
[0004] When processing images generated by imaging flow cytometry, models not only need to extract effective low-level detail features to identify tiny cells, but also need to efficiently fuse feature information from different network layers to distinguish overlapping targets and understand the global context. Existing methods still largely employ standard structures in the feature fusion stage, which may lead to the weakening or loss of initially enhanced low-level detail information during transmission to higher-level networks, while the high-level semantic information is insufficient to accurately locate densely packed small targets. Therefore, when facing complex dynamic scenes such as dense and overlapping cells, existing technologies still suffer from insufficient detection accuracy and recall, resulting in a high false negative rate, making it difficult to fully meet the demands for high-precision, high-real-time detection. Summary of the Invention
[0005] In view of this, the purpose of the present invention is to provide a real-time cell detection method, device and storage medium based on the improved YOLOv12, which aims to solve the problems of low detection accuracy and high false negative rate in complex scenarios such as dense and overlapping cells when the prior art processes imaging flow cytometry images due to insufficient multi-scale feature fusion and insufficient expression of small target features.
[0006] According to a first aspect of the present invention, a real-time cell detection method based on an improved YOLOv12 is provided, which is applied to a target detection model of YOLOv12, the method comprising: An attention enhancement module (AFE) is added to the backbone network of the target detection model; features are extracted from the image to be detected input to the backbone network, and the target features are enhanced by the channel attention mechanism and spatial attention mechanism of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network. In the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; Multiple fused output images from the neck network are input into multiple detection heads of the target detection model to obtain target detection results at different scales.
[0007] Preferably, The process involves extracting features from the image to be detected input into the backbone network, and enhancing the target features through the channel attention and spatial attention mechanisms of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network, including: The image to be detected, which is of a preset size, is input into the backbone network. The image is then processed by 3×3 convolution through the first convolution module Conv and the second convolution module Conv of the backbone network in sequence, thereby reducing the spatial resolution of the image to be detected and increasing the number of channels. The output image of the second convolution module Conv is input into the first feature extraction module C3k2, and features are extracted through the Bottleneck sequence of the first feature extraction module C3k2, while maintaining spatial resolution and expanding the number of channels. The output image of the first feature extraction module C3k2 is input into the third convolution module Conv to perform 3×3 convolution processing, which further reduces the spatial resolution while maintaining the number of channels. The output image of the third convolutional module Conv is input into the first attention enhancement module AFE. The first attention enhancement module AFE performs feature weighting through the channel attention submodule and the spatial attention submodule without changing the spatial resolution and number of channels of the input image. The output image of the first attention enhancement module AFE is input into the second feature extraction module C3k2, and features are extracted using the Bottleneck sequence, which further expands the number of channels while maintaining spatial resolution. The output image of the second feature extraction module C3k2 is input into the fourth convolution module Conv to perform 3×3 convolution processing, which further reduces the spatial resolution while maintaining the number of channels. The output image of the fourth convolutional module Conv is input into the first attention fusion module A2C2f. The first attention fusion module A2C2f performs feature aggregation through convolution and residual network, and enhances the features of the target region through the region attention mechanism without changing the spatial resolution and number of channels of the input image. The output image of the first attention fusion module A2C2f is input into the fifth convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while expanding the number of channels; The output image of the fifth convolutional module Conv is input into the second attention enhancement module AFE. The key features are enhanced by the channel attention submodule and the spatial attention submodule of the second attention enhancement module AFE without changing the spatial resolution and number of channels of the input image. The output image of the second attention enhancement module AFE is input into the second attention fusion module A2C2f. The second attention fusion module A2C2f performs feature aggregation through convolution and residual networks, and enhances the features of the target region through a region attention mechanism without changing the spatial resolution and number of channels of the input image.
[0008] Preferably, The attention enhancement module (AFE) includes: a channel attention submodule and a spatial attention submodule; The channel attention submodule includes: The channel attention submodule performs global max pooling and global average pooling on the input image in the spatial dimension, respectively; The max pooling feature and the average pooling feature are respectively input into a multilayer perceptron with the same shared parameters, and the multilayer perceptron outputs the max pooling MLP feature and the average pooling MLP feature respectively. The max pooling MLP features and average pooling MLP features are added channel by channel. The added features are then used to generate channel attention weights through a sigmoid activation function. The input image is then multiplied channel by channel attention weights to form a new channel-enhanced feature map.
[0009] Preferably, The spatial attention submodule includes: Receive the channel enhancement feature map from the channel attention submodule; Max pooling and average pooling are performed on the channel enhanced feature map along the channel dimension to obtain channel max pooling features and channel average pooling features. The channel max pooling features and channel average pooling features are concatenated along the channel dimension to obtain a concatenated feature map. The stitched feature map is activated using the ReLU activation function, and then spatial attention weights are generated using the Sigmoid activation function. The channel enhancement feature map is multiplied pixel by pixel with the spatial attention weights to obtain the fused feature map.
[0010] Preferably, The neck network concatenates and fuses multiple low-level output images of the backbone network with upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images, including: The output image of the second attention fusion module A2C2f is input into the first upsampling module, which performs spatial resolution magnification on the input image while keeping the number of channels unchanged. The output image of the first upsampling module and the output image of the fourth convolution module Conv are input into the first stitching module Concat. The first stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the first stitching module Concat is input into the third attention fusion module A2C2f. The region attention mechanism of the third attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the third attention fusion module A2C2f is input into the second upsampling module, which performs spatial resolution magnification on the input image while keeping the number of channels unchanged. The output image of the second upsampling module and the output image of the first attention enhancement module AFE are input into the second stitching module Concat. The second stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the second upsampling module is input into the fourth attention fusion module A2C2f. The region attention mechanism of the fourth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the fourth attention fusion module A2C2f is input into the first detection head, and the first detection head outputs the first target detection result.
[0011] Preferably, it further includes: The output image of the fourth attention fusion module A2C2f is also input into the sixth convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while maintaining the number of channels. The output image of the sixth convolution module Conv and the output image of the first upsampling module are input into the third stitching module Concat. The third stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the third stitching module Concat is input into the fifth attention fusion module A2C2f. The region attention mechanism of the fifth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the fifth attention fusion module A2C2f is input into the second detection head, and the second detection head outputs the second target detection result.
[0012] Preferably, it further includes: The output image of the fifth attention fusion module A2C2f is also input into the seventh convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while maintaining the number of channels. The output images of the seventh convolutional module Conv and the fifth convolutional module Conv are input into the fourth stitching module Concat. The fourth stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the fourth stitching module Concat is input into the sixth attention fusion module A2C2f. The region attention mechanism of the sixth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the sixth attention fusion module A2C2f is input into the third detection head, and the third detection head outputs the third target detection result.
[0013] According to a second aspect of the present invention, a real-time cell detection device based on an improved YOLOv12 is provided, which is applied to a target detection model of YOLOv12, the device comprising: Improved backbone network module: used to add attention enhancement module AFE to the backbone network of the target detection model; to extract features from the image to be detected input to the backbone network, and to enhance the target features through the channel attention mechanism and spatial attention mechanism of the attention enhancement module AFE, so as to obtain multiple low-level output images of the backbone network. Improved neck network module: In the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; Detection head module: used to input multiple fused output images of the neck network into multiple detection heads of the target detection model to obtain target detection results at different scales.
[0014] According to a third aspect of the present invention, a storage medium is provided, the storage medium storing a computer program, which, when executed by a host controller, implements the steps of the above-described method.
[0015] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: This application incorporates an attention enhancement module (AFE) into the backbone network of the existing YOLOv12 model. This module combines channel attention and spatial attention mechanisms, employing adaptive compression and spatial information aggregation strategies to effectively enhance the model's ability to represent key features such as tiny cells and blurred edges. Furthermore, in the neck network, the attention fusion module A2C2f (Advanced Attention Cascaded Feature Fusion) replaces the original standard C3k2 module at the target node. Simultaneously, the fusion path between low-level and high-level features is optimized, achieving synergistic optimization of feature extraction and multi-scale feature fusion. This structure enhances the model's feature extraction capabilities for tiny and blurred targets and improves the efficiency of multi-scale feature fusion, thereby significantly improving detection accuracy and recall in complex scenarios such as dense and overlapping cells, effectively reducing the false negative rate. Moreover, the technical solution of this application maintains low computational complexity while improving detection performance, meeting the real-time requirements of scenarios such as imaging-based flow cytometry analysis.
[0016] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0018] Figure 1 This is a schematic flowchart illustrating a real-time cell detection method based on an improved YOLOv12, according to an exemplary embodiment. Figure 2 This is a schematic diagram of the overall architecture of the original YOLOv12, shown according to another exemplary embodiment; Figure 3 This is a schematic diagram of the overall architecture of the improved YOLOv12, illustrated according to another exemplary embodiment; Figure 4 This is a schematic diagram of the overall architecture of the attention enhancement module (AFE) according to another exemplary embodiment; Figure 5 This is a detailed schematic diagram illustrating three types of red blood cells according to another exemplary embodiment; Figure 6 This is a schematic diagram of representative sample images of the AnimalRBC dataset, illustrated according to another exemplary embodiment. Figure 7 This is a schematic diagram of a real-time cell detection device based on an improved YOLOv12, according to another exemplary embodiment. In the attached diagram: 1-Improved backbone network module, 2-Improved neck network module, 3-Detection head module. Detailed Implementation
[0019] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0020] Example 1 Figure 1 This is a schematic flowchart illustrating a real-time cell detection method based on an improved YOLOv12, according to an exemplary embodiment. Figure 1 As shown, the method includes: S1, add an attention enhancement module (AFE) to the backbone network of the target detection model; extract features from the image to be detected input to the backbone network, and enhance the target features through the channel attention mechanism and spatial attention mechanism of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network. S2, in the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; S3, input the multiple fused output images of the neck network into the multiple detection heads of the target detection model respectively to obtain target detection results at different scales; It is understood that, in order to facilitate a better understanding of the innovations of this application, this embodiment describes the existing YOLOv12 model framework, as shown in the appendix. Figure 2 As shown, YOLOv12, as a representative of real-time detection models, has achieved a breakthrough in balancing accuracy and efficiency. The YOLOv12 architecture consists of three main components: Backbone, Neck, and Head networks. The following sections will provide a detailed explanation of each part of the original YOLOv12 model: The backbone network employs Residual Efficient Layer Aggregation Network (R-ELAN), an enhanced variant of Efficient Layer Aggregation Network (ELAN), which combines block-level residual connections and an adaptive expansion strategy. This optimization improves feature reuse efficiency while maintaining stable gradient propagation with minimal computational overhead. The integration of 7×7 large-kernel separable convolutions expands the receptive field, thereby improving the model's ability to locate small targets. Through meticulous optimization of the modern GPU memory hierarchy, this architecture improves computational throughput and reduces inference latency without affecting detection performance. The Neck network's A2C2f module employs an Area Attention mechanism, which significantly enhances the contextual modeling capability of multi-scale features through a spatially guided feature fusion strategy. To address the high memory consumption of traditional attention methods, memory access paths are optimized to reduce computational overhead, achieving efficient feature integration while maintaining low inference latency (<5ms). Furthermore, this module adopts a Dynamic Weighted Multi-scale Fusion strategy, significantly improving the detection accuracy of multi-scale targets (especially small-scale cells) by learning the spatial importance weights of different feature layers. The detection head adopts a decoupled design, separating the classification and localization task branches to alleviate task conflicts. The traditional dual 3×3 convolutional layers are replaced with lightweight depthwise separable convolutional modules, which improves computational efficiency while significantly reducing model parameters.
[0021] This application proposes a rapid cell detection model based on an improved YOLOv12, aiming to achieve real-time cell detection on imaging flow cytometers. The model architecture is shown in the attached figure. Figure 3As shown, in the backbone network, this application introduces a lightweight attention enhancement module (AFE, Adaptive Feature Enhancement). This module adaptively fuses channel and spatial features, effectively suppressing background noise and significantly enhancing the feature expression ability of small cell targets. At the end of the backbone, it retains efficient multi-scale feature extraction capabilities. An AFE is placed after the P3 / 8 layer features output by the backbone network. The P3 / 8 layer features refer to feature maps whose spatial resolution is downsampled by 8 times relative to the input image size. Feature maps at this level typically retain rich spatial details and texture information, which is crucial for detecting small targets. Placing the AFE here enhances the feature information before it is further compressed and abstracted, thereby maximizing the preservation and highlighting of the features of small cells. As an optional implementation, an AFE can also be inserted after deeper network layers, such as P5 / 32 layers, to enhance the discriminative power of high-level semantic information. As a preferred implementation, in order to adaptively adjust the degree of information compression at different network depths, the shared multilayer perceptron in the channel attention submodule can adopt a hierarchical compression ratio strategy. Specifically, in the AFE (Automatic Front-End) configuration of the shallow layers of the backbone network (such as after layers P3 / 8), the first fully connected layer of the multilayer perceptron can compress the number of channels C to C / r, where r is the first compression ratio, for example, r=8. In the AFE configuration of the deeper layers of the backbone network (such as after layers P5 / 32), a second compression ratio can be set, for example, r=16. Since the feature maps of deeper networks typically have more channels and richer semantic information, using a larger compression ratio can significantly reduce computation and parameter count while effectively aggregating information; while shallower networks have richer features, using a smaller compression ratio helps retain more original information.
[0022] In the feature fusion network (Neck) part, this application replaces the C3k2 module in the key node with the A2C2f module (advanced attention cascaded feature fusion module), realizing a mechanism innovation of the feature pyramid structure. This module uses a channel-space dual attention mechanism to dynamically enhance key features and improves the gradient information flow efficiency through a cross-level feature cascade structure, significantly optimizing the fusion effect of multi-scale features. These improvements work together to significantly improve detection accuracy (95.5% mAP@0.5, a 3.2% improvement over the baseline YOLOv12), providing reliable technical support for rapid cell detection in the medical field. After understanding the improvements to YOLOv12, the specific execution process is as follows: Backbone network: As attached Figure 3 As shown, the image with input (640, 640, 3) is fed into the improved YOLOv12 backbone network; The first convolutional module Conv performs a 3×3 convolution (same padding, stride=2), downsamples the spatial size by half, and increases the number of channels from 3 to 16, outputting an image of (320, 320, 16). The second convolutional module Conv performs a 3×3 convolution (same padding, stride=2), spatially downsamples by half again and increases the number of channels from 16 to 32, outputting an image of (160, 160, 32). The first feature extraction module, C3k2, enters a lightweight feature extraction structure. The feature extraction submodule is set to False (disabled). It uses the Bottleneck sequence (first reducing the number of feature channels, processing, and then expanding back). Specifically, when the feature extraction submodule is disabled, the C3K2 module degenerates into a residual connection structure, retaining only the basic functions of channel segmentation and feature concatenation. Channel segmentation: The input feature map is divided into two parts, which are processed through different paths. Residual connection: After disabling the submodule, only the shallow feature branches that are directly passed are retained, similar to the standard C3 module. Feature concatenation: The outputs of the two branches are fused through the Concat operation of the concatenation module to form the final feature map. The first feature extraction module, C3k2, expands the input image channels to 64 without changing the spatial resolution, and outputs an image of (160, 160, 64). The third convolution module Conv performs a 3×3 convolution (same padding, stride=2), spatially downsamples to (80,80) and maintains 64 channels, outputting an image of (80, 80, 64); The first attention enhancement module (AFE) weights the features in the channel attention submodule and the spatial attention submodule (max / average pooling in the channel direction → MLP, channel convergence in the spatial direction → conv → sigmoid). This module does not change the shape, and the output is still an image of (80, 80, 64). The attention enhancement module AFE adopts a cascaded dual attention mechanism, mathematically expressed as:
[0023] in F in As input features, and These represent the channel and spatial attention functions, respectively. The dynamic channel attention path employs an innovative dynamic initialization, automatically acquiring the number of input channels during the first forward propagation. Furthermore, the compression bottleneck is adjustable, and a hierarchical compression ratio r is introduced to control the feature compression intensity.
[0024]
[0025] In the formula, , For global feature descriptors, For dimensionality reduction mapping, δ is the ReLU activation function, r is the dynamic compression ratio, and the compression ratio strategy is shallow. (High compression), deep (Low compression); The spatial attention path is based on cross-channel feature aggregation, and its calculation process is as follows:
[0026] (5) In the formula, 7 7 convolution kernels, Indicates the splicing channel; Key innovations of the Attention Enhancement Module (AFE) include: (1): Dynamic channel adaptation mechanism. This mechanism dynamically initializes the channel attention module according to the channel dimension of the input features at runtime, thereby achieving zero-configuration deployment and cross-architecture compatibility. This not only removes the channel parameters required by traditional modules, but also reduces the number of parameters by 20% through delayed initialization, thus optimizing memory usage. (2): Layered compression ratio strategy, which differentiates the feature characteristics of different network depths. When a high compression ratio r=8 is used in the shallow layer, background noise and redundant information are removed by high compression, and the recognition of basic morphological features of cell outline and texture is enhanced, which helps the model to quickly capture the overall shape of the cell. When a low compression ratio r=16 is used in the deep layer, the key discrimination details are retained by low compression for the high-level semantic features required for cell category discrimination, ensuring classification accuracy and enabling the model to accurately distinguish cell types. (3): Gradient cooperative modulation, the specific gradient expression is:
[0027] The dual attention mechanism synergistically modulates gradient propagation, enhances the gradient response in key cell regions, and suppresses gradient interference from background noise. The number of parameters and computational complexity of AFE are comparable to those of mainstream attention mechanisms such as SE and CBAM. This AFE design can effectively enhance feature representation capabilities while maintaining low computational complexity, making it suitable for a variety of computer vision tasks.
[0028] The specific implementation steps include: Channel attention submodule: As attached Figure 4 As shown, the shape is The feature map is input into the channel attention submodule of the attention enhancement module (AFE). The channel attention submodule performs global max pooling and global average pooling on the input image in the spatial dimension, respectively, and the resulting feature shapes are all... The max-pooling and average-pooling features are input into a three-layer perceptron (MLP) with the same shared parameters. The MLP outputs max-pooling MLP features and average-pooling MLP features respectively, while the MLP output remains unchanged. The shape is as follows: Max-pooling MLP features and average-pooling MLP features are added channel-wise. The added features are then processed using a Sigmoid activation function to generate channel attention weights. The input feature map is then multiplied channel-wise with these channel attention weights to form a new channel-enhanced feature map, with the shape remaining the same. ; Spatial Attention Submodule: As attached Figure 4 As shown, the output feature map of the channel attention submodule is input into the spatial attention submodule. The spatial attention submodule first performs max pooling and average pooling on the input feature map along the channel dimension, respectively, and the resulting spatial maps are all... Then, the two images are stitched together along the channel dimension to form... The feature map is input into the ReLU activation function, and then spatial attention weights are generated by sigmoid activation. Finally, these spatial attention weights are multiplied pixel by pixel with the input feature map to obtain a shape of... Feature map; that is, the final fused feature map, which is the final output image of the attention enhancement module (AFE). The second feature extraction module C3k2: enters the lightweight feature extraction structure, the feature extraction submodule = False (off), uses the Bottleneck sequence to expand the channels to 128 without changing the spatial resolution, and outputs an image of (80, 80, 128); The fourth convolution module Conv performs a 3×3 convolution (same padding, stride=2) to downsample the features, and the output space becomes (40, 40) while the number of channels remains 128, resulting in an image of (40, 40, 128). The first attention fusion module, A2C2f, has Region Attention = true (enabled). A2C2f is an improved feature extraction module in YOLOv12, combining Region Attention (A2) and residual connections to improve feature extraction efficiency and accuracy. Input / output processing: Dimensionality reduction (128→64) of input features and dimension increase (64→128) of output features are achieved through two 1×1 convolutional layers. The ABlock module is the core component, containing: Region Attention (A2): Generates query (q), key (k), and value (v) vectors through convolutional layers. Locational encoding (7×7 depthwise separable convolutions) enhances local-global feature interaction; MLP layer: two convolutional layers (128→256→128) are used for non-linear feature transformation, with SiLU as the activation function; Residual connection: used to stabilize training and enhance feature representation; Features include: efficient attention mechanism: the A2 module reduces the computational complexity of traditional self-attention through region attention while maintaining a large receptive field; multi-scale feature fusion: combining MLP and residual connection to improve feature representation capability; this block does not change the spatial resolution and maintains 128 channels, outputting an image of (40, 40, 128); The fifth convolutional module, Conv, performs a 3×3 convolution (same padding, stride=2) to downsample the space to (20,20) and expand the channels to 256, outputting an image of (20, 20, 256). The second attention enhancement module (AFE) enhances key features by applying channel and spatial attention mechanisms. This module does not change the shape and outputs an image of (20, 20, 256). The second attention fusion module A2C2f: Region Attention = true (enabled). This block does not change the spatial resolution and maintains 256 channels, outputting an image of (20, 20, 256). Neck network: First upsampling module: The (20, 20, 256) image output by the second attention fusion module A2C2f is input into the first upsampling module. The spatial size is enlarged to (40, 40) by upsampling ×2, while the channels remain unchanged. The output is an image of (40, 40, 256). The first stitching module Concat takes as input (40, 40, 256) images output by the first upsampling module and (40, 40, 128) images output by the fourth convolution module Conv, respectively. The two images are spatially consistent and are stitched along the channel dimension to obtain 256 + 128 = 384 channels. The output is an image of (40, 40, 384). The third attention fusion module A2C2f: Region attention = False (off). When region attention is off, the residual connection and feature aggregation capabilities of the A2C2f module still exist. Multi-scale feature fusion is achieved through multi-layer convolution and residual branching, reducing the number of channels to 128 (spatial invariance), and the output is an image of (40, 40, 128). The second upsampling module: takes the (40, 40, 128) image output by the third attention fusion module A2C2f, upsamples it by 2 to spatially enlarge it to (80, 80), keeping the channels unchanged, and outputs an image of (80, 80, 128); The second stitching module Concat takes as input the image (80,80,128) output by the second upsampling module and the image (80,80,64) output by the first attention enhancement module AFE. The two images are spatially consistent and are stitched along the channel dimension to obtain a channel 128+64=192, and the output is an image (80, 80, 192). Fourth attention fusion module A2C2f: Region attention = False (off), reduce the number of channels to 64, and output an image of (80,80,64); The sixth convolutional module Conv performs a 3×3 convolution (same padding, stride=2) on the (80,80,64) image output by the fourth attention fusion module A2C2f to downsample the features, keeping the number of channels unchanged, and outputs an image of (40, 40, 64). The third stitching module, Concat, takes as input the (40,40,64) image output from the sixth convolution module, Conv, and the (40,40,256) image output from the first upsampling module. Since they are spatially consistent, they are stitched along the channel dimension to obtain a channel count of 64 + 256 = 320, and the output is an image of (40, 40, 320). Fifth attention fusion module A2C2f: Region attention = False (off), reduce the number of channels to 128, and output an image of (40, 40, 128); The seventh convolutional module, Conv, performs a 3×3 convolution (same padding, stride=2) downsampling to a low resolution, outputting an image of (20, 20, 128). The fourth stitching module, Concat, takes as input the (20,20,128) image output by the seventh convolution module, Conv, and the (20,20,256) image output by the fifth convolution module, which are spatially consistent. They are stitched along the channel dimension to obtain a channel 128+256=384, and the output is an image of (20, 20, 384). The sixth attention fusion module A2C2f: Region attention = False (off), downscaling the channels to 256, outputting an image of (20,20,256); Detection head: First detection head: Receives the (80,80,64) image output by the fourth attention fusion module A2C2f and completes the first scale target detection; Second detection head: Receives the (40,40,128) image output by the fifth attention fusion module A2C2f and completes the second scale target detection; The third detection head receives the (20,20,256) image output by the sixth attention fusion module A2C2f and completes the third-scale target detection. It should be noted that each detection branch typically contains convolutional layers, which are used to ultimately predict the bounding box coordinates, confidence score, and class probability of the target. This embodiment performs two key reconstructions on the neck network: The first reconstruction focuses on optimizing the upsampling fusion path: In the traditional YOLOv12 model, the upsampling path of the neck network typically involves upsampling deep feature maps (such as P5 / 32) and then concatenating them with the corresponding intermediate layer feature maps (such as P4 / 16) from the backbone network. The improvement in this embodiment is that when it is necessary to fuse the lowest-level features to generate feature maps for detecting small targets, the original P3 / 8 layer features of the backbone network are no longer used. Instead, the enhanced feature maps processed by AFE are used directly, such as connecting the output of the first attention enhancement module AFE directly to the second concatenation module Concat in the neck network. This path ensures that the lowest-level detail features with the highest information value, which have been filtered and enhanced by the attention mechanism, can be directly and losslessly injected into the feature pyramid fusion process, thereby greatly enhancing the model's ability to capture details of tiny cellular targets.
[0029] The second reconstruction focuses on the key feature fusion node of the neck network. A cascaded feature fusion module with integrated attention mechanism, specifically the A2C2f module, is used to replace the standard feature fusion module (such as the C3k2 module) in the original YOLOv12-n model. The C3k2 module typically consists of several basic convolutional layers and a bottleneck structure, and its feature fusion capability is relatively limited. In contrast, A2C2f explicitly integrates an attention mechanism within a C3k2-like cascaded bottleneck structure. For example, it can incorporate a dual attention unit similar to AFE. This design allows for… When fusing feature maps from different paths (e.g., features from the backbone network and features from the upsampling path), A2C2f can adaptively learn how to weight and combine this information, thereby achieving deeper and more intelligent feature interaction and fusion, and improving non-linear expression capabilities. It is particularly effective in distinguishing morphologically similar or overlapping cells. The A2C2f module (fourth attention fusion module A2C2f, fifth attention fusion module A2C2f, and sixth attention fusion module A2C2f) was used in the three key fusion nodes of the neck network. This embodiment also provides a method for constructing a dedicated animal cell microscopic image dataset: In the field of biomedical image analysis and cell detection, high-quality, scene-specific labeled datasets are the key foundation for model training and performance verification. Cell targets are usually characterized by small scale, high morphological similarity, and dense distribution, which brings great challenges to model feature extraction and discrimination.
[0030] In recent years, several specialized public datasets have been proposed for cell detection tasks in the medical field. These include datasets for white blood cell classification and identification (such as LISC), benchmark datasets for blood cell detection (such as BBBC038v1), and various challenge datasets for microscopic cell segmentation or classification (such as the ISBI Cell Segmentation Challenge). These datasets provide valuable resources for related research, but they mainly focus on specific types (such as human blood cells) or specific applications (such as segmentation or classification). Furthermore, their data acquisition equipment (such as conventional microscopes), cell type diversity, and imaging throughput often deviate from the actual application environment of imaging flow cytometers.
[0031] To fill this gap, this embodiment independently constructed a dedicated animal cell microscopic image dataset, AnimalRBC, with detailed images of the three types of red blood cells as attached. Figure 5 As shown, all images were captured instantaneously by a 2000 fps high-speed camera as cells passed through the microfluidic channel at a rate of 1.5–2.5 μL / min, realistically reproducing the deformation, rotation, and overlap of cells in a flowing state, rather than traditional static microsections. Its main features and value are: (1) Species and cell type diversity: The dataset contains three types of target cells: guinea pig red blood cells, chicken red blood cells, and sheep red blood cells. Selecting red blood cells from different species not only enriches the diversity of cell types, but also serves as an effective standard sample for verifying the model's ability to distinguish subtle differences in features among similar cells due to their relatively regular morphology but the potential for subtle morphological and size differences between species. (2) Self-built imaging platform: Unlike commercial equipment, the data acquisition of this dataset relies on the imaging high-speed flow cytometer system independently developed and built by the team. This system has been specially optimized for the high-speed capture requirements of cell microscopic images, and can accurately capture the real physical process of cells flowing at high speed under the sheath fluid and being imaged instantaneously during flow cytometry; (3) Small-scale target characteristics: Red blood cells are small target objects under a microscope, which is highly consistent with the "small-scale target detection problem of cells" emphasized in the abstract, and puts forward clear requirements for the feature extraction ability of the model; (4) Precise annotation: The research team performed precise bounding box annotations on all target cells in the dataset, and the category information was clear.
[0032] The establishment of the AnimalRBC dataset provides a highly targeted and scenario-relevant validation platform for the improved algorithms proposed in this embodiment (such as the AFE module for enhanced small cell feature extraction and the optimized multi-scale fusion structure). Compared with general datasets and single-cell type datasets, it more directly reflects the real needs and challenges of rapid multi-species cell detection tasks using imaging flow cytometry, and provides an indispensable basis for evaluating and comparing the performance of the model in the target application field.
[0033] This example, based on the aforementioned AnimalRBC dataset, provides a specific experimental case, as shown below: AnimalRBC dataset: The experimental data were all obtained from raw images captured by a high-speed camera at 2000 frames per second under dynamic flow conditions. Each frame recorded the instantaneous state of three types of target cells—guinea pig red blood cells, chicken red blood cells, and sheep red blood cells—passing through the field of view at high speed in the fluid flow. All images had a resolution of 1280×1024 pixels. System sampling was performed at 100-frame intervals, and all samples were manually annotated with bounding box precision using LabelImg 1.8.6 software. In the YOLO format, each object was encoded as a 5-tuple—normalized center coordinates, size (x_center, y_center, width, height), and class index (0-2). This format ensures computational efficiency and reduces storage requirements, making it very suitable for high-resolution multi-object detection tasks. The final dataset contains 300 images, divided into training and validation sets in a 6:1 ratio. Representative samples of the dataset are attached. Figure 6 As shown; Experimental platform and hyperparameter settings: All experiments were conducted under standardized laboratory conditions. Hardware specifications are detailed in Table 1. The training process employed a uniform hyperparameter configuration: input images were adjusted to 640×640 resolution, training epochs were 300, patience was set to 20, and batch size was set to 16 to balance GPU memory utilization and training stability. The model used a stochastic gradient descent (SGD) optimizer, with momentum parameter μ=0.937 and weight decay coefficient... The initial learning rate was 0.01, and a cosine annealing scheduling strategy was used for adjustment.
[0034] Table 1 Hardware Specifications
[0035] This comprehensive configuration enables YOLOv12 to balance detection accuracy and inference efficiency, improving the overall performance of cell detection. Evaluation indicators: To evaluate the performance of YOLOv12, this embodiment uses several key metrics: precision, recall, F1 score, and mean average precision (mAP). In addition, model complexity is evaluated based on gigaflops per second (GFLOPs) and the number of parameters (M).
[0036] Precision is defined as the proportion of correctly predicted positive samples out of all samples predicted as positive. It reflects the accuracy of the model's positive sample predictions, and the calculation formula is:
[0037] in TP(True cases) represent the number of correctly predicted positive samples. FP (False positives) refers to the number of negative samples that are incorrectly predicted as positive.
[0038] Recall measures the proportion of all actual positive samples correctly identified by the model, indicating the model's ability to capture positive samples. It is defined as:
[0039] The F1 score, the harmonic mean of precision and recall, provides a balanced evaluation metric, which is particularly valuable in imbalanced datasets. Its calculation formula is:
[0040] Average precision (AP) is calculated from the area under the precision-recall curve, based on the intersection-union (IoU) score between predicted and actual bounding boxes. It is defined as:
[0041] in, It is the first i Accuracy at a threshold, It is the change in recall rate at that threshold.
[0042] Mean Average Precision (mAP) is the average of the average precision across all categories. Specifically, mAP@0.5 refers to the AP calculated at an IoU threshold of 0.50, used to measure the model's accuracy in locating fast-moving cells in dynamic streaming images, while mAP@0.5:0.95 is the average of the APs across multiple IoU thresholds ranging from 0.50 to 0.95 with a step size of 0.05. The overall mAP calculation formula is:
[0043] in, n It is the total number of categories. It is a category c The average accuracy.
[0044] YOLOv12 showed significant improvements in all key performance metrics during training. The poor performance in the early stages was mainly due to small cell size, occlusion, and low contrast. The mAP@50 (the target recognition ability when the cross-union threshold is 0.5) increased by more than 250%, indicating that the model can detect cells even under challenging conditions such as low resolution or the presence of impurities.
[0045] Model comparison experiment To evaluate the performance of different detection models on AnimalRBC, this embodiment conducted a comprehensive comparison with several mainstream YOLO variants, including YOLOv5, YOLOv6, YOLOv8, YOLOv10, and YOLOv11, under the same experimental settings. The experimental results are shown in Table 2 below. The improved YOLOv12 in this application achieves superior overall performance in both detection accuracy and model efficiency. Specifically, the model in this application achieves the highest mAP@0.5 among all models and also performs well in other metrics, with mAP@0.5:0.95, representing a 3.2% improvement over the previous best model YOLOv12-n. Furthermore, it achieves the highest precision among all models, significantly outperforming other models. On the AnimalRBC dataset, YOLO-AF achieves the highest recall and F1 score, demonstrating its powerful capabilities in cell detection tasks.
[0046] Table 2. Comparison of experimental results for different YOLO models
[0047] Ablation experiment: To evaluate the performance of the module, this embodiment conducted a large number of ablation experiments on the AnimalRBC dataset. The experimental results are shown in Table 3 below, where A represents the AFE module and B represents the reconstructed feature pyramid network.
[0048] Table 3 Quantitative comparison of ablation experimental results on the AnimalRBC dataset
[0049] The results from the AnimalRBC dataset show that adding either of the two modules individually can improve performance across different behavior categories. However, when the two modules are used together, the model performance is further improved due to their complementary effects, with mAP@0.5 reaching 95.5%, which is 3.2% higher than the benchmark model YOLOv12. More notably, mAP@0.5:0.95 reaches 0.635, indicating that the model has robust detection capabilities for fine-grained behaviors and small targets.
[0050] Example 2 Figure 7 This is a schematic diagram of a real-time cell detection device based on an improved YOLOv12, according to another exemplary embodiment, the device comprising: Improved backbone network module 1: used to add an attention enhancement module (AFE) to the backbone network of the target detection model; to extract features from the image to be detected input to the backbone network, and to enhance the target features through the channel attention mechanism and spatial attention mechanism of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network. Improved neck network module 2: In the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; Detection head module 3: Used to input multiple fused output images of the neck network into multiple detection heads of the target detection model to obtain target detection results at different scales.
[0051] Example 3 This embodiment provides a storage medium storing a computer program, which, when executed by a host controller, implements the various steps in the above method. It is understood that the storage medium mentioned above can be a read-only memory, a hard disk, or an optical disk, etc.
[0052] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0053] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.
[0054] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0055] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0056] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0057] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0058] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0059] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0060] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A real-time cell detection method based on an improved YOLOv12, applied to the target detection model of YOLOv12, characterized in that, The method includes: An attention enhancement module (AFE) is added to the backbone network of the target detection model; features are extracted from the image to be detected input to the backbone network, and the target features are enhanced by the channel attention mechanism and spatial attention mechanism of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network. In the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; The neck network concatenates and fuses multiple low-level output images of the backbone network with upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images, including: The bottom-level output image of the second attention fusion module A2C2f is input into the first upsampling module. The first upsampling module enlarges the spatial resolution of the input image while keeping the number of channels unchanged. The output image of the first upsampling module and the output image of the fourth convolution module Conv of the backbone network are input into the first stitching module Concat. The first stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the first stitching module Concat is input into the third attention fusion module A2C2f. The region attention mechanism of the third attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the third attention fusion module A2C2f is input into the second upsampling module, which performs spatial resolution magnification on the input image while keeping the number of channels unchanged. The output image of the second upsampling module and the output image of the first attention enhancement module AFE are input into the second stitching module Concat. The second stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the second stitching module Concat is input into the fourth attention fusion module A2C2f to obtain the fused output image. The region attention mechanism of the fourth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. Multiple fused output images from the neck network are input into multiple detection heads of the target detection model to obtain target detection results at different scales.
2. The method according to claim 1, characterized in that, The process involves extracting features from the image to be detected input into the backbone network, and enhancing the target features through the channel attention and spatial attention mechanisms of the attention enhancement module (AFE) to obtain multiple low-level output images of the backbone network, including: The image to be detected, which is of a preset size, is input into the backbone network. The image is then processed by 3×3 convolution through the first convolution module Conv and the second convolution module Conv of the backbone network in sequence, thereby reducing the spatial resolution of the image to be detected and increasing the number of channels. The output image of the second convolution module Conv is input into the first feature extraction module C3k2, and features are extracted through the Bottleneck sequence of the first feature extraction module C3k2, while maintaining spatial resolution and expanding the number of channels. The output image of the first feature extraction module C3k2 is input into the third convolution module Conv to perform 3×3 convolution processing, which further reduces the spatial resolution while maintaining the number of channels. The output image of the third convolutional module Conv is input into the first attention enhancement module AFE. The first attention enhancement module AFE performs feature weighting through the channel attention submodule and the spatial attention submodule without changing the spatial resolution and number of channels of the input image. The output image of the first attention enhancement module AFE is input into the second feature extraction module C3k2, and features are extracted using the Bottleneck sequence, which further expands the number of channels while maintaining spatial resolution. The output image of the second feature extraction module C3k2 is input into the fourth convolution module Conv to perform 3×3 convolution processing, which further reduces the spatial resolution while maintaining the number of channels. The output image of the fourth convolutional module Conv is input into the first attention fusion module A2C2f. The first attention fusion module A2C2f performs feature aggregation through convolution and residual network, and enhances the features of the target region through the region attention mechanism without changing the spatial resolution and number of channels of the input image. The output image of the first attention fusion module A2C2f is input into the fifth convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while expanding the number of channels; The output image of the fifth convolutional module Conv is input into the second attention enhancement module AFE. The key features are enhanced by the channel attention submodule and the spatial attention submodule of the second attention enhancement module AFE without changing the spatial resolution and number of channels of the input image. The output image of the second attention enhancement module AFE is input into the second attention fusion module A2C2f. The second attention fusion module A2C2f performs feature aggregation through convolution and residual networks, and enhances the features of the target region through a region attention mechanism without changing the spatial resolution and number of channels of the input image.
3. The method according to claim 2, characterized in that, The attention enhancement module (AFE) includes: a channel attention submodule and a spatial attention submodule; The channel attention submodule includes: The channel attention submodule performs global max pooling and global average pooling on the input image in the spatial dimension, respectively; The max pooling feature and the average pooling feature are respectively input into a multilayer perceptron with the same shared parameters, and the multilayer perceptron outputs the max pooling MLP feature and the average pooling MLP feature respectively. The max pooling MLP features and average pooling MLP features are added channel by channel. The added features are then used to generate channel attention weights through a sigmoid activation function. The input image is then multiplied channel by channel attention weights to form a new channel-enhanced feature map.
4. The method according to claim 3, characterized in that, The spatial attention submodule includes: Receive the channel enhancement feature map from the channel attention submodule; Max pooling and average pooling are performed on the channel enhanced feature map along the channel dimension to obtain channel max pooling features and channel average pooling features. The channel max pooling features and channel average pooling features are concatenated along the channel dimension to obtain a concatenated feature map. The stitched feature map is activated using the ReLU activation function, and then spatial attention weights are generated using the Sigmoid activation function. The channel enhancement feature map is multiplied pixel by pixel with the spatial attention weights to obtain the fused feature map.
5. The method according to claim 4, characterized in that, Also includes: The output image of the fourth attention fusion module A2C2f is also input into the sixth convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while maintaining the number of channels. The output image of the sixth convolution module Conv and the output image of the first upsampling module are input into the third stitching module Concat. The third stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the third stitching module Concat is input into the fifth attention fusion module A2C2f. The region attention mechanism of the fifth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the fifth attention fusion module A2C2f is input into the second detection head, and the second detection head outputs the second target detection result.
6. The method according to claim 5, characterized in that, Also includes: The output image of the fifth attention fusion module A2C2f is also input into the seventh convolution module Conv to perform 3×3 convolution processing, which reduces the spatial resolution while maintaining the number of channels. The output images of the seventh convolutional module Conv and the fifth convolutional module Conv are input into the fourth stitching module Concat. The fourth stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the fourth stitching module Concat is input into the sixth attention fusion module A2C2f. The region attention mechanism of the sixth attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the sixth attention fusion module A2C2f is input into the third detection head, and the third detection head outputs the third target detection result.
7. A real-time cell detection device based on an improved YOLOv12, applied to the target detection model of YOLOv12, characterized in that, The device includes: Improved backbone network module: used to add attention enhancement module AFE to the backbone network of the target detection model; to extract features from the image to be detected input to the backbone network, and to enhance the target features through the channel attention mechanism and spatial attention mechanism of the attention enhancement module AFE, so as to obtain multiple low-level output images of the backbone network. Improved neck network module: In the neck network of the target detection model, the original feature extraction module C3k2 of the target node is replaced with the attention fusion module A2C2f; the neck network splices and fuses multiple low-level output images of the backbone network with the upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images; The neck network concatenates and fuses multiple low-level output images of the backbone network with upsampled high-level feature maps through the attention fusion module A2C2f to obtain multiple fused output images, including: The bottom-level output image of the second attention fusion module A2C2f is input into the first upsampling module. The first upsampling module enlarges the spatial resolution of the input image while keeping the number of channels unchanged. The output image of the first upsampling module and the output image of the fourth convolution module Conv of the backbone network are input into the first stitching module Concat. The first stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the first stitching module Concat is input into the third attention fusion module A2C2f. The region attention mechanism of the third attention fusion module A2C2f is turned off. Cross-stage feature fusion is achieved through convolution and residual network to reduce the number of channels of the input image while maintaining the spatial resolution. The output image of the third attention fusion module A2C2f is input into the second upsampling module, which performs spatial resolution magnification on the input image while keeping the number of channels unchanged. The output image of the second upsampling module and the output image of the first attention enhancement module AFE are input into the second stitching module Concat. The second stitching module Concat stitches the two input images along the channel dimension while keeping the spatial resolution unchanged. The output image of the second stitching module Concat is input into the fourth attention fusion module A2C2f to obtain the fused output image; the region attention mechanism of the fourth attention fusion module A2C2f is turned off, and cross-stage feature fusion is achieved through convolution and residual networks to reduce the number of channels of the input image while maintaining the spatial resolution unchanged; Detection head module: used to input multiple fused output images of the neck network into multiple detection heads of the target detection model to obtain target detection results at different scales.
8. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by the main controller, implements the various steps of the real-time cell detection method based on the improved YOLOv12 as described in any one of claims 1-6.
Citation Information
Patent Citations
Vehicle detection method based on improved YOLOv12n
CN120451922A
Improved YOLOv5 protective equipment detection method combining channel selection and attention mechanism
CN120635573A