Preprocessing method and device of model input data and image recognition equipment
By determining the channel ratio combination of multispectral data samples, the problem of insufficient robustness of multispectral image recognition models when light source intensity and distance change is solved, and better liveness detection results are achieved.
Patent Information
- Application Number
- CN202211001398.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-19
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2042-08-19
AI Technical Summary
Existing multispectral image recognition models lack robustness when light source intensity and image acquisition distance vary, affecting recognition results.
By acquiring the channel ratio set of multispectral data samples, the optimal channel ratio combination is determined, and the target channel ratio combination is determined based on the target multispectral data samples as the input of the image recognition model, thus eliminating the influence of light source intensity and distance.
This improved the robustness of the image recognition model under different light source intensities and distances, and enhanced the accuracy of liveness detection.
Smart Images

Figure CN115424321B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image recognition, and in particular relates to methods, apparatus and image recognition devices for preprocessing model input data. Background Technology
[0002] Multispectral images contain richer image data than RGB images, and are therefore widely used in image recognition. Existing image recognition models for recognizing multispectral images are generally trained directly using multispectral images as training samples. However, the spectral data of multispectral images is easily affected by factors such as light source intensity and image acquisition distance. When the light source intensity or image acquisition distance changes, it will affect the recognition results of the image recognition model, resulting in insufficient robustness of the image recognition model. Summary of the Invention
[0003] In view of this, embodiments of this application provide a method, apparatus, and image recognition device for preprocessing model input data. Using preprocessed data as input to an image recognition model can improve the robustness of the image recognition model.
[0004] The first aspect of this application provides a training method for an image recognition model and a preprocessing method for model input data, comprising: acquiring a set of channel ratios for P preset multispectral data samples, wherein the set of channel ratios includes the ratios of gray values of all pairs of channels in the preset multispectral data samples, wherein P is greater than or equal to 1 and is a positive integer; determining an optimal channel ratio combination based on the set of channel ratios for the P preset multispectral data samples, wherein the optimal channel ratio combination includes at least two channel ratios; acquiring Q target multispectral data samples, wherein Q is greater than or equal to 1 and is a positive integer; and determining Q target channel ratio combinations based on the Q target multispectral data samples and the optimal channel ratio combination as input to the image recognition model.
[0005] In some embodiments, determining the optimal channel ratio combination based on the channel ratio set of P preset multispectral data samples includes: obtaining S (1≤S≤n-1) candidate channel ratio sets based on the channel ratio set of each preset multispectral data sample in the P preset multispectral data samples, wherein the i-th candidate channel ratio set includes all i (N≥i≥2) channel ratios in the channel ratio set of each preset multispectral data sample as a group of candidate channel ratio combinations, where n is the number of channels in each preset multispectral data sample, N is the number of channel ratios in the channel ratio set of each preset multispectral data sample, and S, N, n, and i are all positive integers; inputting all candidate channel ratio sets in the P*S candidate channel ratio sets into the test model, and determining the optimal channel ratio combination based on the output result of the test model, wherein the formula for calculating the number of channel ratios is N=(n-1)*n / 2.
[0006] In some embodiments, all candidate channel ratio sets in the P*S candidate channel ratio sets are input into the test model, and the optimal channel ratio combination is determined based on the output of the test model. This includes: sequentially inputting all candidate channel ratio combinations in the P*S candidate channel ratio sets into the test model to obtain the accuracy values of all candidate channel ratio combinations; selecting the candidate channel ratio combination with the highest accuracy value as the optimal channel ratio combination; and determining the channel ratio combination corresponding to the optimal channel ratio combination as the optimal channel ratio combination. Alternatively, starting from the first set of candidate channel ratios, input all candidate channel ratio combinations from the P*S sets of candidate channel ratios with the same group into the test model sequentially to obtain the accuracy value of all candidate channel ratio combinations in the set of candidate channel ratios with the same group; compare the maximum accuracy value in the current set of candidate channel ratios with the maximum accuracy value in the next set of candidate channel ratios with the same group, until the maximum accuracy value in the (j-1)th set of candidate channel ratios with the same group is greater than the maximum accuracy value in the jth set of candidate channel ratios with the same group. Then, determine the candidate channel ratio combination corresponding to the maximum accuracy value in the (j-1)th set as the optimal channel ratio combination, where 2≤j≤S and j is a positive integer; determine the channel ratio combination corresponding to the optimal channel ratio combination as the optimal channel ratio combination.
[0007] In some embodiments, the channel grayscale values of the multispectral data samples are the average grayscale values of a specified region corresponding to the face image. The number of channels in the preset multispectral data samples is the same as the number of channels in the target multispectral data samples.
[0008] A second aspect of this application provides a preprocessing apparatus for model input data, comprising: a first acquisition module, configured to acquire a set of channel ratios for P preset multispectral data samples, the set of channel ratios including the ratios of gray values of all pairs of channels in the preset multispectral data samples, wherein P is greater than or equal to 1 and is a positive integer; an optimal channel ratio combination determination module, configured to determine an optimal channel ratio combination based on the set of channel ratios for P preset multispectral data samples, the optimal channel ratio combination including at least two channel ratios; a second acquisition module, configured to acquire Q target multispectral data samples, wherein Q is greater than or equal to 1 and is a positive integer; and a target channel ratio combination determination module, configured to determine Q target channel ratio combinations based on the Q target multispectral data samples and the optimal channel ratio combination as input to an image recognition model.
[0009] A third aspect of this application provides an image recognition device, including a multispectral camera, a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the preprocessing method for model input data as described in the first aspect above.
[0010] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the preprocessing method for model input data as described in the first aspect above.
[0011] The fifth aspect of this application provides a computer program product that, when run on an image recognition device, causes the image recognition device to perform the model input data preprocessing method of any one of the first aspects described above.
[0012] The beneficial effects of this application embodiment compared with the prior art are as follows: by obtaining the ratio of gray values of all pairs of channels in multiple preset multispectral data samples, the optimal channel ratio combination is determined, and then multiple target channel ratio combinations are determined based on multiple target multispectral data samples and the optimal channel ratio combination. Thus, multiple target channel ratio combinations can be used as input data for image recognition models, eliminating the influence of distance and light source intensity. The trained model has better robustness for liveness detection under different light source intensities and different distances. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0014] Figure 1 This is a schematic diagram of the structure of an image recognition device provided in an embodiment of this application;
[0015] Figure 2 This is a schematic diagram illustrating the implementation flow of a model input data preprocessing method provided in an embodiment of this application;
[0016] Figure 3 This is a schematic diagram of a method for combining channel ratios according to an embodiment of this application;
[0017] Figure 4 This is a graph showing the trend of accuracy as a function of the number of channels, provided in one embodiment of this application.
[0018] Figure 5 This is a schematic diagram of a preprocessing device for model input data provided in an embodiment of this application. Detailed Implementation
[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0020] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0022] Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0023] Figure 1 This is a schematic diagram of the structure of an image recognition device provided in an embodiment of this application. The image recognition device 1 includes a processor 11, a memory 12, and a multispectral camera 14. A computer program 13 is stored in the memory 12 and can run on the processor 11. When the processor 11 executes the computer program 13, it implements the preprocessing method for model input data described later. Alternatively, when the processor 11 executes the computer program 13, it implements the functions of each module in the various device embodiments described later.
[0024] For example, computer program 13 may be divided into one or more modules, one or more of which are stored in memory 12 and executed by processor 11. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 13 in image recognition device 1.
[0025] Those skilled in the art will understand that Figure 1 This is merely an example of image recognition device 1 and does not constitute a limitation on image recognition device 1. It may include more or fewer components than shown, or combine certain components, or different components. For example, image recognition device 1 may also include input / output devices, network access devices, buses, etc.
[0026] Processor 11 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0027] The memory 12 can be an internal storage unit of the image recognition device 1, such as a hard disk or RAM of the image recognition device 1. The memory 12 can also be an external storage device of the image recognition device 1, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the image recognition device 1. Furthermore, the memory 12 can include both internal and external storage units of the image recognition device 1. The memory 12 is used to store computer programs and other programs and data required by the image recognition device 1. The memory 12 can also be used to temporarily store data that has been output or will be output.
[0028] The multispectral camera 14 is mainly used to acquire multispectral images, which can be images of faces or other objects (such as vehicles, obstacles, etc.), and can be images of real people or images of sculptors. In some embodiments of this application, the multispectral camera 14 may include a photosensitive chip and a filter array, wherein the filter array may include filters corresponding to multiple spectral bands. After the incident light beam is filtered by the filter array, an image corresponding to the spectral band is obtained. The photosensitive chip is divided into multiple imaging units corresponding to the shape of each filter in the filter array. Each imaging unit has a spectral response channel with different spectral transmittance, and each spectral response channel corresponds to receiving a target light beam of one spectral band. For example, a multispectral image obtained by a 3×3 filter array contains information from nine different channels. By acquiring the spectral response value information (grayscale value) of each first pixel region, the average spectral response value of a certain first pixel region can be calculated and used as the spectral response value information of that first pixel region, thereby obtaining the spectral response value information (average grayscale value) of each spectral band in n spectral bands.
[0029] For the spectral data of a multispectral image in any two channels, the following relationship exists:
[0030]
[0031] Where λ1 and λ2 represent the wavelengths corresponding to the two channels, and I1(λ1) and I1(λ2) represent the grayscale values (response values) of the two channels when the distance from the light source is d1. and Let λ1 and λ2 represent the light source intensities of the two channels at a distance of d1 from the light source, respectively; c(λ1) and c(λ2) represent the filter response parameters of the two channels, respectively; r1(λ1) and r1(λ2) represent the reflectivities of the two channels at a distance of d1 from the light source, respectively; and I2(λ1) and I2(λ2) represent the response values (grayscale values) of the two channels at a distance of d2 from the light source, respectively. and Let r1 and r2(λ2) represent the light source intensities of the two channels when the distance between the light source and the light source is d2, respectively, and let r2(λ1) and r2(λ2) represent the reflectivities of the two channels when the distance between the light source and the light source is d2, respectively.
[0032] It can be seen that, at the same distance, the influence of the ratio of light source intensity to channel gray value (response value) is a constant α. Therefore, by selecting the optimal channel to compare the target spectral data for preprocessing, the stability of the data can be improved. Moreover, the reflectance coefficients of real people and sculptors are different for different bands, and the ratio of reflectance in different bands can be used as an effective feature for liveness detection.
[0033] The following is an exemplary description of the preprocessing method for model input data provided in this application.
[0034] Please see the appendix Figure 2 The model input data preprocessing method provided in one embodiment of this application includes:
[0035] S101: Obtain the channel ratio set of P preset multispectral data samples. The channel ratio set includes the ratio of gray values of all pairs of channels in the preset multispectral data samples, where P is greater than or equal to 1 and is a positive integer.
[0036] S102: Determine the optimal channel ratio combination based on the channel ratio set of P multispectral data samples. The optimal channel ratio combination includes at least two channel ratios.
[0037] S103: Obtain Q target multispectral data samples, where Q is greater than or equal to 1 and is a positive integer;
[0038] S104: Determine the combination of Q target channel ratios based on Q target multispectral data samples and the optimal channel ratio combination, and use it as the input of the image recognition model.
[0039] The preprocessing method for model input data provided in the above embodiments will be described in detail below.
[0040] First, obtain P preset multispectral data samples. These P preset multispectral data samples include P preset multispectral images. These images can be acquired by a multispectral camera and can be images of faces or other objects (such as vehicles, obstacles, etc.). Taking a face image as an example, some of the P preset multispectral images are of real people, while others are images of prosthetics.
[0041] A preset multispectral image is synthesized from the spectral signals corresponding to each channel. By processing the spectral signals corresponding to each channel, the preset spectral data for each channel can be obtained. The preset spectral data can be the grayscale value or the brightness value of the corresponding channel. In one embodiment, the preset multispectral image is a face image. The preset spectral data can be a certain grayscale value or the average grayscale value of a specified area in the face image. For example, it can be the average grayscale (or brightness) of the face, cheek, or forehead in the corresponding channel.
[0042] For n (n is a positive integer) channels, each channel is represented by ch1, ch2, ch3...chn. Then, for any two channels chi and chj, the channel ratio can be represented by chi / chj (i and j are positive integers). For a preset multispectral image, the ratio between the gray values of the chi channel and the chj channel is the ratio of the gray values of the two channels. Any two channels can form a channel ratio, and the total number of channel ratios can be determined based on the number of channels. For example, if the number of channels is n, the formula for calculating the number of channel ratios is N = (n-1)*n / 2, meaning that each preset multispectral image corresponds to N channel ratios. Each preset multispectral image has N pairs of gray value ratios between its channels, and the set of all pairwise gray value ratios in all preset multispectral images constitutes the channel ratio set.
[0043] In one embodiment, after determining the number N channel ratios, the N channel ratios can be represented by feature vectors. The number of elements in the feature vectors is the same as the total number of channel ratios; that is, each element in the feature vector corresponds to a channel ratio, and all channel ratios are unique. For example, if the total number of channel ratios is 10, then the number of elements in the feature vectors is 10. Randomly selecting T elements (where T represents a positive integer greater than 1) from the feature vectors—for example, randomly selecting T elements from N elements sequentially—results in R possible combinations of channel ratios. N coded sequences are used to represent whether each channel is selected. The initial value of each element in the coded sequence is 0. The value of the selected element is set to 1. This method is used to select the combination of T channels. For example, if the encoding is set to 36 bits, [0 ...
[0044] Based on the channel ratio set of each of the P preset multispectral data samples, S (1≤S≤n-1) candidate channel ratio sets are obtained. The i-th candidate channel ratio set includes all i (N≥i≥2) channel ratios in the channel ratio set of each preset multispectral data sample as a group of candidate channel ratio combinations, where n is the number of channels in each preset multispectral data sample, and N is the number of channel ratios in the channel ratio set of each preset multispectral data sample. All candidate channel ratio sets in the P*S candidate channel ratio sets are input into the test model, and the optimal channel ratio combination is determined according to the output result of the test model.
[0045] Specifically, each preset multispectral data sample has n channels and N channel ratios. From these N channel ratios, all i-th channel ratios are selected as a group, thus allowing the selection of... Each channel ratio is used as a combination of channel ratio values for the i-th group. The channel ratio is used as the combination of channel ratio values in the (i+1)th group. Let P be the number of channel ratio combinations. Given P preset multispectral data samples, there are P*S candidate channel ratio sets. Input all channel ratio combinations from these P*S candidate sets into the test model, and determine the optimal channel ratio combination based on the model's output.
[0046] If the preset multispectral image is a real person image, the label for the channel ratio combination corresponding to that real person image is 1; if the preset multispectral image is a prosthetic image, the label for the channel ratio combination corresponding to that prosthetic image is 0. Each channel ratio combination is input into the test model, and the test model outputs the result corresponding to each channel ratio combination, which is either 0 or 1. The test model is either a machine learning model or a deep learning model. For any preset multispectral image in any channel ratio combination, if the label matches the output result, the test result corresponding to that preset multispectral image is correct; if the label does not match the output result, the test result corresponding to that preset multispectral image is incorrect. The accuracy rate of each channel ratio combination is calculated for P preset multispectral images with the same channel ratio combination, and this accuracy rate is used as the precision value.
[0047] In one embodiment, all candidate channel ratio combinations in the P*S candidate channel ratio sets are sequentially input into the test model to obtain the accuracy values of all candidate channel ratio combinations; the candidate channel ratio combination with the highest accuracy value is selected as the optimal channel ratio combination; and the channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination.
[0048] Specifically, all candidate channel ratio combinations from the S*P candidate channel ratio sets can be sequentially input into the test model. For example, inputting the P channel ratio combinations corresponding to (ch1 / ch3, ch1 / ch4) into the test model will yield P output results (0 or 1). If P = 100, there are 25 0s and 75 1s, so the candidate channel ratio combination is 75%.
[0049] In one embodiment, starting from the first set of candidate channel ratios, all candidate channel ratio combinations from the P*S sets of candidate channel ratios with the same group are sequentially input into the test model to obtain the accuracy value of all candidate channel ratio combinations in the set of candidate channel ratios with the same group. The maximum accuracy value in the current set of candidate channel ratios with the same group is compared with the maximum accuracy value in the next set of candidate channel ratios with the same group, until the maximum accuracy value in the (j-1)th (2≤j≤S)th set of candidate channel ratios with the same group is greater than the maximum accuracy value in the jth set of candidate channel ratios with the same group. Then, the candidate channel ratio combination corresponding to the maximum accuracy value in the (j-1)th set is determined as the optimal channel ratio combination. The channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination.
[0050] Specifically, the candidate channel ratio set includes combinations of candidate channel ratios grouped into sets of 2, 3, 4, ..., and n-1 channel ratios. S can be equal to n-1 or any value less than n-1. When j=2, all candidate channel ratio combinations grouped into sets of 2 are sequentially input into the test model to obtain all corresponding precision values, and the highest precision value is selected. For example, in j=2, (ch1 / c The channel ratio combination (h3, ch1 / ch4) has the highest precision value of 25%. Following this, the maximum precision values are 35% for j=3, 55% for j=4, and 50% for j=5. Since the maximum precision value for j=4 is greater than that for j=5, the fourth candidate channel ratio combination corresponding to the maximum precision value of j=4 can be considered the optimal channel ratio combination. Similarly, the channel ratio combinations corresponding to the device, such as (ch1 / ch2, ch1 / ch3, ch1 / ch4, ch1 / ch5), can also be considered optimal channel ratio combinations. This method of determining the optimal channel ratio combination by comparing each set of candidate channel ratios in order of their number reduces the need to determine the precision values for subsequent sets of candidate channel ratios, thus reducing computational load and improving efficiency in determining the optimal channel ratio combination.
[0051] After determining the optimal channel ratio combination, the target multispectral data samples can be preprocessed for model training. In one embodiment, the number of channels in the preset multispectral data samples is the same as the number of channels in the target multispectral data samples. For example, if the preset multispectral data samples have 9 channels, then the target multispectral data samples also have 9 channels. This ensures that the optimal channel ratio combination determined by the preset multispectral data samples matches the optimal channel ratio combination corresponding to the target multispectral samples, improving computational accuracy.
[0052] Acquire Q target multispectral data samples, where Q is greater than or equal to 1 and is a positive integer; determine the Q target channel ratio combinations based on the Q target multispectral data samples and the optimal channel ratio combination as input to the image recognition model.
[0053] Specifically, the Q target multispectral data samples include Q target multispectral images. These target multispectral images can be the same as or different from preset multispectral images. Some of the target multispectral images are real person images, while others are prosthetic images. Processing the target multispectral images yields target spectral data for each channel. This target spectral data can be a specific grayscale value or an average grayscale value. Based on the target spectral data, the ratio corresponding to each channel ratio in the optimal channel ratio combination is calculated. The data set composed of these ratios is the target channel ratio data. In one embodiment, the target spectral data serves as the training data for the model. The image recognition model is trained using Q target channel ratio data to obtain the optimal parameters. Based on the optimal parameters, the trained image recognition model is obtained. When new target spectral data is obtained (this target spectral data refers to the image to be recognized), the corresponding channel ratio data is determined according to the optimal channel ratio combination. This channel ratio data is then input into the trained image recognition model to obtain the recognition result of the multispectral image.
[0054] The following section uses a 9-channel model as an example to illustrate the preprocessing method for the model input data provided in this application.
[0055] For the 9 channels, each channel is represented by ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, and ch9. Any two channels can form a channel ratio, as follows: Figure 3 Combining two channels in the order shown yields 36 channel ratios. The feature vector composed of these 36 channel ratios is...
[0056] [ch1 / ch9,ch2 / ch9,ch3 / ch9,ch4 / ch9,ch5 / ch9,ch6 / ch9,ch7 / ch9,ch8 / ch9,ch1 / ch8,ch2 / ch8,ch3 / ch8,ch4 / ch8,ch5 / ch8,ch6 / ch8,ch7 / ch8,ch1 / ch7,ch2 / ch7,ch3 / ch7, ch4 / ch7,ch5 / ch7,ch6 / ch7,ch1 / ch6,ch2 / ch6,ch3 / ch6,ch4 / ch6,ch5 / ch6,ch1 / ch5,ch2 / ch5,ch3 / ch5,ch4 / ch5,ch1 / ch4,ch2 / ch4,ch3 / ch4,ch1 / ch3,ch2 / ch3,ch1 / ch2].
[0057] The P preset multispectral data samples include P preset spectral images, which are acquired by a 9-channel spectral camera. The channel data corresponding to the P preset spectral images can be represented as a P*9 matrix, and the channel ratio corresponding to the P preset spectral images can be represented as a P*36 matrix.
[0058] For each preset multispectral image, the initial value of the elements in the candidate feature vector is 0 (i.e. none of them are selected), that is, the feature vector is [0 ... Each time, elements at different positions are selected from the feature vector, and the selected elements are set to 1. For example, if the feature vector is [1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], then the channel ratios corresponding to the first 9 elements are selected, and the corresponding candidate channel ratio combinations are [ch1 / ch9,ch2 / ch9,ch3 / ch9,ch4 / ch9,ch5 / ch9,ch6 / ch9,ch7 / ch9,ch8 / ch9,ch1 / ch8]. The combination of channel ratios corresponding to all selected elements is the candidate channel ratio combination.If we select one channel ratio from the 36 channel ratios each time as a candidate channel ratio combination (using 1 for simplicity, the actual scheme usually starts with 2 channel ratios), then the first group of candidate channel ratios is a combination of all candidate channel ratios obtained by assigning a value of 1 to every two elements of the feature vector in turn. That is, the feature vector is [1 0 ... 0 ... [1] There are a total of 36 feature vectors, corresponding to the selected channel ratio combinations as follows: ch1 / ch9, ch2 / ch9, ch3 / ch9, ch4 / ch9, ch5 / ch9, ch6 / ch9, ch7 / ch9, ch8 / ch9, ch1 / ch8, ch2 / ch8, ch3 / ch8, ch4 / ch8, ch5 / ch8, ch6 / ch8, ch7 / ch8, ch1 / ch7, ch2 / ch7, ch3 / ch7, ch4 / ch7 The ratio of each channel ratio can be determined based on the average gray value of each channel in the candidate channel ratio combination, ch5 / ch7, ch6 / ch7, ch1 / ch6, ch2 / ch6, ch3 / ch6, ch4 / ch6, ch5 / ch6, ch1 / ch5, ch2 / ch5, ch3 / ch5, ch4 / ch5, ch1 / ch4, ch2 / ch4, ch3 / ch4, ch1 / ch3, ch2 / ch3, ch1 / ch2.
[0059] Specifically, when the channel ratio is 36, the number of candidate channel ratio combinations with a channel ratio of 2 is 630, which are the channel ratio combinations corresponding to [ch1 / ch2,ch1 / ch3], [ch1 / ch3,ch1 / ch4], [ch1 / ch4,ch1 / ch5], [ch1 / ch5,ch1 / ch6], [ch1 / ch6,ch1 / ch7], [ch1 / ch7,ch1 / ch8], [ch1 / ch8,ch1 / ch9], [ch1 / ch8,ch1 / ch9], ... [ch1 / ch35,ch1 / ch36], [ch2 / ch3,ch2 / ch4] ... [ch7 / ch8,ch7 / ch9]. The channel ratio combination is determined based on the average gray value of each channel in each preset spectral image. All channel ratio combinations are input into the test model. The accuracy value of each channel ratio combination is calculated based on the output of the test model. The maximum accuracy value is determined from these 630 accuracy values.
[0060] The same method is used to calculate the maximum precision value when the channel ratio is 3, and then compared with the maximum precision value when the channel ratio is 2. If the maximum precision value when the channel ratio is 3 is less than the maximum precision value when the channel ratio is 2, then the maximum precision values for other channel ratios are no longer calculated. The channel ratio combination corresponding to the maximum precision value when the channel ratio is 2 is taken as the optimal channel ratio combination, and the channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination. If the maximum precision value when the channel ratio is 3 is greater than the maximum precision value when the channel ratio is 2, then the maximum precision value when the channel ratio is 4 is calculated, and so on.
[0061] For example, if the maximum precision value when the channel ratio is 8 is less than the maximum precision value when the channel ratio is 9, and the maximum precision value when the channel ratio is 10 is less than the maximum precision value when the channel ratio is 9, then the channel ratio combination corresponding to the maximum precision value when the channel ratio is 9 is taken as the optimal channel ratio combination, and the channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination.
[0062] For a preset spectral image with 9 channels, calculate the maximum precision value corresponding to the number of channels. For example... Figure 4 As shown, the horizontal axis X represents the number of channels and the vertical axis Y represents the maximum precision value. It can be seen that when the number of channels increases from 2 to 9, the maximum precision value gradually increases. When the number of channels is greater than 9, the maximum precision value begins to gradually decrease. Therefore, the channel ratio combination corresponding to the maximum precision value when the number of channels is 9 is the optimal channel ratio combination, and the channel ratio combination corresponding to the optimal channel ratio combination is the optimal channel ratio combination.
[0063] In one embodiment, the optimal channel ratio combination corresponding to the 9 channels is [ch5 / ch6, ch5 / ch2, ch5 / ch9, ch8 / ch1, ch7 / ch4, cg5 / ch7, ch9 / ch1, ch2 / ch4, ch3 / ch7]. After acquiring multiple target multispectral images, the average gray value of each target multispectral image in the 9 channels is determined. The ratio corresponding to each channel ratio in the optimal channel ratio combination is calculated based on the average gray value; the dataset composed of these ratios is the target channel ratio combination. After normalizing the target channel ratio combination, the image recognition model is trained to obtain the optimal parameters of the image recognition model. Then, based on the trained image recognition model, the target channel ratio combination to be recognized is obtained from the target multispectral image to be recognized, resulting in the final image recognition result.
[0064] In this embodiment, the optimal channel ratio combination is determined by obtaining the ratio of gray values of all pairs of channels in a preset multispectral data sample. Then, a target channel ratio combination is determined based on the target multispectral data sample and the optimal channel ratio combination. Compared to the multispectral data sample, the target channel ratio combination can reduce the impact of image acquisition distance and light source intensity on the spectral data. Training the image recognition model using the target channel ratio combination yields an image recognition model with better robustness.
[0065] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0066] Corresponding to the model input data preprocessing method in the above embodiment, Figure 5 This paper shows a structural block diagram of a preprocessing apparatus for model input data provided in an embodiment of this application. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0067] The preprocessing device for the model input data includes: a first acquisition module 51, used to acquire a set of channel ratios for P preset multispectral data samples, the set of channel ratios including the ratio of gray values of all pairs of channels in the preset multispectral data samples, wherein P is greater than or equal to 1 and is a positive integer; an optimal channel ratio combination determination module 52, used to determine an optimal channel ratio combination based on the set of channel ratios for P preset multispectral data samples, the optimal channel ratio combination including at least two channel ratios; a second acquisition module 53, used to acquire Q target multispectral data samples, wherein Q is greater than or equal to 1 and is a positive integer; and a target channel ratio combination determination module 54, used to determine Q target channel ratio combinations based on the Q target multispectral data samples and the optimal channel ratio combination as input to the image recognition model.
[0068] In one embodiment, the optimal channel ratio combination determination module 52 is specifically used to: obtain S candidate channel ratio sets based on the channel ratio set of each preset multispectral data sample in P preset multispectral data samples, wherein the i-th candidate channel ratio set includes all i-th channel ratios in the channel ratio set of each preset multispectral data sample as a candidate channel ratio combination, where n is the number of channels in each preset multispectral data sample, N is the number of channel ratios in the channel ratio set of each preset multispectral data sample, N≥i≥2, 1≤S≤n-1 and N, n, i, and S are all positive integers; input all candidate channel ratio sets in the P*S candidate channel ratio sets into the test model, and determine the optimal channel ratio combination based on the output result of the test model.
[0069] In one embodiment, the optimal channel ratio combination determination module 52 is further configured to: sequentially input all candidate channel ratio combinations from the P*S candidate channel ratio sets into the test model to obtain the accuracy values of all candidate channel ratio combinations; select the candidate channel ratio combination with the highest accuracy value as the optimal channel ratio combination; and determine the channel ratio combination corresponding to the optimal channel ratio combination as the optimal channel ratio combination.
[0070] In one embodiment, the optimal channel ratio combination determination module 52 is further configured to: starting from the first group of candidate channel ratio sets, sequentially input all candidate channel ratio combinations in the P*S candidate channel ratio sets of the same group into the test model to obtain the accuracy value of all candidate channel ratio combinations in the candidate channel ratio sets of the same group; combine the candidate channel ratio combination with the largest accuracy value in the current group with the candidate channel ratio combination with the largest accuracy value in the next group, until the maximum accuracy value of the (j-1)th group is greater than the maximum accuracy value of the jth group, then determine the candidate channel ratio combination corresponding to the maximum accuracy value of the (j-1)th group as the optimal channel ratio combination, where 2≤j≤S and j is a positive integer; and determine the channel ratio combination corresponding to the optimal channel ratio combination as the optimal channel ratio combination.
[0071] In one embodiment, the formula for calculating the number of channels is N = (n-1)*n / 2.
[0072] In one embodiment, the channel grayscale value of the multispectral data sample is the average grayscale value of a specified region corresponding to the face image.
[0073] In one embodiment, the number of channels of the preset multispectral data sample is the same as the number of channels of the target multispectral data sample.
[0074] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0075] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0076] In the embodiments provided in this application, it should be understood that the disclosed apparatus / image recognition device and method can be implemented in other ways. For example, the apparatus / image recognition device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0077] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0078] If an integrated module / unit is implemented as 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, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0079] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0080] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for preprocessing model input data, characterized in that, include: Obtain a set of channel ratios for P preset multispectral data samples. The set of channel ratios includes the ratio of gray values of all pairs of channels in the preset multispectral data samples, where P is greater than or equal to 1 and is a positive integer. The optimal channel ratio combination is determined based on the set of channel ratio values of P preset multispectral data samples, and the optimal channel ratio combination includes at least two channel ratios; Obtain Q multispectral data samples of the target, where Q is greater than or equal to 1 and is a positive integer; Based on the Q target multispectral data samples and the optimal channel ratio combination, Q target channel ratio combinations are determined as input to the image recognition model.
2. The method as described in claim 1, characterized in that, The determination of the optimal channel ratio combination based on the set of channel ratios of P preset multispectral data samples includes: Based on the channel ratio set of each of the P preset multispectral data samples, S candidate channel ratio sets are obtained. The i-th candidate channel ratio set includes all i-channel ratios in the channel ratio set of each preset multispectral data sample as a group of candidate channel ratio combinations, where n is the number of channels in each preset multispectral data sample, N is the number of channel ratios in the channel ratio set of each preset multispectral data sample, N≥i≥2, 1≤S≤n-1, and N, n, i, and S are all positive integers. Input all the candidate channel ratio sets in the P*S candidate channel ratio sets into the test model, and determine the optimal channel ratio combination based on the output of the test model.
3. The method as described in claim 2, characterized in that, The step of inputting all candidate channel ratio sets from the P*S candidate channel ratio sets into the test model, and determining the optimal channel ratio combination based on the output of the test model, includes: Input all candidate channel ratio combinations from the P*S candidate channel ratio sets into the test model in sequence to obtain the accuracy value of all candidate channel ratio combinations; The candidate channel ratio combination with the highest accuracy value is selected as the optimal channel ratio combination; The channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination.
4. The method as described in claim 2, characterized in that, The step of inputting all candidate channel ratio sets from the P*S candidate channel ratio sets into the test model, and determining the optimal channel ratio combination based on the output of the test model, includes: Starting from the first set of candidate channel ratios, all candidate channel ratio combinations from the P*S sets of candidate channel ratios that are in the same group are sequentially input into the test model to obtain the accuracy value of all candidate channel ratio combinations from the sets of candidate channel ratios that are in the same group. The maximum precision value in the current set of candidate channel ratios of the same group is compared with the maximum precision value in the next set of candidate channel ratios of the same group. This process continues until the maximum precision value in the (j-1)th set of candidate channel ratios of the same group is greater than the maximum precision value in the j-th set of candidate channel ratios of the same group. Then, the candidate channel ratio combination corresponding to the maximum precision value in the (j-1)th set is determined as the optimal channel ratio combination, where 2≤j≤S and j is a positive integer. The channel ratio combination corresponding to the optimal channel ratio combination is determined as the optimal channel ratio combination.
5. The method as described in claim 2, characterized in that, The formula for calculating the number of channels is N = (n-1) * n / 2.
6. The method as described in claim 1, characterized in that, The channel grayscale value of the multispectral data sample is the average grayscale value of the specified region corresponding to the face image.
7. The method as described in claim 1, characterized in that, The number of channels in the preset multispectral data sample is the same as the number of channels in the target multispectral data sample.
8. A preprocessing device for model input data, characterized in that, include: The first acquisition module is used to acquire a set of channel ratios for P preset multispectral data samples. The set of channel ratios includes the ratio of gray values of all pairs of channels in the preset multispectral data samples, where P is greater than or equal to 1 and is a positive integer. The optimal channel ratio combination determination module is used to determine the optimal channel ratio combination based on the set of channel ratio values of P preset multispectral data samples, wherein the optimal channel ratio combination includes at least two channel ratios; The second acquisition module is used to acquire Q target multispectral data samples, where Q is greater than or equal to 1 and is a positive integer; The target channel ratio combination determination module is used to determine Q target channel ratio combinations based on Q target multispectral data samples and the optimal channel ratio combination, so as to serve as input to the image recognition model.
9. An image recognition device, comprising a multispectral camera, a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Living body detection method and equipment
CN112580433A
Light source spectrum and multi-spectral reflectivity image obtaining methods and devices and electronic equipment
CN113340817A