Sample labeling method, device, computer equipment and storage medium

Through computer vision and neural network technology, deep feature matrices are used to calculate similarity, automatically match and obtain label information, solving the problem of low efficiency of large-scale data labeling and realizing an efficient automated labeling process.

CN112749723BActive Publication Date: 2024-10-18SF TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201911054723.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-31
Publication Date
2024-10-18
Estimated Expiration
2039-10-31

AI Technical Summary

Technical Problem

With the development of big data and deep learning, the increase in the type and volume of data sets has led to a decrease in data annotation efficiency. Existing technologies mainly rely on manual annotation and are difficult to cope with the difficulty of annotating large-scale data volumes.

Method used

By obtaining the depth feature matrix of the sample to be labeled, calculating the distance matrix with the labeled sample, determining the matching sample and obtaining its label information, automatic labeling is achieved and the labeling efficiency is improved.

Benefits of technology

There is no need for manual labeling. The neural network is used to extract the deep feature matrix to calculate the similarity and accurately match the label information of the labeled samples, which significantly improves the labeling efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112749723B_ABST
    Figure CN112749723B_ABST
Patent Text Reader

Abstract

The present application relates to a sample labeling method, device, computer equipment and storage medium. The method comprises: obtaining a sample to be labeled; inputting the sample to be labeled into a trained neural network, extracting the deep feature matrix of the sample to be labeled through the neural network; calculating a first distance matrix between the deep feature matrix of the sample to be labeled and the deep feature matrix of each first labeled sample; determining a matching sample of the sample to be labeled from the first labeled sample according to the first distance matrix; obtaining label information of the matching sample, and using the label information as the label information of the sample to be labeled. The use of this method can improve labeling efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a sample annotation method, apparatus, computer equipment and storage medium. Background Art

[0002] In recent years, with the development of big data and deep learning, various forms of data sets have emerged. As the types of data sets increase, the amount of data also increases. The increase in data volume has brought about high-precision models, laying the foundation for the implementation of algorithms in the industry.

[0003] However, when training a model based on a data set, the data needs to be labeled in advance. The existing data labeling system mainly relies on manual labeling. Therefore, the increase in data volume makes data labeling extremely difficult, which reduces the efficiency of labeling. Summary of the invention

[0004] Based on this, it is necessary to provide a sample labeling method, device, computer equipment and storage medium that can improve labeling efficiency in response to the above technical problems.

[0005] A sample labeling method, the method comprising:

[0006] Obtain samples to be labeled;

[0007] Inputting the sample to be labeled into a trained neural network, and extracting a deep feature matrix of the sample to be labeled through the neural network;

[0008] Calculate and obtain a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample;

[0009] Determining, according to the first distance matrix, matching samples of the sample to be labeled from the first labeled samples;

[0010] The label information of the matching sample is obtained, and the label information is used as the label information of the sample to be labeled.

[0011] In one embodiment, the step of calculating and obtaining a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample includes:

[0012] Obtaining a deep feature matrix of the first labeled sample;

[0013] Respectively calculating the first Euclidean distance between the deep feature matrix of the sample to be labeled and the deep feature matrix of each of the first labeled samples;

[0014] The first Euclidean distances are used as matrix elements of a first distance matrix to obtain a first distance matrix.

[0015] In one embodiment, determining a matching sample of the sample to be labeled from the first labeled samples according to the first distance matrix includes:

[0016] Selecting a first preset number of matrix elements from the first distance matrix according to the size of each matrix element in the first distance matrix;

[0017] Determine the first labeled sample corresponding to each selected matrix element and return it to the user;

[0018] Receive a matching sample selected by a user from the first labeled samples.

[0019] In one embodiment, the method further comprises:

[0020] Acquire training samples, where the training samples include second labeled samples and unlabeled samples;

[0021] Inputting the second labeled sample into a preset neural network, training the preset neural network, and obtaining a trained initial neural network;

[0022] Selecting valuable samples from the unlabeled samples;

[0023] The value samples are input into the initial neural network, and the initial neural network is iteratively trained to obtain a trained neural network.

[0024] In one embodiment, selecting valuable samples from the unlabeled samples includes:

[0025] Inputting each of the unlabeled samples into the initial neural network, and extracting a deep feature matrix of each of the unlabeled samples through the initial neural network;

[0026] Calculate and obtain a second distance matrix between the depth feature matrix of each of the unlabeled samples and the depth feature matrix of each of the second labeled samples;

[0027] According to the second distance matrix, valuable samples are selected from the unlabeled samples.

[0028] In one embodiment, the calculating and obtaining a second distance matrix between the depth feature matrix of each of the unlabeled samples and the depth feature matrix of each of the second labeled samples includes:

[0029] Obtaining a deep feature matrix of each of the second labeled samples;

[0030] Combining the deep feature matrix of any one of the unlabeled samples with the deep feature matrices of each of the second labeled samples to obtain a matrix pair;

[0031] Calculating the Euclidean distance between two deep feature matrices in each of the matrix pairs;

[0032] The Euclidean distances of the matrix pairs are used as matrix elements of a second distance matrix to obtain a second distance matrix.

[0033] In one embodiment, selecting valuable samples from the unlabeled samples according to the second distance matrix includes:

[0034] According to the size of the matrix element corresponding to each of the unlabeled samples in the second distance matrix, respectively select a second preset number of matrix elements from the corresponding matrix element for each of the unlabeled samples;

[0035] Respectively calculating the average value of a second preset number of matrix elements corresponding to each of the unlabeled samples;

[0036] According to the size of each of the average values, the unlabeled samples corresponding to each of the average values ​​are sorted;

[0037] Unlabeled samples whose ranking positions are greater than the first threshold and less than the second threshold are selected as valuable samples.

[0038] A sample labeling device, comprising:

[0039] An acquisition module is used to obtain samples to be labeled;

[0040] An extraction module, used for inputting the sample to be labeled into a trained neural network, and extracting a deep feature matrix of the sample to be labeled through the neural network;

[0041] A calculation module, used for calculating a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample;

[0042] A determination module, configured to determine, according to the first distance matrix, a matching sample of the sample to be labeled from the first labeled samples;

[0043] The labeling module is used to obtain label information of the matching sample and use the label information as label information of the sample to be labeled.

[0044] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above-mentioned sample labeling methods when executing the computer program.

[0045] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned sample labeling methods.

[0046] The above-mentioned sample labeling method, device, computer equipment and storage medium, by combining computer vision, after obtaining the sample to be labeled, use a neural network to extract the deep feature distance of the sample to be labeled, and then calculate the distance matrix based on the deep feature matrix, so as to accurately determine the similarity between the sample to be labeled and the labeled sample. Furthermore, according to the distance matrix that can represent the similarity, the corresponding labeled samples are matched, and the label information of the matched labeled samples is used as the label information of the sample to be labeled, without manual labeling, which improves the efficiency of labeling. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A diagram of an application environment of a sample labeling method in an embodiment;

[0048] Figure 2 A schematic diagram of a flow chart of a sample labeling method in an embodiment;

[0049] Figure 3 A schematic diagram of a process for training a neural network in one embodiment;

[0050] Figure 4 A flow chart of a sample labeling method in an embodiment;

[0051] Figure 5 is a structural block diagram of a sample labeling device in one embodiment;

[0052] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0054] The sample annotation method provided in this application can be applied to Figure 1In the application environment shown. The application environment involves a terminal 102 and a server 104, and the terminal 102 communicates with the server 104 through a network. After the terminal 102 receives the uploaded sample to be labeled, the terminal 102 can implement the above-mentioned sample labeling method alone. The terminal 102 can also send the received sample to be labeled to the server 104, and the server 104 implements the above-mentioned sample labeling method. Specifically, taking the terminal 102 as an example, after the terminal 102 obtains the sample to be labeled, the sample to be labeled is input into the trained neural network, and the deep feature matrix of the sample to be labeled is extracted through the neural network. The terminal 102 calculates the first distance matrix between the deep feature matrix of the sample to be labeled and the deep feature matrix of each first labeled sample. The terminal 102 determines the matching sample of the sample to be labeled from the first labeled sample according to the first distance matrix. The terminal 102 obtains the label information of the matching sample and uses the label information as the label information of the sample to be labeled. The terminal 102 may be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0055] In one embodiment, Figure 2 As shown, a sample annotation method is provided, which is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:

[0056] Step S202: Obtain samples to be labeled.

[0057] The sample to be labeled refers to the sample image that needs to be labeled at present. The sample images are different according to different application scenarios, such as images of various commodities (clothing, food, dishes, flowers, etc.).

[0058] Specifically, when it is necessary to annotate the sample image, the user can upload the sample image to be annotated to the terminal through an input device connected to the terminal or a wireless transmission function. The input device includes but is not limited to a keyboard, a mouse, and a USB (Universal Serial Bus) interface. The terminal obtains the sample to be annotated by receiving the sample image uploaded by the user. Alternatively, the user can also upload the sample image to be annotated to the terminal in advance and store it locally. When annotation is required, an annotation instruction is issued to the terminal through an input device connected to the terminal to instruct the terminal to perform a sample annotation task. The terminal can obtain the corresponding sample image from the local as the sample to be annotated through the annotation instruction.

[0059] Step S204: input the sample to be labeled into the trained neural network, and extract the deep feature matrix of the sample to be labeled through the neural network.

[0060] Among them, the neural network is a model that explores and simulates the functions of the human brain's nervous system by modeling and connecting the basic unit neurons of the human brain, and develops an artificial system with functional information processing functions such as learning, association, memory and pattern recognition. In general, a neural network is an algorithmic mathematical model for distributed parallel information processing. In this embodiment, the neural network is a model that has been pre-trained with training samples and is used to extract deep features of samples to be labeled, including but not limited to convolutional neural networks, fast convolutional neural networks, deep residual networks, and multi-granularity networks. Since this embodiment requires fine-grained classification and recognition of samples to be labeled, this embodiment preferably uses a multiple granularity network (Multiple Granularity Network).

[0061] The basic network of the multi-granularity network is based on ResNet-50 (50-layer residual network). The first three layers of ResNet-50 are used to extract the basic features of the sample image, and three branches are used for high-level semantic features. The first branch is responsible for extracting the global feature information of the entire image, the second branch is used to divide the image into two parts, the upper and lower parts, to extract medium-grained feature information, and the third branch is used to divide the image into three parts, the upper, middle and lower parts, so as to extract finer-grained feature information. The features of the last three branches are subjected to maximum pooling and dimensionality reduction operations, and the final results are judged by Softmax (logistic regression) or Triplet loss (triplet loss function). Among them, the deep feature matrices extracted by the three branches of the multi-granularity network are 256 dimensions, 512 dimensions and 1024 dimensions respectively.

[0062] Specifically, after the terminal obtains the sample to be labeled, the pre-trained neural network is called. The sample to be labeled is input into the neural network, and the feature of the sample to be labeled is extracted through the neural network to obtain the deep feature matrix of the sample to be labeled. Taking the multi-granularity network as an example, the sample to be labeled is input into the multi-granularity network. First, the basic features of the sample to be labeled are extracted through the basic network ResNet-50 of the multi-granularity network. Then the basic features are input into the three branches respectively, and the three branches respectively extract the 256-dimensional deep feature matrix, 512-dimensional deep feature matrix and 1024-dimensional deep feature matrix of the sample to be labeled.

[0063] It should be understood that, since different neural networks accept different sizes of input images, when the size of the sample to be labeled does not meet the image size received by the multi-granularity network, the sample to be labeled should be preprocessed to make it meet the conditions of the multi-granularity network input image. Preprocessing includes but is limited to scaling, cropping, etc. Similarly, if the image quality is to be avoided by the neural network, the sample to be labeled can also be preprocessed such as denoising to ensure the quality of the image.

[0064] Step S206: Calculate and obtain a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample.

[0065] The first labeled sample refers to a sample image that has been labeled, including labeled samples used to train a neural network. In mathematics, a distance matrix is ​​a matrix containing distances between a set of points. In this embodiment, the first distance matrix is ​​a matrix containing similarities between the sample to be labeled and each first labeled sample.

[0066] Specifically, after the deep feature matrix of the sample to be labeled is extracted by the trained neural network, the deep feature matrix of each first labeled sample is obtained. The deep feature matrix of the first labeled sample can be obtained by extracting the first labeled sample in real time using the trained neural network, or it can be extracted in advance using the neural network. After the deep feature matrix of each first labeled sample is obtained, the Euclidean distance between the deep feature matrix of the sample to be labeled and the deep feature matrix of each first labeled sample is calculated respectively. The Euclidean distance indicates the similarity between the sample to be labeled and the first labeled sample. The larger the Euclidean distance, the greater the difference between the two images. The smaller the Euclidean distance, the smaller the difference between the two images, and the more similar. After the Euclidean distance between the deep feature matrix of the sample to be labeled and the deep feature matrix of each first labeled sample is calculated, the Euclidean distance is used as a matrix element to obtain a first distance matrix. For example, assuming the sample to be labeled A, the first labeled samples B1, B2, and B3. Then the Euclidean distance AB1 between A and B1, the Euclidean distance AB2 between A and B2, and the Euclidean distance AB3 between A and B3 can be calculated. The first distance matrix with AB1, AB2, and AB3 as matrix elements is shown in Table 1 below:

[0067] Table 1: First distance matrix

[0068]

[0069] Step S208: determining matching samples of the sample to be labeled from the first labeled samples according to the first distance matrix.

[0070] The matching sample refers to the first labeled sample that has the highest similarity with the sample to be labeled.

[0071] Specifically, after obtaining the first distance matrix, the matrix element with the smallest element value is determined from the first distance matrix according to the size of each matrix element in the first distance matrix. The first labeled sample corresponding to the matrix element is the matching sample of the sample to be labeled. Because the matrix element of the first distance matrix is ​​the Euclidean distance between the sample to be labeled and the first labeled sample, selecting the matrix element with the smallest element value is to select the smallest Euclidean distance, and the first labeled sample corresponding to the smallest Euclidean distance has the highest similarity with the sample to be labeled. For example, taking the above Table 1 as an example, assuming that AB2 is smaller than AB1 and AB3, the first labeled sample B2 corresponding to AB2 is the matching sample of the sample A to be labeled.

[0072] Step S210, obtaining label information of the matching sample, and using the label information as label information of the sample to be labeled.

[0073] The label information is the label information marked on the sample, and the label information can be limited according to the actual sample. Taking the commodity as an example, the label information includes but is not limited to the name, brand, type, color, flavor, etc.

[0074] Specifically, after a matching sample with the sample to be labeled is determined from each first labeled sample, the label information of the matching sample can be obtained because the matching sample is a labeled sample. Then, the label information is used as the label information of the sample to be labeled to complete the labeling of the sample to be labeled. After the sample to be labeled is labeled, it can be added to the first labeled sample and matched with the next sample to be labeled.

[0075] The above sample labeling method, by combining computer vision, uses a neural network to extract the depth feature distance of the sample to be labeled after obtaining the sample to be labeled, and then calculates the distance matrix based on the depth feature matrix, so as to accurately determine the similarity between the sample to be labeled and the labeled sample. Furthermore, the corresponding labeled samples are matched according to the distance matrix that can represent the similarity, and the label information of the matched labeled samples is used as the label information of the sample to be labeled, without manual labeling, which improves the efficiency of labeling.

[0076] In one embodiment, calculating the first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrices of each first labeled sample specifically includes: obtaining the depth feature matrix of the first labeled sample; respectively calculating the first Euclidean distance between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample; using each first Euclidean distance as a matrix element of the first distance matrix to obtain the first distance matrix.

[0077] Specifically, when calculating the first distance matrix, first obtain the deep feature matrix of each first labeled sample obtained by using the neural network. Then, the deep feature matrix of the sample to be labeled is respectively calculated with the deep feature matrix of each first labeled sample to obtain the corresponding first Euclidean distance. Finally, the first Euclidean distance is used as an element of the matrix to obtain the first distance matrix. Euclidean distance in mathematics is the straight-line distance between two points in Euclidean space. In this embodiment, the Euclidean distance calculation formula of the two deep feature matrices is as follows:

[0078]

[0079] Wherein, D is the first Euclidean distance, i is the number of rows of the deep feature matrix, j is the number of columns of the deep feature matrix, U represents the deep feature matrix of the sample to be labeled, and L represents the deep feature matrix of the first labeled sample. Since the deep features extracted by the three branches of the multi-granularity network are 256 dimensions, 512 dimensions, and 1024 dimensions respectively. When calculating the Euclidean distance, the acquired deep feature matrix can be one or more of 256 dimensions, 512 dimensions, and 1024 dimensions. It should be understood that when calculating the Euclidean distance, the dimension of the deep feature matrix of the sample to be labeled should be consistent with the dimension of the deep feature matrix of the first labeled sample. That is, if the deep feature matrix of the sample to be labeled acquires 256 dimensions, the deep feature matrix of the first labeled sample should also be 256 dimensions. In this embodiment, the similarity between each labeled sample and the sample to be labeled can be accurately determined by calculating the Euclidean distance, so as to facilitate the subsequent matching of the corresponding samples for the samples to be labeled.

[0080] In one embodiment, determining matching samples of the samples to be labeled from the first labeled samples according to the first distance matrix specifically includes: selecting a first preset number of matrix elements from the first distance matrix according to the size of each matrix element in the first distance matrix; determining the first labeled samples corresponding to each selected matrix element and returning them to the user; and receiving matching samples selected by the user from the first labeled samples.

[0081] The first preset number is a preset value of candidate matching samples, which may be 5, 10, 15, etc. The first preset number is not specifically limited in this embodiment and may be set according to actual needs.

[0082] Specifically, when matching samples from the first labeled samples, in addition to determining that the first labeled sample corresponding to the smallest matrix element in the first distance matrix is ​​a matching sample. It is also possible to select the same number of matrix elements as the first preset number from the first distance matrix according to the size of each matrix element in the first matrix through a preset first preset number. Then, the first labeled sample corresponding to the selected matrix element is returned to the labeler, that is, displayed on a display device connected to the terminal for selection by the labeler. After the labeler clicks to confirm the selected first labeled sample through the input device, the first labeled sample selected by the labeler is used as a matching sample. For example, if the first preset number is 5, 5 matrix elements can be selected in order from small to large according to the size of the matrix elements in the first distance matrix. The 5 matrix elements are the 5 matrix elements with the smallest values ​​in the first distance matrix, and the corresponding 5 first labeled samples are the 5 samples most similar to the sample to be labeled. Then, the 5 first labeled samples corresponding to the 5 matrix elements are obtained and returned to the labeler for display, and the labeler selects one from the 5 first labeled samples as a matching sample. In this implementation, a preset number of recommended candidate samples are selected for the annotator to finally select matching samples. On the basis of improving the annotation efficiency, the accuracy of annotation is further improved through human participation in decision-making.

[0083] In one embodiment, Figure 3 As shown, before obtaining the sample to be labeled, a step of training the neural network is also included, which specifically includes the following steps:

[0084] Step S302: Acquire training samples, where the training samples include second labeled samples and unlabeled samples.

[0085] Training samples refer to data sets used to train neural networks, including labeled second labeled samples and unlabeled samples that have not been labeled. Training samples can be manually collected using an image acquisition device (camera, terminal with camera function), or obtained from an open source data library. The second labeled samples are samples that are obtained after the labeling personnel select a small number of representative samples from the training samples and label them using labeling tools. The second labeled samples refer to samples used to train the initial neural network. Unlabeled samples are samples that have not been labeled by labelers, and are used to select valuable samples and perform iterative training on the initial neural network. After obtaining the second labeled samples and unlabeled samples, the second labeled samples and unlabeled samples can be uploaded to the terminal as training samples.

[0086] Step S304: input the second labeled sample into a preset neural network, train the preset neural network, and obtain a trained initial neural network.

[0087] Specifically, after the training sample is obtained, the preset neural network is called. The preset neural network is a neural network (multi-granularity network) that has been pre-configured with a network structure but has not been trained with sample annotation. After initializing the preset neural network parameters, the second annotated sample in the training sample is input into the preset neural network, and the second annotated sample is used to complete the preliminary training of the preset neural network to obtain the initial neural network.

[0088] Step S306: selecting valuable samples from unlabeled samples.

[0089] Among them, valuable samples are valuable unlabeled samples, which can be understood as difficult examples. By selecting valuable samples to iteratively train the initial neural network, it is helpful to improve the accuracy of the network.

[0090] In one embodiment, selecting valuable samples from unlabeled samples specifically includes: inputting each unlabeled sample into an initial neural network, extracting a deep feature matrix of each unlabeled sample through the initial neural network; calculating a second distance matrix between the deep feature matrix of each unlabeled sample and the deep feature matrix of each second labeled sample; and selecting valuable samples from the unlabeled samples based on the second distance matrix.

[0091] The second distance matrix is ​​the distance matrix between the unlabeled sample and the second labeled sample.

[0092] Specifically, after the initial neural network is trained, value samples with valid values ​​can be selected from the unlabeled samples. The selection of value samples is to input each unlabeled sample into the initial neural network for feature extraction to obtain a deep feature matrix of the unlabeled sample. Similarly, the second distance matrix between the deep feature matrix of each unlabeled sample and the deep feature matrix of each second labeled sample is calculated. Then, after sorting each second labeled sample according to the size of each matrix element in the second distance matrix, select the sample that meets the requirements as the value sample.

[0093] Step S308, inputting the value samples into the initial neural network, iteratively training the initial neural network, and obtaining a trained neural network.

[0094] Specifically, after selecting the value samples, the value samples are labeled. The value samples can be returned to the labeling personnel, who can directly label the value samples using the labeling tools. Since the value samples are selected from the unlabeled samples from which the deep feature matrix has been extracted. Therefore, the Euclidean distance between the deep feature matrix of the value sample and the deep feature matrix of each second labeled sample can be used to select a first preset number of second labeled samples as candidate samples for the labeling personnel to select the final matching samples. The label information of the matching sample corresponding to the value sample is used as the label information of the value sample, thereby completing the labeling of the value sample.

[0095] The labeled value samples are input into the initial neural network for iterative training. It should be understood that the value samples can be used alone to iteratively train the initial neural network, or the value samples can be added to the second labeled samples to obtain an updated second labeled sample iterative training neural network. After this iterative training is completed, if the total number of labeled samples currently used is sufficient, the training can be stopped to obtain a trained neural network. If the labeled samples used are still insufficient after this iterative training, value samples can be selected from the unlabeled samples again for iterative training until the data set used for training is sufficient. Among them, unlabeled samples can be continuously added according to actual needs, for example, new samples can be collected and added to the unlabeled samples. In this embodiment, after the initial neural network is obtained through pre-training, valuable samples are automatically selected to iteratively train the neural network, thereby improving the accuracy of the classification model.

[0096] In one embodiment, a second distance matrix between a depth feature matrix of each unlabeled sample and a depth feature matrix of each second labeled sample is calculated, specifically comprising: obtaining a depth feature matrix of each second labeled sample; combining the depth feature matrix of any unlabeled sample with the depth feature matrix of each second labeled sample to obtain a matrix pair; calculating the Euclidean distance between two depth feature matrices in each matrix pair; and using the Euclidean distance of each matrix pair as a matrix element of a second distance matrix to obtain a second distance matrix.

[0097] Specifically, after using the initial neural network to obtain the deep feature matrix of each unlabeled sample, the deep feature matrix of each unlabeled sample is calculated with the deep feature matrix of each second labeled sample to obtain the corresponding Euclidean distance. That is, each unlabeled sample must determine its similarity with the second labeled sample. Specifically, the deep feature matrix of the unlabeled sample can be respectively combined with the deep feature matrix of each second labeled sample to form a matrix pair, and the matrix pair includes a deep feature matrix of the unlabeled sample and a deep feature matrix of the labeled sample. After forming a matrix pair, the Euclidean distance of the two deep feature matrices in the matrix pair can be calculated. Then the Euclidean distance of the matrix pair is used as the matrix element to obtain the second distance matrix. For example, if the unlabeled samples include 1, 2, 3, 4, the second labeled samples include 1, 2, 3...n. The matrix pairs are (1,1), (1,2), (1,3)...(1,n), (2,1), (2,2), (2,3)...(2,n), (3,1), (3,2), (3,3)...(3,n), (4,1), (4,2), (4,3)...(4,n), and the corresponding Euclidean distances are 11, 12, 13..., 1n, 21, 22, 23..., 2n, 31, 32, 33..., 3n, 41, 42, 43..., 4n. Then, the second distance matrix can be shown in Table 2 below:

[0098] Table 2: Second distance matrix

[0099]

[0100] In one embodiment, according to the second distance matrix, valuable samples are selected from unlabeled samples, specifically including: according to the size of the matrix elements corresponding to each unlabeled sample in the second distance matrix, selecting a second preset number of matrix elements from the corresponding matrix elements for each unlabeled sample; calculating the average value of the second preset number of matrix elements corresponding to each unlabeled sample; according to the size of each average value, sorting the unlabeled samples corresponding to each average value; selecting unlabeled samples whose sorting position is greater than the first threshold and less than the second threshold as value samples.

[0101] Among them, the second preset number refers to the numerical value pre-set for selecting the corresponding number of matrix elements for the unlabeled samples. The first threshold and the second threshold are the ranking values ​​pre-set for selecting valuable samples. The second preset number, the first threshold and the second threshold can be set according to the actual situation. In this embodiment, the second preset number is preferably 5. The first threshold is preferably 30%, and the second threshold is preferably 50%. Because according to the actual situation, the second labeled samples ranked in the top 30% are already samples that are very similar to the unlabeled samples. The initial neural network has been trained with the second labeled samples and has fully learned the characteristics of this type of image, so there is no need to learn again. Therefore, the second labeled samples before 30% are worthless samples. And at 50% is very likely to be noise data, or a sample type that the initial neural network is currently very unfamiliar with, and can wait for subsequent iterations to use.

[0102] Specifically, after obtaining the second distance matrix, according to the size of the matrix element corresponding to each unlabeled sample, a second preset number of matrix elements are selected for each unlabeled sample from small to large. Taking the above Table 2 as an example, that is, unlabeled sample 1, the first 5 matrix elements are selected from the corresponding matrix elements 11, 12, 13..., 1n according to the rule from small to large. The selection rules of the matrix elements of unlabeled sample 2, unlabeled sample 3 and unlabeled sample 4 are the same as those of unlabeled sample 1, and will not be repeated here.

[0103] Then, calculate the average value of the selected 5 matrix elements. According to the size of the average value of each unlabeled sample, sort the unlabeled sample 1, unlabeled sample 2, unlabeled sample 3 and unlabeled sample 4 from small to large. Finally, select the corresponding unlabeled samples according to the first threshold and the second threshold. For example, according to the order of the average value from small to large, it is unlabeled sample 1, unlabeled sample 2, unlabeled sample 3, and unlabeled sample 4. Then, the first 30% of the samples are unlabeled sample 1, and the last 50% of the samples are unlabeled sample 3 and unlabeled sample 4, that is, the sample that is less than the first threshold and greater than the second threshold is unlabeled sample 2, and unlabeled sample 2 is the value sample.

[0104] In one embodiment, Figure 4 As shown, a sample labeling process framework diagram is provided. The sample labeling method is explained in detail according to the sample labeling process framework diagram.

[0105] S1, obtaining a labeled sample set used for training, and using the labeled samples in the labeled sample set used for training to train a preset neural network model to obtain a trained neural network.

[0106] S2, using the initial neural network model, extract the deep feature matrix of the unlabeled samples in the unlabeled sample set used for training. Then, the distance matrix is ​​calculated based on the deep feature matrix of the unlabeled samples and the deep feature matrix of the labeled samples in S1. From the distance matrix, 5 corresponding matrix elements are selected from small to large for each unlabeled sample, and the average value of these 5 matrix elements is calculated. According to the average value of each unlabeled sample, the unlabeled samples are sorted from small to large, and the unlabeled samples with a sorting position greater than 30% and less than 50% are selected as value samples.

[0107] S3, since the value sample is selected from the unlabeled sample in S2. Therefore, directly match the value sample with the first preset number of candidate matching samples from each matrix element corresponding to the value sample in the distance matrix in S2. Return the candidate matching samples to the labeler, who selects the final matching samples from the candidate matching samples. Use the label information of the matching sample as the label information of the value sample. Alternatively, the value sample can be directly returned to the labeler for labeling.

[0108] S4: Add the value samples with existing label information as labeled samples to the labeled sample set to obtain an updated labeled sample set. Then, return to S1 and iteratively train the neural network using the updated labeled sample set. Repeat steps S1-S4 until the data set in the labeled sample set meets the actual data volume required, and then stop training the model.

[0109] S5, after obtaining the trained neural network, the trained neural network can be used to perform sample labeling tasks. That is, obtain the sample to be labeled, input the sample to be labeled into the trained neural network, and extract the deep feature matrix of the sample to be labeled through the neural network. Calculate the Euclidean distance between the deep feature matrix of the sample to be labeled and the deep feature matrix of each labeled sample in the labeled sample set obtained by S1-S4 respectively, and use the obtained Euclidean distances as matrix elements to obtain the distance matrix between the sample to be labeled and each labeled sample. Then, according to the size of each matrix element in the distance matrix between the sample to be labeled and each labeled sample, select the smallest matrix element as the matching sample of the sample to be labeled. It is also possible to select a first preset number of candidate samples and return them to the labeling personnel, who will select the final matching sample from the candidate samples. Finally, use the label information of the matching sample corresponding to the sample to be labeled as the label information of the sample to be labeled to complete the labeling of the sample to be labeled.

[0110] It should be understood that after the labeling of the sample to be labeled is completed, the sample to be labeled can be added to the labeled sample set as a labeled sample. When a certain number of labeled samples to be labeled are added to the labeled sample set, the labeled sample set can be used to train the neural network again to ensure the subsequent accuracy of the neural network.

[0111] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0112] In one embodiment, Figure 5 As shown, a sample annotation device is provided, including: an acquisition module 502, an extraction module 504, a calculation module 506, a determination module 508 and an annotation module 510, wherein:

[0113] The acquisition module 502 is used to acquire samples to be labeled.

[0114] The extraction module 504 is used to input the sample to be labeled into the trained neural network, and obtain the deep feature matrix of the sample to be labeled through the neural network.

[0115] The calculation module 506 is used to calculate a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample.

[0116] The determination module 508 is configured to determine matching samples of the sample to be labeled from the first labeled samples according to the first distance matrix.

[0117] The labeling module 510 is used to obtain label information of the matching sample and use the label information as label information of the sample to be labeled.

[0118] In one embodiment, the calculation module 506 is also used to obtain the depth feature matrix of the first labeled sample; calculate the first Euclidean distance between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample; use each first Euclidean distance as a matrix element of the first distance matrix to obtain the first distance matrix.

[0119] In one embodiment, the determination module 508 is also used to select a first preset number of matrix elements from the first distance matrix based on the size of each matrix element in the first distance matrix; determine the first labeled samples corresponding to each selected matrix element and return them to the user; and receive matching samples selected by the user from the first labeled samples.

[0120] In one embodiment, the sample labeling device also includes a training module for obtaining training samples, the training samples include a second labeled sample and an unlabeled sample; inputting the second labeled sample into a preset neural network, training the preset neural network, and obtaining a trained initial neural network; selecting valuable samples from the unlabeled samples; inputting the valuable samples into the initial neural network, iteratively training the initial neural network, and obtaining a trained neural network.

[0121] In one embodiment, the training module is also used to input each unlabeled sample into an initial neural network, extract a deep feature matrix of each unlabeled sample through the initial neural network; calculate a second distance matrix between the deep feature matrix of each unlabeled sample and the deep feature matrix of each second labeled sample; and select valuable samples from the unlabeled samples based on the second distance matrix.

[0122] In one embodiment, the training module is also used to obtain the deep feature matrix of each second labeled sample; combine the deep feature matrix of any unlabeled sample with the deep feature matrix of each second labeled sample to obtain a matrix pair; calculate the Euclidean distance between the two deep feature matrices in each matrix pair; use the Euclidean distance of each matrix pair as the matrix element of the second distance matrix to obtain the second distance matrix.

[0123] In one embodiment, the training module is also used to select a second preset number of matrix elements from the corresponding matrix elements for each unlabeled sample according to the size of the matrix elements corresponding to each unlabeled sample in the second distance matrix; calculate the average value of the second preset number of matrix elements corresponding to each unlabeled sample; sort the unlabeled samples corresponding to each average value according to the size of each average value; and select unlabeled samples whose sorting position is greater than the first threshold and less than the second threshold as value samples.

[0124] For the specific definition of the sample annotation device, please refer to the definition of the sample annotation method above, which will not be repeated here. Each module in the above-mentioned sample annotation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0125] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a sample annotation method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0126] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0127] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0128] Obtain samples to be labeled;

[0129] Input the sample to be labeled into the trained neural network, and extract the deep feature matrix of the sample to be labeled through the neural network;

[0130] Calculate and obtain a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample;

[0131] Determine, according to the first distance matrix, a matching sample of the sample to be labeled from the first labeled samples;

[0132] Get the label information of the matching sample and use the label information as the label information of the sample to be labeled.

[0133] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0134] Obtain the deep feature matrix of the first labeled sample; calculate the first Euclidean distances between the deep feature matrix of the sample to be labeled and the deep feature matrices of each first labeled sample; use each first Euclidean distance as a matrix element of the first distance matrix to obtain the first distance matrix.

[0135] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0136] According to the size of each matrix element in the first distance matrix, a first preset number of matrix elements are selected from the first distance matrix; the first labeled samples corresponding to each selected matrix element are determined and returned to the user; and the matching samples selected by the user from the first labeled samples are received.

[0137] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0138] Acquire training samples, which include second labeled samples and unlabeled samples; input the second labeled samples into a preset neural network, train the preset neural network, and obtain a trained initial neural network; select value samples from the unlabeled samples; input the value samples into the initial neural network, iteratively train the initial neural network, and obtain a trained neural network.

[0139] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0140] Each unlabeled sample is input into an initial neural network, and a deep feature matrix of each unlabeled sample is extracted through the initial neural network; a second distance matrix between the deep feature matrix of each unlabeled sample and the deep feature matrix of each second labeled sample is calculated; and valuable samples are selected from the unlabeled samples according to the second distance matrix.

[0141] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0142] Obtain the deep feature matrix of each second labeled sample; combine the deep feature matrix of any unlabeled sample with the deep feature matrix of each second labeled sample to obtain a matrix pair; calculate the Euclidean distance of the two deep feature matrices in each matrix pair; use the Euclidean distance of each matrix pair as the matrix element of the second distance matrix to obtain the second distance matrix.

[0143] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0144] According to the size of the matrix elements corresponding to each unlabeled sample in the second distance matrix, a second preset number of matrix elements are selected from the corresponding matrix elements for each unlabeled sample; the average value of the second preset number of matrix elements corresponding to each unlabeled sample is calculated respectively; according to the size of each average value, the unlabeled samples corresponding to each average value are sorted; and the unlabeled samples whose sorting position is greater than the first threshold and less than the second threshold are selected as value samples.

[0145] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0146] Obtain samples to be labeled;

[0147] Input the sample to be labeled into the trained neural network, and extract the deep feature matrix of the sample to be labeled through the neural network;

[0148] Calculate and obtain a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample;

[0149] Determine, according to the first distance matrix, a matching sample of the sample to be labeled from the first labeled samples;

[0150] Get the label information of the matching sample and use the label information as the label information of the sample to be labeled.

[0151] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0152] Obtain the deep feature matrix of the first labeled sample; calculate the first Euclidean distances between the deep feature matrix of the sample to be labeled and the deep feature matrices of each first labeled sample; use each first Euclidean distance as a matrix element of the first distance matrix to obtain the first distance matrix.

[0153] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0154] According to the size of each matrix element in the first distance matrix, a first preset number of matrix elements are selected from the first distance matrix; the first labeled samples corresponding to each selected matrix element are determined and returned to the user; and the matching samples selected by the user from the first labeled samples are received.

[0155] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0156] Acquire training samples, which include second labeled samples and unlabeled samples; input the second labeled samples into a preset neural network, train the preset neural network, and obtain a trained initial neural network; select value samples from the unlabeled samples; input the value samples into the initial neural network, iteratively train the initial neural network, and obtain a trained neural network.

[0157] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0158] Each unlabeled sample is input into an initial neural network, and a deep feature matrix of each unlabeled sample is extracted through the initial neural network; a second distance matrix between the deep feature matrix of each unlabeled sample and the deep feature matrix of each second labeled sample is calculated; and valuable samples are selected from the unlabeled samples according to the second distance matrix.

[0159] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0160] Obtain the deep feature matrix of each second labeled sample; combine the deep feature matrix of any unlabeled sample with the deep feature matrix of each second labeled sample to obtain a matrix pair; calculate the Euclidean distance of the two deep feature matrices in each matrix pair; use the Euclidean distance of each matrix pair as the matrix element of the second distance matrix to obtain the second distance matrix.

[0161] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0162] According to the size of the matrix elements corresponding to each unlabeled sample in the second distance matrix, a second preset number of matrix elements are selected from the corresponding matrix elements for each unlabeled sample; the average value of the second preset number of matrix elements corresponding to each unlabeled sample is calculated respectively; according to the size of each average value, the unlabeled samples corresponding to each average value are sorted; and the unlabeled samples whose sorting position is greater than the first threshold and less than the second threshold are selected as value samples.

[0163] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0164] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0165] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A sample labeling method, the method comprising: Obtain samples to be labeled; Inputting the sample to be labeled into a trained neural network, and extracting a deep feature matrix of the sample to be labeled through the neural network; Calculate and obtain a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample; Determining, according to the first distance matrix, matching samples of the sample to be labeled from the first labeled samples; Obtaining label information of the matching sample, and using the label information as label information of the sample to be labeled; The method further comprises: Acquire training samples, where the training samples include second labeled samples and unlabeled samples; Inputting the second labeled sample into a preset neural network, training the preset neural network, and obtaining a trained initial neural network, wherein the preset neural network is a neural network with a pre-configured network structure and has not been trained with sample labeling; Inputting each of the unlabeled samples into the initial neural network, and extracting a deep feature matrix of each of the unlabeled samples through the initial neural network; Obtaining a deep feature matrix of each of the second labeled samples; Combining the deep feature matrix of any one of the unlabeled samples with the deep feature matrices of each of the second labeled samples to obtain a matrix pair; Calculating the Euclidean distance between two deep feature matrices in each of the matrix pairs; Taking the Euclidean distances of the matrix pairs as matrix elements of a second distance matrix, to obtain a second distance matrix; According to the size of the matrix element corresponding to each of the unlabeled samples in the second distance matrix, respectively select a second preset number of matrix elements from the corresponding matrix element for each of the unlabeled samples; Respectively calculating the average value of a second preset number of matrix elements corresponding to each of the unlabeled samples; According to the size of each of the average values, the unlabeled samples corresponding to each of the average values ​​are sorted; Select unlabeled samples whose ranking position is greater than the first threshold and less than the second threshold as valuable samples; The value samples are input into the initial neural network, and the initial neural network is iteratively trained to obtain a trained neural network.

2. The method according to claim 1, characterized in that The step of calculating and obtaining a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample includes: Obtaining a deep feature matrix of the first labeled sample; Respectively calculating the first Euclidean distance between the deep feature matrix of the sample to be labeled and the deep feature matrix of each of the first labeled samples; The first Euclidean distances are used as matrix elements of a first distance matrix to obtain a first distance matrix.

3. The method according to claim 1, characterized in that The step of determining, according to the first distance matrix, a matching sample of the sample to be labeled from the first labeled samples includes: Selecting a first preset number of matrix elements from the first distance matrix according to the size of each matrix element in the first distance matrix; Determine the first labeled sample corresponding to each selected matrix element and return it to the user; Receive a matching sample selected by a user from the first labeled samples.

4. A sample labeling device, characterized in that: The device comprises: An acquisition module is used to obtain samples to be labeled; An extraction module, used for inputting the sample to be labeled into a trained neural network, and extracting a deep feature matrix of the sample to be labeled through the neural network; A calculation module, used for calculating a first distance matrix between the depth feature matrix of the sample to be labeled and the depth feature matrix of each first labeled sample; A determination module, configured to determine, according to the first distance matrix, a matching sample of the sample to be labeled from the first labeled samples; A labeling module, used to obtain label information of the matching sample and use the label information as label information of the sample to be labeled; A training module is used to obtain training samples, wherein the training samples include second labeled samples and unlabeled samples; input the second labeled samples into a preset neural network, train the preset neural network, and obtain a trained initial neural network, wherein the preset neural network is a neural network with a pre-configured network structure and has not been trained with sample labeling; input each of the unlabeled samples into the initial neural network, extract the deep feature matrix of each of the unlabeled samples through the initial neural network; obtain the deep feature matrix of each of the second labeled samples; combine the deep feature matrix of any one of the unlabeled samples with the deep feature matrix of each of the second labeled samples to obtain a matrix pair; calculate each of the matrix pairs The Euclidean distance between the two deep feature matrices in the example embodiment of the present invention is as follows: the Euclidean distance between each of the matrix pairs is used as the matrix element of the second distance matrix to obtain the second distance matrix; according to the size of the matrix element corresponding to each of the unlabeled samples in the second distance matrix, a second preset number of matrix elements are selected from the corresponding matrix elements for each of the unlabeled samples; the average value of the second preset number of matrix elements corresponding to each of the unlabeled samples is calculated respectively; according to the size of each of the average values, the unlabeled samples corresponding to each of the average values ​​are sorted; the unlabeled samples whose sorting position is greater than the first threshold and less than the second threshold are selected as value samples; the value samples are input into the initial neural network, and the initial neural network is iteratively trained to obtain a trained neural network.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Face information labelling method and device and storage medium

    CN107808149A