A Colony Classification Method Based on Persistent Homology and an Improved EfficientNet Algorithm
By introducing Persistent Homology and improving the EfficientNet algorithm, and utilizing ECA and SCoT self-attention mechanisms, the accuracy and efficiency issues in the rapid detection of pathogenic bacteria in existing technologies are solved, achieving efficient and reliable colony classification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DALIAN UNIV
- Filing Date
- 2024-09-11
- Publication Date
- 2026-05-12
AI Technical Summary
Existing rapid antigen methods and PCR detection methods have large error rates. Although colony culture results are accurate, they are time-consuming and make it difficult to quickly and accurately distinguish between pathogenic bacteria such as Candida albicans and Staphylococcus epidermidis.
We employ a colony classification method based on Persistent Homology and an improved EfficientNet algorithm. Through feature extraction and classification processing, we use PH to enhance key feature regions of the image, introduce ECA convolutional attention mechanism and SCoT self-attention mechanism, construct an improved EfficientNet feature extraction network, and perform multi-dimensional feature weight allocation and classification.
It achieves efficient and accurate identification of Candida albicans and Staphylococcus epidermidis in a short time, with a classification accuracy improved by about 10.29% to 98.64%, thus improving the model's generalization ability and recognition performance.
Smart Images

Figure CN119295799B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, specifically relating to a colony classification method based on Persistent Homology and an improved EfficientNet algorithm. Background Technology
[0002] In recent years, with the development of computer technology, image processing technology, and artificial intelligence theory and technology, computer vision technology has developed rapidly and been widely applied, playing an important role in scientific research and medical fields.
[0003] Computer vision technology is a highly interdisciplinary field, involving artificial intelligence, optics, mechanics, computer graphics, and neurobiology. It has been widely applied in commerce, military, meteorology, and natural disaster prediction, bringing about revolutionary changes to people's lives. For example, the emergence of technologies such as facial recognition and autonomous driving relies heavily on computer vision. Furthermore, computer vision technology is constantly evolving, developing from single-dimensional to multi-dimensional approaches, and its applications are expanding. In the medical field, applications of computer vision technology mainly manifest in image recognition and analysis, pathological image analysis, surgical guidance and navigation, health monitoring and remote diagnosis, and personalized medicine.
[0004] In today's society, the vast majority of diseases are caused by bacterial or fungal infections, such as respiratory tract infections, urinary tract infections, and skin infections. Often, although some pathogens are different species, their symptoms are almost identical. For example, Candida albicans and Staphylococcus epidermidis skin infections can both cause dermatitis or acne, while blood infections can cause high fever, making it difficult for the average person to distinguish between them. To address this, rapid antigen testing, PCR testing, and colony culture are often used to identify the specific pathogen. However, while rapid antigen methods and PCR testing are fast, they have a certain degree of error; colony culture results are more accurate but take longer. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, this invention provides a colony classification method based on Persistent Homology and an improved EfficientNet algorithm. The method consists of two parts: feature extraction and classification processing. In the data preprocessing stage, Persistent Homology (PH) is used to enhance key feature regions of the image, and the dataset is expanded. The MBConv (Mobile Inverted Bottleneck Convolution) module in EfficientNet is redesigned according to the design principles of convolutional networks, introducing ECA convolutional attention after the first convolution. A novel self-attention mechanism, SCoT, is introduced after the last layer of the MBConv module to learn multi-dimensional feature weight allocation. Finally, a linear classifier, Softmax, is used to classify the features and output the recognition results.
[0006] The above-mentioned objective of this invention is achieved through the following technical solution: a colony classification method based on Persistent Homology and an improved EfficientNet algorithm, comprising the following steps:
[0007] S1: Collect the dataset and filter and crop the collected image data;
[0008] S2: Use Persistent Homology to extract features from the image;
[0009] S3: Introduce the ECA attention mechanism into the MBConv module of the EfficientNet-B0 classification model;
[0010] S4: Perform secondary classification of images based on the SCoT self-attention mechanism.
[0011] Furthermore, S1 specifically refers to:
[0012] S1.1 Dataset Collection: Self-collected datasets of Candida albicans and Staphylococcus epidermidis were used.
[0013] S1.2 Screening: For the collected colony data, screen out the colony parts that are stuck together, incompletely grown, or not fully photographed, and retain the complete and single colony data.
[0014] S1.3 Cropping: For the colony images retained after screening, crop them to an appropriate size for individual colonies. For the dataset that has been screened and cropped, expand the dataset using data augmentation methods.
[0015] Furthermore, S2 specifically includes:
[0016] S2.1 Constructing a point cloud: Generate a set P containing data points from the provided image. These points are called a point cloud. They can be points in Euclidean space or points in other metric spaces.
[0017] S2.2 Determine the parameters: Select a parameter ε to represent the size or radius of the constructed shape. ε determines the maximum distance between two points that can form a connection; different parameters ε will result in different topological feature extraction maps.
[0018] S2.3 Constructing a Complex: Use an ε-dashed sphere with radius ε to encircle each point in P, and connect this point to all other points within the sphere;
[0019] S2.4 Analyze the topology: Obtain topological information about the dataset by analyzing the topology of the constructed complex.
[0020] Furthermore, S3 specifically includes:
[0021] S3.1 Input data into the improved EMBConv (Mobileinverted Bottleneck Convolution) structure. Image data processed by PH topological feature extraction and data augmentation, and then by a standard 3x3 convolution kernel, is input into the EMBConv structure module.
[0022] S3.2 Import 1×1 convolution kernels. This is used to change the number of channels in the data feature map, i.e., to increase the dimensionality. Batch Normalization (BN) and Swish achieve this with fewer parameters, which helps reduce computational cost and the risk of overfitting.
[0023] S3.3 introduces 3×3 Depthwise Conv convolutions. Each input channel is processed using an independent 3×3 convolution kernel, keeping the number of channels constant. Then, batch normalization is applied to standardize the data for each channel, giving it a distribution with a mean of 0 and a standard deviation of 1. Next, non-linearity is introduced through the Swish activation function, which effectively avoids the gradient vanishing problem and enhances the expressive power of the model.
[0024] S3.4 Enters the ECA module. The ECA attention mechanism identifies key features and important information in the data, assigns higher weight to these features, and appropriately ignores relatively unimportant information.
[0025] S3.5 imports a 1x1 ordinary convolution. It includes a Batch Normalization (BN) module for data dimensionality reduction.
[0026] S3.6 finally enters the Dropout layer. This module randomly sets some elements in the input data to zero according to a set probability, thereby reducing the model's dependence on specific neurons and enhancing the model's generalization ability. This effectively prevents overfitting of the neural network and improves the model's performance on unseen data.
[0027] S3.7 imports the output data into the remaining six layers of the MBConv module of the neural network, and then feeds the output into the SCoT self-attention mechanism.
[0028] EfficientNet enhances the network by uniformly scaling its depth, width, and image resolution using a fixed set of scaling factors. The number of stacked modules determines the network depth, the width comes from the number of depthwise separable convolution kernels, and the size of the input image determines the image resolution.
[0029] The Mobileinverted Bottleneck Convolution (MBConv) is a key component of the EfficientNet model series. Its structure is similar to depthwise separable convolutions. First, a 1×1 point convolution is performed on the input feature map to increase its dimensionality. Then, depthwise convolutions are used to extract information from the high-dimensional features. Finally, a 1×1 point convolution is used for dimensionality reduction. To focus on key features, a Squeeze and Excitation (SE) channel attention mechanism is introduced after the depthwise convolution within this module. The SE module first performs Global Average Pooling (GAP) on the feature map, then transforms the high-dimensional global feature map into a low-dimensional feature vector through a compression dimensionality reduction operation, thus obtaining the global features across channels. However, the dimensionality reduction operation is detrimental to the prediction capabilities of the channel attention mechanism, resulting in weaker extraction of inter-channel relationships and lower efficiency. To avoid the negative impact of dimensionality reduction in the SE module, an Efficient Channel Attention (ECA) module is used to achieve efficient local cross-channel interaction and reduce the number of parameters.
[0030] Furthermore, S4 specifically includes:
[0031] S4.1 Input Data. Import the pre-processed data into the SCoT self-attention mechanism.
[0032] S4.2 Feature Partitioning. The feature map S is divided into n parts, denoted as [S0, S1, ..., Sn]. n-1This indicates that the number of channels in each segment is C1 = C / N. At the same time, for each segmented channel feature map, multi-scale convolution kernels are used to group convolution to extract spatial information of feature maps at different scales, and the group size is adaptively selected according to the size of the convolution kernel.
[0033] S4.3 Spatial Branch Processing. In the spatial branch learning part, the self-attention block operates on the input tensor X to highlight or suppress features while maintaining high resolution in its orthogonal directions. Softmax normalization is applied to the bottleneck tensor to increase the dynamic range of attention, followed by tone mapping using the Sigmoid function.
[0034] S4.4 Contextual Information Branch Processing. For the contextual information branch learning part, for the two-dimensional feature modules of different channels formed by the previous segmentation, k×k sets of convolutions are used on all adjacent keys in the k×k grid in space to represent each key in combination with the context content.
[0035] S4.5 combines two learning methods. It uses a static context key K. 1 Conditioned by the concatenation of query Q, the attention matrix is achieved through two consecutive 1×1 convolutions, containing W with the ReLU activation function. θ And W without an activation function δ .
[0036] S4.6 outputs the processed data to a 1×1 convolutional layer and pooling layer for further processing, and uses a linear classifier Softmax to classify the features and output the recognition results.
[0037] Attention mechanisms enable models to focus more effectively on relevant information when processing complex input data, thereby improving performance. Attention mechanisms can be viewed as a dynamic weight allocation method that highlights important parts by assigning different weights to each input element. Here, we introduce a novel attention mechanism, SCoT (Space Contextual Transformer), which captures the correlation between different time steps in a sequence to understand the temporal dependencies in the sequence data, while simultaneously processing the spatial information of multi-scale input feature maps and effectively establishing long-term dependencies between multi-scale channel attention.
[0038] The advantages of this invention compared to existing technologies are as follows: It introduces PH-extracted features into the improved EfficientNet model, combines the improved EMBConv with the backbone network using the aforementioned improvement strategy, and adds a ScoTAttention module to construct an improved EfficientNet feature extraction network. When a colony image is input into the network, it first passes through a conv layer and the MBConv module to extract feature information layer by layer. The ScoTAttention module learns from both spatial and contextual information aspects of these extracted features, identifying important and irrelevant features. The network rationally allocates computational resources based on the importance of the features, achieving high recognition accuracy with fewer parameters. Attached Figure Description
[0039] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0040] Figure 1 When choosing the size or radius parameter ε to represent the shape being constructed, the value of ε determines the maximum distance that can be connected between two points. For a point cloud composed of a graphic, different parameters ε result in different topological feature extraction maps. The figures show the topological graphics constructed when ε takes values of 1, 3, and 7 for this graphic. The most suitable value is selected to ensure the completeness of the graphic's topological features to the greatest extent.
[0041] Figure 2 An improved MBConv module in EfficientNet;
[0042] Figure 3 This is the structure diagram of the SCoT self-attention mechanism. First, the input two-dimensional effective feature map is divided into n parts, and multi-scale convolutional kernels are used to group and convolve the parts to extract spatial information from feature maps of different scales, reducing the number of parameters. Then, two different learning methods—spatial channels and contextual information—are combined to guide self-attention learning. Finally, the final weight values are calculated by fusing the results.
[0043] Figure 4 CA and SE were inoculated into TSB medium and cultured at 37°C for 18 hours. The growth status was then determined after culturing at 37°C for another 18 hours.
[0044] Figure 5The dataset is processed using the PH (Hypertext Transfer) technique. First, the images in the dataset are processed into grayscale. For the resulting grayscale images, appropriate filters are set by modifying parameters, and their topological features are extracted, highlighting these features within the dataset. In the diagram, image a represents the original image of the dataset without PH feature extraction; image b represents the grayscale image after grayscale processing; image c represents the topological grayscale image filtered by the PH filter; image d represents the editable component after PH processing; and image e represents the final image data with extracted topological features.
[0045] Figure 6 The figures show the topological feature representations extracted from CA and SE, respectively, which are the persistent graphs (PDs) generated by PH. These features capture the topological properties of the dataset and possess scale invariance to some extent. Here, a and b represent the PD representation and PD variants of the CA dataset, and c and d represent the corresponding parts of the SE dataset. As can be clearly seen from the figure, after VR complex construction and filtering by PH, different topological components of the data are represented by birth and death times, and their lifecycles are calculated. Components with lifecycles greater than a threshold are selected, and any components outside the selected components are eliminated, thus constructing the final topological image.
[0046] Figure 7 The improved overall module structure diagram includes a Persistent Homology feature extraction module, a convolutional layer module, an EMBConv module, an MBConv module, an SCoT-Attention module, and a pooling layer module. As described in S3 of Example 1, the EMBConv module replaces the SE attention mechanism in the original MBConv module with an ECA attention mechanism to allocate image weights, and is renamed the EMBConv module. The SCoT self-attention mechanism, as described in S4 of Example 1, first divides the input two-dimensional effective feature map into n parts, and uses multi-scale convolutional kernels to group convolutions to extract spatial information from feature maps of different scales, reducing the number of parameters. It combines two different learning methods—spatial channel and contextual information—to guide self-attention learning. Finally, the final weight values are calculated by fusion.
[0047] Figure 8 The figure shows the experimental results. During the testing process, the accuracy of this experimental training for the CA and SE dual-models reached 98.4% for classifying CA colonies and 98.9% for classifying SE colonies. Detailed Implementation
[0048] The present invention is described in detail below through specific embodiments, but this does not limit the scope of protection of the present invention. Unless otherwise specified, the experimental methods used in the present invention are all conventional methods, and the experimental equipment, materials, reagents, etc. used can all be obtained commercially.
[0049] Example 1
[0050] An improved EfficientNet network method based on Persistent Homology, applying the EMBConv module and the SCoT self-attention mechanism.
[0051] This study is divided into two parts: feature extraction and classification. In the data preprocessing stage, key feature regions of the images are enhanced using PH (Hypertext Transfer Effect) and the dataset is expanded. Based on the design principles of convolutional networks, the MBConv module in EfficientNet was redesigned, introducing ECA (Electronic Convolutional Attention) after the first convolution. Finally, a linear classifier, Softmax, is used to classify the features and output the recognition results. Experimental results demonstrate that the improved model achieves a classification accuracy of 98.64% on this dataset, an improvement of approximately 10.29% compared to the original EfficientNetB0 network.
[0052] S1: Collect the dataset and filter and crop the collected image data;
[0053] S1.1: Data set self-collection.
[0054] The dataset used was a self-collected dataset. *Candida albicans* and *Staphylococcus epidermidis* were inoculated into TSB medium and incubated at 37°C for 18 hours. The OD value was measured to be 0.3, and the calculated bacterial count was 2.4e8. The original bacterial culture was then serially diluted to 10⁻¹, 1 / 2, 1 / 3, 1 / 4, and 1 / 5 using TSB. 50 μL of each diluted culture was then spread onto TSA solid medium using swabs and incubated at 37°C for 18 hours. Colony images were collected using an S4T digital microscope at a resolution of 640*480. The captured colony images were then filtered and cropped. The initial dataset is attached. Figure 7 As shown.
[0055] S1.2 Filtering.
[0056] For the collected colony data, discard any colonies that are stuck together, incompletely grown, or poorly photographed. Retain only complete, single colony data.
[0057] S1.3 Cutting.
[0058] For the colony images that have been selected and retained, taking into account factors such as size and shape, they are cropped into individual colonies of 80*80 pixels to facilitate the next step of processing.
[0059] The dataset, after being filtered and pruned, was augmented using data augmentation techniques, resulting in a final dataset containing 3168 Candida albicans and 3096 Staphylococcus epidermidis. The dataset was then divided into training and testing sets in an 8:2 ratio.
[0060] S2: Use Persistent Homology to extract features from images and fuse them with data augmentation;
[0061] Considering the limited number of effective features and the lack of prominent features in the colony images of the dataset, a pH feature extraction method is introduced. The relevant definitions are as follows:
[0062] S2.1 Constructing a point cloud.
[0063] Generate a set P containing data points from the provided image. We call these points a point cloud. These points can be points in Euclidean space or points in other metric spaces.
[0064] S2.2 Determine the parameters.
[0065] Choose a parameter ε to represent the size or radius of the constructed shape. ε determines the maximum distance that can be connected between two points; different parameters ε result in different topological feature extraction maps. The topological features of the images in the PH-detected dataset are introduced into the collected colony images. In the experiment, the window_size parameter is set to 5, and the border_width parameter is set to 1 for image processing.
[0066] S2.3 Construct the complex.
[0067] We use a dashed sphere of radius ε to circle every point in P, and connect each point to all other points within the circle. The result is shown in the appendix. Figure 8 As shown.
[0068] First, we construct the neighborhood graph of the point set data. The neighborhood graph is an undirected weighted graph (G,ω), where G = (V,E), V is the vertex set, E is the edge set, and ω: E → R. Our edges are created by connecting points where we have previously defined a distance (using the parameter ε) between them. In particular,
[0069] E ε ={{u,v}|d(u,v)≤ε,u≠v∈V} (1)
[0070] Here, u and v are two points belonging to the vertex set V, and d(u,v) is the metric function for the two points u,v∈V. The weight function simply sets the weight of each edge to be equal to the distance between the two points on the edge. That is,
[0071]
[0072] Where ω is the mapping from each edge to a real number, i.e., the weight, E ε(V). Represents the set of vertices that meet the distance requirement of parameter ε. Next, the VR expansion is formed from the neighborhood graph generated in the first step. Given a neighborhood graph (G,ω), the VR complex (R(G),ω) (where R is the VR complex) weight filter is given as follows:
[0073]
[0074] For σ∈R(G),
[0075]
[0076] Generally, a sphere around a point in d-dimensional space is a generalization of the spheres around that point in (d-1)-dimensional space (a sphere refers to the set of all points in space equidistant from a given point). Therefore, a sphere in R is a line segment around a given point. 2 The sphere in the image is round, R 3 The spheres in the equation are spheres, and so on, forming a VR complex structure. As shown in the formula below, the complex structure is contained within the proportion ε, and the set V... ε (P) is any subset σ of P, that is, the distance between any distinct points in σ is no greater than the parameter ε.
[0077]
[0078] S2.4 Analyze the topology. By analyzing the topology of the constructed complex, topological information about the dataset can be obtained, such as connectivity and the presence of holes.
[0079] First, we calculate the homology group of the simplex. Before the calculation, we add an orientation to the simplex and define its edges as (d-1)-dimensional simplexes formed by removing a point from the d-dimensional simplex. Since the edges of a simplex are always closed, the edges of the edges are always 0. Consider the simplex V. ε In (P), the simplex is a linear combination of integer coefficients, λ₁σ₁ + λ₂σ₂ + ... + λ k σ k A group can be defined by addition.
[0080] ∑λ i (u i ,v i )+∑u i (u i ,v i )=∑(λ i +u i )(u i ,v i (6)
[0081] Its identity element is 0, forming an abelian group, also known as a chain group. Therefore, the d-dimensional homology group of the K simplex complex is defined as follows:
[0082] H d (K)=Z d (K) / B d (K) (7)
[0083] Among them, C d (K) denotes the d-chain group on the simple complex K, and its left edge homomorphism B. d (K), the homomorphic kernel of the identity element obtained after the submapping is the d-dimensional chain group C. d The d of the (K) subgroup is a closed linked group, denoted as Z. d (K). And C d All edges in (K), i.e., those after homomorphic mapping δ:C d+1 (K)→C d The homomorphic image obtained by (K) is a d-dimensional chain group C. d A subgroup of (K) is also a d-dimensional closed group chain Z. d The subgroup of (K) (because all its edges are closed) is called the d-dimensional edge closed chain group, or simply the d-dimensional edge group, denoted as B. d (K), where B n ≤Z n ≤C n Next, we calculate the connectivity number of the simplicial complex. If we consider the columns of the matrix as a set of basis vectors: β1, β2, ..., β k Then the dimension of the space spanned by these column vectors is the rank of the matrix, and the connectivity number can be defined as .
[0084] b n =rank(Z) n )-rank(B n (8)
[0085] This allows us to calculate the PersistentHomology topological features of different data.
[0086] The persistence graph (PD) generated by PH can be used as a feature representation of data, as shown in the attached figure. Figure 6 As shown. These features can capture the topological properties of the dataset and are scale-invariant to some extent. Figure 6 In this context, 'a' and 'b' represent the PD representation and PD variants of the CA dataset, while 'c' and 'd' represent the corresponding parts of the SE dataset. Figure 6It can be clearly seen that after PH's VR complex construction and filtering, the different topological components of the data are represented by birth time and death time, and their lifespan is calculated. Components with lifespan greater than the threshold are selected, and any components outside the selected components are eliminated, thereby constructing the final topological image.
[0087] S3: Introducing the innovative EMBConv module into the EfficientNet-B0 classification model by introducing the ECA attention mechanism;
[0088] EfficientNet was chosen as the classification model. It optimizes the network structure by combining scaling of network depth, width, and resolution, achieving a better balance between efficiency and accuracy with limited computational resources. Compared to the SE attention mechanism used in the traditional EfficientNet's MBConv structure, the ECA attention mechanism can better apply adaptive convolution kernels to each channel to calculate channel attention weights, enhancing the perception of different channel features rather than reducing channel features to scalar dimensions. The resulting EMBConv structure replaces the second stage of the original EfficientNet, better adapting to new datasets with topological features extracted via PH.
[0089] The ECA attention module first transforms the effective feature map X (where X∈RH*W*C) input to the network into X1 (where X1∈R1*1*C) through a global average pooling layer. To further transform the resulting feature map X1 into X3 (where X3∈RC*1) to meet the requirements of subsequent convolution operations, the weights of the one-dimensional convolution used are:
[0090]
[0091] in Indicates y i The set of k adjacent channels is used to achieve information exchange between channels through a one-dimensional convolution of size k:
[0092] w=δ(C1D K (y)) (10)
[0093] Where C1D represents one-dimensional convolution, the size of k is proportional to the channel dimension C, and there is a mapping ψ between k and C:
[0094]
[0095] If we use an exponential function with base 2 to represent the nonlinear mapping relationship:
[0096]
[0097] The final formula for the ECA module to adaptively calculate the convolution kernel size k is as follows:
[0098]
[0099] The output feature map is then processed through the sigmoid activation function. Finally, the standardized output is subjected to dimensional transformation to restore its shape, becoming X∈R1*1*C. Finally, the channel attention weights obtained in the previous step are multiplied by the original input feature map to obtain the final result.
[0100] S4: Perform secondary classification of images based on the self-created SCoT self-attention mechanism;
[0101] The previous steps replaced the spatial-dimensional SE attention mechanism with the ECA attention mechanism, which to some extent impairs the feature weights in the spatial dimension of the model. The components constituting the topological features of an image are interconnected, reflecting the multi-layered, stable, and persistent nature of the topological structure. Therefore, this paper innovates a novel self-attention mechanism, SCoT, which weights attention in both spatial and scene conditions. This allows the model to enhance its perceptual capabilities by utilizing the relationships between pixels within local regions, and to adjust the attention allocation based on different contextual information and conditions, thus enabling it to handle complex scenes and multi-object scenarios.
[0102] First, for the two-dimensional effective feature map S input to the network, with a size of H×W×C (H: height, W: width, C: number of channels), the feature map S is divided into n parts, denoted as [S0, S1, ..., S2]. n-1 The diagram shows that the number of channels in each segment is C1 = C / N. For each segmented feature map Si ∈ RC1*W*H, i = 0, 1, 2, ..., n-1, multi-scale convolutional kernels are used to group convolutions to extract spatial information from feature maps of different scales. The main purpose of group convolution is to reduce the number of parameters. The group size is adaptively selected based on the kernel size, and the relationship between the group and kernel size is: G = 2(K-1) / 2.
[0103] Next, we combine two different learning approaches—spatial channels and contextual information—to guide self-attention learning. For the spatial branch, we perform "polarization filtering" in the attention computation. The self-attention block operates on the input tensor X to highlight or suppress features, much like an optical lens filtering light. Polarization filtering, by allowing only light orthogonal to the lateral direction to pass through, can potentially improve the contrast of the image. We borrow a key element from photography: fully folding features in one direction while maintaining high resolution in their orthogonal directions. We increase the dynamic range of attention by using Softmax normalization on the bottleneck tensor (the smallest feature tensor in the attention block), followed by tone mapping using the Sigmoid function. This results in A sp (S)∈R 1×H×W :
[0104] A sp (S)=F SG [σ3(F SM (σ1(F GP (W q (S))))×σ2(W v (S)))] (14
[0105] Among them, W q and W v These are standard 1×1 convolutional layers, where σ1, σ2, and σ3 are three tensor shaping operators, and F... SM It is the SoftMax operator, F GP `x` is a global pool operator, and `×` is the matrix dot product operator. In this part, the output of the spatial branch is `Z`. SP =A SP (S)⊙ SP ,S∈R C×H×W , among which ⊙ SP It is a spatial multiplication operator.
[0106] For the context-integrated branch, while traditional self-attention effectively triggers feature interactions across different spatial locations, all paired query key relationships are learned independently on isolated query key pairs without exploring the rich intermediate context. This severely limits the ability of self-attention learning to perform visual representation learning on 2D feature maps. To alleviate this problem, we construct a unified architecture based on Transformer that integrates context information mining and self-attention learning. This fully utilizes the contextual information between adjacent keys to effectively promote self-attention learning and enhance the representativeness of the output aggregated feature map. For the two-dimensional feature modules with different channels formed by the previous segmentation, S∈R C×H×W Its keys, queries, and values are defined as K=S, Q=S, and V=SW, respectively. vIn spatial representation, k×k sets of convolutions are applied to all adjacent keys within a k×k grid to combine contextual information and represent each key. The learned context keys K 1 ∈R C×H×W Naturally reflecting the static contextual information between locally adjacent bonds, we will K 1 The static context representation is used as the input S. Then, the static context key K is used... 1 Conditioned by the concatenation of query Q, the attention matrix (W with ReLU activation function) is achieved through two consecutive 1×1 convolutions. θ And W without an activation function δ ):
[0107] A = [K] 1 ,Q]W θ W δ (15)
[0108] In other words, in this part, for each head of each attention mechanism, a local attention matrix for each spatial location of A can be learned based on query features and contextualized key features, rather than isolated query key pairs, thus enhancing self-attention learning. Next, based on the contextual attention matrix A, we compute the participating feature map K by aggregating all values V. 2 :
[0109]
[0110] K 2 It is a dynamic context representation of the input S, used to capture dynamic feature interactions between inputs.
[0111] Therefore, for the branch that incorporates contextual information, the output Z is... ct Represented as a static context K through the attention mechanism. 1 and dynamic context K 2 Fusion:
[0112]
[0113] The outputs of the two branches mentioned above are composed of the following in a parallel layout:
[0114]
[0115] By connecting the SCoT self-attention mechanism after the 8th stage, the data processed by the MBConv structure is fed into SCoT for further weight allocation, reorganizing computational resources, and then rationally classifying the data after passing through convolutional layers, thereby improving classification accuracy and computational efficiency. The overall algorithm is described in the appendix. Figure 7 As shown. Experiments were conducted on the dataset following the steps outlined above. (See attached image.) Figure 8As shown in the test, the accuracy of the CA and SE dual-model training in this study reached 98.4% for classifying CA colonies and 98.9% for classifying SE colonies.
[0116] In summary, this study proposes a method for binary classification of bacterial colonies based on Persistent Homology feature extraction technology and an improved EfficientNet. The method utilizes Physics to construct VR complexes and employs filters to extract effective topological features from the colony data, removing irrelevant variables. The processed dataset is then fed into the improved classification model SCoT-EfficientNet, which combines an EMBConv structure with an ECA attention module and an SCoT self-attention mechanism, for training and classification to obtain the final classification results. This method achieves an accuracy of 98.4% for CA colonies and 98.9% for SE colonies. Therefore, this method can provide efficient and reliable guidance for classifying CA and SE colonies in real-world scenarios within a short timeframe.
[0117] The embodiments described above are merely preferred embodiments of the present invention, and not all feasible embodiments of the present invention. Any obvious modifications made by those skilled in the art without departing from the principles and spirit of the present invention should be considered to be included within the scope of protection of the claims of the present invention.
Claims
1. A colony classification method based on Persistent Homology and an improved EfficientNet algorithm, characterized in that, The steps are as follows: S1: Collect the dataset and filter and crop the collected image data; S2: Use Persistent Homology to extract features from the image; S3: Introduce the ECA attention mechanism into the MBConv module of the EfficientNet-B0 classification model; S4: Secondary classification of images based on the SCoT self-attention mechanism; Step S3 specifically involves: S3.1 Input data to the improved EMBConv structure: Image data that has undergone PH topological feature extraction and data augmentation, and has been processed by a regular 3x3 convolution kernel, is input into the EMBConv structure module; S3.2 Import a 1×1 convolution kernel; S3.3 Import 3×3 Depthwise Conv Convolution: Each input channel is processed using an independent 3×3 convolution kernel, keeping the number of channels constant. Then, batch normalization is applied to standardize the data of each channel, giving it a distribution with a mean of 0 and a standard deviation of 1. Then, non-linearity is introduced through the Swish activation function. S3.4 Entering the ECA module: The ECA attention mechanism identifies key features and important information in the data, giving higher weight to these features and ignoring relatively unimportant information. S3.5 imports a 1x1 ordinary convolution, including a BN module; S3.6 enters the Dropout layer; S3.7 imports the output data into the remaining six layers of the MBConv module of the neural network, and feeds the output into the SCoT self-attention mechanism; Step S4 specifically involves: S4.1 Input Data: Import the pre-processed data into the SCoT self-attention mechanism; S4.2 Feature Partitioning: Divide the feature map S into n parts, using [S0, S1, ..., S2] as the basis for the partitioning. n-1 This indicates that the number of channels in each segment is C1 = C / N. At the same time, for each channel feature map, multi-scale convolution kernels are used to group convolution to extract spatial information of feature maps at different scales, and the group size is adaptively selected according to the size of the convolution kernel. S4.3 Spatial Branch Processing: In the spatial branch learning part, the self-attention block operates on the input tensor X to highlight or suppress features; the dynamic range of attention is increased by Softmax normalization on the bottleneck tensor, and then tone mapping is performed using the Sigmoid function; S4.4 Contextual Information Branch Processing: For the contextual information branch learning part, for the two-dimensional feature modules of different channels formed by the previous step segmentation, k×k sets of convolutions are used on all adjacent keys in the k×k grid in space to represent each key in combination with the context content; S4.5 combines two learning methods: using static context key K 1 Conditioned by the concatenation of query Q, the attention matrix is achieved through two consecutive 1×1 convolutions, containing elements with the ReLU activation function. And without activation function ; S4.6 outputs the processed data to a 1×1 convolutional layer and pooling layer for further processing, and uses a linear classifier Softmax to classify the features and output the recognition results.
2. The colony classification method based on Persistent Homology and the improved EfficientNet algorithm according to claim 1, characterized in that, Step S1 specifically involves: S1.1 Dataset Collection: Self-collected datasets of Candida albicans and Staphylococcus epidermidis were used; S1.2 Screening: For the collected colony data, screen out the colony parts that are stuck together, incompletely grown, or not fully photographed, and retain the complete and single colony data; S1.3 Cropping: For the colony images retained after screening, crop them to an appropriate size for individual colonies. For the dataset that has been screened and cropped, expand the dataset using data augmentation methods.
3. The colony classification method based on Persistent Homology and the improved EfficientNet algorithm according to claim 1, characterized in that, Step S2 specifically involves: S2.1 Constructing a point cloud: Generate a set P containing data points from the provided image. These points are called a point cloud. The points are points in Euclidean space or other metric spaces. S2.2 Determine the parameter: Select a parameter , which indicates the size or radius of the constructed shape; S2.3 Constructing Complexes: Using radius The dashed sphere goes around every point in P and connects that point to all other points within the circle. S2.4 Analyze the topology: Obtain topological information about the dataset by analyzing the topology of the constructed complex.