Image detection method based on improved YOLO algorithm
Patent Information
- Application Number
- CN202510127200.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-01
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2045-02-01
AI Technical Summary
但现有目标检测模型存在鲁棒性较差、准确率较低、检测结果不可靠等问题
[0056] Compared with existing technologies, this invention has significant advantages. As can be seen from the above scheme, this invention is an improved target detection algorithm model based on YOLOv8. On the basis of the baseline model, it introduces a more advanced bounding box regression loss function L. (iS-IoU) This invention combines two innovative modules: the Spatial Pyramid Pooling Network (SPPMC) supporting multi-level feature interaction and the Unified Attention Mechanism Network (UECA). The SPPMC network inherits the advantages of networks such as SPP, SPPC, and SPC, and further expands the network's receptive field. The model can more easily capture and process feature information at more scales, improving the network's ability to represent complex data features and mitigating problems such as mutual interference or degradation of feature information. The UECA network inherits the advantages of SE and CA networks, taking into account attention in both channel and spatial dimensions, increasing the network's perceptual range, enhancing the representation of important features, and promoting the fusion of feature information. The main advantages of this invention are as follows:
Smart Images

Figure CN120088208B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically to an image detection method based on an improved YOLO algorithm. Background Technology
[0002] Magnetic Resonance Imaging (MRI) technology, with its advantages of being non-invasive and radiation-free, having high resolution for soft tissues, accurate localization, requiring no contrast agents, enabling multi-planar and multi-parameter imaging, and allowing for non-invasive in vivo chemical analysis, is widely used in the medical field for medical imaging of various human tissues and organs, playing an irreplaceable role in the diagnosis and treatment of various diseases. Object detection is an important research direction in computer vision, aiming to study how to automatically and accurately detect, locate, and identify target objects from images or videos. In recent years, with the remarkable achievements of deep learning technology in computer vision tasks, object detection technology has also made leaps and bounds. Using object detection technology to detect and identify lesions in cardiac MRI medical images provides a solution to the aforementioned problems. Object detection models can learn and extract various lesion features from medical images at a deep level, accurately and quickly detecting and identifying diseased tissues or organs in medical images. This not only helps doctors improve the accuracy and efficiency of disease diagnosis but also helps medical researchers conduct in-depth research on diseases, promoting the development of medical technology. However, existing object detection models suffer from problems such as poor robustness, low accuracy, and unreliable detection results. Summary of the Invention
[0003] The purpose of this invention is to overcome the above-mentioned shortcomings and propose an image detection method based on an improved YOLO algorithm that significantly improves model performance, effectively enhances model robustness and detection performance.
[0004] This invention provides an image detection method based on an improved YOLO algorithm, wherein the method includes the following steps:
[0005] Step 1: Collect MRI images with lesions and divide the images into training image set, test image set and validation image set;
[0006] Step 2: Constructing the object detection network model: This object detection network model is based on an improved YOLO algorithm network architecture. The improved YOLO algorithm network architecture is based on the basic framework of YOLOv8. The improved backbone network includes a C2f module, a convolutional module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities. The improved neck network includes an upsampling layer, a stitching layer, a C2f module, a convolutional layer, and an embedded attention mechanism (UECA) module to perform multi-scale feature map fusion and improve feature fusion efficiency. The improved head network uses an improved bounding box regression loss function L... (iS-IoU)This accelerates the convergence speed of the model and improves positioning accuracy;
[0007] The improved multi-channel spatial pyramid pooling module (SPPMC) first uses three convolutional layers to capture the spatial features of the input image and generate feature maps. Then, four pooling layers with kernel sizes of 5, 9, 13, and 17 are connected in parallel with a residual network structure. The feature information is then output after convolution operations are performed through convolutional layers with kernel sizes of 1 and 3. The pooling layers and the parallel residual network structure generate receptive fields of 1×1, 5×5, 7×7, 11×11, 15×15, and 19×19, enabling the network to extract image feature information at more scales, obtain richer contextual information, and enhance the network's perceptual capabilities. The calculation process of the receptive field is as follows:
[0008] R0=1; R1=k1
[0009] R n =R (n-1) + (k n-1 ) * (n≥2)
[0010] Where Rn represents the receptive field size of the nth layer of the neural network, k n s represents the size of the convolutional kernel or pooling kernel in the nth layer of the neural network. i This represents the convolution stride or pooling stride of the i-th layer of the neural network.
[0011] The embedded attention mechanism UECA module is located in the last layer of the improved neck network. It combines and improves upon the attention mechanisms SE and CA. It is formed by a weighted parallel connection of the squeezing excitation submodule of the attention mechanism SE and the coordinate information embedding submodule of the attention mechanism CA, effectively processing feature information in both channel and spatial dimensions. The UECA module is an independent computational unit, and the computation process can be represented by the process of enhancing the input tensor X to the output tensor Y.
[0012]
[0013] in, Represents an input three-dimensional tensor of shape C′×H′×W′; The output three-dimensional tensor has a shape of C×H×W; C′, H′, W′ and C, H, W represent the number of channels of the input tensor X and the output tensor Y, the number of pixels in the vertical direction of the image, and the number of pixels in the horizontal direction of the image, respectively; L1 and L2 represent the outputs of the extrusion excitation submodule and the coordinate information embedding submodule, respectively.
[0014] The extrusion excitation submodule first performs a compression operation on the input tensor X in both horizontal and vertical spatial dimensions H×W, as follows:
[0015]
[0016] Where z represents the channel output result after compression operations in the vertical and horizontal spatial dimensions H×W; z C This indicates the output result of the Cth channel after the squeezing operation;
[0017] Then, channel dependencies are captured on the squeeze operation output. This process uses a gating mechanism function with Sigmoid activation. The output of this submodule is... Represented as:
[0018] L1=σ (T1 δ (T2 z))
[0019] in, For the Sigmoid function; 、 These are linear transformation parameters used to learn the importance of capturing each channel; d represents the reduction ratio of the control block size. Represents the ReLU function;
[0020] The coordinate information embedding submodule first encodes each channel along the horizontal coordinate (H, 1) and vertical coordinate (1, W) for any input tensor X, thereby generating feature information z. C h (h) and z C w (w), represented as:
[0021] z C h (h)=(1 / W) *∑ (0≤i≤W) x C (h,i)
[0022] z C w (w) = (1 / H) *∑ (0≤j≤H) x C (j,w)
[0023] Among them, z C h (h) represents the output of the Cth channel at height h; z C w (w) represents the output of the Cth channel with width w;
[0024] Secondly, the generated feature information is concatenated and transformed by convolution to obtain the feature map. , represented as:
[0025]
[0026] Among them, [z h , z w The symbol ] represents the concatenation operation of spatial dimensions, and F1 represents the 1×1 convolution transformation function. It is a non-linear activation function;
[0027] Then, the acquired feature map f is decomposed into f in spatial dimensions H and W. h and f w They are then subjected to convolution transformations to obtain the feature vector g. h and g w , represented as:
[0028] g h = σ (F h (f h ))
[0029] g w = σ (F w (f w ))
[0030] Where σ represents the sigmoid function; F h and F w This represents a 1×1 convolution transformation in the spatial dimension;
[0031] Finally, for the eigenvector g h and g w The weighted integration yields the output L2 of the coordinate information embedding submodule, which is represented as:
[0032] L 2 = g h * g w
[0033] The improved bounding box regression loss function L (iS-IoU) Auxiliary bounding boxes are used to participate in calculating the intersection-union ratio (IU) of the ground truth bounding box (GT) and the anchor box, while the distance loss is calculated. The shape loss Ω is introduced into the bounding box regression loss function, defined as follows:
[0034]
[0035] Among them, IoU in To assist in the intersection-union ratio of the bounding boxes;
[0036] Step 3: Train the target detection network model: Input the training image set into the target detection network model for training; first, adjust the size of each image in the training image set to be consistent, then divide each training image into grid blocks. When the center point of the target to be detected exists in the grid of the block, predict the type and location information of the target to be detected, i.e., the pathology; use the test image set and the validation image set to evaluate and verify the trained target detection network model;
[0037] Step 4: Image detection: Use the trained object detection network model to detect lesions in the image.
[0038] An image detection system based on an improved YOLO algorithm, comprising:
[0039] The magnetic resonance imaging acquisition module acquires magnetic resonance images needed to determine pathology.
[0040] Object detection network model construction module: This object detection network model is built based on an improved YOLO algorithm network architecture. The improved YOLO algorithm network architecture is based on the basic framework of YOLOv8 and includes: Input part: The input image undergoes adaptive resizing, adjusting to a 640×640 pixel RGB format image, and is then input into the improved backbone network for further processing; the improved backbone network includes a C2f module, a convolution module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities; the improved neck network includes a path aggregation network-feature pyramid network (PAN-FPN) and an embedded attention mechanism (UECA) module to perform multi-scale feature map fusion and improve feature fusion efficiency; the improved head network is the prediction output module, employing an improved bounding box regression loss function L... (iS-IoU) This accelerates the convergence speed and improves positioning accuracy.
[0041] Lesion detection module: Loads the trained target detection network model, inputs the target image to be detected, and performs lesion detection.
[0042] The above-mentioned image detection method based on the improved YOLO algorithm includes the following steps: In step 1, the nuclear magnetic resonance images are labeled using the labeling tool LabelImg, and the labeled nuclear magnetic resonance images are divided into a training image set, a test image set, and a verification image set in a ratio of 7:2:1.
[0043] The above image detection method based on the improved YOLO algorithm, wherein: in step 2, the IoU in The cross-union ratio (CUP) of the auxiliary bounding box is calculated using the following formula:
[0044]
[0045] Among them, b gt It is the center point of the ground truth bounding box and the auxiliary ground truth bounding box, with coordinates (x... c gt , y c gt The coordinates of the upper left and lower right corners of the auxiliary ground truth bounding box are (b...). l gt b t gt ) and (b r gt b b gt ); These are the center points of the anchor frame and the auxiliary anchor frame, respectively, with coordinates (x, y, y). c , y c ); The coordinates of the upper left and lower right corners of the auxiliary anchor frame are respectively (b l b t ) and (b r b b ); r is the auxiliary bounding box scaling factor; in_inter is the area of the intersection of the auxiliary ground truth box and the auxiliary anchor box; in_union is the area of the union of the auxiliary ground truth box and the auxiliary anchor box.
[0046] The above image detection method based on the improved YOLO algorithm, wherein: r is an auxiliary bounding box scaling factor, which is related to the size of the lesion region in the collected MRI images.
[0047] The above image detection method based on the improved YOLO algorithm, wherein: in step 2, the distance loss... The differences in the center positions of the GT frame and the anchor frame in the horizontal and vertical directions are described by the following formula:
[0048]
[0049] in, and are the weights in the horizontal and vertical directions, respectively, and are related to the size of the ground truth box; s is the scaling factor, and c is the weights of b and b'. gt The diagonal distance between the smallest closed bounding boxes.
[0050] The above image detection method based on the improved YOLO algorithm, wherein: s is a scaling factor, which is related to the size of the lesion region in the collected MRI images.
[0051] The above image detection method based on the improved YOLO algorithm, wherein: in step 2, the shape loss Ω describes the difference in shape size between the ground truth bounding box and the anchor bounding box, and the calculation formula is:
[0052]
[0053] Among them, w, h and w gt h gt θ represents the width and height of the GT frame and the anchor frame, respectively, and Θ represents the degree of concern regarding shape loss.
[0054] The above image detection method based on the improved YOLO algorithm, wherein: in step 3, the size of each image in the training image set is adjusted to 640×640.
[0055] The above-mentioned image detection method based on the improved YOLO algorithm includes the following steps: In step 4, the image lesion detection is performed using a trained target detection network model: First, the trained target detection network model is loaded, the target image to be detected is input, and after obtaining all output candidate detection boxes for lesion detection, non-maximum suppression is performed on all output candidate boxes to suppress redundant detection boxes, and the final output is performed.
[0056] Compared with existing technologies, this invention has significant advantages. As can be seen from the above scheme, this invention is an improved target detection algorithm model based on YOLOv8. On the basis of the baseline model, it introduces a more advanced bounding box regression loss function L. (iS-IoU) This invention combines two innovative modules: the Spatial Pyramid Pooling Network (SPPMC) supporting multi-level feature interaction and the Unified Attention Mechanism Network (UECA). The SPPMC network inherits the advantages of networks such as SPP, SPPC, and SPC, and further expands the network's receptive field. The model can more easily capture and process feature information at more scales, improving the network's ability to represent complex data features and mitigating problems such as mutual interference or degradation of feature information. The UECA network inherits the advantages of SE and CA networks, taking into account attention in both channel and spatial dimensions, increasing the network's perceptual range, enhancing the representation of important features, and promoting the fusion of feature information. The main advantages of this invention are as follows:
[0057] (1) The multi-channel spatial pyramid pooling structure (SPPMC) supporting multi-level feature interaction of the present invention has a simple structure and can be well ported to object detection models. This structure connects multiple max pooling layers and convolutional layers with different sampling rates in parallel, enriching the scale of the receptive field in the network. This design enables the network to extract more comprehensive feature information from the input feature map, covering more fine and coarse features. In addition, this structure also adopts a strategy of processing the extracted global or local feature information separately and then fusing them. This strategy helps to reduce the interference and information redundancy between global and local information, enhances the model's ability to effectively represent the features of the input data, and improves the model's efficiency in processing complex data.
[0058] (2) The Fusion Attention Mechanism (UECA) of this invention is composed of a weighted parallel connection of a squeeze excitation submodule and a coordinate information embedding submodule to comprehensively consider attention in both channel and spatial dimensions. This design effectively improves the network's ability to acquire target context information and its perception range, and helps to better handle long-distance dependencies. In addition, this mechanism learns to adjust the weights of channels and space, enhancing the representation of important features and suppressing interference from irrelevant features, making the network more focused on key feature information.
[0059] (3) Combine SPPMC, UECA and the single-stage target detection network architecture YOLOv8, and optimize the bounding box regression loss function to solve the problems of unreliable detection of lesions and poor model robustness of target detection models in MRI medical images.
[0060] In summary, this invention effectively improves the robustness and detection performance of the target detection model.
[0061] The following specific embodiments further illustrate the beneficial effects of the present invention. Attached Figure Description
[0062] Figure 1 This is a flowchart of the present invention;
[0063] Figure 2 This is a schematic diagram of the target detection network model structure of the present invention;
[0064] Figure 3 This is a schematic diagram of the improved multi-channel spatial pyramid pooling module structure of the present invention;
[0065] Figure 4 This is a schematic diagram of the UECA module structure for the embedded attention mechanism of the present invention;
[0066] Figure 5 The improved bounding box regression loss function L of this invention (iS-IoU) Schematic diagram of the calculation principle;
[0067] Figure 6 This is a flowchart of an example. Detailed Implementation
[0068] The following detailed description, in conjunction with the accompanying drawings and preferred embodiments, outlines the specific implementation, features, and effectiveness of an image detection method based on an improved YOLO algorithm proposed in accordance with the present invention.
[0069] See Figure 1 The present invention provides an image detection method based on an improved YOLO algorithm, wherein the method includes the following steps:
[0070] Step 1: Collect MRI images with lesions and divide the images into training image set, test image set, and validation image set; the MRI images are labeled using the labeling tool LabelImg. The labeled MRI images are divided into training image set, test image set, and validation image set in a ratio of 7:2:1.
[0071] Step 2: Constructing the object detection network model: This object detection network model is based on an improved YOLO algorithm network architecture, which is an improvement on the basic framework of YOLOv8 (e.g., Figure 2 The improved backbone network includes a C2f module, a convolutional module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities. The improved neck network includes upsampling layers, a concatenation layer (Concat), a C2f module, convolutional layers, and an embedded attention mechanism (UECA) module to perform multi-scale feature map fusion and improve feature fusion efficiency. The improved head network uses an improved bounding box regression loss function L. (iS-IoU) This accelerates the convergence speed of the model and improves positioning accuracy;
[0072] The improved multi-channel spatial pyramid pooling module SPPMC (such as...) Figure 3 First, three convolutional layers are used to capture the spatial features of the input image and generate feature maps. Then, four pooling layers with kernel sizes of 5, 9, 13, and 17 are connected in parallel with a residual network structure. The feature information is then output after convolution operations are performed through convolutional layers with kernel sizes of 1 and 3. The pooling layers and the parallel residual network structure generate receptive fields of 1×1, 5×5, 7×7, 11×11, 15×15, and 19×19, enabling the network to extract image feature information at more scales, obtain richer contextual information, and enhance the network's perceptual ability. The calculation process of the receptive field is as follows:
[0073] R0=1; R1=k1
[0074] R n =R (n-1) + (k n-1 ) * (n≥2)
[0075] Where Rn represents the receptive field size of the nth layer of the neural network, kn represents the size of the convolutional kernel or pooling kernel of the nth layer of the neural network, and s i This represents the convolution stride or pooling stride of the i-th layer of the neural network.
[0076] The embedded attention mechanism UECA module (such as Figure 4Located in the last layer and the fifth layer from the bottom of the improved neck network, it integrates the attention mechanism SE and the attention mechanism CA for improvement. It is composed of a weighted parallel connection of the squeezing excitation submodule of the attention mechanism SE and the coordinate information embedding submodule of the attention mechanism CA, which effectively processes the feature information of the channel and spatial dimensions. The UECA module is an independent computational unit, and the computation process can be represented by the process of enhancing the input tensor X to the output tensor Y.
[0077]
[0078] in, Represents an input three-dimensional tensor of shape C′×H′×W′; The output 3D tensor has a shape of C×H×W; C′, H′, W′ and C, H, W represent the number of channels in the input tensor X and the output tensor Y, the number of pixels in the vertical direction of the image, and the number of pixels in the horizontal direction of the image, respectively. L1 and L2 represent the outputs of the squeeze excitation submodule and the coordinate information embedding submodule, respectively.
[0079] The extrusion excitation submodule first performs a compression operation on the input tensor X in both horizontal and vertical spatial dimensions H×W, as follows:
[0080]
[0081] Where z represents the channel output result after compression operations in the vertical and horizontal spatial dimensions H×W; z C This indicates the output result of the Cth channel after the squeezing operation;
[0082] Then, channel dependencies are captured on the squeeze operation output. This process uses a gating mechanism function with Sigmoid activation. The output of this submodule is... Represented as:
[0083] L1=σ (T1 δ (T2 z))
[0084] in, For the Sigmoid function; 、 These are linear transformation parameters used to learn the importance of capturing each channel; h represents the reduction ratio of the control block size. Represents the ReLU function;
[0085] The coordinate information embedding submodule first encodes each channel along the horizontal coordinate (H, 1) and vertical coordinate (1, W) for any input tensor X, thereby generating feature information z. Ch (h) and z C w (w), represented as:
[0086]
[0087] Among them, z C h (h) represents the output of the Cth channel at height h; z C w (w) represents the output of the Cth channel with width w;
[0088] Secondly, the generated feature information is concatenated and transformed by convolution to obtain the feature map. , represented as:
[0089]
[0090] Among them, [z h , z w ] represents the splicing operation of spatial dimensions, and F1 represents the 1×1 convolution transformation function; It is a non-linear activation function;
[0091] Then, the acquired feature map f is decomposed into f in spatial dimensions H and W. h and f w They are then subjected to convolution transformations to obtain the feature vector g. h and g w , represented as:
[0092]
[0093] Where σ represents the sigmoid function; F h and F w This represents a 1×1 convolution transformation in the spatial dimension.
[0094] Finally, for the eigenvector g h and g w We then perform a weighted integration to obtain L2, which is represented as:
[0095]
[0096] The improved bounding box regression loss function L (iS-IoU) ,like Figure 5 As shown, auxiliary bounding boxes are used to participate in calculating the intersection-union ratio (IU) of the ground truth bounding boxes (GT boxes) and anchor boxes, while the distance loss is also considered. and shape loss The bounding box regression loss function is introduced and defined as follows:
[0097]
[0098] Among them, IoU in The cross-union ratio (CUP) of the auxiliary bounding box is calculated using the following formula:
[0099]
[0100] Among them, b gt It is the center point of the ground truth bounding box and the auxiliary ground truth bounding box, with coordinates (x... c gt , y c gt The coordinates of the upper left and lower right corners of the auxiliary ground truth bounding box are (b...). l gt b t gt ) and (b r gt b b gt ); These are the center points of the anchor frame and the auxiliary anchor frame, respectively, with coordinates (x, y, y). c , y c ); The coordinates of the upper left and lower right corners of the auxiliary anchor frame are respectively (b l b t ) and (b r b b ); r is the auxiliary bounding box scaling factor, which is related to the size of the lesion region in the collected MRI images; in_inter is the area of the intersection of the auxiliary GT box and the auxiliary anchor box; in_union is the area of the union of the auxiliary GT box and the auxiliary anchor box.
[0101] The distance loss The differences in the center positions of the GT frame and the anchor frame in the horizontal and vertical directions are described by the following formula:
[0102]
[0103] in, and , representing the weights in the horizontal and vertical directions, respectively, are related to the size of the ground truth bounding box; s is a scaling factor, related to the size of the lesion region in the collected MRI images; c is the weights of b and b gt The diagonal distance between the smallest closed bounding boxes;
[0104] The shape loss Ω describes the difference in shape and size between the GT frame and the anchor frame, and is calculated using the following formula:
[0105]
[0106] Among them, w, h and w gt h gt These are the width and height of the GT frame and the anchor frame, respectively. This indicates a level of concern regarding shape loss.
[0107] Step 3: Training the target detection network model: Input the training image set into the target detection network model for training; The training of the target detection network model: First, adjust the size of each image in the training image set to be consistent, then divide each training image into grid blocks. When the center point of the target to be detected exists in the grid of the block, the type and location information of the target to be detected, i.e., the lesion, are predicted; The trained target detection network model is evaluated and verified using a test image set and a validation image set; The size of each image in the training image set is adjusted to 640×640.
[0108] Step 4: Image detection: Use the trained object detection network model to detect lesions in the image.
[0109] The method of using a trained target detection network model for image lesion detection is as follows: First, the trained target detection network model is loaded, the target image to be detected is input, and after obtaining all output candidate detection boxes for lesion detection, non-maximum suppression is performed on all output candidate boxes to suppress redundant detection boxes, and the final output is performed.
[0110] An image detection system based on an improved YOLO algorithm, comprising:
[0111] The magnetic resonance imaging (MRI) image acquisition module acquires MRI images of lesions that need to be identified.
[0112] Object detection network model construction module: This object detection network model is built based on an improved YOLO algorithm network architecture. The improved YOLO algorithm network architecture is based on the basic framework of YOLOv8 and includes: Input part: The input image undergoes adaptive resizing, adjusting to a 640×640 pixel RGB format image, and is then input into the improved backbone network for further processing. The improved backbone network includes a C2f module, 5 convolutional layers, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities, extracting 80×80, 40×40, and 20×20 feature maps. The improved neck network includes a path aggregation network-feature pyramid network (PAN-FPN) and an embedded attention mechanism (UECA) module for multi-scale feature map fusion, improving feature fusion efficiency. The improved head network is the prediction output module, employing an improved bounding box regression loss function L... (iS-IoU) This accelerates the convergence speed and improves positioning accuracy.
[0113] Lesion detection module: Loads the trained target detection network model, inputs the target image to be detected, and performs lesion detection.
[0114] Specifically, such as Figure 6 As shown below, using MRI images of heart disease as an example, the workflow of the image detection method based on the improved YOLO algorithm is explained as follows:
[0115] Step 1: Obtain the patient's cardiac MRI images. This invention uses the patient's cardiac MRI images as the original dataset. Each image is 640*640 pixels in size. The MRI images in nii.gz format are converted into JPG format required by the object detection model for training of the object detection network model.
[0116] Step 2: Image annotation. The heart lesions in the image are annotated using the LabelImg image annotation tool. The dataset used in this invention was annotated under the guidance of professional doctors. The obtained data is divided into training set, validation set and test set in a ratio of 7:2:1 for training and evaluation of the object detection network model.
[0117] Step 3: Object Detection Network Model Construction: Based on the improved YOLOv8 framework, a neural network model for cardiac lesion detection is built, such as... Figure 2 As shown, the improvements mainly include using a multi-channel spatial pyramid pooling module (SPPMC) in the last layer of the backbone network, enhancing the network's ability to extract multi-scale features. A fusion attention mechanism (UECA) module is used in the neck network, improving the network's ability to focus on key feature information and increasing feature fusion efficiency. Furthermore, the object detection network model uses an improved bounding box regression loss function L... (iS-IoU) This is to optimize the model training process and improve positioning accuracy.
[0118] (1) The improved backbone network is constructed using a C2f module, a convolutional module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to extract features from cardiac MRI images and obtain shared feature maps. Specifically, the backbone network consists of 5 convolutional layers, 4 C2f modules, and 1 SPPMC module, ultimately outputting feature maps at three scales: 80×80, 40×40, and 20×20, for subsequent neck network enhancement and fusion. The SPPMC module is a spatial pyramid pooling network module with stronger perceptual and adaptive capabilities. The key idea is that this module enhances the network's ability to capture multi-scale feature information and strengthens its perceptual capabilities by expanding the receptive field size of the network model.
[0119] like Figure 3 As shown, the overall architecture of the SPPMC module mainly includes the following steps:
[0120] First, spatial features (such as edges and textures) of the input image are obtained through convolutional layers with kernels of 1, 3, and 1, and feature maps are generated. Then, the feature maps output by the convolutional layers are processed by four max pooling layers of different sizes in parallel to extract feature information of the image at different scales. Then, the network module concatenates and fuses the multi-scale feature information extracted by the pooling layers with the feature information extracted by the residual network, and inputs it into convolutional layers with kernels of 1 and 3 for further feature extraction, fusion, and feature map dimensionality reduction. The obtained feature information is converted into a feature vector of fixed size, which is convenient for subsequent classification and regression tasks.
[0121] The pooling layers and parallel residual network structures in the network generate receptive fields of sizes 1×1, 5×5, 7×7, 11×11, 15×15, and 19×19, enabling the network to extract image feature information at more scales, obtain richer contextual information, and enhance the network's perceptual capabilities. The calculation process of the receptive field is as follows:
[0122] R0=1; R1=k1
[0123] R n =R (n-1) + (k n-1 ) * (n≥2)
[0124] Where Rn represents the receptive field size of the nth layer of the neural network, k n s represents the size of the convolutional kernel or pooling kernel in the nth layer of the neural network. i This represents the convolution stride or pooling stride of the i-th layer of the neural network.
[0125] (2) The improved neck network consists of two upsampling layers, four concatenation layers, four C2f modules, two convolutional layers, and two fusion attention mechanism modules (UECA). The upsampling layers, concatenation layers, C2f modules, and convolutional layers are the original YOLOv8 structure. The UECA module is a newly added and improved module, placed in the last layer and the fifth layer from the bottom of the neck network. It is used to increase the network's ability to effectively process feature information in both channel and spatial dimensions, better focus on key feature information, and promote the effective fusion of features.
[0126] like Figure 4 As shown, the overall architecture of the UECA module mainly includes the following steps:
[0127] After the UECA module acquires the input information, it first undergoes weighted processing by the extrusion excitation submodule and the coordinate information embedding submodule. Then, the information processed by the two submodules is weighted and fused. The calculation process can be represented by transforming the input tensor X into the output tensor Y:
[0128]
[0129] in, Represents an input three-dimensional tensor of shape C′×H′×W′; The output 3D tensor has a shape of C×H×W; C′, H′, W′ and C, H, W represent the number of channels in the input tensor X and the output tensor Y, the number of pixels in the vertical direction of the image, and the number of pixels in the horizontal direction of the image, respectively. L1 and L2 represent the outputs of the squeeze excitation submodule and the coordinate information embedding submodule, respectively.
[0130] a. Extrusion Excitation Submodule:
[0131] First, the input tensor X is compressed in both horizontal and vertical spatial dimensions H×W:
[0132] z C = *[1 / (H×W)]
[0133] z C ∈z
[0134] Where z represents the channel output result after compression operations in the vertical and horizontal spatial dimensions H×W; z C This indicates the output result of the Cth channel after the squeezing operation.
[0135] Then, channel dependencies are captured on the squeeze operation output. This process uses a gating mechanism function with Sigmoid activation. The output of this submodule is... Represented as:
[0136] L1=σ (T1 δ (T2 z))
[0137] in, For the Sigmoid function; 、 These are linear transformation parameters used to learn the importance of capturing each channel; h represents the reduction ratio of the control block size. This represents the ReLU function.
[0138] b. Coordinate information embedding submodule:
[0139] First, for any input tensor X, the pooling kernel encodes each channel along the horizontal coordinate (H, 1) and the vertical coordinate (1, W) to generate feature information z. C h (h) and z C w (w), represented as:
[0140] z C h (h)=(1 / W) *∑ (0≤i≤W) x C (h,i)
[0141] z C w (w) = (1 / H) *∑ (0≤j≤H) x C (j,w)
[0142] Among them, z C h (h) represents the output of the Cth channel at height h; z C w (w) represents the output of the Cth channel with width w;
[0143] Secondly, the generated feature information is concatenated and transformed by convolution to obtain the feature map f:
[0144]
[0145] Among them, [z h , z w ] represents the splicing operation of spatial dimensions, and F1 represents the 1×1 convolution transformation function; It is a non-linear activation function;
[0146] Then, the acquired feature map f is decomposed into f in spatial dimensions H and W. h and f w They are then subjected to convolution transformations to obtain the feature vector g. h and g w :
[0147] g h = σ (F h (f h ))
[0148] g w = σ (F w (f w ))
[0149] Where σ represents the sigmoid function; F h and F wThis represents a 1×1 convolution transformation in the spatial dimension.
[0150] Finally, for the eigenvector g h and g w We then perform weighted integration to obtain L2:
[0151] L 2 = g h * g w
[0152] (3) The improved target detection network model uses an improved bounding box regression loss function L (iS-IoU) Optimize the model's training process, accelerate convergence, and improve object detection accuracy. The bounding box regression loss function L... (iS-IoU) The calculation includes the following steps:
[0153] Loss function L (iS-IoU) By using Figure 5 The auxiliary bounding box shown is used to participate in calculating the intersection-union ratio (IU) of the ground truth (GT) box and the anchor box, and the effects of distance loss and shape loss are considered. Loss function L (iS-IoU) The calculation is as follows:
[0154]
[0155] Among them, IoU in To assist in the intersection-union ratio of the bounding boxes, For distance loss; This is for shape loss.
[0156] a. Intersection over Union (IoU) of auxiliary bounding boxes in It is mainly used to help measure the degree of overlap between the predicted bounding box and the ground truth bounding box. The higher the value, the more accurate the prediction.
[0157] IoU in = (in_inter) / (in_union)
[0158] in_inter = (min(b r gt , b r )-max(b l gt , b l )) * (min(b b gt , b b )-max(b t gt , b t ))
[0159] in_union = (wgt * h gt ) * r 2 +(w * h) * r 2 -in_inter
[0160] b l gt = x c gt - (w gt * r) / 2;b r gt = x c gt + (w gt * r) / 2
[0161] b t gt = y c gt - (h gt * r) / 2;b b gt = y c gt + (h gt * r) / 2
[0162] b l = x c - (w * r) / 2;b r = x c + (w * r) / 2
[0163] b t = y c - (h * r) / 2;b b = y c + (h * r) / 2
[0164] Among them, b gt It is the center point of the ground truth bounding box and the auxiliary ground truth bounding box, with coordinates (x... c gt , y c gt The coordinates of the upper left and lower right corners of the auxiliary ground truth bounding box are (b...). l gt b t gt ) and (b r gt b b gt ); These are the center points of the anchor frame and the auxiliary anchor frame, respectively, with coordinates (x, y, y). c , yc ); The coordinates of the upper left and lower right corners of the auxiliary anchor frame are respectively (b l b t ) and (b r b b ); r is the auxiliary bounding box scaling factor, which is related to the size of the lesion region in the collected MRI images; in_inter is the area of the intersection of the auxiliary GT box and the auxiliary anchor box; in_union is the area of the union of the auxiliary GT box and the auxiliary anchor box.
[0165] b. Distance loss Primarily used to reduce the impact of differences in the center positions of the GT frame and anchor frame in the horizontal and vertical directions:
[0166]
[0167] in, and , representing the weights in the horizontal and vertical directions, respectively, are related to the size of the ground truth bounding box; s is a scaling factor, related to the size of the lesion region in the collected MRI images; c is the weights of b and b gt The diagonal distance between the smallest closed bounding boxes;
[0168] c. Shape loss Primarily used to mitigate the impact of differences in shape and size between the GT frame and the anchor frame:
[0169]
[0170] Among them, w, h and w gt h gt These are the width and height of the GT frame and the anchor frame, respectively. Indicates the level of concern regarding shape loss.
[0171] Step 4: Model Training. Import the training set data divided in Step 2 into the improved YOLO neural network for training. No pre-trained model is used during training. The number of iterations is set to 200, and the batch size is set to 8. After training, the best-performing model from the 200 iterations is selected for further evaluation.
[0172] Step 5: Model Validation. Using the validation dataset obtained in Step 2, the anchor boxes identified by the improved YOLO model are compared with the anchor boxes annotated under the guidance of professional doctors. The neural network model generates a corresponding report based on the comparison and validation results. The overall performance of the model can be evaluated using metrics such as precision (P), recall (R), F1 score, average precision (AP), mean average precision (mAP), and floating-point operations (GFLOPs). The calculation methods for these metrics are as follows:
[0173]
[0174] Where TP represents true positives, which refers to the number of samples correctly predicted as positive by the model; FP represents false positives, which refers to the number of samples incorrectly predicted as positive by the model; FN represents false negatives, which refers to the number of samples incorrectly predicted as negative by the model; and N is the number of types of heart disease in the dataset.
[0175] Compared to directly incorporating data into the training of the YOLOv8 neural network, this invention demonstrates superior performance in detecting various heart diseases.
[0176] Step 6: Cardiac disease detection. The trained optimal model is used to detect cardiac MRI images of the patient, identifying cardiac lesions in the MRI images using rectangular bounding boxes. This can assist radiologists in analyzing cardiac MRI images, improving their diagnostic efficiency. This method improves the accuracy of the object detection network model in detecting cardiac diseases, and its performance on various evaluation metrics is superior to the original YOLOv8 model.
[0177] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications, equivalent changes, and alterations made to the above embodiments without departing from the technical essence of the present invention shall still fall within the scope of the present invention.
Claims
1. An image detection method based on an improved YOLO algorithm, characterized in that: The method includes the following steps: Step 1: Collect MRI images with lesions and divide the images into training image set, test image set and validation image set; Step 2: Constructing the object detection network model: This object detection network model is based on an improved YOLO algorithm network architecture. The improved YOLO algorithm network architecture is based on the basic framework of YOLOv8. The improved backbone network includes a C2f module, a convolutional module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities. The improved neck network includes an upsampling layer, a stitching layer, a C2f module, a convolutional layer, and an embedded attention mechanism (UECA) module to perform multi-scale feature map fusion and improve feature fusion efficiency. The improved head network uses an improved bounding box regression loss function L... (iS-IoU) This accelerates the convergence speed of the model and improves positioning accuracy; The improved multi-channel spatial pyramid pooling module (SPPMC) first uses three convolutional layers to capture the spatial features of the input image and generate feature maps. Then, four pooling layers with kernel sizes of 5, 9, 13, and 17 are connected in parallel with a residual network structure. The feature information is then output after convolution operations are performed through convolutional layers with kernel sizes of 1 and 3. The pooling layers and the parallel residual network structure generate receptive fields of 1×1, 5×5, 7×7, 11×11, 15×15, and 19×19, enabling the network to extract image feature information at more scales, obtain richer contextual information, and enhance the network's perceptual capabilities. The calculation process of the receptive field is as follows: R0=1; R1=k1 R n =R (n-1) + (k n-1 ) * Where Rn represents the receptive field size of the nth layer of the neural network, k n s represents the size of the convolutional kernel or pooling kernel in the nth layer of the neural network. i This represents the convolution stride or pooling stride of the i-th layer of the neural network. The embedded attention mechanism UECA module is located in the last layer of the improved neck network. It combines and improves upon the attention mechanisms SE and CA. It is formed by a weighted parallel connection of the squeezing excitation submodule of the attention mechanism SE and the coordinate information embedding submodule of the attention mechanism CA, effectively processing feature information in both channel and spatial dimensions. The UECA module is an independent computational unit, and the computation process can be represented by the process of enhancing the input tensor X to the output tensor Y. in, Represents an input three-dimensional tensor of shape C′×H′×W′; The output three-dimensional tensor has a shape of C×H×W; C′, H′, W′ and C, H, W represent the number of channels of the input tensor X and the output tensor Y, the number of pixels in the vertical direction of the image, and the number of pixels in the horizontal direction of the image, respectively; L1 and L2 represent the outputs of the extrusion excitation submodule and the coordinate information embedding submodule, respectively. The extrusion excitation submodule first performs a compression operation on the input tensor X in both horizontal and vertical spatial dimensions H×W, as follows: Where z represents the channel output result after compression operations in the vertical and horizontal spatial dimensions H×W; z C This indicates the output result of the Cth channel after the squeezing operation; Then, channel dependencies are captured on the squeeze operation output. This process uses a gating mechanism function with Sigmoid activation. The output of this submodule is... Represented as: L1=σ (T1 δ (T2 z)) in, For the Sigmoid function; 、 These are linear transformation parameters used to learn the importance of capturing each channel; d represents the reduction ratio of the control block size. Represents the ReLU function; The coordinate information embedding submodule first encodes each channel along the horizontal coordinate (H, 1) and vertical coordinate (1, W) for any input tensor X, thereby generating feature information z. C h (h) and z C w (w), represented as: z C h (h)=(1 / W) *∑ (0≤i≤W) x C (h,i) z C w (w)= (1 / H) *∑ (0≤j≤H) x C (j,w) Among them, z C h (h) represents the output of the Cth channel at height h; z C w (w) represents the output of the Cth channel with width w; Secondly, the generated feature information is concatenated and transformed by convolution to obtain the feature map. , represented as: Among them, [z h , z w The symbol ] represents the concatenation operation of spatial dimensions, and F1 represents the 1×1 convolution transformation function. It is a non-linear activation function; Then, the acquired feature map f is decomposed into f in spatial dimensions H and W. h and f w They are then subjected to convolution transformations to obtain the feature vector g. h and g w , represented as: g h = σ (F h (f h )) g w = σ (F w (f w )) Where σ represents the sigmoid function; F h and F w This represents a 1×1 convolution transformation in the spatial dimension; Finally, for the eigenvector g h and g w The weighted integration yields the output L2 of the coordinate information embedding submodule, which is represented as: L 2 = g h * g w The improved bounding box regression loss function L (iS-IoU) Auxiliary bounding boxes are used to participate in calculating the intersection-union ratio (IU) of the ground truth bounding box (GT) and the anchor box, while the distance loss is calculated. The shape loss Ω is introduced into the bounding box regression loss function, defined as follows: Among them, IoU in To assist in the intersection-union ratio of the bounding boxes; Step 3: Train the target detection network model: Input the training image set into the target detection network model for training; first, adjust the size of each image in the training image set to be consistent, then divide each training image into grid blocks. When the center point of the target to be detected exists in the grid of the block, predict the type and location information of the target to be detected, i.e., the pathology; use the test image set and the validation image set to evaluate and verify the trained target detection network model; Step 4: Image detection: Use the trained object detection network model to detect lesions in the image.
2. The image detection method based on the improved YOLO algorithm as described in claim 1, characterized in that: In step 1, the nuclear magnetic resonance images are labeled using the labeling tool LabelImg, and the labeled nuclear magnetic resonance images are divided into a training image set, a test image set, and a verification image set in a ratio of 7:2:
1.
3. The image detection method based on the improved YOLO algorithm as described in claim 1, characterized in that: In step 2, the IoU in The cross-union ratio (CUP) of the auxiliary bounding box is calculated using the following formula: Among them, b gt It is the center point of the ground truth bounding box and the auxiliary ground truth bounding box, with coordinates (x... c gt , y c gt The coordinates of the upper left and lower right corners of the auxiliary ground truth bounding box are (b...). l gt b t gt ) and (b r gt b b gt ); These are the center points of the anchor frame and the auxiliary anchor frame, respectively, with coordinates (x, y, y). c ,y c ); The coordinates of the upper left and lower right corners of the auxiliary anchor frame are respectively (b l b t ) and (b r b b ); r is the scale factor of the auxiliary bounding box; in_inter is the area of the intersection of the auxiliary ground truth box and the auxiliary anchor box; in_union is the area of the union of the auxiliary ground truth box and the auxiliary anchor box; w, h and w gt h gt These are the width and height of the anchor frame and the GT frame, respectively.
4. The image detection method based on the improved YOLO algorithm as described in claim 3, characterized in that: The r is the auxiliary bounding box scaling factor, which is related to the size of the lesion region in the collected MRI images.
5. The image detection method based on the improved YOLO algorithm as described in claim 3, characterized in that: In step 2, the distance loss The differences in the center positions of the GT frame and the anchor frame in the horizontal and vertical directions are described by the following formula: in, and are the weights in the horizontal and vertical directions, respectively, and are related to the size of the ground truth box; s is the scaling factor, and c is the weights of b and b'. gt The diagonal distance between the smallest closed bounding boxes.
6. The image detection method based on the improved YOLO algorithm as described in claim 5, characterized in that: The s is a scaling factor, which is related to the size of the lesion region in the collected MRI images.
7. The image detection method based on the improved YOLO algorithm as described in claim 1, characterized in that: In step 2, the shape loss Ω describes the difference in shape and size between the GT frame and the anchor frame, and is calculated using the following formula: Among them, w, h and w gt h gt θ represents the width and height of the anchor frame and the GT frame, respectively, and Θ represents the degree of concern regarding shape loss.
8. The image detection method based on the improved YOLO algorithm as described in claim 1, characterized in that: In step 3, the size of each image in the training image set is adjusted to 640×640.
9. The image detection method based on the improved YOLO algorithm as described in claim 1, characterized in that: The method of using a trained target detection network model for image lesion detection is as follows: First, the trained target detection network model is loaded, the target image to be detected is input, and after obtaining all output candidate detection boxes for lesion detection, non-maximum suppression is performed on all output candidate boxes to suppress redundant detection boxes, and the final output is performed.
10. An image detection system based on an improved YOLO algorithm, characterized in that: Using the method according to any one of claims 1-9, comprising: The magnetic resonance imaging acquisition module acquires magnetic resonance images needed to determine pathology. Object detection network model construction module: This object detection network model is built based on an improved YOLO algorithm network architecture. The improved YOLO algorithm network architecture is based on the basic framework of YOLOv8 and includes: Input part: The input image undergoes adaptive resizing, adjusting to a 640×640 pixel RGB format image, and is then input into the improved backbone network for further processing; the improved backbone network includes a C2f module, a convolution module, and an improved multi-channel spatial pyramid pooling module (SPPMC) to enhance image feature extraction capabilities; the improved neck network includes a path aggregation network-feature pyramid network (PAN-FPN) and an embedded attention mechanism (UECA) module to perform multi-scale feature map fusion and improve feature fusion efficiency; the improved head network is the prediction output module, employing an improved bounding box regression loss function L... (iS-IoU) This accelerates the convergence speed and improves positioning accuracy. Lesion detection module: Loads the trained target detection network model, inputs the target image to be detected, and performs lesion detection.