Improved lightweight YOLOX-nano model and detection method for target detection
By using an improved lightweight YOLOX-nano model, combined with an improved coordinate attention mechanism and a hybrid spatial pyramid pooling structure, the problems of time-consuming and low-accuracy white blood cell detection are solved, achieving fast and accurate white blood cell detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-18
- Publication Date
- 2026-03-24
AI Technical Summary
Existing white blood cell testing methods are time-consuming, their accuracy depends on the experience of medical technicians, and the expensive equipment requires professional training, lacking ease of operation and testing precision.
An improved lightweight YOLOX-nano model, including a backbone network, a neck network, and a prediction network, is adopted. Combined with an improved coordinate attention mechanism and a hybrid spatial pyramid pooling structure, the accuracy of feature fusion and object detection is improved.
It enables rapid, real-time, and accurate detection of white blood cells, reducing the workload of medical technicians and improving the efficiency of patient examinations.
Smart Images

Figure CN115908255B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of white blood cell detection technology, and in particular to an improved lightweight YOLOX-nano model and detection method for target detection. Background Technology
[0002] The identification and counting of white blood cells are crucial in the diagnosis and treatment of diseases because white blood cells are an essential part of the human immune system, responsible for protecting the body from various diseases and infections. Among these tests, identifying the white blood cell count, as part of a complete blood count, is one of the most important clinical blood tests. This test can diagnose inflammation, infection, leukemia, or certain immune system disorders.
[0003] Generally, cell counting is performed by medical technicians using microscopes and human vision. However, this process is extremely time-consuming, and its accuracy can be affected by the technician's experience and physical fatigue, leading to low reliability. While white blood cell differential counting can also be performed using laser, electrical, or optical detection equipment, these methods are very expensive and typically require specialized training. Therefore, a user-friendly and highly accurate white blood cell detection vision system that enables rapid detection of white blood cells in microscopic images is of significant practical importance. Summary of the Invention
[0004] The purpose of this section is to outline some aspects of embodiments of the present invention and to briefly describe some preferred embodiments. Simplifications or omissions may be made in this section, as well as in the abstract and title of this application, to avoid obscuring the purpose of these documents; however, such simplifications or omissions should not be construed as limiting the scope of the invention.
[0005] In view of the problems existing in the above and / or existing improved lightweight YOLOX-nano models and methods for object detection, this invention is proposed.
[0006] Therefore, the problem to be solved by this invention is how to provide an improved lightweight YOLOX-nano model for object detection.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution: an improved lightweight YOLOX-nano model for object detection, comprising: a backbone network, including a Focus module, convolution 1, convolution 2, CSP module 1, convolution 3, CSP module 2, convolution 4, CSP module 3, convolution 5, a hybrid spatial pyramid pooling structure, and a CSP module 4 arranged sequentially; and a neck network, including an improved coordinate attention mechanism 1 connected to the CSP module 4, an improved coordinate attention mechanism 2 connected to the CSP module 3, an improved coordinate attention mechanism 3 connected to the CSP module 2, and a convolution 6, an upsampling module 1, an improved coordinate attention mechanism 4, a concatenation module 1, a CSP module 5, a convolution 7, an upsampling module 2, a concatenation module 2, a CSP module 6, a downsampling module 1, a concatenation module 3, a CSP module 7, a downsampling module 2, a concatenation module 3, a concatenation module 7, and a concatenation module 2, a concatenation module 4, a concatenation module 5, a hybrid spatial pyramid pooling structure, and a CSP module 4 arranged sequentially; and a neck network, including an improved coordinate attention mechanism 1 connected to the CSP module 4, an improved coordinate attention mechanism 2 connected to the CSP module 3, an improved coordinate attention mechanism 4, a concatenation module 1, a CSP module 5, a convolution 7, an upsampling module 2, a concatenation module 2, a CSP module 6, a downsampling module 1, a concatenation module 3, a CSP module 7, a downsampling module 2, a concatenation module 4, a concatenation module 5, a concatenation module 6, a downsampling module 1, a concatenation module 3, a CSP module 7, a downsampling module 2, and a concatenation module 4, The network consists of an oncat module 4 and a CSP module 8. The improved coordinate attention mechanism 3 is connected to the concatenation concat module 2, the improved coordinate attention mechanism 2 is connected to the concatenation concat module 1, the improved coordinate attention mechanism 1 is connected to convolution 6, and convolution 6 is connected to the concatenation concat module 4. Convolution 7 is connected to the concatenation concat module 3. The prediction network includes a YOLOHead module 1 connected to the CSP module 6, a YOLOHead module 2 connected to the CSP module 7, and a YOLOHead module 3 connected to the CSP module 8. The hybrid spatial pyramid pooling structure includes an average pooling module, a max pooling module, and a concatenation concat module 5 connected to convolution 8, and a convolution 9 connected to the concatenation concat module 5. The average pooling module and the max pooling module are both connected to the concatenation concat module 5.
[0008] As a preferred embodiment of the improved lightweight YOLOX-nano model for object detection described in this invention, the average pooling module includes 13×13, 9×9 and 5×5 average pooling; the max pooling module includes 13×13, 9×9 and 5×5 max pooling.
[0009] As a preferred embodiment of the improved lightweight YOLOX-nano model for object detection described in this invention, the CSP module refers to obtaining a first intermediate value and a second intermediate value after passing the input feature map through convolution 10 and convolution 11 respectively. The first intermediate value is input into the SimAM attention mechanism, and the second intermediate value is input into the residual network. Then, the outputs of the two are concatenated and passed through the channel shuffling module to shuffle the grouping order between channels, better fuse the feature sequences, and improve the communication quality between channels.
[0010] The SimAM attention mechanism is represented by the following formula.
[0011]
[0012]
[0013]
[0014] In the formula, This represents the average value of all neurons in that channel. This represents the variance of all neurons in this channel, where M represents the number of neurons in this channel, and x represents the variance of all neurons in this channel. i Let u represent the i-th neuron. t This represents the average value excluding neuron t, where t represents the neuron. Let λ represent the energy of the smallest neuron, and λ be a coefficient.
[0015] As a preferred embodiment of the improved lightweight YOLOX-nano model for object detection described in this invention, the improved coordinate attention mechanism includes parallel global average pooling, X-direction average pooling, and Y-direction average pooling. After performing global average pooling, X-direction average pooling, and Y-direction average pooling on the input features, the intermediate values of global pooling, X-pooling, and Y-pooling are obtained respectively. The intermediate value of global pooling is then sequentially processed by a one-dimensional convolution with an adaptive K-kernel selection, a Sigmoid non-linear activation, and an element-wise dot product before being output. The intermediate values of X-pooling and Y-pooling are fused for feature fusion, and then processed by two-dimensional convolution, batch normalization, non-linear activation, two-layer two-dimensional convolution, and Sigmoid non-linear activation before being output.
[0016] As a preferred embodiment of the improved lightweight YOLOX-nano model for object detection described in this invention, the improved coordinate attention mechanism refers to the process of aggregating features along two orthogonal directions to perform one-dimensional weight encoding during the acquisition of feature mapping attention weights, and performing nonlinear complementarity on the feature mapping through ID weights in the orthogonal directions. It includes three steps: coordinate information embedding, coordinate attention generation, and efficient channel attention generation.
[0017] During the coordinate information embedding step, global pooling is decomposed into two feature encoding operations. For input X, height h, and width w, the output of the c-th channel is... Expressed by the following formula:
[0018]
[0019]
[0020] The two transformations described above aggregate features along the two spatial directions i and j and return a pair of direction-aware attention maps. This operation corresponds to the X-average pooling and Y-average pooling parts.
[0021] During the coordinate attention generation step, the two generated feature maps are concatenated, and a shared 1×1 convolution is used to transform the F1 function, generating an intermediate feature map f of spatial information in the horizontal and vertical directions. w ∈R C / r×W Where r represents the downsampling ratio, and then two 1×1 convolutions F are used. h F w For the feature mapping f respectively w ∈R C / r×W and f w ∈R C / r×W The transformation yields the result g. h g w This can be represented by the following formula.
[0022] g h =σ(F h (f h ))
[0023] g w =σ(F w (f w ))
[0024] In the formula, σ represents the Sigmoid activation function;
[0025] When performing the efficient channel attention generation step, the input feature map F c Global average pooling is performed, followed by adaptive one-dimensional convolution with kernel size k. After the operation, the weights of each channel are obtained through the Sigmoid function, and the weights are multiplied by the corresponding elements of the original input feature map to output the feature map. The formula is described as follows:
[0026]
[0027] In the formula, e c For feature mapping, σ represents the Sigmoid activation function. F represents a one-dimensional convolution operation with a kernel size of k. c For the input feature map, Avgpool represents the average pooling operation;
[0028] The value of k is calculated using the following formula:
[0029]
[0030] In the formula, k is the kernel size and C is the channel dimension. This represents the closest odd number. γ and b are hyperparameters, set to 2 and 1 respectively.
[0031] The output y of the improved coordinate attention mechanism c (i,j) is represented by the following formula.
[0032]
[0033] In the formula, y c (i,j) represents the final output feature map after the improved coordinate attention module; e c (i,j) represents the feature map output after efficient channel attention; This represents the feature map output along the horizontal X direction; This represents the feature map output along the vertical Y direction.
[0034] Another objective of this invention is to provide a target-oriented detection method to address the problems of slow detection speed and low detection accuracy in existing white blood cell detection methods.
[0035] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a detection method for target detection, comprising the following steps,
[0036] Acquire and filter white blood cell image data;
[0037] Create a white blood cell dataset and divide it into three categories: training set, validation set, and test set;
[0038] Build an improved lightweight YOLOX-nano model;
[0039] The improved lightweight YOLOX-nano model was trained and evaluated.
[0040] Obtain the test results.
[0041] As a preferred embodiment of the target detection method of the present invention, when screening the acquired white blood cell image data, images of basophils, eosinophils, lymphocytes, monocytes and neutrophils are retained.
[0042] As a preferred embodiment of the target detection method described in this invention, when creating the white blood cell dataset, the LabelImg calibration tool is used to annotate the type and location information of white blood cells, and the data is saved as JPG image files and XML annotation files containing the above information, respectively, to obtain all white blood cell images.
[0043] As a preferred embodiment of the target detection method described in this invention, in the hybrid spatial pyramid pooling structure, the input feature map F in ∈R W×H×C A 1×1 convolutional layer is used to obtain refined channel information, which is then converted into a feature map F'∈R. W×H×C / 2 Then, max pooling and average pooling operations with different kernel sizes are performed simultaneously to generate six different receptive field feature maps. The original features are then concatenated to form a comprehensive feature map F. cat ∈R W×H×7C / 2 This process achieves the fusion of local and global features. Finally, through a 1×1 convolutional layer, all features are integrated and a single feature map F is output. out ∈R W×H×C The formula is described as follows:
[0044]
[0045] In the formula, Maxpool and Avgpool represent the max pooling and average pooling operations with kernel sizes of 5×5, 9×9, and 13×13, respectively. This indicates a splicing operation.
[0046] As a preferred embodiment of the target detection method described in this invention, when evaluating the improved lightweight YOLOX-nano model, the evaluation is mainly based on the average of P precision, R recall, AP mean precision, mAP mean precision, and F1 score, with FPS rate, Params number of parameters, FLOPs floating-point operations and weight size as auxiliary evaluation factors.
[0047] The beneficial effects of this invention are: it enables rapid, real-time, and accurate detection of five types of white blood cells, including basophils, eosinophils, lymphocytes, monocytes, and neutrophils; it is user-friendly and easy to operate, effectively reducing the workload and dependence of medical technicians, and improving the efficiency of patient examinations. Attached Figure Description
[0048] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0049] Figure 1 This is a schematic diagram of the network structure of the improved lightweight YOLOX-nano model for object detection in Example 1.
[0050] Figure 2 This is a schematic diagram of the CSP module of the improved lightweight YOLOX-nano model for target detection in Example 1.
[0051] Figure 3 This is a schematic diagram of the improved coordinate attention mechanism structure of the improved lightweight YOLOX-nano model for object detection in Example 1.
[0052] Figure 4 This is a schematic diagram of the hybrid spatial pyramid pooling structure of the improved lightweight YOLOX-nano model for object detection in Example 1.
[0053] Figure 5 This is an overall flowchart of the target detection method in Example 2.
[0054] Figure 6 This is a flowchart of the white blood cell dataset acquisition process for the target detection method in Example 2.
[0055] Figure 7 This diagram illustrates a comparison of the model described in this invention with other existing technologies in terms of mAP, number of parameters, and computational complexity, using the target detection method described in Example 3. Detailed Implementation
[0056] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0057] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0058] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0059] Example 1
[0060] Reference Figures 1-4 This is the first embodiment of the present invention, which provides an improved lightweight YOLOX-nano model for object detection. The improved lightweight YOLOX-nano model for object detection includes a backbone network, a neck network, and a prediction network.
[0061] Specifically, such as Figure 1 The backbone network consists of the following modules arranged in sequence: Focus module, Convolution 1, Convolution 2, CSP module 1, Convolution 3, CSP module 2, Convolution 4, CSP module 3, Convolution 5, Hybrid Spatial Pyramid Pooling Structure, and CSP module 4.
[0062] The neck network includes an improved coordinate attention mechanism 1 connected to the CSP module 4, an improved coordinate attention mechanism 2 connected to the CSP module 3, an improved coordinate attention mechanism 3 connected to the CSP module 2, and a convolution 6, an upsampling module 1, an improved coordinate attention mechanism 4, a concatenation module 1, a CSP module 5, a convolution 7, an upsampling module 2, a concatenation module 2, a CSP module 6, a downsampling module 1, a concatenation module 3, a CSP module 7, a downsampling module 2, a concatenation module 4, and a CSP module 8 arranged sequentially. The improved coordinate attention mechanism 3 is connected to the concatenation module 2, the improved coordinate attention mechanism 2 is connected to the concatenation module 1, the improved coordinate attention mechanism 1 is connected to the convolution 6, the convolution 6 is connected to the concatenation module 4, and the convolution 7 is connected to the concatenation module 3.
[0063] The prediction network includes YOLOHead module 1 connected to CSP module 6, YOLOHead module 2 connected to CSP module 7, and YOLOHead module 3 connected to CSP module 8.
[0064] The hybrid spatial pyramid pooling structure includes an average pooling module, a max pooling module, and a concatenation module 5 connected to convolution 8, as well as a convolution 9 connected to the concatenation module 5. Both the average pooling module and the max pooling module are connected to the concatenation module 5. The hybrid spatial pyramid pooling structure can retain the most salient features at different scales and improve the receptive field of the feature map for both global and local regions, thereby increasing the contextual information of the receptive field.
[0065] Preferably, the average pooling module includes 13×13, 9×9 and 5×5 average pooling; the max pooling module includes 13×13, 9×9 and 5×5 max pooling.
[0066] like Figure 2The CSP module refers to obtaining a first intermediate value and a second intermediate value after passing the input feature map through convolution 10 and convolution 11, respectively. The first intermediate value is input into the SimAM attention mechanism, and the second intermediate value is input into the residual network. Then, the outputs of the two are concatenated and passed through the channel shuffling module to shuffle the grouping order between channels, so as to better fuse the feature sequences and improve the communication quality between channels.
[0067] The SimAM attention mechanism can effectively generate true three-dimensional weights and defines the following energy function for each neuron, expressed by the following formula:
[0068]
[0069]
[0070]
[0071] In the formula, This represents the average value of all neurons in that channel. This represents the variance of all neurons in this channel, where M represents the number of neurons in this channel, and x represents the variance of all neurons in this channel. i Let u represent the i-th neuron. t This represents the average value excluding neuron t, where t represents the neuron. Let λ represent the energy of the smallest neuron, and λ be a coefficient. This formula shows that energy... The lower the value of t, the more specific the neuron is to its surrounding neurons, and the more important it is for visual processing. Therefore, the importance of each neuron can be expressed as... After determining the importance of neurons, the feature matrix is enhanced according to the definition of the attention mechanism, and its formula is as follows:
[0072]
[0073] In the formula, X represents the fused feature map, and X represents the input feature map. Let E represent the attention weight matrix of the channel, and let E represent the energy matrix.
[0074] The Channel Shuffling (SC) module shuffles and reorders the channels of the concatenated feature layers to improve the communication quality between channels. In other words, for the feature map generated by the previous convolutional layer, the channels in each group are first divided into several subgroups. Then, in the next convolutional layer, each group uses a different subgroup. That is, a convolutional layer is divided into G groups, and the output channel size is adjusted to (G, n), transposed, and flattened as the input to the next layer. Without increasing computational cost or parameters, the grouping order is shuffled to better fuse feature information and enhance classification performance.
[0075] Furthermore, the improved coordinate attention mechanism can further focus on the key points of feature map information. It includes global average pooling, X-direction average pooling, and Y-direction average pooling set in parallel. After performing global average pooling, X-direction average pooling, and Y-direction average pooling on the input features, the intermediate values of global pooling, X-pooling, and Y-pooling are obtained respectively. The intermediate value of global pooling is then passed through a one-dimensional convolution with an adaptive K kernel, a Sigmoid non-linear activation, and an element-wise dot product before being output. The intermediate values of X-pooling and Y-pooling are fused for feature fusion, and then passed through a two-dimensional convolution, batch normalization, non-linear activation, two layers of two-dimensional convolution, and a Sigmoid non-linear activation before being output.
[0076] The improved coordinate attention mechanism refers to a process of aggregating features along two orthogonal directions to perform one-dimensional weight encoding during the acquisition of feature map attention weights, and using ID weights in the orthogonal directions to perform nonlinear complementation on the feature map, thereby enhancing the feature map's ability to express the target region of interest. It includes three steps: coordinate information embedding, coordinate attention generation, and efficient channel attention generation.
[0077] During the coordinate information embedding step, global pooling is decomposed into two feature encoding operations to facilitate attentional capture of spatial long-range dependencies with precise location information. For input X, height h, and width w, the output of the c-th channel is... Expressed by the following formula:
[0078]
[0079]
[0080] The two transformations described above aggregate features along the two spatial directions i and j, and return a pair of direction-aware attention maps. This operation corresponds to the X-average pooling and Y-average pooling parts.
[0081] During the coordinate attention generation step, the two generated feature maps are concatenated, and a shared 1×1 convolution is used to transform the F1 function, generating an intermediate feature map f of spatial information in the horizontal and vertical directions. w ∈R C / r×W Where r represents the downsampling ratio, and then two 1×1 convolutions F are used. h F w For the feature mapping f respectively w ∈R C / r×W and f w ∈R C / r×W The transformation yields the result g. h g w This can be represented by the following formula.
[0082] g h =σ(F h (f h ))
[0083] g w =σ(F w (f w ))
[0084] In the formula, σ represents the Sigmoid activation function.
[0085] When performing the efficient channel attention generation step, the input feature map F c Global average pooling is performed, followed by adaptive one-dimensional convolution with kernel size k. After the operation, the weights of each channel are obtained through the Sigmoid function, and the weights are multiplied by the corresponding elements of the original input feature map to output the feature map. The formula is described as follows:
[0086]
[0087] In the formula, e c For feature mapping, σ represents the Sigmoid activation function. F represents a one-dimensional convolution operation with a kernel size of k. c For the input feature map, Avgpool represents the average pooling operation. The value of k is calculated using the following formula:
[0088]
[0089] In the formula, k is the kernel size and C is the channel dimension. This represents the closest odd number. γ and b are hyperparameters, set to 2 and 1 respectively.
[0090] The output y of the improved coordinate attention mechanism c (i,j) is represented by the following formula.
[0091]
[0092] In the formula, y c (i,j) represents the final output feature map after the improved coordinate attention module; e c (i,j) represents the feature map output after efficient channel attention; This represents the feature map output along the horizontal X direction; This represents the feature map output along the vertical Y direction.
[0093] This not only efficiently integrates spatial coordinate information into the generated feature map, but also extracts feature information more comprehensively, and identifies and locates targets more accurately.
[0094] Preferably, in this embodiment, the global activation function is improved by changing the SiLU function of the original YOLOX network to the Mish function, introducing more nonlinear factors, increasing the nonlinear variation of the neural network model, and improving the information expression ability of the neural network model.
[0095] Furthermore, the formula for the Mish function is described as follows:
[0096] Mish(x)=x·tanh(ln(1+exp(x))).
[0097] Furthermore, this embodiment improves the loss calculation function by selecting a more suitable function, EIOU, to calculate the loss. This is beneficial for obtaining a better model and faster convergence speed during training, thereby improving detection accuracy.
[0098] The calculation of the EIOU loss function consists of three parts, namely the overlap loss L IOU Calculation of center distance loss L dis and width and height loss L asp The calculation formula is described as follows:
[0099]
[0100] In the formula, ρ(·) represents the Euclidean distance; w gt ,h gt B represents the center coordinates, width, and height of the actual bounding box, respectively; ctr w and h represent the center coordinates, width, and height of the prediction box, respectively; c w ,c h These are the width and height of the minimum bounding rectangle of the prediction box, respectively.
[0101] Example 2
[0102] Reference Figures 1-6 This is a second embodiment of the present invention, which provides a detection method for target detection. The target detection method includes the following steps:
[0103] S1. Obtain and filter white blood cell image data;
[0104] S2. Create a white blood cell dataset and divide it into three categories: training set, validation set, and test set;
[0105] S3. Build an improved lightweight YOLOX-nano model;
[0106] S4. Train and evaluate the improved lightweight YOLOX-nano model;
[0107] S5. Obtain the test results.
[0108] Specifically, in step S1, when filtering the acquired white blood cell image data, images of basophils, eosinophils, lymphocytes, monocytes, and neutrophils are retained.
[0109] In step S2, when creating the white blood cell dataset, the LabelImg annotation tool is used to annotate the type and location information of white blood cells, and the data is saved as JPG image files and XML annotation files containing the above information, respectively, to obtain all white blood cell images. Finally, the dataset is divided into training set, validation set and test set according to a certain ratio.
[0110] When building the improved lightweight YOLOX-nano model, in the hybrid spatial pyramid pooling structure, the input feature map F in ∈R W×H×C A 1×1 convolutional layer is used to obtain refined channel information, which is then converted into a feature map F'∈R. W×H×C / 2 Then, max pooling and average pooling operations with different kernel sizes are performed simultaneously to generate six different receptive field feature maps. The original features are then concatenated to form a comprehensive feature map F. cat ∈R W×H×7C / 2 This process achieves the fusion of local and global features. Finally, through a 1×1 convolutional layer, all features are integrated and a single feature map F is output. out ∈R W×H×C The formula is described as follows:
[0111]
[0112] In the formula, Maxpool and Avgpool represent the max pooling and average pooling operations with kernel sizes of 5×5, 9×9, and 13×13, respectively. This indicates a splicing operation.
[0113] Furthermore, when evaluating the improved lightweight YOLOX-nano model, the evaluation was primarily based on the average of P precision, R recall, AP mean precision, mAP mean precision, and F1 score, supplemented by FPS rate, number of params, number of floating-point operations (FLOPs), and weight size.
[0114] The main evaluation criteria are as follows:
[0115]
[0116]
[0117]
[0118]
[0119]
[0120] In the formula, TP, FP, and FN represent the number of true positive, false positive, and false negative samples, respectively. P represents precision, which is the proportion of successfully detected true positive instances. R is recall, which is the proportion of all detected true targets. F1 is usually used as a metric to balance P and R; a higher F1 value indicates better performance. AP represents the area under the PR curve, used to evaluate the overall performance of each class on the test model. mAP represents the average AP for each class, expressing the average goodness or badness across all classes, evaluated using confidence thresholds of 0.5, 0.75, and 0.5:0.05:0.95, respectively.
[0121] In the auxiliary evaluation criteria, FPS represents the number of images that can be processed per second; a higher value indicates a faster detection speed. Params represents the number of parameters, affecting the memory usage during model inference. FLOPs represents floating-point operations, which can be understood as computational cost. Weight size represents the space occupied by the convolution weights.
[0122] Example 3
[0123] Reference Figure 7 To verify the feasibility of the present invention, a third embodiment is provided.
[0124] Specifically, S1, several normal peripheral blood smears were obtained from the hospital. These smears were processed using Wright staining by medical technicians and placed on an optical microscope with 100x magnification. Images were captured using a smartphone camera through the microscope eyepiece to obtain raw images of the blood cells. These raw images were then cropped to a resolution of 575×575 pixels. Images containing five types of white blood cells—basophils, eosinophils, lymphocytes, monocytes, and neutrophils—were selected, and images without white blood cells were discarded. During image selection, the images were optimized based on the proportion of each type of white blood cell to match the normal proportions, and redundant or low-quality images were removed. A total of 14,514 white blood cell images were obtained.
[0125] S2. Using the LabelImg annotation tool, the type and location information of white blood cells are labeled, and saved as JPG image files and XML annotation files containing the above information, respectively, to obtain all white blood cell images. To facilitate type differentiation and image counting, the names of the two file formats are matched accordingly, and the images are numbered starting with "category + 00001" until all images are numbered. The images are then divided into training, validation, and test sets in a 7:2:1 ratio, with each of the three sample sets containing images of the five white blood cell categories mentioned above.
[0126] S3. Improved lightweight YOLOX-nano model;
[0127] S4. A deep learning environment was configured using the PyTorch framework and Anaconda compiler, with Python as the programming language. Training set image samples were input into the network, and image features of five types of white blood cells were learned through convolution. Simultaneously, validation set image samples were input for network model evaluation and validation, providing real-time assessment of the training model's performance and guiding subsequent parameter optimization. Before starting the training model, the network's hyperparameters needed to be initialized. The settings were as follows: input image size was 640×640, using Mosaic data augmentation, cosine annealing of the learning rate, and the Adam optimizer with an optimizer momentum of 0.937, a learning rate of 0.001, a total training epoch of 150, and a batch size of 32. Freeze-training was used. The network was then comprehensively evaluated using metrics such as P precision, R recall, AP (average precision), mAP (average mean AP), F1 score (FPS), Params (number of parameters), FLOPs (floating-point operations), and weight size.
[0128] S5. Input test set image samples into the network and output test set images with prediction result labels. The location of white blood cells is marked with boxes, and the predicted white blood cell category and prediction probability are labeled. Different white blood cell categories are labeled with different colors: red represents basophils, yellow represents eosinophils, green represents lymphocytes, blue represents monocytes, and purple represents neutrophils.
[0129] All experiments were pre-trained on the COCO dataset to obtain pre-trained weights. Transfer learning was then used to train, validate, and test on the same white blood cell dataset. The improved YOLOX-nano algorithm proposed in this patent is compared with the original algorithm in Table 1. The results show that the AP value for each type is higher than the original AP value, especially for eosinophils, lymphocytes, and monocytes, where the AP values are significantly improved. Furthermore, the table shows that the accuracy for detecting basophils, lymphocytes, and monocytes reached 96.77%, 98.01%, and 97.33%, respectively, representing improvements of 15.69%, 18.70%, and 8.72%. The improvement is even more significant. In terms of recall, eosinophils and monocytes performed well, with improvements of 2.52% and 3.85%, respectively, while neutrophils showed a decrease of 0.55%. On the comprehensive metric represented by the F1 score, the five types performed 0.98, 0.92, 0.98, 0.95, and 0.99, respectively, representing improvements of 0.08, 0.03, 0.10, 0.06, and 0.01. The mAP values at different thresholds were also 2.13%, 1.04%, and 0.65% higher than the original, indicating good robustness of the model.
[0130] Table 1 Comparison with the original algorithm
[0131]
[0132]
[0133] For the large volume of routine blood tests in hospitals, real-time performance and high accuracy are of paramount importance for saving patients' time and diagnosing diseases. Therefore, this study compared the algorithm with several popular lightweight deep learning detection models, including YOLOv5-nano, YOLOv4-tiny, and MobileNetv2-SSD, evaluating other metrics affecting speed and accuracy. Table 2 shows the experimental results of the improved YOLOX-nano algorithm proposed in this patent, comparing it with other models on the test set at IOU = 0.5, based on various evaluation metrics.
[0134] Table 2 Comparison of Evaluation Metrics for Different Detection Models on the Test Set: Experimental Results
[0135] Detectors mAP@.5 / % <![CDATA[FPS / (f·s -1 )]]> Params / M GFLOPs / s Weight Size / Mb YOLOX-nano 96.98 140.48 0.897 2.553 3.7 YOLOv5-nano 96.92 152.53 1.771 4.241 6.9 YOLOv4-tiny 97.39 125.75 5.883 16.190 22.5 MobileNetv2-SSD 98.70 117.91 4.074 4.056 16.3 Improved YOLOX-nano 99.11 131.21 1.015 2.635 4.2
[0136] From Table 2 and Figure 7As can be seen, the improved YOLOX-nano algorithm has the highest mAP@.5 value. While the increased number of network layers in the improved algorithm slightly reduces the detection speed, the impact is minimal and still meets real-time requirements. Its FPS value is close to YOLOv4-tiny and 13.3 FPS higher than MobileNetv2-SSD. The improved YOLOX-nano algorithm has the fewest parameters (Params) and computational FLOPs outside of the original algorithm, but these values are far lower than other detection algorithms. From the perspective of weight size, its 4.2Mb size is still suitable for deployment on mobile phones.
[0137] Therefore, the method proposed in this patent still improves the accuracy of white blood cell detection while ensuring real-time performance, and the effectiveness of the method is demonstrated through comparative experiments, achieving a balance between accuracy and speed.
[0138] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A detection method for an improved lightweight YOLOX-nano model for object detection, characterized in that: Includes the following steps, Acquire and filter white blood cell image data; Create a white blood cell dataset and divide it into three categories: training set, validation set, and test set; Build an improved lightweight YOLOX-nano model; The improved lightweight YOLOX-nano model was trained and evaluated. Obtain test results; The improved lightweight YOLOX-nano model includes: an improved coordinate attention mechanism; The improved coordinate attention mechanism includes parallel global average pooling, X-direction average pooling, and Y-direction average pooling. After performing global average pooling, X-direction average pooling, and Y-direction average pooling on the input features respectively, the intermediate values of global pooling, X-pooling, and Y-pooling are obtained respectively. The intermediate value of global pooling is then passed through a one-dimensional convolution with an adaptive K kernel, a sigmoid non-linear activation, and an element-wise dot product before being output. The intermediate values of X-pooling and Y-pooling are used for feature fusion, and then passed through two-dimensional convolution, batch normalization, non-linear activation, two layers of two-dimensional convolution, and a sigmoid non-linear activation before being output. The improved coordinate attention mechanism also includes: In the process of obtaining the attention weights of the feature map, features are aggregated along two orthogonal directions to perform a one-dimensional weight encoding process, and the feature map is nonlinearly complemented by the ID weights in the orthogonal directions. This process includes three steps: coordinate information embedding, coordinate attention generation, and efficient channel attention generation. During the coordinate information embedding step, global pooling is decomposed into two feature encoding operations. For input X, height h, and width w, the output of the c-th channel is... Expressed by the following formula: The two transformations described above occur along two spaces. The orientation is aggregated to generate a pair of orientation-aware attention maps, which correspond to the X-average pooling and Y-average pooling parts of the operation. During the coordinate attention generation step, the two generated feature maps are concatenated, and a shared 1×1 convolution is used to transform the F1 function to generate intermediate feature maps of spatial information in the horizontal and vertical directions. Where r represents the downsampling ratio, and then two 1×1 convolutions are used. , For feature mapping respectively and The result obtained by performing the transformation , This can be represented by the following formula. In the formula, 𝜎 represents the Sigmoid activation function; When performing the efficient channel attention generation step, the input feature map is... Global average pooling is performed, followed by adaptive one-dimensional convolution with kernel size k. After the calculation, the weights of each channel are obtained through the Sigmoid function 𝜎, and the weights are multiplied by the corresponding elements of the original input feature map to output the feature map. The formula is described as follows: In the formula, For feature mapping, 𝜎 represents the Sigmoid activation function. This represents a one-dimensional convolution operation with a kernel size of k. For the input feature map, Avgpool represents the average pooling operation; The value of k is calculated using the following formula: In the formula, k is the kernel size and C is the channel dimension. This represents the closest odd number. γ and b are hyperparameters, set to 2 and 1 respectively. Improved output of coordinate attention mechanism This can be represented by the following formula. In the formula, This represents the final output feature map after the improved coordinate attention module. This represents the feature map output after passing through efficient channel attention; This represents the feature map output along the horizontal X direction; This represents the feature map output along the vertical Y direction.
2. The target detection method as described in claim 1, characterized in that: When filtering the acquired white blood cell image data, images of basophils, eosinophils, lymphocytes, monocytes, and neutrophils are retained.
3. The target-oriented detection method as described in claim 1 or 2, characterized in that: When creating the white blood cell dataset, the LabelImg annotation tool was used to label the type and location information of white blood cells, and the data was saved as JPG image files and XML annotation files containing the above information, thus obtaining all the white blood cell images.
4. The target detection method as described in claim 3, characterized in that: In the hybrid spatial pyramid pooling structure, the input feature map A 1×1 convolutional layer is used to obtain refined channel information, which is then converted into feature maps. Then, max pooling and average pooling operations with different kernel sizes are performed simultaneously to generate six different receptive field feature maps. The original features are then concatenated to form a comprehensive feature map. This process achieves the fusion of local and global features. Finally, through a 1×1 convolutional layer, all features are integrated and a single feature map is output. The formula is described as follows: In the formula, Maxpool and Avgpool represent the max pooling and average pooling operations with kernel sizes of 5×5, 9×9, and 13×13, respectively. This indicates a splicing operation.
5. The target detection method as described in claim 4, characterized in that: When evaluating the improved lightweight YOLOX-nano model, the main metrics were P precision, R recall, AP mean precision, mAP mean precision, and F1 score, with FPS rate, Params number of parameters, FLOPs floating-point operations, and weight size as auxiliary evaluation factors.
6. The target detection method as described in claim 1, characterized in that: The improved lightweight YOLOX-nano model includes: the improved lightweight YOLOX-nano model includes a CSP module; The CSP module refers to the process of passing the input feature map through convolution 10 and convolution 11 respectively to obtain the first intermediate value and the second intermediate value. The first intermediate value is then input into the SimAM attention mechanism, and the second intermediate value is input into the residual network. The outputs of the two are then concatenated and passed through the channel shuffling module to shuffle the grouping order between channels, thereby better fusing the feature sequences and improving the communication quality between channels. The SimAM attention mechanism is represented by the following formula. In the formula, This represents the average value of all neurons in that channel. This represents the variance of all neurons in that channel. This indicates the number of neurons in that channel. Represents the i-th neuron. This represents the average value excluding neuron t, where t represents the neuron. This represents the energy of the smallest neuron. is a coefficient.
Citation Information
Patent Citations
Lightweight target detection method and system based on improved YOLOv4-tiny
CN114283469A
Blood cell detection and counting GUI system manufacturing method, system and terminal
CN114997272A