A method for localizing lesions of pneumonia in children based on improved YOLOv8

By improving the feature extraction and fusion technology of the YOLOv8 model, the problems of low lesion detection accuracy and long detection time caused by the complexity of CXR images in children were solved, and more efficient lesion localization was achieved.

CN118552535BActive Publication Date: 2024-11-22HUAQIAO UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411017521.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-11-22
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

Existing CXR images of children are complex and the lesions are blurry, resulting in low accuracy and long detection time for pneumonia lesions, and lack of precise localization of the lesion area.

Method used

An improved YOLOv8 model, including a backbone feature extraction network, a neck feature fusion network, and a head detection head, is adopted. C2f-AKConv, BiFPN, and DySample techniques are used for feature extraction and fusion to achieve lesion localization.

Benefits of technology

It improves the detection accuracy and localization efficiency of pneumonia lesions, reduces interference from feature loss and organ superimposition, and significantly improves the accuracy of lesion localization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552535B_ABST
    Figure CN118552535B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for locating children's pneumonia lesions based on improved YOLOv8, relates to the field of target detection technology, and comprises the following steps: constructing a children's pneumonia lesion localization model and training it; realizing children's pneumonia lesion localization by using the trained children's pneumonia lesion localization model; the children's pneumonia lesion localization model comprises a Backbone feature extraction network, a Neck feature fusion network and a Head detection head; the Backbone feature extraction network extracts features of different scales from the input image; the Neck feature fusion network performs feature fusion on features of different scales and outputs fusion features of different scales; the Head detection head performs classification regression prediction based on fusion feature maps of different sizes to locate children's pneumonia lesions. The present invention does not significantly increase the detection time, accurately extracts the boundary and contour detail features of the lesions that are easy to lose, and improves the accuracy of locating children's pneumonia lesions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of target detection technology, and in particular to a method for locating children's pneumonia lesions based on improved YOLOv8. Background Art

[0002] Pneumonia is a common and potentially fatal respiratory disease, especially in children. The high mortality rate is partly due to the low detection rate of pneumonia, as diagnosing pneumonia in children is inherently difficult. Chest X-ray is currently the preferred diagnostic option because it has the advantages of low cost, high popularity, and less impact on human health compared to CT and MRI scans. However, manual X-ray analysis by doctors with limited experience in diagnosing pneumonia in children may lead to misdiagnosis or missed diagnosis, and the large number of patients will increase the workload of primary care doctors. To alleviate this situation, the rapid development of relevant auxiliary diagnostic technologies is urgently needed.

[0003] At present, deep learning as an artificial intelligence technology is constantly expanding its application scope, including the medical and health fields such as pneumonia diagnosis. At the same time, related challenges are gradually emerging. On the one hand, children's CXR images are complex, with overlapping organs and blurred lesions, which makes them challenging for models that are not optimized for these features and prone to losing some detailed features. On the other hand, current pneumonia diagnosis methods mainly rely on detection and classification, but lack precise positioning of lesion areas. This means that doctors still need to spend a lot of time looking for lesion areas when evaluating images, thus failing to significantly improve diagnostic efficiency. Solving these challenges is crucial to using deep learning technology to improve the diagnosis of pneumonia in children. Summary of the invention

[0004] The purpose of the present invention is to solve the problem in the prior art that pneumonia lesion detection has low accuracy and is time-consuming due to multiple CXR image overlaps, blurred lesions and the like.

[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a method for locating pneumonia lesions in children based on improved YOLOv8, comprising the following steps:

[0006] Collect CXR images of children with pneumonia to obtain a data set;

[0007] Construct a pediatric pneumonia lesion localization model based on improved YOLOv8;

[0008] Train a model for localizing lesions of pneumonia in children based on the dataset;

[0009] Use the trained pediatric pneumonia lesion localization model to localize pediatric pneumonia lesions;

[0010] The childhood pneumonia lesion localization model includes a Backbone feature extraction network, a Neck feature fusion network and a Head detection head which are connected in sequence; the Backbone feature extraction network extracts features of different scales from the input image; the Neck feature fusion network fuses features of different scales and outputs fused features of different scales; the Head detection head adopts a Decoupled Head detection head, and the three detection heads respectively receive fused feature maps of large, medium and small sizes and perform classification regression prediction to obtain the childhood pneumonia lesion localization.

[0011] Preferably, the Backbone feature extraction network includes:

[0012] Convolution module, downsamples the input image to obtain feature maps of different scales;

[0013] The C2f-AKConv module uses AKConv to extract features from the feature map, and the AKConv dynamically adjusts the shape of the convolution kernel to adapt to the specific features of the image.

[0014] Preferably, the process of extracting features by AKConv comprises the following steps:

[0015] Use coordinate generation algorithms to define initial positions for convolution kernels of arbitrary sizes;

[0016] Conv2d performs a convolution operation on the input image and adjusts the initial sampling shape according to the learned Offset offset;

[0017] Resample the feature map using the adjusted sampling shape;

[0018] The resampled feature map is successively reshaped by Reshape, Conv convolution, Norm normalization and SiLU activation function, and then output as a new feature map.

[0019] Preferably, the method of defining an initial position for a convolution kernel of any size using a coordinate generation algorithm comprises the following steps:

[0020] Generate the sampling grid as a regular sampling grid;

[0021] Create an irregular grid for sampling points other than the initial position;

[0022] Finally, they are concatenated to generate the overall sampling grid.

[0023] Preferably, the Neck feature fusion network uses the BiFPN network to fuse pneumonia information between different levels, which is expressed as:

[0024] ;

[0025] in, represents the fused features, Σ represents the fusion operation; Represents features from different levels, Represents the feature The learnable weights of each Then apply Relu to ensure ≥ 0; is a small positive number to prevent the denominator from being zero; represents the sum of all weights; each normalized weight The value is between 0 and 1.

[0026] Preferably, before the Neck feature fusion network performs the fusion operation, DySample upsampling is used to reconstruct a high-resolution feature map from the low-resolution input feature map, which is expressed as:

[0027] ;

[0028] ;

[0029] ;

[0030] in, represents the input feature map, Represents the upsampling scale factor; represents the grid sampling operation, Represents the reconstructed high-resolution feature map; Indicates the offset, represents the original sampling grid; Represents a linear layer operation.

[0031] Preferably, before the Neck feature fusion network performs the fusion operation, the DySample upsampling with a static range factor is used to reconstruct a high-resolution feature map on the input feature map, which is expressed as:

[0032] ;

[0033] ;

[0034] ;

[0035] in, represents the input feature map, Represents the upsampling scale factor; represents the grid sampling operation, Represents the reconstructed high-resolution feature map; Indicates the offset, represents the original sampling grid; Represents a linear layer operation.

[0036] Preferably, before the Neck feature fusion network performs the fusion operation, the input feature map is firstly reconstructed into a high-resolution feature map by upsampling the input feature map with a dynamic range factor, which is expressed as:

[0037] ;

[0038] ;

[0039] ;

[0040] in, represents the input feature map, Represents the upsampling scale factor; represents the grid sampling operation, Represents the reconstructed high-resolution feature map; Indicates the offset, represents the original sampling grid; Represents a linear layer operation.

[0041] Preferably, the method of using the trained pediatric pneumonia lesion localization model to localize pediatric pneumonia lesions comprises the following steps:

[0042] Resize the CXR image to be detected to obtain an input image;

[0043] The input image is passed through the Backbone feature extraction network to accurately extract pneumonia features and output feature maps of three different sizes;

[0044] The Neck feature fusion network fuses the feature maps from three different stages of Backbone and outputs three fused feature maps of different sizes;

[0045] The three Decoupled Head detection heads receive three fused feature maps of different sizes respectively, and perform convolution operations on each fused feature map in two branches; the two branches include a regression branch and a classification branch. The regression branch is used to determine the regression parameters of the prediction box coordinates corresponding to each feature point. After the regression parameters are adjusted, the lesion prediction box can be obtained; the classification branch is used to predict the probability that each feature point corresponds to a certain CXR image type.

[0046] The present invention has the following beneficial effects:

[0047] (1) The present invention uses C2f-AKConv to replace the C2f module of YOLOv8. The AKConv in C2f-AKConv can dynamically adjust the shape and position of its convolution kernel according to the learned offset for the input CXR image to better match and cover the lesion area. This adaptive sampling position adjustment strategy enables more accurate pneumonia feature extraction for lesions of various shapes and sizes; at the same time, AKConv supports linear increase or decrease in the number of convolution parameters, which helps to optimize performance in a hardware environment;

[0048] (2) The present invention improves the Neck feature fusion network into a BiFPN network (Bidirectional Feature Pyramid Network), which promotes higher-level pneumonia feature fusion without significantly increasing the computational cost. At the same time, BiFPN adds weights to each input feature to optimize the feature fusion process, so that the network pays more attention to pneumonia features with large amounts of information;

[0049] (3) The present invention uses DySample to replace Upsample in the Neck feature fusion network to better reconstruct high-resolution feature maps; DySample uses a point sampling method. Compared with the previous kernel-based dynamic upsampler, it not only has fewer parameters, floating-point operations, GPU memory and latency, but also performs better than other upsamplers in various prediction tasks. Reconstructing high-resolution feature maps by upsampling with DySample can alleviate the interference of organ overlap and reduce the loss of pneumonia features.

[0050] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments, but the present invention is not limited to the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 A method step diagram of an embodiment of the present invention;

[0052] Figure 2 This is a schematic diagram of a model for localizing lesions of pneumonia in children according to an embodiment of the present invention;

[0053] Figure 3 This is a schematic diagram of the C2f module of YOLOv8;

[0054] Figure 4 A schematic diagram of AKConv used in an embodiment of the present invention;

[0055] Figure 5 A schematic diagram of a BiFPN network used in an embodiment of the present invention;

[0056] Figure 6Schematic diagram of DySample used in an embodiment of the present invention, wherein (a) is an overall schematic diagram, and (b) is a schematic diagram of a sampling point generator. DETAILED DESCRIPTION

[0057] See also Figure 1 FIG. 1 is a diagram showing steps of a method according to an embodiment of the present invention, comprising the following steps:

[0058] S101, collect CXR images of children with pneumonia and obtain a data set;

[0059] S102, building a pediatric pneumonia lesion localization model based on improved YOLOv8;

[0060] S103, training a model for localizing lesions of pneumonia in children based on a dataset;

[0061] S104, localizing lesions of pneumonia in children using the trained lesion localization model for pneumonia in children;

[0062] The pediatric pneumonia lesion localization model is as follows Figure 2 As shown in the figure, it includes a Backbone feature extraction network, a Neck feature fusion network and a Head detection head connected in sequence; the Backbone feature extraction network extracts features of different scales on the input image; the Neck feature fusion network fuses features of different scales and outputs fused features of different scales; the detection head adopts a Decoupled Head detection head, and the three detection heads respectively receive fused feature maps of large, medium and small sizes and perform classification regression prediction to obtain the location of childhood pneumonia lesions.

[0063] The pediatric pneumonia lesion localization model of the embodiment of the present invention is improved based on the basic YOLOv8 model. The basic YOLOv8 model is divided into three parts: the first is the backbone feature extraction network, which is mainly composed of a stack of C2f modules and convolution modules, where the C2f module structure is as follows: Figure 3 As shown in the figure. After the input image is passed to the basic YOLOv8 model, it is first resized to a fixed size and then extracted through the Backbone network. The convolution downsampling operation of the Backbone network can gradually compress the image resolution and increase the channel dimension, and finally obtain three feature maps of different sizes, which are then passed to the Neck feature fusion network of the model for feature fusion. Finally, the Decoupled Head detection head performs classification regression prediction on the three fused feature maps of different sizes output by the Neck feature fusion network.

[0064] Specifically, the pediatric pneumonia lesion localization model described in the present invention makes the following improvements to the basic YOLOv8 model: (1) the C2f module in the Backbone feature extraction network and the Neck feature fusion network is replaced by C2f-AKConv; (2) the Neck feature fusion network is improved to a BiFPN network; (3) DySample is used to replace Upsample in the Neck network.

[0065] (1) Replace the C2f module in the Backbone feature extraction network and the Neck feature fusion network with C2f-AKConv. Specifically, replace the standard convolution of Bottleneck in the C2f module with AKConv. The structure of AKConv is as follows: Figure 4 As shown in the figure. AKConv proposes a new coordinate generation algorithm that allows irregular convolution kernels to have sampling grids. According to the convolution kernel size N, an initial irregular sampling set Pn of size (1, 2N, 1, 1) is generated. Pn contains n coordinate points, giving the initial irregular sampling shape of the convolution kernel. The coordinate generation algorithm first generates the sampling grid into a regular sampling grid, then creates irregular grids for the remaining sampling points, and finally splices them to generate the overall sampling grid.

[0066] Select a position P0 = (m, n) on the input feature map, add the offset of P0 to each coordinate point in Pn, and obtain the actual sampling coordinates at the input feature map P0 position, for example, Pn = {(0, 0), (1, 0), ...}, then the actual sampling coordinates are {(m, n), (m+1, n), ...}. After defining the initial coordinates Pn of the irregular convolution, the convolution operation corresponding to the position P0 can be defined as follows:

[0067] ;

[0068] in, Represents the convolution parameters.

[0069] The sampling offset Offset at position P0 is learned by the Conv2d convolution operation, which has dimensions (B, 2N, H, W), where N is the convolution kernel size, and Figure 4 For example, N = 5. The modified coordinates are obtained by adding Offset to the actual sampling coordinates (Pn + P0), and the sampling shape is adjusted to fit the target shape. Subsequently, the feature values ​​are resampled on the input feature map according to the adjusted sampling coordinates. The resampling operation uses bilinear interpolation to sample the feature map at the irregular modified coordinate P0. The resampled feature values ​​are multiplied and accumulated with the convolution kernel parameters to obtain the convolution output feature values ​​at the P0 position. Repeat the above steps at all positions of the input feature map to aggregate all resampled features. Figure 4In

[15] , features are stacked column by column in space and row convolutions of size (N, 1) are used with a stride of (N, 1) to aggregate features of irregular shapes.

[0070] To address the problem that the features corresponding to the sampling positions of irregular convolution kernels are difficult to extract, features can be stacked on rows or columns to use column convolution or row convolution to extract features corresponding to irregular sampling shapes. In addition, the features can be converted to four dimensions (C, N, H, W), and then Conv3d with a step size and convolution size (N, 1, 1) can be used to extract features. Of course, the features on the channel dimension can also be superimposed on (CN, H, W), and then a 1×1 convolution can be used to reduce the dimension to (C, H, W). The above methods can all be used to extract features corresponding to irregular sampling shapes. You only need to reshape the features and use the corresponding convolution operations. Figure 4 The final Reshape and Conv in represent the above method.

[0071] Finally, the resampled feature map is reshaped (Reshape), convolution (Conv), normalized (Norm) and SiLU activation function to obtain the entire output feature map. AKConv can dynamically adjust the shape and position of its convolution kernel according to the learned offset for the input CXR image, so as to better match and cover the lesion area. This adaptive sampling position adjustment strategy enables it to achieve more accurate pneumonia feature extraction for lesions of various shapes and sizes and reduce feature loss.

[0072] (2) Improve the Neck feature fusion network to a BiFPN network. The network structure of BiFPN is as follows: Figure 5 As shown. The main idea of ​​BiFPN is efficient bidirectional cross-scale connection and weighted feature fusion. The purpose of multi-scale feature fusion is to aggregate features of different resolutions. Formally, given a list of multi-scale features: =( , ,...),in Indicates level The goal of BiFPN is to find a transformation f that effectively aggregates features of different resolutions and outputs a new feature list: = f( ).

[0073] In order to improve the efficiency of feature fusion, BiFPN proposes several optimization methods for cross-scale connections: First, delete those nodes with only one input edge. If a node has only one input edge and no feature fusion is performed, its contribution to the feature network that fuses different features is small. Then, between the original input node and the output node, if they are at the same level, an additional edge is added to fuse more features without increasing too much computational cost. Finally, each bidirectional (top-down and bottom-up) path is used as a feature network layer and repeated multiple times to achieve higher-level feature fusion.

[0074] Since different input features have different resolutions, they usually contribute unequally to the output features. In the past, a common approach was to first adjust them to the same resolution and then add them together, treating all input features equally. To solve this problem, BiFPN adds an additional weight to each input feature, allowing the network to learn the importance of each input feature. BiFPN proposes a fast normalized fusion method, which can be expressed as the following formula:

[0075] ;

[0076] In the formula, by Then apply Relu to ensure ≥ 0, and = 0.0001 is a small value to avoid numerical instability. Each normalized weight has a value between 0 and 1.

[0077] The final BiFPN integrates bidirectional cross-scale connections and fast normalization fusion. As a specific example, it is described here Figure 5 Two fused features of the 6th level of BiFPN shown in:

[0078]

[0079] in, It is usually an upsampling or downsampling operation for resolution matching. The embodiment of the present invention adopts Dysample upsampling; It is usually a convolution operation used for feature processing, and the embodiment of the present invention adopts C2f-AKconv; is the intermediate feature at level 6 on the top-down path, is the output feature of level 6 on the bottom-up path; all other features are constructed in a similar manner.

[0080] By improving the Neck feature fusion network to a BiFPN network and promoting higher-level pneumonia feature fusion, the contextual information of the organ overlap area can be better captured and the interference of organ overlap can be alleviated.

[0081] (3) Use DySample to replace Upsample in the Neck network. The structure of DySample is as follows: Figure 6 As shown in the figure, (a) is the overall schematic diagram, and (b) is the schematic diagram of the sampling point generator. DySample is an ultra-lightweight and effective dynamic upsampler that bypasses dynamic convolution and formulates an upsampling strategy from the perspective of point sampling.

[0082] The initial version of DySample is implemented in two steps: Grid Sampling and Naive Implementation. The first is Grid Sampling. Given a size of Feature map and a size of The sampling set , where the first dimension of 2 represents the x and y coordinates, and the grid sampling function uses The positions in will assume bilinear interpolation Resample to size of . The process is defined as:

[0083]

[0084] Then there is the Naive Implementation, given the upsampling scale factor and size Feature map , using input and output channels as and A linear layer of size Offset , and then reshaped into . Then the sampling set is offset and the original sampling grid The sum of

[0085]

[0086]

[0087] The reshaping operation is omitted. Finally, the sampling set by the grid sample can be used to generate a size of Upsampled feature map .

[0088] The initial version of DySample One point in each sampling position is fixed at the same initial position ( ), this approach ignores the The positional relationship between adjacent points makes the initial sampling position distribution uneven. If the generated offsets are all zero, the upsampled features are equivalent to NN interpolated features. To address this problem, the initial position is changed to "bilinear initialization", where zero offset will result in a bilinear interpolated feature map. Due to the existence of the normalization layer, the value of a certain output feature is usually in the range of [-1, 1], centered on 0. Therefore, the local The walking ranges of the sampled positions may overlap severely, and this overlap can easily affect the prediction near the boundary, and this error will gradually propagate and cause output artifacts. To alleviate this situation, the offset is multiplied by a factor of 0.25, which just meets the theoretical boundary condition between overlap and non-overlap. This factor is called the "static range factor" and makes the walking range of the sampled positions locally constrained, see Figure 6 As shown in (b), the offset It is expressed as:

[0089]

[0090] In addition, the feature maps are grouped and upsampled, where the features in each group share the same sampling set. Specifically, the feature map can be divided into g groups along the channel dimension, and g groups of offsets are generated.

[0091] To increase the flexibility of the offset, we further generate a point-by-point "dynamic range factor" by linearly projecting the input features. By using the sigmoid function and a static factor of 0.5, the dynamic range will be a value in the range of [0, 0.5] centered at 0.25 as the static range. The dynamic range operation can be referred to Figure 6 As shown in (b), the offset It is expressed as:

[0092] ;

[0093] DySample's offset generation styles can be divided into two types: LP and PL. LP is "linear + pixel shuffle", which first uses linear projection to generate The offset set is then reshaped to meet the spatial size. PL is "pixel shuffle + linear", which first converts the feature map Reshape The size of , and then linearly project it onto With other hyperparameters fixed, the number of parameters can be reduced to 1 / .

[0094] DySample includes four variants depending on the form of the range factor (static / dynamic) and the offset generation style (LP / PL):

[0095] (1) DySample: LP style, with static range factor;

[0096] (2) DySample+: LP style, with dynamic range factor;

[0097] (3) DySample-S: PL style with static range factor;

[0098] (4) DySample-S+: PL style with dynamic range factor;

[0099] In the DySample series, the "-S" version has fewer parameters and GFLOPs overhead, but more memory usage and latency because the PL requires an additional Storage. The "+" version introduces more computation. DySample+, which performs best in the target detection task in the DySample series, is used to replace the Upsample in the Neck network, and the input feature map is divided into four groups along the channel dimension to generate an offset. By reconstructing the high-resolution feature map using DySample upsampling, the interference of organ overlap can be alleviated and the loss of pneumonia features can be reduced.

[0100] Specifically, the S104 includes the following steps:

[0101] S1041, resizing the CXR image to be detected to obtain an input image;

[0102] S1042, the input image is passed through the Backbone feature extraction network to accurately extract pneumonia features and output feature maps of three different sizes;

[0103] S1043, the Neck feature fusion network fuses the three feature maps of different sizes from Backbone and outputs three fused feature maps of different sizes;

[0104] S1044, the Decoupled Head detection head receives three fused feature maps of different sizes respectively, and each fused feature map is divided into two branches for convolution operation; the two branches include a regression branch and a classification branch, the regression branch is used to determine the regression parameters of the prediction box coordinates corresponding to each feature point, and the lesion prediction box can be obtained after the regression parameters are adjusted; the classification branch is used to predict the probability that each feature point corresponds to a certain CXR image type.

[0105] In the S1044, the Decoupled Head detection head includes three sizes of detection heads: large, medium and small. Not all of the three different sizes of detection heads may have outputs. This depends on the size distribution of lesions in the input pneumonia image. YOLOv8 will automatically learn to assign detection heads of different sizes to focus on detecting targets of corresponding sizes. In YOLOv8, each prediction head will output a set of preliminary prediction results, including predicted bounding boxes, target classification probabilities, and target confidences. To obtain the final detection output results, some post-processing steps are required:

[0106] (1) Non-Maximum Suppression (NMS): Since the same target may be detected by multiple prediction heads at different feature layers, there will be multiple overlapping prediction boxes. The role of NMS is to select the one with the highest confidence from these overlapping prediction boxes and filter out other redundant predictions.

[0107] (2) Threshold filtering: After NMS, the remaining prediction results will be further filtered according to the set confidence threshold and score threshold. Boxes below the threshold will be removed.

[0108] (3) Bounding box decoding: The last step is to decode the remaining predicted bounding boxes from offsets relative to the anchor boxes into pixel coordinates to obtain the final output format.

[0109] After NMS, threshold filtering and decoding, the final output result is a list, each element of which is (x1, y1, x2, y2, obj_conf, class_conf, class_id), representing the bounding box, target confidence, class probability and class id respectively.

[0110] By inputting the constructed data set into the improved model for repeated iterative training, we can eventually obtain the model with the best lesion localization effect.

[0111] Specifically, the data set is the collected CXR images of children with pneumonia. CXR images use the high penetration ability of X-rays to achieve transmission imaging of the patient's lungs. Compared with CT imaging, the radiation dose of X-rays is relatively low and less harmful to the human body. The patient's lungs are scanned using a medical X-ray machine. The X-ray image formed a few seconds later will be clearly displayed on the screen of the X-ray machine for doctors to observe and diagnose. The quality of the data set will directly affect the effect of lesion localization. The collected CXR images of children with pneumonia are annotated and classified using the annotation tool Labelimg, including three types: pneumonia, normal, and unidentifiable. Labels are made according to the YOLO data set format. The data set includes three parts: Images, Labels, and Classes. Images is the image file in the data set, and the image format is jpg; Labels is the annotation file, which contains the category and location information of the target object in each image; Classes is the category file, which contains the category information of all target objects in the data set. In the data preprocessing stage, data enhancement, sample interpolation and other technologies are used to expand the data set. Common augmentation methods include mirroring, rotating, translating, filtering, and contrast adjustment of the original image to obtain more samples. In addition, generative adversarial networks can be used to generate new pneumonia samples to improve the diversity of the dataset.

[0112] In order to meet the detection speed requirements, the present invention selects the fast-response YOLOv8 model as the benchmark network. C2f-AKConv is used to replace the C2f module, and the accurate and flexible pneumonia feature extraction is completed through irregular convolution operations; the Neck feature fusion network is improved to the BiFPN network to realize the communication and fusion of pneumonia information between different levels, and enhance the effect of multi-scale pneumonia feature fusion; DySample is used to replace Upsample in the Neck network to better reconstruct the high-resolution feature map. The improved model can better extract the lesion boundary and contour detail features that are easily lost in previous methods without significantly increasing the detection time, promote the communication of pneumonia information between different levels, and realize the efficient fusion of multi-scale pneumonia features, thereby effectively reducing the interference of organ overlap and feature loss, and the accuracy of locating the location of pneumonia lesions has been significantly improved.

[0113] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for localizing pneumonia lesions in children based on improved YOLOv8, characterized in that: The following steps are involved: Collect CXR images of children with pneumonia to obtain a data set; Constructing a pediatric pneumonia lesion localization model, wherein the pediatric pneumonia lesion localization model is improved based on the basic YOLOv8 model; Training the children's pneumonia lesion localization model based on the data set; Localizing the lesions of pneumonia in children using the trained lesion localization model of pneumonia in children; The pediatric pneumonia lesion localization model includes a Backbone feature extraction network, a Neck feature fusion network and a Head detection head connected in sequence; The Head detection head uses a Decoupled Head detection head. The three detection heads receive fused feature maps of large, medium and small sizes respectively and perform classification regression prediction to obtain the location of pneumonia lesions in children. The Backbone feature extraction network extracts features of different scales from the input image; the Backbone feature extraction network is a hierarchical structure of the first to tenth layers consisting of a Conv convolution module, a Conv convolution module, a C2f-AKConv module, a Conv convolution module, a C2f-AKConv module, a Conv convolution module, a C2f-AKConv module, a Conv convolution module, a C2f-AKConv module, and an SPPF module connected in sequence from top to bottom; Conv convolution module downsamples the input image to obtain feature maps of different scales; C2f-AKConv module, which uses AKConv to extract features from feature maps. AKConv dynamically adjusts the shape of the convolution kernel to adapt to the specific features of the image; The AKConv feature extraction process includes the following steps: using a coordinate generation algorithm to define an initial position for a convolution kernel of any size; performing a convolution operation on the input image through Conv2d, and adjusting the initial sampling shape according to the learned Offset offset; resampling the feature map using the adjusted sampling shape; the resampled feature map is sequentially subjected to Reshape reshaping, Conv convolution, Norm normalization, and SiLU activation function, and then output as a new feature map; The method of using a coordinate generation algorithm to define an initial position for a convolution kernel of any size includes the following steps: generating a sampling grid into a regular sampling grid; creating irregular grids for sampling points other than the initial position; and finally splicing them to generate an overall sampling grid; The Neck feature fusion network performs feature fusion on features of different scales and outputs fusion features of different scales; The Neck feature fusion network uses the BiFPN network to fuse pneumonia information between different levels, which is expressed as: Among them, O represents the fused feature, Σ represents the fusion operation; I i Represents features from different levels, w i Represents the feature I i The learnable weights of each w i Then apply Relu to ensure w i ≥0;∈ is a small positive number to prevent the denominator from being zero;∑ j w j represents the sum of all weights; each normalized weight The value of is between 0 and 1; And, before the Neck feature fusion network performs a fusion operation, it is selected to first reconstruct a high-resolution feature map by using DySample upsampling with a static range factor added to the input feature map, or it is selected to first reconstruct a high-resolution feature map by using DySample upsampling with a dynamic range factor added to the input feature map; Before the Neck feature fusion network performs the fusion operation, the DySample upsampling with a static range factor is used to reconstruct a high-resolution feature map on the input feature map, which is expressed as: x′=grid_sample(x,s); s = g + o; o = 0.25linear(x); Where x represents the input feature map, s represents the upsampling scale factor; grid_sample represents the grid sampling operation, x′ represents the reconstructed high-resolution feature map; o represents the offset, g represents the original sampling grid; linear represents the linear layer operation; Before the Neck feature fusion network performs the fusion operation, the DySample upsampling with the dynamic range factor added is used to reconstruct the high-resolution feature map of the input feature map, which is expressed as: x′=grid_sample(x,s); s = g + o; o=0.5sigmoid(linear1(x))·linear2(x); Among them, x represents the input feature map, s represents the upsampling scale factor; grid - sample represents the grid sampling operation, x′ represents the reconstructed high-resolution feature map; o represents the offset, g represents the original sampling grid; linear represents the linear layer operation; The left side of the Neck feature fusion network is a hierarchical structure of the first to sixth layers consisting of a DySample upsampling module, a Concat module, a C2f-AKConv module, a DySample upsampling module, a Concat module, and a C2f-AKConv module, which is connected from bottom to top, and then the right side of the Neck feature fusion network is connected, and the hierarchical structure of the first to sixth layers consisting of a Conv convolution module, a Concat module, a C2f-AKConv module, a Conv convolution module, a Concat module, and a C2f-AKConv module is connected from top to bottom to form the right side; At the same time, the output of the SPPF module of the tenth layer of the Backbone feature extraction network is respectively input into the DySample up-sampling module located in the first layer on the left side of the Neck feature fusion network and the Concat module located in the fifth layer on the right side of the Neck feature fusion network; And, at the same time, the output of the C2f-AKConv module located at the seventh layer of the Backbone feature extraction network is respectively input to the Concat module located at the second layer on the left side of the Neck feature fusion network and the Concat module located at the second layer on the right side of the Neck feature fusion network; And, at the same time, the output of the C2f-AKConv module located in the fifth layer of the Backbone feature extraction network is input into the Concat module located in the fifth layer on the left side of the Neck feature fusion network; And, at the same time, the output of the C2f-AKConv module located in the third layer on the left side of the Neck feature fusion network is input to the Concat module located in the second layer on the right side of the Neck feature fusion network; The method of using the trained pediatric pneumonia lesion localization model to localize pediatric pneumonia lesions comprises the following steps: Resize the CXR image to be detected to obtain an input image; The input image is passed through the Backbone feature extraction network to accurately extract pneumonia features and output feature maps of three different sizes; The Neck feature fusion network fuses the feature maps from three different stages of Backbone and outputs three fused feature maps of different sizes; The three Decoupled Head detection heads receive three fused feature maps of different sizes respectively, and perform convolution operations on each fused feature map in two branches; the two branches include a regression branch and a classification branch. The regression branch is used to determine the regression parameters of the prediction box coordinates corresponding to each feature point. After the regression parameters are adjusted, the lesion prediction box can be obtained; the classification branch is used to predict the probability of the CXR image type corresponding to each feature point.