A fast aggregation classification method based on feature similarity calculation
By integrating the attention mechanism of gradient features and frequency domain features in the transfer learning mode, and combining infinite norms and density-based clustering algorithms, a fast aggregation classification method is realized, solving the problem of difficulty in responding to demand changes and stability in traditional methods, and improving the system's adaptability and computing efficiency.
Patent Information
- Application Number
- CN202411943666.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-27
AI Technical Summary
Traditional artificial feature extraction and training modes are difficult to respond quickly to demand changes, and it is difficult to ensure high stability of predicted results in industrial visual environments, especially in application scenarios where NG products are not allowed to be misjudged as OK products.
A fast aggregation classification method based on feature similarity calculation is proposed. By integrating the attention mechanism of gradient features and frequency domain features in the transfer learning mode, retraining the skeleton network, obtaining high-dimensional features, and using infinite norms for distance comparison, combining density-based clustering algorithm to eliminate noise points, achieving rapid classification.
This method can add new training data without forgetting existing knowledge, flexibly increase or decrease the number of categories, improve the adaptability and flexibility of the system, reduce the computational complexity, and improve the stability and generalization ability of the model.
Smart Images

Figure CN119380113B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a fast aggregation classification method based on feature similarity calculation. Background Art
[0002] As an important branch of machine vision, fast classification is mainly used to distinguish whether an image belongs to a specific category in an industrial vision environment. Unlike other machine vision tasks, classification tasks focus more on qualitative analysis, that is, determining whether an image belongs to a predefined discrete category number or giving a close value of a category.
[0003] In traditional classification methods, feature extraction schemes are manually designed, and attributes such as color histograms, texture features (such as gray-level co-occurrence matrices), shape features (such as geometric descriptions after edge detection), and high-dimensional geometric features are selected as attributes to characterize image categories according to specific needs. These attributes are used as variables in expressions to calculate the similarity between categories. Traditional methods include machine learning algorithms such as support vector machines (SVMs), random forests, k-means clustering, and early neural network perceptrons.
[0004] With the development of deep learning technology, convolutional neural networks (CNN) have been introduced into the field of machine vision. CNN architectures (such as LeNet, AlexNet, VGGNet, ResNet, etc.) can be trained using large-scale datasets to achieve forward classification of input images. Deep learning models can automatically adjust parameters to obtain feature information, thereby achieving end-to-end learning without human intervention, which makes them very popular in classification applications. In addition, pre-trained models can be used as backbone networks, and network layers or functional blocks can be customized for specific projects on this basis to increase training speed and obtain more stable results.
[0005] However, traditional manual feature extraction and training models are difficult to respond quickly to changes in demand. Due to the complexity and interference factors of the industrial vision operating environment, these methods often cannot guarantee high stability of prediction results, especially for application scenarios where NG products cannot be misjudged as OK products. In addition, when the environment changes, technicians need to frequently adjust parameters to meet the detection rate requirements, which increases maintenance costs.
[0006] Secondly, the manually designed features have strong correlations in position, rotation angle and scaling, which requires good pre-positioning functions to assist feature extraction. The change amplitudes of different features also vary significantly, and it is a challenge to unify them to a consistent change rate, which puts higher requirements on project development, resulting in longer pre-commissioning time and the need for a large number of maintenance personnel to participate during project implementation to ensure the stable operation of the equipment. Summary of the invention
[0007] In order to solve the deficiencies in the prior art, the present invention proposes a fast aggregation classification method based on feature similarity calculation, comprising the steps of:
[0008] S1: Obtain the training data set of the target application scenario based on various public data sets and actual application images of the project, and extract the gradient features and frequency domain features of each training image;
[0009] S2: In the transfer learning mode, the skeleton network is retrained to obtain the model and the high-dimensional features are obtained by integrating the attention mechanism after the dimension unification of each training image and the corresponding gradient features and frequency domain features;
[0010] S3: Based on the high-dimensional feature information of the scene obtained from each training image, the benchmark core features are selected under distance comparison based on the infinite norm;
[0011] S4: Based on the benchmark core features, a density-based clustering algorithm is used to obtain the feature matrix of the data set that needs to be trained after removing noise points;
[0012] S5: Extract the gradient features and frequency domain features of the target input image, and integrate them with the attention mechanism after dimension unification of the target input image to obtain the target high-dimensional feature information;
[0013] S6: Classify the target input image based on the distance between the target high-dimensional feature information and the benchmark core features in the feature matrix.
[0014] Furthermore, in the step S1, the gradient feature is obtained by converting the image into a grayscale image and then calculating the gradient amplitude, and the formula is expressed as follows:
[0015]
[0016] In the formula, Point to the grayscale image The gradient amplitude at The midpoint of the grayscale image Department The gradient component in the direction, The midpoint of the grayscale image Department The gradient component in the direction.
[0017] Furthermore, in the step S1, the original spatial domain image is transformed into the frequency domain range by using the fast Fourier transform, and the real part information after the frequency domain transformation is taken as the frequency domain feature. The frequency domain transformation formula is expressed as follows:
[0018]
[0019] In the formula, is the fast Fourier transform function, is the coordinate point in the frequency domain, is the image in the spatial domain at coordinates The gray level at are the width and height of the image in the spatial domain, is a natural number, Is an imaginary number.
[0020] Furthermore, in the step S2, the ResNet50 network architecture is used as the basis of the skeleton network, and intermediate data processing and downsampling operations are adopted to remove the output layer of the original framework and replace it with a high-dimensional feature information output of the same dimension under the global average pooling strategy.
[0021] Furthermore, the feature output of the same dimension under global average pooling is expressed as follows:
[0022]
[0023] In the formula, For the The global average pooling output value of feature maps, For the Feature map area Located in The elements at For the The number of all elements in the feature map.
[0024] Furthermore, in the step S2, the integration under the attention mechanism is realized through the SimAM network architecture, and the formula is expressed as follows:
[0025]
[0026] In the formula, is the enhanced image obtained after integration, is the energy function of the amplitude input, is the energy function of the frequency domain input, is the image in the spatial domain, It is the convolution operation.
[0027] Furthermore, in the step S3, the distance acquisition under the infinite norm is expressed as the following formula:
[0028]
[0029] In the formula, is high-dimensional feature information, High-dimensional feature information exist The value on the dimension, High-dimensional feature information exist The value on the dimension, High-dimensional feature information and high-dimensional feature information The infinite norm distance between To find the maximum value function.
[0030] Furthermore, in the step S3, the selection of the benchmark core features is specifically as follows:
[0031] When the number of training data samples in a class is less than the preset number, the distance between each sample and other samples in the class is calculated, and the sample with the largest distance and / or the smallest sum of distances is selected as the benchmark core feature;
[0032] When the number of training data samples within a class is greater than or equal to the preset number, the distance between each sample and other samples within the class is calculated, and the one with the smallest distance sum is selected as the benchmark core feature.
[0033] Furthermore, in the step S4, the characteristic matrix is obtained by using the density-based clustering algorithm to remove noise points as follows:
[0034] Taking any benchmark core feature as the center of the circle, obtain the number of other benchmark core features within the neighborhood range within the preset distance radius of the center of the circle;
[0035] If the number is greater than or equal to the preset minimum number of points, the benchmark core feature is the core point;
[0036] If the number is less than the preset minimum number of points, but is within the neighborhood of other core points, then the benchmark core feature is a boundary point;
[0037] If it is neither a core point nor a boundary point, the benchmark core feature is a noise point.
[0038] Furthermore, in the step S6, the distance between the target high-dimensional feature information and each benchmark core feature in the feature matrix is obtained by the following formula:
[0039]
[0040] In the formula, It is the distance between the target high-dimensional feature information and each benchmark core feature in the feature matrix.
[0041] Compared with the prior art, the present invention has at least the following beneficial effects:
[0042] (1) The fast aggregation classification method based on feature similarity calculation described in the present invention can perform incremental training on trained categories, that is, add new training data without forgetting existing knowledge, and can also flexibly increase or decrease the number of categories, greatly improving the adaptability and flexibility of the system;
[0043] (2) By introducing advanced processing methods such as gradient feature extraction, frequency domain feature extraction, and attention mechanism, combined with convolutional neural network (CNN) and global average pooling strategy, the present invention can achieve fast classification in a low-configuration environment;
[0044] (3) The density-based clustering algorithm (DBSCAN) is used to process noisy data sets, effectively removing noise points and ensuring the quality of training data, thereby improving the stability and generalization ability of the model;
[0045] (4) Allowing the model to be updated instantly to include new samples or to create new categories when images that do not belong to any existing categories are detected, ensuring that the system can quickly adapt to changes in demand without having to retrain the entire network;
[0046] (5) The global average pooling operation significantly reduces the number of channels, compresses the data size, and integrates the feature distribution information within the channel, so that the network can perform subsequent processing tasks in a more compact and semantically rich feature representation form, reducing the computational complexity and improving the model's understanding and application efficiency of features;
[0047] (6) Using the distance between feature vectors as the similarity metric instead of the traditional softmax activation function, this allows us to give a result that is significantly different from the normal similarity when faced with untrained images, thereby more reliably determining whether the image belongs to any existing category;
[0048] (7) Due to the adoption of the transfer learning method and the use of the pre-trained ResNet50 network architecture as the backbone network, only the newly modified parts of the specific application scenario need to be iteratively updated, which greatly simplifies the deployment process and reduces the dependence on high-performance hardware. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A step diagram of a fast aggregation classification method based on feature similarity calculation. DETAILED DESCRIPTION
[0050] The following are specific embodiments of the present invention and the accompanying drawings to further describe the technical solution of the present invention, but the present invention is not limited to these embodiments.
[0051] This embodiment aims to demonstrate the specific application of a fast aggregation classification method based on feature similarity calculation, as well as the innovations and effects of the device in actual industrial scenarios. Through detailed case analysis, we will explain the specific control method during the operation of the system and give the results of the trial operation (or the theoretically feasible method) to prove the advantages of the present invention. Figure 1 As shown, the present invention proposes a fast aggregation classification method based on feature similarity calculation, which specifically includes the following steps:
[0052] S1: Obtain the training data set of the target application scenario based on various public data sets and actual application images of the project, and extract the gradient features and frequency domain features of each training image;
[0053] S2: In the transfer learning mode, the skeleton network is retrained to obtain the model and the high-dimensional features are obtained by integrating the attention mechanism after the dimension unification of each training image and the corresponding gradient features and frequency domain features;
[0054] S3: Based on the high-dimensional feature information of the scene obtained from each training image, the benchmark core features are selected under distance comparison based on the infinite norm;
[0055] S4: Based on the benchmark core features, a density-based clustering algorithm is used to obtain the feature matrix of the data set that needs to be trained after removing noise points;
[0056] S5: Extract the gradient features and frequency domain features of the target input image, and integrate them with the target input image after dimension unification using the attention mechanism to obtain the target high-dimensional feature information;
[0057] S6: Classify the target input image based on the distance between the target high-dimensional feature information and the benchmark core features in the feature matrix.
[0058] It is not difficult to see from the above overall steps that the present invention aims to analyze the input image as a whole and determine which predefined category the image is most likely to belong to. If the image does not meet the characteristics of any known category, the system will return the result of "all categories are not met". This process is not limited to simple binary judgments (i.e., belonging to or not belonging to a certain category), but also provides a matching score for each possible category, which allows users to understand the degree of similarity between the image and different categories.
[0059] In terms of technical implementation, the present invention is based on a convolutional neural network (CNN) as the core algorithm. CNN is a deep learning model that is particularly suitable for processing image data. It can automatically learn useful feature representations from a large amount of unlabeled or labeled data. Through the operation of multiple layers of convolutional layers, pooling layers, and fully connected layers, CNN can effectively extract high-dimensional feature information from images. These features may be complex patterns and structures that are difficult for humans to directly recognize.
[0060] In order to evaluate the degree of consistency between the image and each predefined category, the present invention further introduces a method of feature distance measurement. Specifically, during the training phase, the system constructs one or more representative feature vectors for each category. When a new image is input, CNN generates a feature vector for the image, and then calculates the distance between this feature vector and the feature vectors of each predefined category. Commonly used distance measurement methods include Euclidean distance, cosine similarity, etc. Smaller distance values mean higher similarity, while larger distances indicate larger differences.
[0061] Before using the convolutional neural network, the present invention also includes two aspects of processing the image data, namely, gradient feature extraction and frequency domain feature extraction.
[0062] Among them, gradient features play an important role in the field of computer vision and image processing, especially in edge detection, texture analysis, shape recognition, and target detection. Gradient features mainly describe the direction and rate of change of pixel intensity in an image, and can capture the boundary information of objects and other significant spatial structures.
[0063] Since the gradient direction is calculated relative to the local structure, gradient features usually have a certain degree of rotation invariance, which makes them perform well when dealing with the same object at different angles. Combined with multi-scale analysis techniques (such as Gaussian pyramids), gradient features can provide consistent descriptions at different scales, which helps improve the robustness and accuracy of feature matching. Therefore, in feature matching and image alignment, gradient features can help find similar areas between two images, which is very important for applications such as stitching panoramas and 3D reconstruction.
[0064] Mathematically, the gradient is a vector operator, usually applied to scalar fields (such as grayscale images or single-channel images with one value per pixel), which points to the direction in which the function grows fastest, and its magnitude indicates the speed of growth. In the present invention, the gradient feature corresponds to the grayscale change at the location where the grayscale information of the image changes dramatically.
[0065] In order to calculate the gradient in an image, a common method is to use a differential filter, such as the Sobel operator, the Prewitt operator, or the Scharr operator. These operators approximate partial derivatives through convolution operations. Taking the Sobel operator as an example, it can be used in and Apply the following two 3×3 convolution kernels in the direction:
[0066] Sobel X direction:
[0067]
[0068] Sobel Y direction:
[0069]
[0070] By convolving the two convolution kernels with the image respectively, we can get the image and Gradient component in direction and Then, the gradient magnitude and direction of each pixel position can be calculated. So, assuming the image dataset is , ( is a constant), where It is The coordinates of the pixels, It is The gray value of each pixel. , its gradient amplitude after grayscale image conversion is:
[0071]
[0072] In the formula, Point to the grayscale image The gradient amplitude at The midpoint of the grayscale image Department The gradient component in the direction, The midpoint of the grayscale image Department The gradient component in the direction.
[0073] Frequency domain features are an important type of features in the field of image processing and computer vision. They analyze the structure and texture information of images by converting them from the spatial domain to the frequency domain. Unlike spatial domain methods that operate directly at the pixel level, frequency domain methods can capture global patterns, periodic components, and changes at different scales in images, which gives them unique advantages in certain application scenarios.
[0074] The basis of frequency domain features lies in frequency domain transformation, the most commonly used of which is Fourier Transform. Fourier Transform can decompose a function (such as the gray value distribution of an image) into a superposition of a series of sine waves, each of which has a specific frequency, amplitude, and phase. For two-dimensional images, Discrete Fourier Transform (DFT) or Fast Fourier Transform (FFT) are also widely used.
[0075] Frequency domain features have the advantages of rotation, translation and scale invariance, strong noise resistance, efficient calculation, rich mathematical tools, adaptability to complex backgrounds and lighting changes, and easy fusion with other features in feature matching. These characteristics make frequency domain features widely used in the fields of computer vision and image processing, especially in matching tasks that require high precision and high efficiency, such as image registration, target recognition, three-dimensional reconstruction, etc. It is precisely because frequency domain features have the above-mentioned significant advantages in feature matching that these advantages make them more effective than spatial domain features in certain application scenarios. Based on this, the present invention uses fast Fourier transform to perform frequency domain transformation, so that subtle changes in the image can be highlighted in the frequency domain, while areas where frequency domain changes are not obvious are greatly suppressed. The formula is expressed as follows:
[0076]
[0077] In the formula, is the fast Fourier transform function, is the coordinate point in the frequency domain, is the image in the spatial domain at coordinates The gray level at are the width and height of the image in the spatial domain, is a natural number, Is an imaginary number.
[0078] In frequency domain processing, since processing the real and imaginary parts of a complex number at the same time will increase the computational complexity, the present invention only needs to focus on the amplitude change information of the frequency domain part. Therefore, here we only need to extract the real part of the frequency domain feature as the feature information we need.
[0079] Based on these feature information obtained from the training data set (derived from the accumulated industrial application data set, Kylberg texture detection data set, COCO data set and other public data sets), the model to be trained can be trained. In terms of feature type selection, the present invention selects a deep learning scheme to select the feature type, and uses its gradient descent big data automatic learning function to obtain high-dimensional features. In this embodiment, the ResNet50 network architecture is selected as the skeleton network, and the gradient disappearance problem is solved by the residual block introduced by it, so that the network can be deeper, thereby extracting richer feature information for transfer learning operations.
[0080] Among them, transfer learning is an important technology in the field of machine learning and deep learning. It improves the performance and training efficiency of the model by applying the knowledge learned from one task to another related task. The core idea of transfer learning is to use existing knowledge to accelerate the learning process of new tasks, especially when the target task has limited data or computing resources.
[0081] The original ResNet50 network consists of multiple convolutional layers (Conv) and pooling layers (POOL), which are responsible for extracting feature information at different levels. By gradually reducing the spatial resolution (i.e., downsampling), the network can capture local to global features from the input image. At the same time, the original ResNet50 network contains a fully connected layer for classification tasks, and the output dimension of this layer corresponds to the number of categories in the image dataset. In order to adapt to the new task, we removed this fully connected layer and retained the previous convolutional layer and pooling layer.
[0082] At the same time, after the last convolutional layer, we apply the global average pooling strategy (GAP). The role of GAP is to calculate the average value of each channel in the entire spatial dimension, and condense the two-dimensional feature map of each channel into a single mean statistic. This not only reduces the dimension of the feature vector, but also retains the main information of each channel, which helps to improve the robustness and generalization ability of the model. The formula for the global average pooling operation is as follows:
[0083]
[0084] In the formula, For the The global average pooling output value of feature maps, For the Feature map area Located in The elements at For the The number of all elements in the feature map.
[0085] By applying the above optimization strategy to the skeleton network, high-dimensional feature information is extracted from the input image. These features not only contain rich spatial and semantic information, but also have good generalization and noise resistance. Specifically, the final feature vector is obtained by applying global average pooling to the output of the last convolutional layer, and its dimension is equal to the number of channels of the last convolutional layer. This strategy not only significantly reduces the number of channels and compresses the data size, but also integrates the feature distribution information within the channel to a certain extent, so that the network can perform subsequent final feature decisions or other processing tasks in a more compact and semantically rich feature representation form, thereby reducing the computational complexity while improving the model's comprehensive understanding and application efficiency of features.
[0086] After the original image, gradient image and frequency domain image are processed by convolutional neural network, in order to meet the real-time requirements, the present invention uniformly preprocesses these three types of original data to ensure that they have outputs of the same dimension when input into the subsequent network. Specifically, the present invention first uses the starting convolution layer and normalization layer in the skeleton network to perform preliminary processing on these three types of data. This process not only extracts low-level spatial features, but also stabilizes the training process through normalization operations, reducing the risk of gradient disappearance or explosion. After these processes, all types of input data are converted into feature maps with the same dimension, laying the foundation for subsequent enhancement processing.
[0087] Furthermore, in convolutional neural networks (CNNs), attention mechanisms dynamically adjust the importance of different feature regions, allowing the model to better focus on key information, thereby improving performance. However, traditional attention mechanisms usually require the introduction of additional parameters and complex calculations, which increases the complexity and computational cost of the model, especially in mobile devices or embedded systems, where this overhead may be unbearable.
[0088] To this end, the present invention introduces the SimAM (Simple and Effective Attention Mechanism) network architecture principle to further improve the quality of feature representation. Among them, SimAM is a lightweight, parameter-free convolutional neural network attention mechanism, which generates attention weights by calculating the local self-similarity of feature images. Unlike traditional attention mechanisms, SimAM does not require additional parameters or complex calculations, so it can significantly reduce computational overhead while maintaining high performance, which is very suitable for real-time applications.
[0089] In the specific implementation, SimAM calculates the self-similarity of each feature map by comparing the local areas of each feature map pairwise. For each pixel position, SimAM considers the pixel values in its surrounding neighborhood and generates an attention weight based on the similarity of these values. This weight reflects the importance of the position, and a high weight means that the features at this position are more significant and should receive more attention in subsequent processing. In this way, SimAM can effectively capture important information in the feature map while suppressing irrelevant or noise components.
[0090] In order to fully utilize the advantages of SimAM, the present invention applies this mechanism in the spatial domain and frequency domain respectively. In the spatial domain, SimAM directly acts on the output feature map of the convolution layer to enhance the spatial structural information of the image. In the frequency domain, the present invention first performs a fast Fourier transform on the feature map, converts the spatial domain features into a frequency domain representation, and then applies SimAM in the frequency domain. In this way, SimAM can not only enhance low-frequency components (such as the overall structure of the image), but also strengthen high-frequency components (such as edges and details), thereby comprehensively improving the richness and accuracy of feature representation.
[0091] Finally, the feature map enhanced by SimAM is fed into the subsequent network layer for further processing. Due to the lightweight design of SimAM, the entire processing process does not significantly increase the computational burden, ensuring the real-time performance of the system. In addition, the parameter-free nature of SimAM makes the model easier to deploy and maintain, especially suitable for resource-constrained environments such as mobile devices or embedded systems.
[0092] Then, based on the network architecture principle of SimAM, the gradient input and frequency domain input are processed to comprehensively enhance the original image:
[0093]
[0094] In the formula, is the enhanced image obtained after integration, is the energy function of the amplitude input, is the energy function of the frequency domain input, is the image in the spatial domain, It is the convolution operation.
[0095] Among them, the energy function is a mathematical tool widely used in many fields such as physics, chemistry, computer science and engineering to describe the state or configuration of a system. It is usually expressed as a scalar value that reflects the amount of "energy" a system has in a specific state. In different contexts, the energy function may have different names and specific forms, such as Hamiltonian in physics, free energy in statistical mechanics, and cost function, loss function or objective function in machine learning and optimization problems.
[0096] Energy function is a mapping from state space to the set of real numbers, that is ,in represents the state space of the system, Represents a specific state of the system. The value of the energy function Reflects the system status In many cases, the natural tendency of a system is to evolve toward the state with the lowest energy. Therefore, we look for the state that minimizes the energy function. At the core of many problems is solving the following optimization problem:
[0097]
[0098] In the present invention, the formula of the energy function is defined as follows:
[0099]
[0100] In the formula, For the The energy function under each channel is: For the The weight value under each channel, For the The offset value of each channel, For the The output of each channel, For the Channel input, is the number of the neuron channel, For the The total number of energy functions in the channel, is the hyperparameter regularization term.
[0101] The analytical solution for the weights and biases in the above formula is as follows:
[0102]
[0103] In the formula, For input The mean of For input The variance of .
[0104] in,
[0105]
[0106] Substituting into the energy function formula, the minimum energy can be converted into the following formula:
[0107]
[0108] So far, the present invention has successfully constructed an efficient deep learning model based on the skeleton network ResNet50. This model not only inherits the powerful feature extraction capability of the pre-trained network, but also adapts to new target tasks through customized network layers and transfer learning technology. Specifically, the present invention unifies the processing method of multimodal data by modifying the input and output; reduces the training time and computing resource consumption by freezing some layers and loading pre-trained weights; and gradually improves the performance of the model by iteratively updating using training data. This design enables the present invention to achieve a good balance between real-time and accuracy.
[0109] After completing the high-dimensional feature extraction of the image, the present invention further cleans the data within each category and selects the benchmark core features. This process aims to ensure that the features in each category are representative and stable, while avoiding the problems caused by the "curse of high dimensionality". The Curse of Dimensionality is a common phenomenon in machine learning, data mining, and statistics. It refers to the fact that as the data dimension increases, the distance characteristics between data points change significantly, resulting in a sharp drop in the performance of many algorithms. The Curse of Dimensionality not only affects the efficiency of traditional algorithms, but also poses a challenge to modern deep learning models.
[0110] Therefore, although in the previous stage the present invention successfully extracted high-dimensional features of each image by using a skeleton network as the basic network structure, combined with transfer learning and global average pooling. These high-dimensional features not only contain rich spatial and semantic information, but also have good generalization ability and noise resistance. However, due to the characteristics of high-dimensional data, directly using these features may lead to "high-dimensional disaster", that is, the distances between points tend to be equal, which reduces the distinction between features. Therefore, the present invention takes special measures to deal with this problem in subsequent processing.
[0111] First, after obtaining high-dimensional features, the present invention first performs data cleaning on the data within each category. The purpose of data cleaning is to remove outliers, noise points and other bad samples that may affect the performance of the model. Specifically, the present invention performs data cleaning in the following manner.
[0112] When the number of training samples in a class is less than 5:
[0113] For the case where there are fewer training samples within a class (i.e., the sample size is less than 5), the present invention adopts a more detailed feature selection strategy to ensure that the most representative benchmark core features can be found even in the case of small samples. The specific steps are as follows:
[0114] (1) For each sample in a class, calculate the distance between it and the samples in other classes. The distance metric used here is Norm (i.e., infinite norm), rather than the traditional Euclidean distance or Manhattan distance, is expressed as follows:
[0115] In the formula, is high-dimensional feature information, High-dimensional feature information exist The value on the dimension, High-dimensional feature information exist The value on the dimension, High-dimensional feature information and high-dimensional feature information The infinite norm distance between To find the maximum value function;
[0116] (2) According to the calculated distance, the present invention selects two different benchmark samples:
[0117] Maximum distance method: select the sample with the largest distance from other samples in the class as the benchmark core feature. This sample is usually located at the edge of the class and can better represent the boundary feature of the class;
[0118] Minimum distance sum method: Calculate the distance sum between two samples in the class, and select the sample with the smallest distance sum as the benchmark core feature. This sample is usually located in the center of the class and can better represent the typical features of the class.
[0119] Through these two methods, the present invention can find the most representative benchmark core features in small sample conditions, ensuring that the model can accurately capture the main features within the class.
[0120] When the number of in-class training samples is greater than or equal to 5:
[0121] For the case where there are a large number of training samples within a class (i.e., the sample size is greater than or equal to 5), the present invention adopts a more robust feature selection strategy to ensure that the benchmark core features can represent the overall distribution within the class. The specific steps are as follows:
[0122] (1) For all samples in a class, calculate the pairwise distance between them. Again, the distance metric used here is norm to avoid the problem of distances between points tending to be equal in high-dimensional space;
[0123] (2) Based on the calculated distance, select the sample with the smallest distance sum as the benchmark core feature. Specifically, the present invention calculates the distance sum between each sample and all other samples, and selects the sample with the smallest distance sum as the benchmark core feature. This sample is usually located in the center of the class and can better represent the typical features of the class.
[0124] In this way, the present invention can find the most representative benchmark core features in a large sample situation, ensuring that the model can accurately capture the overall distribution within the class while avoiding overfitting problems.
[0125] The present invention ensures that the samples in each category can be reasonably represented by processing high-dimensional features and selecting benchmark core features. According to the number of training samples in different categories, the present invention designs two different benchmark core feature selection schemes: for small samples, the maximum distance method and the minimum distance sum method are used; for large samples, the sample with the minimum distance sum is selected as the benchmark core feature. In addition, the present invention specifically adopts The norm is used as a distance metric to prevent problems caused by the high-dimensional disaster and ensure the accuracy and stability of feature selection.
[0126] After obtaining the benchmark features within the class, the present invention further uses a density-based spatial clustering algorithm (Density-Based Spatial Clustering of Applications with Noise, DBSCAN) to process the noisy data set and effectively select the noisy data. DBSCAN achieves clustering by defining "core points", "boundary points" and "noise points". Specifically, the key points used by DBSCAN are defined as follows:
[0127] 1. (Epsilon, distance radius): Given a point p, Draw a circle with radius p, and the points inside the circle are called neighbors of point p;
[0128] 2. Minimum number of points (minPts): If p points If the number of points in the neighborhood is greater than or equal to minPts, point p is defined as the core point.
[0129] 3. Core Point: point p The density in the neighborhood meets certain conditions and is greater than or equal to minPts;
[0130] 4. Bounder Point: Point p is at the core point q Neighborhood, but its own The number of points in the neighborhood is less than minPts;
[0131] 5. Noise Point: It is neither a core point nor a boundary point.
[0132] Then, after obtaining the intra-class benchmark features After that, you can set and minPts are expanded within the class to obtain sample data that meets the requirements.
[0133] The training phase can be concluded by removing all noise point samples and reorganizing the feature matrix.
[0134] The present invention obtains a feature matrix during the training phase, and each sample corresponds to a feature vector. Therefore, when encountering an untrained image, a new feature vector can be obtained through the above-mentioned feature extraction step and added to the original feature matrix to obtain a new feature matrix. There is no need to retrain the entire network, and the real-time requirements of data training can be met.
[0135] When performing detection and classification tasks, the present invention adopts a unique processing flow, which aims to improve the model's ability to recognize unknown categories and ensure stable and discriminative results when faced with untrained images. Specifically, the present invention not only performs gradient processing and frequency domain transformation on the input image, but also obtains high-dimensional features through the feature extraction network, and uses the distance between feature vectors to represent similarity, rather than relying on activation functions such as softmax commonly used in deep learning. Feature distance is calculated using the dot product between features, and the formula is as follows:
[0136]
[0137] In the formula, It is the distance between the target high-dimensional feature information and each benchmark core feature in the feature matrix.
[0138] When faced with untrained images, activation functions such as softmax often give random results and cannot provide stable classification outputs. This is because under the action of the softmax function, even if the input image is not similar to all known categories, the model will still output a seemingly reasonable probability distribution, resulting in misclassification. However, the present invention uses the distance between feature vectors to represent similarity, which can give clear deviation results when faced with untrained images and avoid misclassification.
[0139] Furthermore, although the probability distribution output by the softmax function is intuitive and easy to understand, it is difficult to explain the physical meaning behind it. In contrast, the distance between feature vectors can directly reflect the similarity between images and has stronger interpretability. Users can intuitively understand the similarity between the current image and each category based on the size of the distance, and thus make more reasonable judgments.
[0140] By adopting gradient processing, frequency domain transformation and feature extraction network, the present invention successfully extracts rich high-dimensional features from the input image. In order to calculate the category to which the current image belongs and the approximate score to which it belongs, the present invention uses the distance between feature vectors to represent the similarity, rather than relying on traditional activation functions such as softmax. This design enables the present invention to give results that are significantly deviated from normal similarity when faced with untrained images, thereby effectively identifying unknown categories. In addition, the similarity calculation method of the present invention has higher stability and interpretability.
[0141] Finally, the predicted result is the similarity metric score of the category. The predicted results can be classified into three processing options:
[0142] 1. Correctly output the results of the image to be detected and the corresponding category similarity;
[0143] 2. If the output category is not the category of the image to be detected, it can be added to the training feature array by incremental training. The features of the current image can be quickly added without forgetting the original training data, and the wrong judgment can be classified into the correct category;
[0144] 3. When it is found during the test that the obtained similarity score has no obvious correlation with all the training categories, it can be considered that the tested image does not belong to any of the trained categories or there is a new image in the existing category. In this case, a new category can be added for training or it can be retrained in the existing category.
[0145] In summary, the fast aggregation classification method based on feature similarity calculation proposed in the present invention can perform incremental training on trained categories, that is, add new training data without forgetting existing knowledge, and can also flexibly increase or decrease the number of categories, greatly improving the adaptability and flexibility of the system.
[0146] By introducing advanced processing methods such as gradient feature extraction, frequency domain feature extraction and attention mechanism, combined with convolutional neural network (CNN) and global average pooling strategy, the present invention can achieve fast classification in a low-configuration environment.
[0147] The density-based clustering algorithm (DBSCAN) is used to process noisy data sets, effectively removing noise points and ensuring the quality of training data, thereby improving the stability and generalization ability of the model;
[0148] This allows the model to be updated on the fly to include new samples, or to create new categories, when images are detected that do not belong to any existing categories, ensuring that the system can quickly adapt to changes in demand without having to retrain the entire network.
[0149] The global average pooling operation significantly reduces the number of channels, compresses the data size, and integrates the feature distribution information within the channel, allowing the network to perform subsequent processing tasks in a more compact and semantically rich feature representation form, reducing computational complexity and improving the model's understanding and application efficiency of features.
[0150] Using the distance between feature vectors as the similarity measure instead of the traditional softmax activation function allows a result that is significantly deviated from the normal similarity to be given when faced with untrained images, thereby more reliably determining whether the image belongs to any existing category.
[0151] At the same time, due to the adoption of the transfer learning method and the use of the pre-trained ResNet50 network architecture as the backbone network, only the newly modified parts of the specific application scenario need to be iteratively updated with data, which greatly simplifies the deployment process and reduces dependence on high-performance hardware.
[0152] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0153] In addition, in the present invention, descriptions such as "first", "second", "one", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0154] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0155] In addition, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
Claims
1. A fast aggregation classification method based on feature similarity calculation, characterized in that: Includes steps: S1: Obtain the training data set of the target application scenario based on various public data sets and actual application images of the project, and extract the gradient features and frequency domain features of each training image; S2: In the transfer learning mode, the skeleton network is retrained to obtain the model and the high-dimensional features are obtained by integrating the attention mechanism after the dimension unification of each training image and the corresponding gradient features and frequency domain features; S3: Based on the high-dimensional feature information of the scene obtained from each training image, the benchmark core features are selected under distance comparison based on the infinite norm; S4: Based on the benchmark core features, a density-based clustering algorithm is used to obtain the feature matrix of the data set that needs to be trained after removing noise points; S5: Extract the gradient features and frequency domain features of the target input image, and integrate them with the target input image after dimension unification using the attention mechanism to obtain the target high-dimensional feature information; S6: classify and judge the target input image according to the distance between the target high-dimensional feature information and the benchmark core features in the feature matrix; In the step S2, the ResNet50 network architecture is used as the basis of the skeleton network, and intermediate data processing and downsampling operations are used to remove the output layer of the original framework and replace it with high-dimensional feature information output of the same dimension under the global average pooling strategy; And the integration under the attention mechanism is realized through the SimAM network architecture, and the formula is expressed as follows: In the formula, is the enhanced image obtained after integration, E M is the energy function of the gradient amplitude input, E F is the energy function of the frequency domain input, and the energy function is unified to the same high dimension through the sigmoid() function. X is the image in the spatial domain, and * is the convolution operation.
2. A fast aggregation classification method based on feature similarity calculation as claimed in claim 1, characterized in that: In the step S1, the gradient feature is obtained by converting the image into a grayscale image and then calculating the gradient amplitude. The formula is as follows: Where M(x,y) is the gradient amplitude at the point (x,y) in the grayscale image, G x (x, y) is the gradient component in the x direction at the point (x, y) in the grayscale image, G y (x,y) is the gradient component in the y direction at the point (x,y) in the grayscale image.
3. A fast aggregation classification method based on feature similarity calculation as claimed in claim 2, characterized in that: In the step S1, the original spatial domain image is transformed into the frequency domain range by using the fast Fourier transform, and the real part information after the frequency domain transformation is taken as the frequency domain feature. The frequency domain transformation formula is expressed as follows: Where F() is the fast Fourier transform function, (u, v) is the coordinate point in the frequency domain, f(x, y) is the grayscale of the image at the coordinate (x, y) in the spatial domain, M and N are the width and height of the image in the spatial domain, e is a natural number, and j is an imaginary number.
4. A fast aggregation classification method based on feature similarity calculation as claimed in claim 1, characterized in that: The feature output of the same dimension under global average pooling is expressed as follows: In the formula, y k is the global average pooling output value of the kth feature map, x kpq is the element located at (p, q) in the k-th feature map region R, and |R| is the number of all elements in the k-th feature map.
5. A fast aggregation classification method based on feature similarity calculation as claimed in claim 1, characterized in that: In the step S3, the distance acquisition under the infinite norm is expressed as the following formula: d(P,Q)=max(|(p i -q i )|) In the formula, P and Q are high-dimensional feature information, p i is the value of high-dimensional feature information P in dimension i, q i is the value of the high-dimensional feature information Q in the i-dimensional space, d(P,Q) is the infinite norm distance between the high-dimensional feature information P and the high-dimensional feature information Q, and max() is the maximum value function.
6. A fast aggregation classification method based on feature similarity calculation as claimed in claim 5, characterized in that: In the step S3, the selection of the benchmark core features is specifically as follows: When the number of training data samples in a class is less than the preset number, the distance between each sample and other samples in the class is calculated, and the sample with the largest distance and / or the smallest sum of distances is selected as the benchmark core feature; When the number of training data samples within a class is greater than or equal to the preset number, the distance between each sample and other samples within the class is calculated, and the one with the smallest distance sum is selected as the benchmark core feature.
7. A fast aggregation classification method based on feature similarity calculation as claimed in claim 1, characterized in that: In the step S4, the characteristic matrix is obtained by performing noise point removal based on the density-based clustering algorithm as follows: Taking any benchmark core feature as the center of the circle, obtain the number of other benchmark core features within the neighborhood range within the preset distance radius of the center of the circle; If the number is greater than or equal to the preset minimum number of points, the benchmark core feature is the core point; If the number is less than the preset minimum number of points, but is within the neighborhood of other core points, then the benchmark core feature is a boundary point; If it is neither a core point nor a boundary point, the benchmark core feature is a noise point.
8. A fast aggregation classification method based on feature similarity calculation as claimed in claim 5, characterized in that: In the step S6, the distance between the target high-dimensional feature information and the benchmark core feature in the feature matrix is obtained by the following formula: In the formula, s u,v is the distance between the target high-dimensional feature information and each benchmark core feature in the feature matrix. The larger the distance, the more similar the two are. i is the value of the target high-dimensional feature in dimension i, v i is the value of the current benchmark core feature in dimension i, and N is the number of dimensions.
Citation Information
Patent Citations
Active learning big data mark method and system
CN106169095A
Video stream target detection method and device based on modular lightweight network
CN116403168A