Image processing method, device and electronic equipment
The feature extraction model is used to select and match candidate sample images for directional training of the target detection model, which solves the problem of limited generalization ability of the detection model, improves the detection accuracy of difficult sample images, and reduces labor costs.
Patent Information
- Application Number
- CN202210113499.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-30
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-01-30
AI Technical Summary
Existing detection models have limited generalization capabilities when generalizing images of different categories. In particular, the detection accuracy for images of a small number of categories (difficult sample images) is poor, resulting in the occurrence of bad cases, and the cost of manual screening of difficult sample images is high.
Use the feature extraction model to filter and match candidate sample images as training data, use the pre-trained feature extraction model to match the detection results of the target sample image and the candidate sample image, and select candidate sample images with similar features for directional training of the target detection model to improve Check the generalization ability of the model.
It effectively improves the generalization ability of the detection model to difficult sample images, reduces the occurrence of bad cases, reduces the cost of manual screening, and improves the accuracy of the detection model.
Smart Images

Figure CN114445811B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of deep learning and computer vision technology, and can be applied to application scenarios such as OCR (Optical Character Recognition), and in particular to an image processing method, device, and electronic device. Background Art
[0002] The detection model trained based on deep learning can detect the location of a specific object in an image. In the process of training the detection model, the number of images of different categories in the sample images used to train the detection model is often different, so the efficiency of using different categories of images to train the detection model in the subsequent training process is different. Summary of the invention
[0003] The present disclosure provides an image processing method, an image processing device and an electronic device.
[0004] According to a first aspect of the present disclosure, there is provided an image processing method, comprising:
[0005] Inputting a target sample image and a detection result of the target sample image into a pre-trained feature extraction model to obtain a target sample feature of the target sample image output by the feature extraction model, wherein the detection result is used to indicate a position of an object in the sample image;
[0006] For each candidate sample image, input the candidate sample image and the detection result of the candidate sample image into the feature extraction model to obtain the candidate sample feature of the candidate sample image output by the feature extraction model;
[0007] Selecting a matching candidate sample image from each of the candidate sample images as a sample image for training a target detection model, wherein the candidate sample features of the matching candidate sample image match the target sample features;
[0008] The feature extraction model is pre-trained with multiple sets of training data, each set of training data includes: at least one sample image pair, a label indicating whether two sample images in the sample image pair are similar, and two samples in the sample image pair are annotated with detection results.
[0009] According to a second aspect of the present disclosure, a feature extraction model training method is provided, comprising:
[0010] For each sample image in each sample image pair, the sample image and the detection result in the sample image are input into the original model to obtain the sample features output by the original model;
[0011] For each sample-sample image pair, calculating the similarity between the sample features of two sample images in the sample image pair;
[0012] For each sample-sample image pair, the model parameters of the original model are adjusted according to the similarity and the label used to indicate whether the two sample images in the sample image pair are similar, until a preset convergence condition is reached, and the adjusted original model is used as a feature extraction model.
[0013] According to a third aspect of the present disclosure, there is provided an image processing apparatus, comprising:
[0014] A first feature extraction module, used for inputting a target sample image and a detection result of the target sample image into a pre-trained feature extraction model, and obtaining a target sample feature of the target sample image output by the feature extraction model, wherein the detection result is used to indicate a position of an object in the sample image;
[0015] A second feature extraction module is used for inputting, for each candidate sample image, the candidate sample image and the detection result of the candidate sample image into the feature extraction model to obtain the candidate sample feature of the candidate sample image output by the feature extraction model;
[0016] A sample screening module, used for selecting a matching candidate sample image from each of the candidate sample images as a sample image for training a target detection model, wherein the candidate sample features of the matching candidate sample image match the target sample features;
[0017] The feature extraction model is pre-trained with multiple sets of training data, each set of training data includes: at least one sample image pair, a label indicating whether two sample images in the sample image pair are similar, and two samples in the sample image pair are annotated with detection results.
[0018] In a fourth aspect of the present disclosure, a feature extraction model training device is provided, comprising:
[0019] A third feature extraction module is used for inputting the sample image and the detection result in the sample image into the original model for each sample image in each sample image pair, so as to obtain the sample feature output by the original model;
[0020] A similarity calculation module, used for calculating, for each sample-sample image pair, the similarity between the sample features of two sample images in the sample image pair;
[0021] The parameter adjustment module is used to adjust the model parameters of the original model for each sample image pair according to the similarity and the label used to indicate whether the two sample images in the sample image pair are similar, until a preset convergence condition is reached, and the adjusted original model is used as a feature extraction model.
[0022] In a fifth aspect of the present disclosure, an electronic device is provided, including:
[0023] at least one processor; and
[0024] a memory communicatively connected to the at least one processor; wherein,
[0025] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any one of the methods of the first aspect or the second aspect.
[0026] In a sixth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to any one of the first aspect or the second aspect above.
[0027] In a seventh aspect of the present disclosure, a computer program product is provided. When the computer program is executed by a processor, the method according to any one of the first aspect or the second aspect is implemented.
[0028] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0030] Figure 1 It is a flow chart of the image processing method provided by the present disclosure;
[0031] Figure 2 It is a flow chart of a method for generating training data in the image processing method provided by the present disclosure;
[0032] Figure 3 It is a flow chart of the feature extraction model training method provided by the present disclosure;
[0033] Figure 4 It is a structural schematic diagram of the original model provided by the present disclosure;
[0034] Figure 5is a structural schematic diagram of an image processing device provided by the present disclosure;
[0035] Figure 6 It is a structural schematic diagram of a feature extraction model training device provided by the present disclosure;
[0036] Figure 7 It is a block diagram of an electronic device used to implement the image processing method or feature extraction model training method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0037] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0038] In order to more clearly illustrate the image processing method provided by the present disclosure, a possible application scenario of the image processing method provided by the present disclosure will be exemplified below. It can be understood that the following example is only one possible application scenario of the image processing method provided by the present disclosure. In other possible embodiments, the image processing method provided by the present disclosure can also be applied to other possible application scenarios, and the following example does not impose any limitations on this.
[0039] In the application scenario of text recognition, in order to facilitate the recognition of text in an image, it is necessary to detect the position of the text in the image. Therefore, a detection model for detecting the position of text in an image is obtained based on deep learning training.
[0040] The trained detection model can be used to represent the mapping relationship between the image and the location of the text. For the convenience of description, the mapping relationship represented by the detection model is recorded as the model mapping relationship. When the training data used to train the detection model is sufficient, the model mapping relationship is generally close to the real mapping relationship between the image and the location of the text.
[0041] However, since the number of sample images of different categories in the sample images used is often different, if the number of images of a certain category (referred to as the first category in this paper) is large, then on the images of the first category, the gap between the model mapping relationship and the true mapping relationship is small, and if the number of images of a certain category (referred to as the second category in this paper) is small, then on the images of the second category, the gap between the model mapping relationship and the true mapping relationship may still be large, that is, the detection model cannot generalize the sample images of the second category well, so the generalization ability of the detection model is limited. This part of the sample images is called difficult sample images in this paper.
[0042] Since the generalization ability of the detection model is limited, when the detection model is used to detect the position of text in an image, the position of the text output by the detection model may be significantly different from the actual position of the text, i.e., a bad case is generated. In order to reduce the generation of bad cases, the generalization ability of the detection model needs to be further improved.
[0043] As mentioned above, the model mapping relationship is close enough to the real mapping relationship on the first category of images, that is, the detection model can generalize the first category of images well. Therefore, even if more sample images of the first category are used to train the detection model, it is difficult to further improve the generalization ability of the detection model, that is, the training efficiency is low.
[0044] On the contrary, if more difficult sample images are used to train the detection model, the generalization ability of the detection model for difficult sample images can be improved, thereby further improving the generalization ability of the detection model.
[0045] Therefore, in order to reduce the generation of bad cases, a certain number of difficult sample images should be used to carry out directional training on the detection model. In the related art, difficult sample images can be manually screened out from a large number of sample images, but the manual cost is high.
[0046] Based on this, the present disclosure provides an image processing method, which is applied to any electronic device with image processing capabilities, including but not limited to servers, personal computers, etc. The image processing method provided by the present disclosure is as follows: Figure 1 As shown, including:
[0047] S101, inputting a target sample image and a detection result in the target sample image into a pre-trained feature extraction model to obtain target sample features output by the feature extraction model.
[0048] S102: For each candidate sample image, the candidate sample image and the detection result in the candidate sample image are input into a feature extraction model to obtain the candidate sample features output by the feature extraction model.
[0049] S103, selecting a matching candidate sample image from all candidate sample images as a sample image for training the object detection model.
[0050] The candidate sample features of the matching candidate sample images are matched with the target sample features. The feature extraction model is pre-trained with multiple sets of training data, each set of training data includes at least one sample image pair, a label indicating whether two sample images in the sample image pair are similar, and the two sample images in the sample image pair are annotated with detection results.
[0051] This embodiment is selected. Since the training data used in training the feature extraction model includes sample image pairs and labels for indicating whether two sample images in the sample image pairs are similar, the features extracted by the feature extraction model can determine whether the sample images are similar. At the same time, since the target sample image and the candidate sample features are obtained based on the detection results, the determined matching candidate sample images can be regarded as sample images that match the target sample image in terms of image and detection results. Therefore, the matching candidate sample images are regarded as sample images of the same category as the target sample image. Using the matching candidate sample images to train the target detection model can enrich the sample images of the category to which the target sample image belongs in the training set, thereby performing targeted training on the target detection model and effectively improving the accuracy of the target detection model.
[0052] Still taking the aforementioned application scenario of text recognition as an example, the image processing method provided by the present disclosure is selected, and the difficult sample image is used as the target sample image, and the model for detecting the position of the text is used as the target detection model. Since the determined matching candidate sample image is regarded as a sample image of the same category as the target sample image, it is considered that the target detection model cannot accurately detect the position of the text in the matching candidate sample image, that is, the matching candidate sample image is a difficult sample image. It can be seen that the difficult sample image is effectively screened out from a large number of candidate sample images, and as analyzed above, using difficult sample images to train the target detection model can effectively improve the accuracy of the target detection model. And since there is no need to manually screen the difficult sample images, the excessively high labor costs caused by manually screening the difficult sample images can be avoided.
[0053] The above S101-S103 will be described below:
[0054] In S101, the target sample image may be a difficult sample image when training the target detection model, or may be an image selected by the user according to actual needs or experience. For example, due to actual needs, the user often uses target detection to detect images of a specific category, and the user selects one or more images belonging to the specific category as the target sample image.
[0055] In the case where the target sample image is a difficult sample image, the target sample image may be a matching candidate sample image determined using the image processing method provided by the present disclosure, or a difficult sample image determined by other methods. Exemplarily, an image at a known object location is detected using a target detection model. If the location output by the target detection model is different from the actual location of the object, that is, the image generates a bad case, the image is used as the target sample image.
[0056] The target detection model is a model used to detect the location of objects in an image. Depending on the application scenario, the object can refer to one or more types of objects such as text, vehicles, pedestrians, road signs, etc.
[0057] The detection result is used to indicate the location of the object in the sample image. The detection result in the sample image can be manually annotated or annotated by a detection model, but the location of the object indicated by the detection result should be close enough to the actual location of the object.
[0058] The feature extraction model is used to realize the mapping between sample images, detection results and sample features. The sample features output by the feature extraction model can be expressed in the form of a feature matrix or in the form of a one-dimensional vector. For example, the sample features are expressed in the form of a class-Matrix (a feature matrix with categories).
[0059] In S102 , there are multiple candidate sample images, and each candidate sample image is annotated with a detection result. The detection result of the candidate sample image and the detection result of the target sample image may be annotated in the same manner or in different manners.
[0060] In S103, it can be understood that since the input of the feature extraction model is the sample image and the detection result in the sample image, and the detection result can be regarded as the detection result of the sample image, the sample features extracted by the feature extraction model can be used to characterize the characteristics of the sample image on the image and the characteristics of the detection result of the sample image. The candidate sample features of the matching candidate sample image match the target features, so it is considered that the candidate sample features of the matching candidate sample image are sufficiently similar to the target sample features, that is, the characteristics of the matching candidate sample image and the target sample image on the image and the detection results are close enough, so it is considered that the matching candidate sample image is a sample image of the same category as the target sample image, and the matching candidate sample image is used as a difficult sample image to train the target detection model, which can enrich the number of sample images of a specific category in the training set, thereby realizing targeted directional training of the target detection model.
[0061] Furthermore, the matching candidate sample image determined in S103 can be used as a new target sample image, and steps S101-S103 can be performed again to further mine sample images of the same category as the target sample image for training the target detection model, thereby further improving the accuracy of the target detection model.
[0062] In a possible embodiment, the aforementioned S103 is implemented in the following manner:
[0063] For each candidate sample image, the similarity between the candidate sample features of the candidate sample image and the target sample features is calculated. In descending order of similarity, a preset number of candidate sample images are selected as sample images for training the target detection model.
[0064] For example, assume that there are 1000 candidate sample images, which are recorded as candidate sample images 1-1000, and the similarity of candidate sample image 1 is greater than that of candidate sample image 2, and the similarity of candidate sample image 2 is greater than that of candidate sample image 3, and so on. If the preset number is 100, candidate sample images 1-100 are selected as sample images for training the target detection model.
[0065] By selecting this embodiment, by selecting the candidate sample image with the highest similarity, the probability that the selected candidate sample image and the target sample image are of the same type of sample image is increased, thereby more accurately performing targeted training on the target detection model to further improve the accuracy of the target detection model.
[0066] The calculation method of the aforementioned similarity may be different depending on the application scenario. For example, the Euclidean distance between the candidate sample feature and the target sample feature may be calculated as the similarity, or the cosine distance between the candidate sample feature and the target sample feature may be calculated as the similarity. The similarity between the candidate sample feature and the target sample feature may also be calculated by simaese (an algorithm model for calculating similarity).
[0067] In this article, the similarity refers to the degree of similarity represented by the similarity, rather than the numerical value of the similarity. Depending on the method of calculating the similarity, the numerical value of the similarity and the degree of similarity represented by the similarity can be positively correlated or negatively correlated.
[0068] For example, assuming that the Euclidean distance is used as the similarity, the value of the similarity is negatively correlated with the degree of similarity represented by the similarity, that is, the smaller the value of the similarity, the higher the degree of similarity represented. Assuming that the cosine distance is used as the similarity, the value of the similarity is positively correlated with the degree of similarity represented by the similarity, that is, the larger the value of the similarity, the higher the degree of similarity represented.
[0069] In another possible embodiment, the aforementioned S103 is also implemented in the following manner:
[0070] For each candidate sample image, the similarity between the candidate sample features of the candidate sample image and the target sample features is calculated. The candidate sample features with similarity greater than a preset similarity threshold are selected as sample images for training the target detection model.
[0071] The similarity threshold may be set according to user needs or actual experience, and the similarity threshold may be a preset fixed value or may be determined based on the similarity of each candidate sample image. For example, assuming that the similarity value range is [0,1], the similarity threshold may be set to values such as 0.8, 0.9, 0.95, etc., or the statistical value (such as mean, median, etc.) of the similarity of all candidate sample images may be used as the similarity threshold.
[0072] The generation of training data will be described below. The training data in the present disclosure is pre-generated, and the device that generates the training data and the execution subject of the image processing method provided by the present disclosure can be the same device or different devices. Figure 2 , Figure 2 The figure shows a flow chart of a training data generation method provided by the present disclosure, comprising:
[0073] S201, obtaining a first sample image and a second sample image annotated with detection results.
[0074] S202: If the first sample image and the second sample image are obtained through processing based on the same image and the processing does not include processing to change the detection result, then generate training data including a sample image pair consisting of the first sample image and the second sample image for representing similar labels.
[0075] Among them, changing the detection result refers to changing the position represented by the detection result. For example, if the detection result is represented in the form of a detection frame, then changing the detection result means that the detection frame is lost or deformed.
[0076] In this article, if two images are similar in image and have the same detection results, they are considered to be the same image. For example, assuming that sample image A is obtained by processing sample image B with noise data, then sample image A is only superimposed with some additional noise data compared to sample image B. Therefore, sample image A and sample image B are similar in image and have the same detection results, so sample image A and sample image B are considered to be the same image.
[0077] On the contrary, if the two images are not similar in image or the detection results are different, they are considered to be different images. For example, taking the object detection model used to detect the location of text in an image as an example, assuming that sample image A is obtained by cropping sample image B, and at least one text area in sample image B is cropped during the cropping process, then the detection result of sample image A is different from the detection result of sample image B, so sample image A and sample image B are considered to be different images.
[0078] By selecting this embodiment, training data can be generated by processing sample images, thereby effectively enriching the training data when training the feature extraction model, so as to improve the accuracy of the feature extraction model obtained by training.
[0079] For the convenience of description, it is assumed that the first sample image and the second sample image are both obtained based on the sample image A, and the processing does not include the processing of changing the detection result. Then the first sample image is similar to the sample image A in the image, and the detection result of the first sample image is the same as the detection result of the sample image A, and the second sample image is similar to the sample image A in the image, and the detection result of the second sample image is the same as the detection result of the sample image A. Therefore, the first sample image is similar to the second sample image in the image, and the detection result of the first sample image is the same as the detection result of the second sample image. Therefore, it is considered that: if the sample features of the first sample image and the second sample image are extracted using the feature extraction model, the similarity between the extracted sample features is greater than the preset similarity threshold, so in the training data containing the image pair consisting of the first sample image and the second sample image, the label should indicate similarity. For the convenience of description below, it is assumed that the label value is 0 or 1. When the label value is 0, it indicates dissimilarity, and when the label value is 1, it indicates similarity.
[0080] In this embodiment, the processing that does not change the detection result includes: noise data processing, data enhancement processing excluding random frame loss processing. For the convenience of description below, the noise data processing is recorded as neg(·), the data enhancement processing is recorded as aug(·), and the sample image A is recorded as A. If the first sample image is obtained by performing noise data processing on sample image A, and the second sample image is obtained by performing noise data processing and data enhancement processing on sample image A, and the data enhancement processing does not include random frame loss processing, then the first sample image is neg(A) and the second sample image is neg(aug(A)). Excluding these processing that does not change the detection result, other processing is processing that changes the detection result, such as random frame loss processing.
[0081] Furthermore, the processing may include directly taking it as. Exemplarily, in one possible embodiment, sample image A is directly taken as the first sample image, and data enhancement processing is performed on sample image A to obtain a second sample image, and random frame loss processing is not included in the data enhancement processing. That is, the first sample image is A, and the second sample image is aug(A). In this embodiment, both the first sample image and the second sample image are obtained based on sample image A, and the processing includes changing the detection result, so the label corresponding to the sample image pair consisting of the first sample image and the second sample image is 1.
[0082] The following will describe the case where the first sample image and the second sample image are obtained by processing different images, or the processing includes changing the detection result. It can be understood that this case is divided into the following two sub-cases:
[0083] Sub-case 1: The first sample image and the second sample image are obtained by processing different images.
[0084] Sub-case 2: The first sample image and the second sample image are obtained by processing based on the same image, and the processing includes a process of changing the detection result.
[0085] For sub-case 1, since the first sample image and the second sample image are obtained by processing based on different images, regardless of whether the processing methods are the same, the first sample image and the second sample image are not similar in image. For sub-case 2, since the processing includes a process of changing the detection result, the detection results of the first sample image and the second sample image will be different.
[0086] It can be seen that when the first sample image and the second sample image are obtained by processing based on different images, or the processing includes changing the detection result, the first sample image and the second sample image are not similar in image, and / or the detection result of the first sample image is different from the detection result of the second sample image.
[0087] Therefore, in a possible embodiment, if the first sample image and the second sample image are obtained by processing based on different images, or the processing includes changing the detection result, then training data is generated including a sample image pair consisting of the first sample image and the second sample image, which is used to represent dissimilar labels.
[0088] By selecting this embodiment, the training data for training the feature extraction model can be further enriched to further improve the accuracy of the feature extraction model obtained through training.
[0089] In another possible embodiment, if the first sample image and the second sample image are obtained through processing based on different images, or the processing includes changing the detection result, then new first sample image and second sample image are re-acquired.
[0090] Each set of training data may contain only one sample image pair or multiple sample image pairs, and the number of sample image pairs in different sets of training data may be the same or different. And the number of labels contained in the training data should be consistent with the number of sample image pairs. For example, if the training data contains one sample image pair, the training data contains one label, and if the training data contains six sample image pairs, the training data contains six labels.
[0091] In a possible embodiment, if the training data contains multiple labels, the multiple labels form an array, such as 101101, wherein each bit in the array corresponds to a sample image pair, and different bits correspond to different sample image pairs. If a bit in the array has a value of 1, it indicates that the two sample images in the sample image pair corresponding to the bit are similar. If a bit in the array has a value of 0, it indicates that the two sample images in the sample image pair corresponding to the bit are not similar.
[0092] The following will explain how to train a feature extraction model based on training data. Figure 3 , Figure 3 The figure shows a flow chart of the feature extraction model training method provided by the present disclosure. The feature extraction model training method provided by the present disclosure is applied to any electronic device with the feature extraction model training capability, and the execution subject of the feature extraction model training method provided by the present disclosure and the execution subject of the image processing method provided by the present disclosure can be the same device or different devices. The feature extraction model training method provided by the present disclosure includes:
[0093] S301, for each sample image in each sample image pair, input the sample image and the detection result in the sample image into the original model to obtain the sample features output by the original model.
[0094] S302: For each sample image pair, calculate the similarity between sample features of two sample images in the sample image pair.
[0095] S303, for each sample image pair, according to the similarity and the label used to indicate whether the two sample images in the sample image pair are similar, adjust the model parameters of the original model until a preset convergence condition is reached, and use the adjusted original model as a feature extraction model.
[0096] This embodiment is selected to adjust the model parameters of the original model by back propagation so that the original model can learn the mapping relationship between sample images and sample features during the training process, thereby training a feature extraction model that can accurately extract sample features.
[0097] S301-S303 will be described below respectively:
[0098] In S301, the model structure of the original model is the same as the model structure of the feature extraction model, and the difference is only in the model parameters. The model parameters of the original model can be pre-set or obtained through training.
[0099] The sample image pairs are the sample image pairs in the training data mentioned above. For more information about the training data, please refer to the previous Figure 2 The relevant description will not be repeated here.
[0100] In S302, the method of calculating the similarity should be the same as the method of calculating the similarity in the aforementioned S102. For example, if the similarity is calculated by simaese in the aforementioned S102, the similarity is also calculated by simaese in S302.
[0101] In S303, it can be understood that the similarity is calculated based on the sample features extracted by the original model, so the similarity can be regarded as a prediction result obtained based on the original model for indicating whether two sample images in a sample image pair are similar, and the label can be regarded as a real result for indicating whether the two sample images in the sample image pair are actually similar. Therefore, by adjusting the model parameters of the original model according to the prediction results and the real results, the prediction results obtained based on the original model can be closer to the real results, that is, the sample features output by the original model are more accurate.
[0102] The preset convergence conditions include, but are not limited to: the number of times the model parameters of the original model are adjusted reaches a preset number threshold, the convergence of the original model reaches a preset convergence threshold, all training data have been used to train the original model, and one or more of the following conditions.
[0103] As analyzed above, by adjusting the model parameters of the original model in S303, the sample features output by the original model will be made more accurate. When the preset convergence conditions are reached, it is considered that the samples output by the original model are accurate enough and there is no need to further adjust the model parameters of the original model. The original model at this time is used as the feature extraction model.
[0104] In a possible embodiment, the aforementioned S303 is implemented in the following manner:
[0105] S3031, constructing a loss function according to the similarity and the label used to indicate whether two sample images in the sample image pair are similar.
[0106] Different types of loss functions can be constructed according to different application scenarios. For example, constrictive loss function, cross entropy loss function, etc. can be constructed.
[0107] S3032, adjusting the model parameters of the original model in the direction of gradient descent of the loss function.
[0108] The direction of gradient descent refers to the direction in which the value of the loss function decreases fastest when only the model parameters of the original model are adjusted. The direction of gradient descent can be determined by taking the partial derivative of the loss function in the dimension of the model parameters.
[0109] By selecting this embodiment, the loss function can be constructed and the model parameters can be adjusted in the direction of gradient descent so that the original model converges as quickly as possible, thereby improving the training efficiency of the feature extraction model.
[0110] In order to more clearly illustrate the feature extraction model training method, the model structure of the original model will be exemplified below. Since the model structure of the original model is exactly the same as the model structure of the feature extraction model, the model structure of the feature extraction model will not be described again.
[0111] See also Figure 4 The original model includes the first encoder module, the second encoder module, the concatenation module, the downsampling module, the class generator module, and the latent space module.
[0112] The input of the first encoding module is the sample image, and the output is the image feature. The input of the second encoding module is the detection result in the sample image, and the output is the detection result feature. In this example, the detection result is represented by a detection frame. In other possible embodiments, the detection result can also be represented in other forms such as text and table, and this example does not impose any restrictions on this. The input of the splicing module is the image feature and the detection result feature, and the output is the splicing feature obtained by splicing the image feature and the detection result feature.
[0113] The input of the downsampling module is the concatenated features, and the output is the downsampling features obtained by downsampling the concatenated features. The input of the class generator module is the downsampling module, and the output is the classification features obtained by classifying the downsampling features. The input of the latent space module is the classification features, and the output is the feature matrix Class-Matrix with categories obtained after encoding the classification features. Class-Matrix is the sample features output by the original model.
[0114] See also Figure 5 , Figure 5 The figure shows a schematic diagram of a structure of an image processing device provided by the present disclosure, comprising:
[0115] A first feature extraction module 501 is used to input a target sample image and a detection result of the target sample image into a pre-trained feature extraction model to obtain a target sample feature of the target sample image output by the feature extraction model, wherein the detection result is used to indicate a position of an object in the sample image;
[0116] A second feature extraction module 502 is used for inputting, for each candidate sample image, the candidate sample image and the detection result of the candidate sample image into the feature extraction model to obtain the candidate sample features of the candidate sample image output by the feature extraction model;
[0117] A sample screening module 503 is used to select a matching candidate sample image from each of the candidate sample images as a sample image for training a target detection model, wherein the candidate sample features of the matching candidate sample image match the target sample features;
[0118] The feature extraction model is pre-trained with multiple sets of training data, each set of training data includes: at least one sample image pair, a label indicating whether two sample images in the sample image pair are similar, and two samples in the sample image pair are annotated with detection results.
[0119] In a possible embodiment, a training data generating module is further included, which is used to obtain a first sample image and a second sample image annotated with the detection result;
[0120] If the first sample image and the second sample image are obtained through processing based on the same image, and the processing does not include processing that changes the detection result, then training data containing a sample image pair consisting of the first sample image and the second sample image and used to represent similar labels is generated.
[0121] In a possible embodiment, the training data generation module is further used to generate training data including an image pair consisting of the first sample image and the second sample image, which is used to represent dissimilar labels, if the first sample image and the second image are not obtained through processing based on the same image, or if the processing includes changing the detection result.
[0122] In a possible embodiment, the target sample image is a difficult sample image when training the target detection model.
[0123] In a possible embodiment, the sample screening module 503 selects a matching candidate sample image from each of the candidate sample images as a sample image for training the target detection model, including:
[0124] For each of the candidate sample images, calculating the similarity between the candidate sample features of the candidate sample image and the target sample features;
[0125] A preset number of the candidate sample images are selected in descending order of the similarity as sample features for training the target detection model.
[0126] See also Figure 6 , Figure 6 The figure shows a structural schematic diagram of a feature extraction model training device provided by the present disclosure, comprising:
[0127] A third feature extraction module 601 is used for inputting, for each sample image in each sample image pair, the sample image and the detection result in the sample image into the original model to obtain the sample feature output by the original model;
[0128] A similarity calculation module 602 is used to calculate, for each sample-sample image pair, the similarity between the sample features of two sample images in the sample image pair;
[0129] The parameter adjustment module 603 is used to adjust the model parameters of the original model for each sample image pair according to the similarity and the label used to indicate whether the two sample images in the sample image pair are similar, until the preset convergence condition is reached, and use the adjusted original model as the feature extraction model.
[0130] In a possible embodiment, the parameter adjustment module 603 adjusts the model parameters of the original model according to the similarity and the label indicating whether the two sample images in the sample image pair are similar, including:
[0131] constructing a loss function according to the similarity and a label used to indicate whether two sample images in the sample image pair are similar;
[0132] The model parameters of the original model are adjusted in the direction of the gradient descent of the loss function.
[0133] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0134] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0135] Figure 7A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0136] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0137] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0138] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as image processing methods or feature extraction model training methods. For example, in some embodiments, the image processing method or feature extraction model training method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the image processing method or feature extraction model training method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the image processing method or the feature extraction model training method in any other suitable manner (eg, by means of firmware).
[0139] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0140] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0141] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0142] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0143] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0144] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0145] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0146] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. An image processing method, comprising: Input a target sample image and a detection result of the target sample image into a pre-trained feature extraction model to obtain a target sample feature of the target sample image, wherein the detection result is used to indicate the position of an object in the sample image, and is obtained by manual annotation and / or detection model annotation; wherein the target sample image is one or more difficult sample images belonging to a specific category when training a target detection model; the target detection model is a model for detecting the position of an object in an image; wherein the feature extraction model is used to extract sample features corresponding to the detection result of the sample image, so as to achieve a mapping between the sample image and the detection result to the sample features, and the feature extraction model is pre-trained with multiple sets of training data, each set of the training data comprising: at least one sample image pair having a label indicating whether two sample images are similar, and the two sample images are annotated with detection results; each of the sample images and their detection results is input into the original model to obtain sample features, and for each sample image pair, the similarity between the sample features of the two sample images in the sample image pair is calculated; according to the similarity and the label, the model parameters of the original model are adjusted to obtain a trained feature extraction model; For each candidate sample image, input the candidate sample image and the detection result of the candidate sample image into the feature extraction model to obtain the candidate sample feature of the candidate sample image; According to the target sample features and the candidate sample features, a matching candidate sample image is selected from each of the candidate sample images as a sample image for training the target detection model.
2. The method according to claim 1, wherein: The training data is obtained in advance in the following manner: Acquire a first sample image and a second sample image annotated with detection results; If the first sample image and the second sample image are obtained through processing based on the same image, and the processing does not include processing that changes the detection result, then training data containing a sample image pair consisting of the first sample image and the second sample image and used to represent similar labels is generated.
3. The method according to claim 2, further comprising: If the first sample image and the second sample image are not obtained through processing based on the same image, or the processing includes processing to change the detection result, training data including an image pair consisting of the first sample image and the second sample image and used to represent dissimilar labels is generated.
4. The method according to claim 1, wherein: The selecting a matching candidate sample image from each of the candidate sample images as a sample image for training the target detection model includes: For each of the candidate sample images, calculating the similarity between the candidate sample features of the candidate sample image and the target sample features; A preset number of the candidate sample images are selected in descending order of the similarity as sample features for training the target detection model.
5. The method according to claim 1, wherein: The adjusting the model parameters of the original model according to the similarity and the label used to indicate whether the two sample images in the sample image pair are similar comprises: constructing a loss function according to the similarity and a label used to indicate whether two sample images in the sample image pair are similar; The model parameters of the original model are adjusted in the direction of the gradient descent of the loss function.
6. An image processing device, comprising: A first feature extraction module is used to input a target sample image and a detection result of the target sample image into a pre-trained feature extraction model to obtain a target sample feature of the target sample image, wherein the detection result is used to indicate the position of an object in the sample image, and is obtained by manual annotation and / or annotation by a detection model, wherein the target sample image is one or more difficult sample images belonging to a specific category when training a target detection model; the target detection model is a model for detecting the position of an object in an image; wherein the feature extraction model is used to extract sample features corresponding to the detection result of the sample image, so as to achieve mapping between the sample image and the detection result to the sample features, and the feature extraction model is pre-trained with multiple sets of training data, each set of the training data comprising: at least one sample image pair having a label indicating whether two sample images are similar, and the two sample images are annotated with detection results; each of the sample images and their detection results is input into the original model to obtain sample features, and for each sample image pair, the similarity between the sample features of the two sample images in the sample image pair is calculated; according to the similarity and the label, the model parameters of the original model are adjusted using a parameter adjustment module to obtain a trained feature extraction model; A second feature extraction module is used for inputting the candidate sample image and the detection result of the candidate sample image into the feature extraction model for each candidate sample image to obtain the candidate sample feature of the candidate sample image; The sample screening module is used to select matching candidate sample images from each of the candidate sample images according to the target sample features and the candidate sample features, as sample images for training the target detection model.
7. The device according to claim 6, further comprising a training data generation module, configured to obtain a first sample image and a second sample image annotated with a detection result; If the first sample image and the second sample image are obtained through processing based on the same image, and the processing does not include processing that changes the detection result, then training data containing a sample image pair consisting of the first sample image and the second sample image and used to represent similar labels is generated.
8. According to the device of claim 7, the training data generation module is also used to generate training data including an image pair consisting of the first sample image and the second sample image, and used to represent dissimilar labels, if the first sample image and the second sample image are not obtained through processing based on the same image, or if the processing includes changing the detection result.
9. The device according to claim 6, wherein: The sample screening module selects a matching candidate sample image from each of the candidate sample images as a sample image for training the target detection model, including: For each of the candidate sample images, calculating the similarity between the candidate sample features of the candidate sample image and the target sample features; A preset number of the candidate sample images are selected in descending order of the similarity as sample features for training the target detection model.
10. The device according to claim 7, wherein: The parameter adjustment module adjusts the model parameters of the original model according to the similarity and a label indicating whether two sample images in the sample image pair are similar, including: constructing a loss function according to the similarity and a label used to indicate whether two sample images in the sample image pair are similar; The model parameters of the original model are adjusted in the direction of the gradient descent of the loss function.
11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.
13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for selecting training samples
CN110070076A
Pedestrian re-recognition method based on combination of image enhancement of deep learning and pseudo twin convolutional neural network
CN111079585A
Image classification model training method and device, image classification method and device and calculation equipment
CN111340105A
Target detection method and device, electronic equipment and readable storage medium
CN113379718A
Generation method for classification model, classification method, apparatus, and medium
EP3944148A2
