Fabric fiber classification method, device and electronic equipment
By extracting and dividing features of near-infrared spectrum data of fabric fibers, constructing time series data, and using long short-term memory network for classification, the problem of low accuracy of fabric fiber classification in the existing technology is solved, and higher recognition accuracy is achieved. Spend.
Patent Information
- Application Number
- CN202410721554.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-06-05
AI Technical Summary
The existing technology has poor ability to analyze the components of fabric fibers. It is especially difficult to identify subtle differences in textiles with complex component combinations, diverse categories, and small differences in some features. Conventional deep learning methods have poor accuracy in analyzing near-infrared spectrum data of fabric fibers. lower.
By extracting and dividing features of near-infrared spectrum data of fabric fibers, construct near-infrared spectrum time series data, and use long short-term memory network to build a classification model to capture long-term dependencies in time series data and improve the accuracy of fiber category identification.
It significantly improves the accuracy of fabric fiber classification, can more effectively identify and analyze subtle differences in fabric fibers, and solves the problem of low accuracy of conventional methods.
Smart Images

Figure CN118296472B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of object recognition and classification, and in particular to a method, device and electronic equipment for classifying fabric fibers. Background Art
[0002] At present, when analyzing the composition of fabric fibers, traditional mathematical analysis, shallow learning or linear unmixing methods are usually used. However, these methods have poor analysis capabilities for textiles with complex composition combinations, diverse categories, and slight differences in some characteristics. It is difficult to identify the subtle differences between different components in fabric fibers. Although deep learning methods can be used to analyze fabric fibers, conventional deep learning methods generally focus on the local morphology, space and numerical information of near-infrared spectral data of fabric fibers, which has great limitations. In fact, the accuracy of the results of analyzing the composition of fabric fibers is poor. Summary of the invention
[0003] The embodiments of the present invention provide a method, device and electronic device for classifying fabric fibers, so as to at least solve the technical problem of low accuracy in classifying fabric fibers in the related art.
[0004] According to one aspect of an embodiment of the present invention, a method for classifying fabric fibers is provided, comprising: extracting features from near-infrared spectral data of fabric fibers to obtain a spectral feature vector sequence; dividing the spectral feature vector sequence to obtain a plurality of first feature vector sequences, wherein different first feature vector sequences have the same length; constructing near-infrared spectral time series data of the fabric fibers based on the spectral feature vector sequence and the first feature vector sequence; and inputting the near-infrared spectral time series data into a fabric fiber classification model to obtain a target fiber category of the fabric fibers.
[0005] Furthermore, feature extraction is performed on the near-infrared spectral data of the fabric fiber to obtain a spectral feature vector sequence, including: feature recognition is performed on the near-infrared spectral data to obtain multiple first spectral feature vectors; smoothing preprocessing is performed on the multiple first spectral feature vectors to obtain multiple second spectral feature vectors; based on the first spectral feature vectors and the second spectral feature vectors, a spectral feature vector sequence is constructed.
[0006] Furthermore, the spectral feature vector sequence is divided to obtain multiple first feature vector sequences, including: expanding the initial truncation length to obtain a target truncation length; truncation of the spectral feature vector sequence according to the target truncation length to obtain a valid feature vector sequence; dividing the valid feature vector sequence according to a preset division length to obtain multiple second feature vector sequences; filling the second feature vector sequence according to a preset division length and a preset value to obtain a first feature vector sequence.
[0007] Furthermore, based on the spectral feature vector sequence and the first feature vector sequence, near-infrared spectral time series data of the fabric fiber is constructed, including: performing feature selection on the spectral feature vector sequence to obtain the spectral feature sequence; determining the sequence number of the first feature vector sequence as the time step; determining the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; based on the time step, the feature number and the first feature vector sequence, near-infrared spectral time series data is constructed.
[0008] Furthermore, the fabric fiber classification model at least includes: a tensor construction module, at least one hidden layer unit and a fully connected layer, and the near-infrared spectral time series data is input into the fabric fiber classification model to obtain the target fiber category of the fabric fiber, including: in the tensor construction module, based on the time step of the near-infrared spectral time series data, the number of features and feature data corresponding to different time steps, and the batch number of the fabric fiber classification model, construct a time series data tensor; in the hidden layer unit, feature extraction is performed on the time series data tensor to obtain a hidden data tensor; in the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; based on the fiber category score, the target fiber category of the fabric fiber is determined.
[0009] Furthermore, the fully connected layer includes: a tensor compression unit, a linear processing unit and an activation classifier. In the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, including: in the tensor compression unit, the hidden data tensor is tensor compressed to obtain a compressed data tensor; in the linear processing unit, the compressed data tensor is linearly processed to obtain a linear data tensor; and the linear data tensor is scored using the activation classifier and multiple fiber categories to obtain a fiber category score.
[0010] Furthermore, the above method also includes: inputting the near-infrared spectral time series data of sample fibers belonging to a preset fiber category into the initial fiber classification model to obtain an initial classification result; constructing a classification loss function based on the initial classification result and the preset fiber category; constructing a model evaluation result based on the classification loss function on a preset evaluation dimension; and adjusting the initial fiber classification model based on the model evaluation result to obtain a fabric fiber classification model.
[0011] According to another aspect of an embodiment of the present invention, a fabric fiber classification device is also provided, including: a feature extraction module, used to extract features from near-infrared spectral data of fabric fibers to obtain a spectral feature vector sequence; a sequence division module, used to divide the spectral feature vector sequence to obtain multiple first feature vector sequences, wherein different first feature vector sequences have the same length; a time series construction module, used to construct near-infrared spectral time series data of fabric fibers based on the spectral feature vector sequence and the first feature vector sequence; and a category recognition module, used to input the near-infrared spectral time series data into a fabric fiber classification model to obtain a target fiber category of the fabric fibers.
[0012] Furthermore, the feature extraction module is also used to: perform feature recognition on near-infrared spectral data to obtain multiple first spectral feature vectors; perform smoothing preprocessing on the multiple first spectral feature vectors to obtain multiple second spectral feature vectors; and construct a spectral feature vector sequence based on the first spectral feature vectors and the second spectral feature vectors.
[0013] Furthermore, the sequence division module is also used to: expand the initial truncation length to obtain a target truncation length; truncate the spectral feature vector sequence according to the target truncation length to obtain a valid feature vector sequence; divide the valid feature vector sequence according to a preset division length to obtain multiple second feature vector sequences; fill the second feature vector sequence according to a preset division length and a preset value to obtain a first feature vector sequence.
[0014] Furthermore, the time series construction module is also used to: perform feature selection on the spectral feature vector sequence to obtain a spectral feature sequence; determine the sequence number of the first feature vector sequence as the time step; determine the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; and construct near-infrared spectral time series data based on the time step, feature number and first feature vector sequence.
[0015] Furthermore, the fabric fiber classification model includes at least: a tensor construction module, at least one hidden layer unit and a fully connected layer, and the category recognition module is also used to: in the tensor construction module, construct a time series data tensor based on the time step of the near-infrared spectral time series data, the number of features and feature data corresponding to different time steps, and the batch number of the fabric fiber classification model; perform feature extraction on the time series data tensor in the hidden layer unit to obtain a hidden data tensor; perform full connection processing on the hidden data tensor in the fully connected layer to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; determine the target fiber category of the fabric fiber based on the fiber category score.
[0016] Furthermore, the fully connected layer includes: a tensor compression unit, a linear processing unit and an activation classifier, and the category recognition module is also used to: perform tensor compression on the hidden data tensor in the tensor compression unit to obtain a compressed data tensor; perform linear processing on the compressed data tensor in the linear processing unit to obtain a linear data tensor; and score the linear data tensor using the activation classifier and multiple fiber categories to obtain a fiber category score.
[0017] Furthermore, the above-mentioned device also includes: an initial classification module, which is used to input the near-infrared spectral time series data of sample fibers belonging to a preset fiber category into an initial fiber classification model to obtain an initial classification result; a function construction module, which is used to construct a classification loss function based on the initial classification result and the preset fiber category; a model evaluation module, which is used to construct a model evaluation result based on the classification loss function on a preset evaluation dimension; and a model adjustment module, which is used to adjust the initial fiber classification model based on the model evaluation result to obtain a fabric fiber classification model.
[0018] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0019] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0020] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0021] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0022] According to another aspect of the embodiments of the present invention, a computer program is further provided. When the computer program is executed by a processor, the methods in the embodiments of the present invention are implemented.
[0023] In an embodiment of the present invention, feature extraction is performed on near-infrared spectral data of fabric fibers to obtain a spectral feature vector sequence; the spectral feature vector sequence is divided to obtain a plurality of first feature vector sequences; near-infrared spectral time series data of fabric fibers is constructed based on the spectral feature vector sequence and the first feature vector sequence; the near-infrared spectral time series data is input into a fabric fiber classification model to obtain a target fiber category of the fabric fibers, and near-infrared spectral time series data that can reflect the characteristics of the category to which the fabric fibers belong is constructed according to a mapping relationship between the spectral feature data of the near-infrared spectral data of the fabric fibers and the spectral feature vector sequence, and the time series data is processed using a fabric fiber classification model constructed on a long short-term memory network, so that the long-term dependency between different parts in the time series data can be fully captured, thereby improving the accuracy of identifying and classifying fabric fibers, thereby solving the technical problem of low accuracy in classifying fabric fibers in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0025] Figure 1 is a flow chart of a method for classifying fabric fibers according to an embodiment of the present application;
[0026] Figure 2 is a schematic diagram of an application process of a fabric fiber classification model according to an embodiment of the present application;
[0027] Figure 3 is a schematic diagram of a fabric fiber classification process according to an embodiment of the present application;
[0028] Figure 4 It is a structural schematic diagram of a fabric fiber classification device according to an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0032] Near infrared spectrum: Near infrared light (NIR) is an electromagnetic wave between visible light and mid-infrared light. According to the definition of the American Society for Testing and Materials Testing, it refers to electromagnetic waves with a wavelength range of 780 to 2526 nm.
[0033] Component analysis: refers to the technical method of analyzing the components of products or samples by detecting molecular structure through microscopic spectra, laser femtosecond and other methods, and conducting qualitative and quantitative analysis of each component. It can be used to analyze unknown substances, unknown components, etc., quickly determine what the various components in the target sample are, conduct qualitative and quantitative analysis of samples, and identify the materials, raw materials, additives, specific ingredients and contents, foreign matter, etc. of polymer materials such as rubber.
[0034] Long Short-Term Memory Network: Long Short-Term Memory Network (LSTM) is a time recurrent neural network specially designed to solve the long-term dependency problem of general RNN (recurrent neural network). All RNNs have a chain form of repeated neural network modules.
[0035] One-hot encoding: One-hot encoding, also known as one-bit effective encoding, mainly uses a bit state register to encode each state. Each state has its own independent register bit, and only one bit is valid at any time.
[0036] Feature selection: Feature selection is also called feature subset selection (FSS) or attribute selection. It refers to selecting N features from the existing M features to optimize the specific indicators of the system. It is the process of selecting some of the most effective features from the original features to reduce the dimension of the data set. It is an important means to improve the performance of learning algorithms.
[0037] Time series data: Time series data refers to time series data. Time series data is a data column recorded in chronological order for the same unified indicator. Each data in the same data column must be of the same caliber and must be comparable. Time series data can be a number of periods or a number of time points. The purpose of time series analysis is to find out the statistical characteristics and development regularity of the time series within the sample, construct a time series model, and perform out-of-sample predictions.
[0038] Example 1
[0039] According to an embodiment of the present invention, a method embodiment of fabric fiber classification is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] Figure 1 is a flow chart of a method for classifying fabric fibers according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0041] Step S102, extracting features from the near infrared spectrum data of the fabric fiber to obtain a spectrum feature vector sequence.
[0042] The above-mentioned spectral feature vector sequence may refer to a sequence composed of different spectral feature vectors in near-infrared spectral data, and the spectral feature vectors may include but are not limited to: band coordinates, reflectivity, absorptivity, intensity and other characteristics of infrared spectral data of fabric fibers. The above-mentioned near-infrared spectral data may refer to spectral data obtained by collecting data for different spectral features, for example, it may be absorptivity spectral data obtained by collecting absorptivity, reflectivity spectral data collected by collecting reflectivity, etc.
[0043] In an optional scheme of the present embodiment, in order to be able to classify the fabric fibers that currently need to be identified, the fabric fiber classification system (referred to as the classification system for short) can first collect near-infrared spectral data of the fabric fibers, and perform feature extraction on the near-infrared spectral data to obtain multiple spectral features and corresponding spectral feature vectors corresponding to the near-infrared spectral data. Based on the extracted spectral feature vectors, the above-mentioned spectral feature vector sequence for classifying and identifying fabric fibers can be constructed.
[0044] Step S104: divide the spectral feature vector sequence to obtain a plurality of first feature vector sequences.
[0045] The lengths of different first feature vector sequences are the same.
[0046] In an optional scheme of the present embodiment, in order to improve the rationality and efficiency of classifying fabric fibers, the classification system may divide the acquired spectral feature vector sequence to obtain multiple first feature vector sequences of the same length, and classify the fabric fibers based on the first feature vector sequences.
[0047] Step S106, constructing near-infrared spectrum time series data of the fabric fiber based on the spectrum feature vector sequence and the first feature vector sequence.
[0048] In an optional scheme of the present embodiment, in order to improve the correlation between the feature vectors used to identify fabric fibers, thereby improving the accuracy of identifying fabric fibers, time series data can be constructed based on these feature vectors. Based on this, the classification system can construct near-infrared spectral time series data for classifying fabric fibers based on the acquired spectral feature vector sequence and the first feature vector sequence.
[0049] Step S108, inputting the near infrared spectrum time series data into the fabric fiber classification model to obtain the target fiber category of the fabric fibers.
[0050] The above-mentioned fabric fiber classification model may refer to a model with a long short-term memory network.
[0051] In an optional solution of the present embodiment, after obtaining the near-infrared spectrum time series data of the fabric fiber, the data can be input into a pre-trained fabric fiber classification model to perform a component analysis operation on the fabric fiber, thereby realizing the fiber category recognition of the fabric fiber, and obtaining the above-mentioned target fiber category. In order to improve the accuracy of processing the infrared spectrum time series data, the above-mentioned fabric fiber classification model can be a model constructed based on a long short-term memory network, thereby improving the ability to extract time series information from the near-infrared spectrum time series data, so as to better analyze the inherent characteristic characteristics of the near-infrared spectrum time series data of the fabric fiber, and thus improve the accuracy of the target fiber category obtained by classifying the fabric fiber.
[0052] In an embodiment of the present invention, feature extraction is performed on near-infrared spectral data of fabric fibers to obtain a spectral feature vector sequence; the spectral feature vector sequence is divided to obtain a plurality of first feature vector sequences; near-infrared spectral time series data of fabric fibers is constructed based on the spectral feature vector sequence and the first feature vector sequence; the near-infrared spectral time series data is input into a fabric fiber classification model to obtain a target fiber category of the fabric fibers, and near-infrared spectral time series data that can reflect the characteristics of the category to which the fabric fibers belong is constructed according to a mapping relationship between the spectral feature data of the near-infrared spectral data of the fabric fibers and the spectral feature vector sequence, and the time series data is processed using a fabric fiber classification model constructed on a long short-term memory network, so that the long-term dependency between different parts in the time series data can be fully captured, thereby improving the accuracy of identifying and classifying fabric fibers, thereby solving the technical problem of low accuracy in classifying fabric fibers in the related art.
[0053] Furthermore, feature extraction is performed on the near-infrared spectral data of the fabric fiber to obtain a spectral feature vector sequence, including: feature recognition is performed on the near-infrared spectral data to obtain multiple first spectral feature vectors; smoothing preprocessing is performed on the multiple first spectral feature vectors to obtain multiple second spectral feature vectors; based on the first spectral feature vectors and the second spectral feature vectors, a spectral feature vector sequence is constructed.
[0054] The first spectral feature vector mentioned above may refer to a feature vector corresponding to different spectral features in the near-infrared spectral data, and may be a feature vector corresponding to a band coordinate, a feature vector corresponding to a reflectivity, and the like.
[0055] In an optional solution of the present embodiment, when constructing a spectral feature vector sequence, the classification system may first identify the collected near-infrared spectral data to obtain spectral feature vectors corresponding to different spectral features, that is, to obtain the above-mentioned multiple first spectral feature vectors. In order to improve the accuracy of the constructed spectral feature vector sequence, the classification system may perform smoothing preprocessing on the first spectral feature vector after obtaining the first spectral feature vector to reduce the noise data existing in the feature vector to obtain a second spectral feature vector with higher quality. Finally, in order to ensure the integrity of the identified feature vector, the feature vector used when constructing the spectral feature vector sequence may include the above-mentioned first spectral feature vector and the second spectral feature vector at the same time.
[0056] For example, assuming that the first spectral feature vector currently identified includes: reflectance feature vector , the absorption rate eigenvector , the intensity feature vector and band coordinate feature vector , the classification system can perform smoothing preprocessing on these feature vectors to obtain new reflectivity feature vectors , the new absorption rate eigenvector , the new intensity feature vector and the new band coordinate feature vector Then, according to the first spectral feature vector before smoothing preprocessing and the second spectral feature vector after smoothing preprocessing, the spectral feature vector sequence corresponding to the near-infrared spectrum in the 900-1700nm band is constructed:
[0057] .
[0058] The above spectral feature vector sequence may be a one-dimensional vector with a length of 228.
[0059] Furthermore, the spectral feature vector sequence is divided to obtain multiple first feature vector sequences, including: expanding the initial truncation length to obtain a target truncation length; truncation of the spectral feature vector sequence according to the target truncation length to obtain a valid feature vector sequence; dividing the valid feature vector sequence according to a preset division length to obtain multiple second feature vector sequences; filling the second feature vector sequence according to a preset division length and a preset value to obtain a first feature vector sequence.
[0060] The above-mentioned initial cutoff may refer to a value such as 2 or 10 that is convenient for calculation and processing.
[0061] In an optional scheme of the present embodiment, the classification system extracts the effective interval of the band where the near-infrared spectral data is located from the spectral feature vector sequence to improve the effectiveness of the first feature vector sequence divided. Based on this, the classification system can extract the spectral feature vector sequence according to a preset initial extraction length. In order to make full use of the near-infrared spectral data, the classification system can first expand the above-mentioned initial extraction length according to the extended text input by the user or according to the historical extraction records to obtain the length of the maximum effective interval that can fully extract the band where the near-infrared spectral data is located, that is, expand the above-mentioned target extraction length, and then use the target extraction length to extract the above-mentioned spectral feature vector sequence to obtain the above-mentioned effective feature vector sequence. After obtaining the valid feature vector sequence, the classification system can further divide the valid feature vector sequence according to the preset division length to obtain multiple second feature vector sequences. Considering that the length of the valid feature vector sequence may not be an integer multiple of the preset division length, the actually divided second feature vector sequences may have different lengths. Based on this, in order to ensure the integrity of the divided first feature vector sequence, the classification system can use preset values to fill the second feature vector sequence whose length is less than the preset division length to obtain multiple second feature vector sequences of the same length, and then obtain the above-mentioned first feature vector sequence.
[0062] For ease of understanding, assuming that the current length of the spectral feature vector sequence is 228, the length L of the effective area obtained in the spectral feature vector sequence satisfies 0<L≤228. For example, for ease of division, L can be set to a power of 2 or an integer multiple of 10. Based on this, let L be 190. In order to ensure the validity of the first divided feature vector sequence, the range intercepted from the spectral feature vector sequence using the length L can be set to [20, 210]. The feature vector sequence corresponding to this range can refer to the above-mentioned effective feature vector sequence. It should be noted that this range is only an exemplary display and is not limited. After the effective feature sequence is obtained, the preset division length l can be used. 0 By dividing the effective feature vector sequence, we can get S=[L / l 0 ] second feature vector sequences, for example, assuming the preset division length is 10, 19 vector sequences can be obtained. At this time, the lengths of these 19 sequences are all 10, and these 19 sequences can be determined as the above-mentioned first feature vector sequences. If the division length is 9, 22 sequences can be obtained, and there is only 1 element in the 22nd sequence. At this time, the preset value, such as 0, can be used to fill the 22nd sequence so that the sequence also contains 9 elements. Finally, after completing the filling, the 22 divided sequences can be determined as the above-mentioned first feature vector sequence.
[0063] Furthermore, based on the spectral feature vector sequence and the first feature vector sequence, near-infrared spectral time series data of the fabric fiber is constructed, including: performing feature selection on the spectral feature vector sequence to obtain the spectral feature sequence; determining the sequence number of the first feature vector sequence as the time step; determining the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; based on the time step, the feature number and the first feature vector sequence, near-infrared spectral time series data is constructed.
[0064] In an optional scheme of the present embodiment, in order to improve the rationality of the constructed near-infrared spectrum time series data matching the near-infrared spectrum data, the classification system can first perform a feature selection operation on the spectrum feature vector sequence to obtain a spectrum feature sequence of a feature type that only contains spectrum features. For example, if the spectrum feature vector sequence contains vectors of spectrum features such as band coordinates and reflectivity, then the spectrum feature sequence contains the two spectrum features of band coordinates and reflectivity. Then, the sequence number of the above-mentioned first feature vector sequence can be used as the time step, and the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectrum feature sequence can be used as the feature number corresponding to the time step, and the elements contained in the first feature vector sequence can be combined to construct the above-mentioned infrared spectrum time series data.
[0065] Among them, the formula for feature selection of spectral feature vector sequence can be:
[0066] .
[0067] It should be noted that, in the feature selection process, the selected feature type can be set by the user. For example, the obtained spectral feature sequence can be:
[0068] .
[0069] The number of elements contained in this spectral feature sequence is d=6.
[0070] Continue with the above L=190, l 0 =10 as an example, by dividing the effective feature vector sequence, we can get S=19 first feature vector sequences. Based on this, we can get S×l 0 =19×10 sets of multi-interval sequences q i , where 0≤i<6. Connecting the sets corresponding to different features, we can get:
[0071] Concat{q 0 ,q 1 ,q 2 ,q3 ,q 4 ,q 5 ,q 6 , dim=1}.
[0072] After the connection, we can obtain a multi-interval sequence set with the shape of time step and feature number: S×(l 0 ×d), that is, in S=19 intervals, there are l in different intervals 0 ×d=60 length of feature vector, at this time, the time step is determined to be 19, and the number of features corresponding to different time steps is 60. According to the time step and the number of features, as well as the feature data contained in the different first feature vector sequences obtained by division, the above-mentioned near-infrared spectral time series data can be constructed.
[0073] Furthermore, the fabric fiber classification model at least includes: a tensor construction module, at least one hidden layer unit and a fully connected layer, and the near-infrared spectral time series data is input into the fabric fiber classification model to obtain the target fiber category of the fabric fiber, including: in the tensor construction module, based on the time step of the near-infrared spectral time series data, the number of features and feature data corresponding to different time steps, and the batch number of the fabric fiber classification model, construct a time series data tensor; in the hidden layer unit, feature extraction is performed on the time series data tensor to obtain a hidden data tensor; in the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; based on the fiber category score, the target fiber category of the fabric fiber is determined.
[0074] In an optional scheme of the present embodiment, in order to accurately analyze the infrared spectrum time series data, the fabric fiber classification model may include at least: a tensor construction module, one or more hidden layer units and a fully connected layer. The classification system can input the infrared spectrum time series data into the fabric fiber classification model, first use the above-mentioned tensor construction module to construct a time series data tensor for the time step of the near-infrared spectrum time series data, the number of features corresponding to different time steps, the feature data contained in the time series data, and the number of batches of data processing configured in the fabric fiber classification model, and then use the above-mentioned hidden layer unit to extract features from the time series data tensor to obtain a hidden data tensor that can reflect the category of the fabric fiber, and finally use the fully connected layer to perform full connection processing on the above-mentioned hidden data tensor, and determine the fiber category scores of the fabric fibers belonging to different fiber categories based on the full connection results. The classification system can determine the maximum value from the obtained fiber category scores, and determine the fiber category corresponding to the maximum value as the target fiber category of the fabric fiber.
[0075] For example, the Pytorch tensor computing framework and long short-term memory network can be used to design the above-mentioned fabric fiber classification model. Taking the near-infrared spectral data constructed above as an example, the input feature dimension input_size input to the fabric fiber classification model can be F in =60, time step time_step is T s =19, the number of hidden units hidden_size is set to 100, the number of layers num_layers is set to 3, and the batch size is 128. The corresponding input is a time series data tensor of [128, 19, 60]. The long short-term memory network is used to extract features from the time series data tensor to obtain a hidden data tensor of [128, 19, 100]. The last layer of the hidden data tensor, that is, the output of the long short-term memory network is a tensor of [128, 1, 100]. Based on this, a 128 to n linear fully connected layer is used to fully connect the hidden data tensor to obtain the above fiber score, where n is the number of preset fiber categories. For example, if there are currently 49 categories of fabric fibers, n can be 49. Among them, the long short-term and network can be expressed as:
[0076] ;
[0077] ;
[0078] ;
[0079] ;
[0080] ;
[0081] .
[0082] in, is the retained information after the forget gate at the tth time step, represents the tth hidden layer information, is the forgotten information passing through the forget gate at the t-th time step, is the learning information passing through the learning gate at the tth time step, is the cell state information passing through the memory gate at the tth time step, is the output information of the tth time step, is the feature information of the tth time step, is the input layer weight, is the input layer bias, is the hidden layer weight, For hidden layer paranoia, For the Hidden layer information.
[0083] Furthermore, the fully connected layer includes: a tensor compression unit, a linear processing unit and an activation classifier. In the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, including: in the tensor compression unit, the hidden data tensor is tensor compressed to obtain a compressed data tensor; in the linear processing unit, the compressed data tensor is linearly processed to obtain a linear data tensor; and the linear data tensor is scored using the activation classifier and multiple fiber categories to obtain a fiber category score.
[0084] In an optional scheme of the present embodiment, in order to improve the effect of fully connected processing of the hidden data tensor, a tensor compression unit, a linear processing unit and an activation classifier can be deployed in the fully connected layer, and the hidden data tensor is firstly subjected to tensor compression processing using the above-mentioned tensor compression unit to obtain the above-mentioned compressed data tensor, and then the compressed data tensor is linearly processed using the above-mentioned linear processing unit to obtain the corresponding linear data tensor, and finally the above-mentioned activation classifier and the preset multiple fiber categories are used to score the above-mentioned linear data tensor to obtain the fiber category scores of the fabric fibers belonging to different fiber categories.
[0085] For example, assuming that the hidden data tensor is the above-mentioned tensor of [128, 19, 100], and the corresponding last layer output is [128, 1, 100], then the last layer output is compressed to obtain a compressed data tensor of [128, 100], and then a linear layer of [100, 49] is used for linear processing to obtain a linear data tensor, and then the softmax activation classifier is used to score the linear data tensor according to different fiber categories to obtain the above-mentioned fiber category score, where the activation classifier scoring formula can be:
[0086] .
[0087] Furthermore, the above method also includes: inputting the near-infrared spectral time series data of sample fibers belonging to a preset fiber category into the initial fiber classification model to obtain an initial classification result; constructing a classification loss function based on the initial classification result and the preset fiber category; constructing a model evaluation result based on the classification loss function on a preset evaluation dimension; and adjusting the initial fiber classification model based on the model evaluation result to obtain a fabric fiber classification model.
[0088] In an optional scheme of the present embodiment, in order to improve the accuracy of fabric fiber classification, when training the fabric fiber classification model, the near-infrared spectral time series data of sample fibers belonging to a preset fiber category can be first input into the initial fiber classification model to obtain an initial classification result, and then a loss function is constructed based on the initial classification result and the preset fiber category, and the initial classification model is evaluated based on the classification loss function on preset evaluation dimensions, such as accuracy, recall rate, etc., to construct the above-mentioned model evaluation result. Finally, the classification system can adjust the initial fiber classification model based on the model evaluation result, so as to improve the accuracy of the obtained fabric fiber classification model.
[0089] For ease of understanding, fabric fibers with different components can be considered as one category and encoded as the real category. For example, a sample of fabric fibers containing 49 components including cotton and its blended materials, polyester and its blended materials, nylon and its blended materials, artificial materials and their blended materials can be considered as 49 categories, and these 49 categories can be encoded into Y={y 1 ,y 2 …y 49}, then input the sample into the category identified by the initial fiber classification model as the predicted category, and according to the predicted category and the true category, use the cross entropy loss function to calculate the multi-classification loss of the long short-term memory network to construct the above classification loss function, and continuously minimize the loss value between the predicted category and the true category of the model on the training set, where the loss function can be:
[0090] .
[0091] At the same time, based on the loss function, an evaluation model on a preset dimension, such as an accuracy evaluation model, is used to evaluate the performance of the initial fiber classification model. That is, fabric fibers with different components can be regarded as one category each. If the real category and the predicted category are equal, the prediction is correct, and if they are not equal, the prediction is wrong. Finally, the accuracy of the correct classification of the model components is calculated. The formula for determining the accuracy can be:
[0092] .
[0093] Where N is the total number of samples, is the prediction of the kth sample, and the judgment criteria for correct or incorrect prediction are:
[0094] .
[0095] For ease of understanding, Figure 2is a schematic diagram of an application process of a fabric fiber classification model according to an embodiment of the present application. The process of identifying and classifying fabric fibers can be performed according to Figure 2 From the bottom to the top, first obtain the spectral feature vector sequence corresponding to the near-infrared spectral data of the fabric fiber, such as the feature vector sequence corresponding to the reflectivity reflection of the fabric fiber, the feature vector sequence corresponding to the absorbption, etc., and then divide the near-infrared spectral data to obtain multiple first feature vector sequences. The corresponding features included in the first feature vector sequence can be feature1, feature2...featuren. According to these extracted first feature vector sequences and spectral feature vector sequences, the near-infrared spectral time series data of the fabric fiber is constructed, and the near-infrared spectral time series data is input into the fabric fiber classification model for fiber classification. Category recognition and classification, the fabric fiber classification model may include multiple long short-term memory neural networks, the specific processing process may be as shown above, and will not be repeated here, the output of the fabric fiber classification model may be a fiber category score obtained by scoring the degree of matching between the current fabric fiber and different fiber categories, and the fiber categories may include but are not limited to: cotton (C), linen (L), cotton and linen (C_L), cotton and spandex (C_SP), cotton and polyester (C_P), polyester (P), polyester and linen (P_L), polyester and nylon (P_N), wool (W), wool and silk (W_S), etc. The classification system may determine the fiber category corresponding to the largest fiber category score as the target fiber category of the current fabric fiber.
[0096] Figure 3 is a schematic diagram of a fabric fiber classification process according to an embodiment of the present application, such as Figure 3As shown, the classification system can collect near-infrared spectral data of fabric fibers under different spectral characteristics, and perform data clarification and data preprocessing on the near-infrared spectral data to construct a spectral feature vector sequence of the fabric fiber. At this time, the spectral feature vector sequence can be stored in a preset database, and the spectral feature sequence can be extracted from the preprocessed data by feature selection. The spectral feature vector sequence is then intercepted, split, grouped, filled, and other operations are performed on the spectral feature vector sequence to obtain multiple first feature vector sequences. Finally, the number of elements contained in the spectral feature sequence is used to perform multi-feature connection and timestamp division operations on the first feature vector sequence, and the sequence number of the first feature vector sequence is determined as the time step. At the same time, the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence is determined as the feature number corresponding to different time steps to construct the near-infrared spectral time series data of the fabric fiber. After constructing the near-infrared spectral time series data of the fabric fibers, the classification system can use the pre-trained fabric category classification model to process the near-infrared spectral time series data, that is, first input the infrared spectral time series data into the long short-term memory network model to improve the time characteristics and sequence characteristics of the sequence, and determine the degree of matching between the fabric fibers and different fiber categories based on the time characteristics and sequence characteristics, and finally determine the target fiber category to which the fabric fibers belong based on the matching degree. Among them, when performing time feature extraction and sequence feature extraction on the near-infrared spectral time series data, the model parameters used, such as time step size, input layer weight, input layer bias, number of hidden layer units, hidden layer information, etc., can be set by the user according to their own needs and are not limited here.
[0097] Example 2
[0098] According to another aspect of the embodiment of the present invention, corresponding to the above-mentioned fabric fiber classification method, a fabric fiber classification device is also provided. Figure 4 is a structural schematic diagram of a fabric fiber classification device according to an embodiment of the present application. Figure 4 As shown, the device includes: a feature extraction module 402, a sequence division module 404, a time sequence construction module 406 and a category identification module 408.
[0099] Among them, the feature extraction module 402 is used to extract features from the near-infrared spectral data of the fabric fiber to obtain a spectral feature vector sequence; the sequence division module 404 is used to divide the spectral feature vector sequence to obtain multiple first feature vector sequences, wherein the lengths of different first feature vector sequences are the same; the time series construction module 406 is used to construct the near-infrared spectral time series data of the fabric fiber based on the spectral feature vector sequence and the first feature vector sequence; the category recognition module 408 is used to input the near-infrared spectral time series data into the fabric fiber classification model to obtain the target fiber category of the fabric fiber.
[0100] Furthermore, the feature extraction module is also used to: perform feature recognition on near-infrared spectral data to obtain multiple first spectral feature vectors; perform smoothing preprocessing on the multiple first spectral feature vectors to obtain multiple second spectral feature vectors; and construct a spectral feature vector sequence based on the first spectral feature vectors and the second spectral feature vectors.
[0101] Furthermore, the sequence division module is also used to: expand the initial truncation length to obtain a target truncation length; truncate the spectral feature vector sequence according to the target truncation length to obtain a valid feature vector sequence; divide the valid feature vector sequence according to a preset division length to obtain multiple second feature vector sequences; fill the second feature vector sequence according to a preset division length and a preset value to obtain a first feature vector sequence.
[0102] Furthermore, the time series construction module is also used to: perform feature selection on the spectral feature vector sequence to obtain a spectral feature sequence; determine the sequence number of the first feature vector sequence as the time step; determine the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; and construct near-infrared spectral time series data based on the time step, feature number and first feature vector sequence.
[0103] Furthermore, the fabric fiber classification model includes at least: a tensor construction module, at least one hidden layer unit and a fully connected layer, and the category recognition module is also used to: in the tensor construction module, construct a time series data tensor based on the time step of the near-infrared spectral time series data, the number of features and feature data corresponding to different time steps, and the batch number of the fabric fiber classification model; perform feature extraction on the time series data tensor in the hidden layer unit to obtain a hidden data tensor; perform full connection processing on the hidden data tensor in the fully connected layer to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; determine the target fiber category of the fabric fiber based on the fiber category score.
[0104] Furthermore, the fully connected layer includes: a tensor compression unit, a linear processing unit and an activation classifier, and the category recognition module is also used to: perform tensor compression on the hidden data tensor in the tensor compression unit to obtain a compressed data tensor; perform linear processing on the compressed data tensor in the linear processing unit to obtain a linear data tensor; and score the linear data tensor using the activation classifier and multiple fiber categories to obtain a fiber category score.
[0105] Furthermore, the above-mentioned device also includes: an initial classification module, which is used to input the near-infrared spectral time series data of sample fibers belonging to a preset fiber category into an initial fiber classification model to obtain an initial classification result; a function construction module, which is used to construct a classification loss function based on the initial classification result and the preset fiber category; a model evaluation module, which is used to construct a model evaluation result based on the classification loss function on a preset evaluation dimension; and a model adjustment module, which is used to adjust the initial fiber classification model based on the model evaluation result to obtain a fabric fiber classification model.
[0106] Example 3
[0107] An embodiment of the present application further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of the present invention when running.
[0108] Example 4
[0109] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0110] Example 5
[0111] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in various embodiments of the present invention when executed by a processor.
[0112] Example 6
[0113] An embodiment of the present application further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0114] Example 7
[0115] The embodiments of the present application further provide a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.
[0116] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0117] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0120] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0122] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for classifying fabric fibers, It is characterized in that include: Extract features from the near infrared spectrum data of fabric fibers to obtain a spectrum feature vector sequence; The spectral feature vector sequence is intercepted according to a target interception length to obtain a valid feature vector sequence, wherein the target interception length is a length obtained by extending an initial interception length; Dividing the effective feature vector sequence according to a preset division length to obtain a plurality of first feature vector sequences, wherein different first feature vector sequences have the same length; Based on the spectral feature vector sequence and the first feature vector sequence, constructing near-infrared spectral time series data of the fabric fiber; Inputting the near infrared spectrum time series data into a fabric fiber classification model to obtain a target fiber category of the fabric fiber; Wherein, based on the spectral feature vector sequence and the first feature vector sequence, constructing the near-infrared spectral time series data of the fabric fiber, comprising: performing feature selection on the spectral feature vector sequence to obtain a spectral feature sequence; determining the sequence number of the first feature vector sequence as a time step; determining the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; based on the time step, the feature number and the first feature vector sequence, constructing the near-infrared spectral time series data; The fabric fiber classification model at least includes: a tensor construction module, at least one hidden layer unit and a fully connected layer. The near-infrared spectrum time series data is input into the fabric fiber classification model to obtain the target fiber category of the fabric fiber, including: in the tensor construction module, a time series data tensor is constructed based on the time step of the near-infrared spectrum time series data, the number of features corresponding to different time steps, the feature data contained in the near-infrared spectrum time series data, and the batch number of the fabric fiber classification model; in the hidden layer unit, feature extraction is performed on the time series data tensor to obtain a hidden data tensor; in the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; based on the fiber category score, the target fiber category of the fabric fiber is determined.
2. The method according to claim 1, It is characterized in that Feature extraction is performed on the near infrared spectrum data of fabric fibers to obtain a spectrum feature vector sequence, including: Performing feature recognition on the near-infrared spectrum data to obtain a plurality of first spectrum feature vectors; Performing smoothing preprocessing on the plurality of first spectral feature vectors to obtain a plurality of second spectral feature vectors; The spectral feature vector sequence is constructed based on the first spectral feature vector and the second spectral feature vector.
3. The method according to claim 1, It is characterized in that The spectral feature vector sequence is divided according to a preset division length to obtain a plurality of first feature vector sequences, including: Dividing the effective feature vector sequence according to the preset division length to obtain a plurality of second feature vector sequences; The second feature vector sequence is filled according to the preset division length and the preset value to obtain the first feature vector sequence.
4. The method according to claim 1, It is characterized in that The fully connected layer includes: a tensor compression unit, a linear processing unit and an activation classifier. In the fully connected layer, the hidden data tensor is fully connected to obtain a fiber category score, including: Performing tensor compression on the hidden data tensor in the tensor compression unit to obtain a compressed data tensor; Performing linear processing on the compressed data tensor in the linear processing unit to obtain a linear data tensor; The linear data tensor is scored using the activated classifier and the plurality of fiber categories to obtain the fiber category score.
5. The method according to claim 1, It is characterized in that The method further comprises: Inputting the near infrared spectrum time series data of the sample fibers belonging to the preset fiber category into the initial fiber classification model to obtain the initial classification result; Constructing a classification loss function based on the initial classification result and the preset fiber category; Constructing a model evaluation result based on the classification loss function on a preset evaluation dimension; The initial fiber classification model is adjusted based on the model evaluation result to obtain the fabric fiber classification model.
6. A fabric fiber classification device, It is characterized in that include: A feature extraction module is used to extract features from the near-infrared spectrum data of fabric fibers to obtain a spectrum feature vector sequence; A sequence division module is used to intercept the spectral feature vector sequence according to a target interception length to obtain a valid feature vector sequence, wherein the target interception length is a length obtained by extending the initial interception length; and to divide the valid feature vector sequence according to a preset division length to obtain a plurality of first feature vector sequences, wherein different first feature vector sequences have the same length; A time series construction module, used for constructing near infrared spectrum time series data of the fabric fiber based on the spectrum feature vector sequence and the first feature vector sequence; A category recognition module, used for inputting the near infrared spectrum time series data into a fabric fiber classification model to obtain a target fiber category of the fabric fiber; The time series construction module is further used to: perform feature selection on the spectral feature vector sequence to obtain a spectral feature sequence; determine the sequence number of the first feature vector sequence as a time step; determine the product of the number of elements contained in the first feature vector sequence and the number of elements contained in the spectral feature sequence as the feature number corresponding to different time steps; and construct the near-infrared spectral time series data based on the time step, the feature number and the first feature vector sequence; The fabric fiber classification model at least includes: a tensor construction module, at least one hidden layer unit and a fully connected layer, and the category identification module is also used to: in the tensor construction module, based on the time step of the near-infrared spectrum time series data, the number of features and feature data corresponding to different time steps, and the batch number of the fabric fiber classification model, construct a time series data tensor; in the hidden layer unit, perform feature extraction on the time series data tensor to obtain a hidden data tensor; in the fully connected layer, perform full connection processing on the hidden data tensor to obtain a fiber category score, wherein the fiber category score is used to characterize the score of the fabric fiber belonging to different fiber categories; and determine the target fiber category of the fabric fiber based on the fiber category score.
7. An electronic device, It is characterized in that include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 5 when running.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 5.
9. A computer program product, It is characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 5.
