An abnormal cell detection method based on improved YOLOv7 and Swin-Unet
By improving the YOLOv7 and Swin-Unet models, and combining dynamic head attention and the Swin-Transformer module, the problem of low accuracy in detecting overlapping abnormal cells was solved, achieving efficient and accurate cell detection.
Patent Information
- Application Number
- CN202211726362.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-12-29
Smart Images

Figure CN115965602B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, specifically relating to an abnormal cell detection method based on improved YOLOv7 and Swin-Unet. Background Technology
[0002] Pathological cytology examination refers to the process of taking cytological specimens, such as sputum exfoliated cells or liquid-based cytology, preparing pathological cytology slides using techniques such as smear preparation and pathological sectioning, and then observing the types and characteristics of cells under a microscope to make a diagnosis. For example, screening for diseases such as breast cancer and cervical cancer often relies on pathological cytology examination for diagnosis. Cervical cancer is the most common gynecological malignancy worldwide. Early treatment of cancer is effective, inexpensive, and less difficult, but it often presents with no obvious symptoms and is difficult to detect. In China, cytology (including traditional Pap smears) is the main screening method for common female cancers such as cervical cancer; however, the overall screening level is not high, mainly due to the scarcity of experienced cytopathologists and support staff in the country. Therefore, using computers to assist in the detection of pathological cells is both necessary and valuable.
[0003] Existing detection methods are mainly based on deep learning methods, including object detection methods and instance segmentation methods. Chinese patent application (CN202111048528.2), "An Abnormal Cell Detection Method Based on Introduced Attention Mechanism," uses the advanced object detection network RetinaNet to screen suspicious cells, and then classifies them using a Mean-Teacher network with an introduced attention mechanism. This method effectively suppresses false positives during the detection process and improves detection accuracy, but its performance deteriorates when the noise in the sample increases and overlapping cell clusters increase. The main issues are: (1) difficulty in detecting overlapping abnormal cells; (2) a significant decrease in detection accuracy when the sample contains non-cellular units such as tissue fluid; and (3) the introduced attention mechanism does not fully integrate multi-scale information, and its detection performance needs improvement. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide an abnormal cell detection method based on improved YOLOv7 and Swin-Unet. This method performs staged detection of overlapping abnormal cells that are difficult to detect. By utilizing the characteristics of target detection's good performance on large targets and the high accuracy of instance segmentation, it can effectively detect difficult-to-detect cell samples and is less prone to missed detections and false detections. The detection head adopts a state-of-the-art dynamic head attention mechanism, which fully integrates attention in three dimensions: scale, space, and task, which can greatly improve the detection accuracy.
[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution.
[0006] A method for detecting abnormal cells based on improved YOLOv7 and Swin-Unet includes the following steps:
[0007] Step 1: Collect cell smear images from pathological cytology examinations, and create abnormal cell detection datasets and abnormal cell segmentation datasets;
[0008] Step 2: Build and train an improved YOLOv7 model for the detection of abnormal cells and overlapping cell clusters. Based on the latest YOLOv7 model, improvements are made to address the problem of extracting multi-dimensional feature information, resulting in an improved YOLOv7 model structure, which includes a process module for abnormal cell detection data preprocessing, a backbone network, a neck network, and a detection network.
[0009] Step 3: Build a detection result filtering module to classify cells in the output image of the detection network. Abnormal cell images are used as output, and overlapping cell cluster images are used as input to the segmentation model.
[0010] Step 4: Build and train the Swin-Unet model for segmentation of overlapping cell cluster images: Based on the Unet model most commonly used in the medical field, the Swin-Transformer module is used for sampling to consider the local and global relationships of cell images at multiple scales; the Swin-Unet model structure includes an encoder, a neck network, and a decoder.
[0011] Step 5: Detect abnormal cells using the improved YOLOv7 and Swin-Unet models.
[0012] The process of step 1 is as follows:
[0013] 1-1. Collect cell smear images from pathological cytology examinations, including cervical cell images and breast cell images. Perform sliding window cropping on the original cell smear images, with the cropping size set to 640×640 and the sliding window overlap range set to 50%, to obtain cell images of small regions. Use the LabelImg tool to label individual abnormal cells and overlapping cell clusters with rectangular boxes, save the labels as XML files, and create an abnormal cell detection dataset for training the improved YOLOv7 model.
[0014] 1-2. Filter cell images labeled as overlapping cell clusters in the abnormal cell detection dataset, and use the polygon annotation function of the LabelImg tool to subdivide the segmented regions, perform region annotation, label the abnormal cells and save them to create an abnormal cell segmentation dataset for training the Swin-Unet model.
[0015] Specifically, in step 2, the construction of the improved YOLOv7 model includes:
[0016] 2-1. Build an abnormal cell detection data preprocessing module, including: data enhancement by flipping and translating cell images; and noise reduction of cell images using Gaussian filtering, with the Gaussian kernel function as follows:
[0017]
[0018] Where G(x,y) is the pixel value of the denoised cell image, x,y represents the coordinates of the pixel, and σ is the standard deviation of Gaussian, which determines the smoothness of the cell image;
[0019] 2-2. Constructing the backbone network of the improved YOLOv7 model: The feature maps of the input cell image first pass through a 4-layer CBS module convolution, which includes Conv, BN, and SiLU layers. Then, they pass through a stack of ELAN and MP modules, outputting three feature maps. ELAN includes multiple CBS modules, with the input and output feature sizes remaining constant. The number of channels changes in the first two CBS modules, while the number of input channels remains consistent with the output channels in the subsequent CBS modules. The output of the last CBS module is the required number of channels. The MP module is a concatenation of the output vectors of Maxpool and the CBS modules.
[0020] 2-3. Constructing the neck network of the improved YOLOv7 model: Using the PAFPN structure, the three feature maps output by the backbone network are fused;
[0021] 2-4. Constructing the improved YOLOv7 model's head network: Introducing the dynamic head DyHead module for feature map attention fusion; its dynamic head module structure includes: fitting scale-aware attention, spatial-aware attention, and task-aware attention using stacked attention functions; the formula for applying self-attention is:
[0022] W(F) = π C (π S (π L (F)·F)·F)·F (2)
[0023] Where F∈R L×S×C For the corresponding input feature vectors, R is the set of input feature vectors, L represents the scale of the features, S = H × W is the reshaping of the height H and width W dimensions of the feature map, C represents the number of channels in the feature map, and π L (x), π S (x), π C(x) correspond to independent attention functions in the three dimensions of task, space, and scale, respectively, and correspond to formulas (3), (4), and (5):
[0024]
[0025]
[0026] π C (F)·F=max(α 1 (F)·F c +β 1 (F),α 2 (F)·F c +β 2 (F)) (5)
[0027] In formula (3), f(x) is a linear function approximated by a 1×1 convolution. It is the Hard-Sigmoid activation function;
[0028] In formula (4), K is the number of sparse sampling locations, ω is the weight coefficient corresponding to l and k, and p k +Δp k It is the position of the spatial offset Δm learned through self-learning. k It is position p k The self-learning scalar that should be addressed;
[0029] In formula (5), [α 1 ,α 2 ,β 1 ,β 2 ] T =θ(·) is a hyperfunction that learns to control the activation threshold, F C This represents the feature slice in the Cth channel.
[0030] Specifically, in step 2, the process of training the improved YOLOv7 model is as follows:
[0031] Cell images from the abnormal cell detection dataset are input, with a cell image size of 640×640. The batch size is set to 16, and the model is trained for 180 epochs to obtain the best-performing improved YOLOv7 model. Overlapping cell cluster images are extracted from the detection results, and different IoU (Intersection over Union) ratios are set. Here, @x represents the performance with an IoU threshold of x; mAP represents the average AP calculated for each corresponding class, and the higher the value, the better the detection effect; Recall is the recall rate, and the higher the value, the fewer labeled cells are missed.
[0032] Specifically, the process of building the Swin-Unet model in step 4 includes:
[0033] 4-1. Building the encoder part of the Swin-Unet model: First, the smallest unit of the cell image is transformed from a pixel into a 4×4 patch through Patch Patterning. After preserving the high-dimensional space structure through a linear embedding module, a downsampling process is performed. The initial part still uses the convolutional layers in Unet, and the subsequent two downsampling steps are replaced with paired Swin-Transformers. The basic formula is as follows:
[0034]
[0035] Where Q, K, and V represent the query, key, and value matrices in self-attention, respectively, d represents the dimension, B is the learnable relative position bias, and Attention(Q,K,V) represents the attention function within each patch.
[0036] 4-2. Construct the neck layer of the Swin-Unet model: Use a set of paired Swin-Transformers to filter the downsampled high-dimensional feature information;
[0037] 4-3. Building the decoder part of the Swin-Unet model: The network structure corresponding to the encoder network first goes through two paired Swin-Transformer + Patch Expanding processes. The last layer of features uses the original upsampling + 2 convolutions. Each upsampling module is concatenated with the feature map in the encoder at the same stage to form a residual block. After a linear projection of the output features, it is fed into the convolutional network used for classification to obtain the final output result.
[0038] Specifically, the training process of the Swin-Unet model in step 4 is as follows:
[0039] Using overlapping cell cluster images as input, the batch size is set to 64, and the training is conducted for 80 epochs. Different IoU (Intersection over Union) values are set, which in the segmentation task are the thresholds for predicting the intersection over union ratio between the mask and the ground truth mask.
[0040] In step 5, the process of detecting abnormal cells using the improved YOLOv7 and Swin-Unet models includes:
[0041] 5-1. Obtain cell smear images from pathological cytology examinations, perform sliding window cropping on the cell smear images, and input the cropped cell images into the detection network in sequence;
[0042] 5-2. The improved YOLOv7 network's backbone network extracts features from cell images, feeds feature maps of different scales into the neck network, and after feature fusion, feeds them into the detection head network to output detection results.
[0043] 5-3. Use the detection result filtering module to filter the detection results. Abnormal cells are directly output, while overlapping cell clusters are sent to the segmentation network.
[0044] 5-4. The encoder of the Swin-Unet network downsamples the overlapping cell image, filters it through the neck network, and then enters the decoder network to upsample it using the residual structure. The output feature image enters a convolutional layer to classify the image segmentation region. The regions determined to be abnormal cells are output, and together with the abnormal cells in step 3, they are used as the final output result.
[0045] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0046] 1. This invention employs a phased detection method combining target detection and instance segmentation. It fully utilizes the high precision of the segmentation model to handle overlapping cell clusters that are difficult to detect, while maintaining the high performance of the original detection model and the ease of data labeling to handle individual abnormal cells that are easier to detect. Without sacrificing real-time detection performance, it effectively solves the problem of cell clusters that are difficult to detect and prone to false detection, improving the recall and accuracy of detection. It achieves a good balance between hardware level and accuracy, which is more in line with real-world needs and more feasible.
[0047] 2. This invention introduces a state-of-the-art dynamic head module (DyHead), which simultaneously fits scale-aware attention, spatial awareness attention, and task-aware attention by stacking attention functions. This allows the target detection network to fully consider the cell contextual relevance under multiple dimensions, which is consistent with the actual detection process of pathologists, making the model more robust and improving the detection accuracy.
[0048] 3. This invention introduces the Swin-Transformer attention module, which combines local and global attention of the image through a sliding window mechanism, effectively enhancing the segmentation performance of the segmentation network, improving the model's accuracy in recognizing complex cell clusters, and thus improving the overall detection accuracy. Attached Figure Description
[0049] Figure 1 This is a flowchart of a method according to an embodiment of the present invention.
[0050] Figure 2 This is a schematic diagram of an improved YOLOv7 model structure according to an embodiment of the present invention.
[0051] Figure 3This is a diagram of a dynamic header module according to an embodiment of the present invention.
[0052] Figure 4 This is a schematic diagram of the Swin-Unet model structure according to an embodiment of the present invention.
[0053] Figure 5 This is a diagram of the Swin-Transformer module according to an embodiment of the present invention.
[0054] Figure 6 This is a diagram illustrating the overall algorithm implementation process of one embodiment of the present invention. Detailed Implementation
[0055] This invention discloses an abnormal cell detection method based on an improved YOLOv7 and Swin-Unet, comprising: collecting cell slice images from cytopathological examinations to create an abnormal cell detection dataset and an abnormal cell segmentation dataset; building an improved YOLOv7 model by incorporating a dynamic attention head to enhance the model's robustness for detecting independent abnormal cells and overlapping cell clusters; using the model with the best training performance for abnormal cell detection and filtering the detection results; and inputting overlapping cell clusters from the detection results into the Swin-Unet model for segmentation detection. This invention fully considers the contextual information during cell detection, effectively handles difficult-to-detect cell clusters, and effectively improves accuracy and recall while ensuring detection speed.
[0056] The present invention will now be described in further detail with reference to the accompanying drawings.
[0057] Figure 1 This is a flowchart illustrating a method according to an embodiment of the present invention. Figure 1 As shown, the method in this embodiment includes the following steps:
[0058] Step 1: Collect cell smear images from pathological cytology examinations, and create abnormal cell detection datasets and abnormal cell segmentation datasets;
[0059] 1-1. Collect cell smear images from pathological cytology examinations, including cervical cell images and breast cell images. Perform sliding window cropping on the original cell smear images, with the cropping size set to 640×640 and the sliding window overlap range set to 50%, to obtain cell images of small regions. Use the LabelImg tool to label individual abnormal cells and overlapping cell clusters with rectangular boxes, save the labels as XML files, and create an abnormal cell detection dataset for training the improved YOLOv7 model.
[0060] 1-2. Filter cell images labeled as overlapping cell clusters in the abnormal cell detection dataset, and use the polygon annotation function of the LabelImg tool to subdivide the segmented regions, perform region annotation, label the abnormal cells and save them to create an abnormal cell segmentation dataset for training the Swin-Unet model.
[0061] Step 2: Build and train an improved YOLOv7 model for detecting abnormal cells and overlapping cell clusters. This invention is based on the latest YOLOv7 model and improves upon it to address the problem of extracting multi-dimensional feature information, resulting in the improved YOLOv7 model structure as follows: Figure 2 As shown, its overall structure includes a data preprocessing module (Process), a backbone network, a neck network, and a detection network (Head). The construction of each network is shown below:
[0062] 2-1. Build an abnormal cell detection data preprocessing module, including: data enhancement by flipping and translating cell images; and noise reduction of cell images using Gaussian filtering, with the Gaussian kernel function as follows:
[0063]
[0064] Where G(x,y) is the pixel value of the denoised cell image, x,y represents the coordinates of the pixel, and σ is the standard deviation of Gaussian, which determines the smoothness of the cell image;
[0065] 2-2. Constructing the backbone network of the improved YOLOv7 model: The feature maps of the input cell image first pass through a 4-layer CBS module convolution, which includes Conv, BN, and SiLU layers. Then, they pass through a stack of ELAN and MP modules, outputting three feature maps. ELAN includes multiple CBS modules, with the input and output feature sizes remaining constant. The number of channels changes in the first two CBS modules, while the number of input channels remains consistent with the output channels in the subsequent CBS modules. The output of the last CBS module is the required number of channels. The MP module is a concatenation of the output vectors of Maxpool and the CBS modules.
[0066] 2-3. Construct the improved neck network of the YOLOv7 model: Utilize the PAFPN (Path Aggregation Network with Feature Pyramid Networks) structure to fuse the three feature maps output by the backbone network;
[0067] 2-4. Constructing the improved YOLOv7 model's head network: Introducing the dynamic head DyHead module for feature map attention fusion; its dynamic head module structure includes: fitting scale-aware attention, spatial-aware attention, and task-aware attention using stacked attention functions; the formula for applying self-attention is:
[0068] W(F) = π C (π S (π L (F)·F)·F)·F (2)
[0069] Where F∈R L×S×C For the corresponding input feature vectors, R is the set of input feature vectors, L represents the scale of the features, S = H × W is the reshaping of the height (H) and width (W) dimensions of the feature map, C represents the number of channels in the feature map, and π L (x), π S (x), π C (x) correspond to independent attention functions in the three dimensions of task, space, and scale, respectively, and correspond to formulas (3), (4), and (5):
[0070]
[0071]
[0072] π C (F)·F=max(α 1 (F)·F c +β 1 (F),α 2 (F)·F c +β 2 (F)) (5)
[0073] In formula (3), f(x) is a linear function approximated by a 1×1 convolution. It is the Hard-Sigmoid activation function;
[0074] In formula (4), K is the number of sparse sampling locations, ω is the weight coefficient corresponding to l and k, and p k +Δp k It is the position of the spatial offset Δm learned through self-learning. k It is position p k The self-learning scalar that should be addressed;
[0075] In formula (5), [α 1 ,α 2 ,β 1 ,β 2 ] T =θ(·) is a hyperfunction that learns to control the activation threshold, FC This represents the feature slice in the Cth channel;
[0076] 2-5. Training the improved YOLOv7 model: Input the abnormal cell detection dataset, crop the image size to 640×640, set the batch-size to 16, train for 180 epochs, and obtain the best-performing improved YOLOv7 model. Extract overlapping cell cluster samples from the detection results, set different IoU (Intersection over Union, which is the ratio of the predicted box to the ground truth box in the object detection task) thresholds, and the training results are shown in Table 1.
[0077] Table 1
[0078]
[0079] Here, @x represents the performance when the IoU threshold is set to x, mAP represents the average AP (Average Precision) calculated for each corresponding category. The higher the value, the better the detection effect. Recall, also known as recall rate, means that the higher the value, the fewer labeled cells are missed.
[0080] Step 3: Build a detection result filtering module to classify cells in the output image of the detection network. Abnormal cell images are used as output, and overlapping cell cluster images are used as input to the segmentation model.
[0081] Step 4: Build and train the Swin-Unet model for segmentation of overlapping cell cluster images. This invention is based on the Unet model, which is most commonly used in the medical field. It utilizes the Swin-Transformer module for sampling, targeting the local and global relationships in cell images at multiple scales. The Swin-Unet model structure is as follows: Figure 4 As shown, its overall structure includes an encoder, a neck network, and a decoder, and the construction of each network is shown below:
[0082] 4-1. Building the encoder part of the Swin-Unet model: First, the smallest unit of the cell image is transformed from a pixel into a 4×4 patch through Patch Patterning. After preserving the high-dimensional space structure through a linear embedding module, a downsampling process is performed. The initial part still uses the convolutional layers in Unet, and the subsequent two downsampling steps are replaced with paired Swin-Transformers, the structure of which is as follows. Figure 5 As shown, its basic formula is shown in formula (6):
[0083]
[0084] Where Q, K, and V represent the query, key, and value matrices in self-attention, respectively, d represents the dimension, B is the learnable relative position bias, and Attention(Q,K,V) represents the attention function within each patch.
[0085] 4-2. Construct the neck layer of the Swin-Unet model: Use a set of paired Swin-Transformers to filter the downsampled high-dimensional feature information;
[0086] 4-3. Building the decoder part of the Swin-Unet model: The network structure corresponding to the encoder network first goes through two paired Swin-Transformer + Patch Expanding processes. The last layer of features uses the original upsampling + 2 convolutions. Each upsampling module is concatenated with the feature map in the encoder at the same stage to form a residual block. After a linear projection of the output features, it is fed into the convolutional network used for classification to obtain the final output result.
[0087] 4-4. Training the Swin-Unet model: The overlapping cell clusters were used as the input of the segmentation dataset. The batch size was set to 64, and the model was trained for 80 epochs. Different IoU (Intersection over Union, which is the ratio of the predicted mask to the ground truth mask in the instance segmentation task) thresholds were set. The training results are shown in Table 2.
[0088] Table 2
[0089]
[0090] The indicators are the same as those in Table 1.
[0091] Step 5: Use the improved YOLOv7 and Swin-Unet models to detect abnormal cells. The algorithm flow is as follows: Figure 6 As shown, the detailed process is as follows:
[0092] 5-1. Obtain cell smear images from pathological cytology examinations, perform sliding window cropping on the cell smear images, and input the cropped cell images into the detection network in sequence;
[0093] 5-2. The improved YOLOv7 network's backbone network extracts features from cell images, feeds feature maps of different scales into the neck network, and after feature fusion, feeds them into the detection head network to output detection results.
[0094] 5-3. Use the detection result filtering module to filter the detection results. Abnormal cells are directly output, while overlapping cell clusters are sent to the segmentation network.
[0095] 5-4. The encoder of the Swin-Unet network downsamples the overlapping cell image, filters it through the neck network, and then enters the decoder network to upsample it using the residual structure. The output feature image enters a convolutional layer to classify the image segmentation region. The regions determined to be abnormal cells are output, and together with the abnormal cells in step 3, they are used as the final output result.
Claims
1. A method for detecting abnormal cells based on improved YOLOv7 and Swin-Unet, characterized in that, Includes the following steps: Step 1: Collect cell smear images from pathological cytology examinations, and create abnormal cell detection datasets and abnormal cell segmentation datasets; Step 2: Build and train an improved YOLOv7 model for the detection of abnormal cells and overlapping cell clusters. Based on the YOLOv7 model, improvements are made to address the problem of extracting multi-dimensional feature information, resulting in an improved YOLOv7 model structure, which includes a process module for abnormal cell detection data preprocessing, a backbone network, a neck network, and a detection network. A dynamic head DyHead module is introduced for feature map attention fusion. Its dynamic head module structure includes: fitting scale-aware attention, spatial-aware attention, and task-aware attention using a stack of attention functions; Step 3: Build a detection result filtering module to classify cells in the output image of the detection network. Abnormal cell images are used as output, and overlapping cell cluster images are used as input to the segmentation model. Step 4: Build and train the Swin-Unet model for segmentation of overlapping cell cluster images: Based on the Unet model, the Swin-Transformer module is used for sampling to consider the local and global relationships of cell images at multiple scales; the Swin-Unet model structure includes an encoder, a neck network, and a decoder. Step 5: Detect abnormal cells using the improved YOLOv7 and Swin-Unet models; The process of step 1 is as follows: 1-1. Collect cell smear images from pathological cytology examinations, including cervical cell images and breast cell images. Perform sliding window cropping on the original cell smear images, with the cropping size set to 640×640 and the sliding window overlap range set to 50%, to obtain cell images of small regions. Use the LabelImg tool to label individual abnormal cells and overlapping cell clusters with rectangular boxes, save the labels as XML files, and create an abnormal cell detection dataset for training the improved YOLOv7 model. 1-2. Filter cell images labeled as overlapping cell clusters in the abnormal cell detection dataset, and use the polygon annotation function of the LabelImg tool to subdivide the segmented regions, perform region annotation, label the abnormal cells and save them to create an abnormal cell segmentation dataset for training the Swin-Unet model.
2. The abnormal cell detection method based on improved YOLOv7 and Swin-Unet according to claim 1, characterized in that, In step 2, the construction of the improved YOLOv7 model includes: 2-1. Build an abnormal cell detection data preprocessing module, including: data enhancement by flipping and translating cell images; and noise reduction of cell images using Gaussian filtering, with the Gaussian kernel function as follows: Where G(x,y) is the pixel value of the denoised cell image, x,y represents the coordinates of the pixel, and σ is the standard deviation of Gaussian, which determines the smoothness of the cell image; 2-2. Constructing the backbone network of the improved YOLOv7 model: The feature maps of the input cell image first pass through a 4-layer CBS module convolution, which includes Conv, BN, and SiLU layers. Then, they pass through a stack of ELAN and MP modules, outputting three feature maps. ELAN includes multiple CBS modules, with the input and output feature sizes remaining constant. The number of channels changes in the first two CBS modules, while the number of input channels remains consistent with the output channels in the subsequent CBS modules. The output of the last CBS module is the required number of channels. The MP module is a concatenation of the output vectors of Maxpool and the CBS modules. 2-3. Constructing the neck network of the improved YOLOv7 model: Using the PAFPN structure, the three feature maps output by the backbone network are fused; 2-4. Constructing the improved YOLOv7 model's head network: The formula for applying self-attention is: W(F)=π C (p S (p L (F)·F)·F)·F (2) Where F∈R L×S×C For the corresponding input feature vectors, R is the set of input feature vectors, L represents the scale of the features, S = H × W is the reshaping of the height H and width W dimensions of the feature map, C represents the number of channels in the feature map, and π L (x), π S (x), π C (x) correspond to independent attention functions in the three dimensions of task, space, and scale, respectively, and correspond to formulas (3), (4), and (5): p C (F)·F=max(α 1 (F)·F c +b 1 (F),a 2 (F)·F c +b 2 (F)) (5) In formula (3), f(x) is a linear function approximated by a 1×1 convolution. It is the Hard-Sigmoid activation function; In formula (4), K is the number of sparse sampling locations, ω is the weight coefficient corresponding to l and k, and p k +Δp k It is the position of the spatial offset Δm learned through self-learning. k It is position p k The self-learning scalar that should be addressed; In formula (5), [α 1 ,α 2 ,β 1 ,β 2 ] T =θ(·) is a hyperfunction that learns to control the activation threshold, F C This represents the feature slice in the Cth channel.
3. The abnormal cell detection method based on improved YOLOv7 and Swin-Unet according to claim 1, characterized in that, In step 2, the process of training the improved YOLOv7 model is as follows: The abnormal cell detection dataset is used as input, with cell images of size 640×640. The batch size is set to 16, and the model is trained for 180 epochs to obtain an improved YOLOv7 model. Overlapping cell cluster images are extracted from the detection results, and different IoU (Intersection over Union) ratios are set. Here, @x represents the performance of setting the IoU threshold to x; mAP represents the average AP calculated for each corresponding class. The higher the value, the better the detection effect; Recall is the recall rate. The higher the value, the fewer labeled cells are missed.
4. The abnormal cell detection method based on improved YOLOv7 and Swin-Unet according to claim 1, characterized in that, The process of building the Swin-Unet model in step 4 includes: 4-1. Building the encoder part of the Swin-Unet model: First, the smallest unit of the cell image is transformed from a pixel into a 4×4 patch through Patch Patterning. After preserving the high-dimensional structure through a linear embedding module, a downsampling process is performed. The initial part still uses the convolutional layers in Unet, and the subsequent two downsampling steps are replaced with paired Swin-Transformers, the formula of which is: Where Q, K, and V represent the query, key, and value matrices in self-attention, respectively, d represents the dimension, B is the learnable relative position bias, and Attention(Q,K,V) represents the attention function within each patch. 4-2. Construct the neck layer of the Swin-Unet model: Use a set of paired Swin-Transformers to filter the downsampled high-dimensional feature information; 4-3. Building the decoder part of the Swin-Unet model: The network structure corresponding to the encoder network first goes through two paired Swin-Transformer + Patch Expanding processes. The last layer of features uses the original upsampling + 2 convolutions. Each upsampling module is concatenated with the feature map in the encoder at the same stage to form a residual block. After a linear projection of the output features, it is fed into the convolutional network used for classification to obtain the final output result.
5. The abnormal cell detection method based on improved YOLOv7 and Swin-Unet according to claim 1, characterized in that, The training process of the Swin-Unet model in step 4 is as follows: Using overlapping cell cluster images as input, with a batch size of 64, training for 80 epochs, and different IoU (Intersection over Union) ratios, the segmentation task is represented by predicting the IoU threshold between the mask and the ground truth mask.
6. The abnormal cell detection method based on improved YOLOv7 and Swin-Unet according to claim 1, characterized in that, In step 5, the process of detecting abnormal cells using the improved YOLOv7 and Swin-Unet models includes: 5-1. Obtain cell smear images from pathological cytology examinations, perform sliding window cropping on the cell smear images, and input the cropped cell images into the detection network in sequence; 5-2. The improved YOLOv7 network's backbone network extracts features from cell images, feeds feature maps of different scales into the neck network, and after feature fusion, feeds them into the detection head network to output detection results. 5-3. Use the detection result filtering module to filter the detection results. Abnormal cells are directly output, while overlapping cell clusters are sent to the segmentation network. 5-4. The encoder of the Swin-Unet network downsamples the overlapping cell image, filters it through the neck network, and then enters the decoder network to upsample it using the residual structure. The output feature image enters a convolutional layer to classify the image segmentation region. The regions determined to be abnormal cells are output, and together with the abnormal cells in step 3, they are used as the final output result.
Citation Information
Patent Citations
Abnormal cell detection method based on introduction of attention mechanism
CN113838008A
Fat cell progenitor cell segmentation method based on SUnet algorithm
CN114998360A
Cervical squamous lesion cell detection method based on deep adaptive feature extraction
CN115471838A