Model training sample generation method, device, storage medium and electronic device
By superimposing the image to the background image, and extraction and using the image content in the identification error area when identifying the error, it is used as a training sample, which solves the problem of poor model training effect in existing technologies, and improves the accuracy of the model recognition.
Patent Information
- Application Number
- CN202111152414.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2041-09-29
AI Technical Summary
In the prior art, negative sample images are only marked and trained models are used again, resulting in poor training effects of the model.
By obtaining the image and background image to be recognized, the image to be recognized is superimposed into the background image, the first image is generated, and the first image is recognized by target recognition model. When identifying errors, extract the image content of the identification error area, superimposed it to the background image, and generate the first training sample.
By using the image content of the identification error area as the training sample, the training effect of the target recognition model is improved, and the accuracy of the model recognition is improved.
Smart Images

Figure CN113780472B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, storage medium and electronic device for generating model training samples. Background Art
[0002] In the prior art, when training a recognition model, the model usually recognizes training sample images, identifies the type and area of the image to be recognized in the image, and classifies the image. If the recognition model recognizes the type or area of the image incorrectly, the image is used as a negative sample image, added to the negative sample image set, and the recognition model is trained again.
[0003] However, using the above method, negative sample images are simply labeled and then used again to train the model, resulting in poor training results for the model. Summary of the invention
[0004] Embodiments of the present invention provide a method, device, storage medium and electronic device for generating model training samples, so as to at least solve the technical problem of poor model training effect.
[0005] According to one aspect of an embodiment of the present invention, a method for generating model training samples is provided, comprising: acquiring an image to be recognized and a background image; superimposing the image to be recognized onto the background image to obtain a first image; recognizing the first image using a target recognition model to obtain a recognition result, wherein each of the first images corresponds to one recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image; in the case where there is an erroneous recognition result in the recognition result, extracting the image content of the recognition area of the erroneous recognition result; superimposing the extracted image content onto the background image to obtain a first training sample.
[0006] According to another aspect of an embodiment of the present invention, a model training sample generating device is provided, comprising: an acquisition unit, configured to acquire an image to be identified and a background image; a first superimposing unit, configured to superimpose the image to be identified onto the background image to obtain a first image; a recognition unit, configured to recognize the first image using a target recognition model to obtain a recognition result, wherein each of the first images corresponds to one recognition result, and the recognition result includes a recognition type and a recognition area of the image to be identified in the first image; an extraction unit, configured to extract the image content of the recognition area of the recognition result with an erroneous recognition result when there is an erroneous recognition result in the recognition result; and a second superimposing unit, configured to superimpose the extracted image content onto the background image to obtain a first training sample.
[0007] As an optional example, the first superposition unit includes: a superposition module, used to superimpose each of the above-mentioned images to be identified on each of the above-mentioned background images, and determine each obtained image as the above-mentioned first image; or divide the above-mentioned background image into a target number of parts according to a preset ratio, and superimpose each of the above-mentioned images to be identified on each background image in one of the above-mentioned background images, wherein the above-mentioned target number is the number of the above-mentioned images to be identified.
[0008] As an optional example, the above-mentioned device also includes: a first determination unit, which is used to determine that there is a recognition error in the above-mentioned recognition result when, in the above-mentioned recognition result, the above-mentioned recognition type is different from the real type of the above-mentioned image to be recognized or the above-mentioned recognition area is different from the area of the above-mentioned image to be recognized in the above-mentioned first image.
[0009] As an optional example, the above-mentioned device also includes: a second determination unit, used to determine that the recognition area of the above-mentioned recognition result is different from the area of the above-mentioned image to be recognized in the above-mentioned first image when the ratio of the intersection and union of the recognition area of the above-mentioned recognition result and the area of the above-mentioned image to be recognized in the above-mentioned first image is less than a first threshold.
[0010] As an optional example, the second superposition unit includes: a division module, used to divide the image content into different image content sets according to the different images to be identified in the first image; an adding module, used to add the image content in each image content set to the background image to obtain a second image, wherein the second image belongs to the first training sample.
[0011] As an optional example, the second superimposing unit includes: a recording module, configured to record the area where the image content is located in the background image.
[0012] As an optional example, the above-mentioned device also includes: a determination module, used to use the above-mentioned first image and the above-mentioned first training sample as target training samples; and a training module, used to train the above-mentioned target recognition model using the above-mentioned target training sample.
[0013] According to another aspect of an embodiment of the present invention, a storage medium is provided, in which a computer program is stored, wherein the computer program executes the above-mentioned model training sample generation method when executed by a processor.
[0014] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned model training sample generation method through the above-mentioned computer program.
[0015] In an embodiment of the present invention, a method is adopted, which comprises the following steps: obtaining an image to be identified and a background image; superimposing the image to be identified onto the background image to obtain a first image; identifying the first image using a target recognition model to obtain a recognition result, wherein each of the first images corresponds to one recognition result, and the recognition result includes a recognition type and a recognition area of the image to be identified in the first image; in the case where there is an erroneous recognition result in the recognition result, extracting the image content of the recognition area of the erroneous recognition result; superimposing the extracted image content onto the background image to obtain a first training sample. Since in the above method, in the case where the target recognition model identifies the first image incorrectly, the image content in the recognition area identified by the target recognition model in the first image is extracted and superimposed onto the background image to obtain a first training sample, using the first training sample to train the target recognition model can improve the training effect of the target recognition model, thereby solving the technical problem of poor model training effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0017] Figure 1 is a flowchart of an optional method for generating model training samples according to an embodiment of the present invention;
[0018] Figure 2 is a schematic diagram of superimposing an image to be recognized according to an optional method for generating model training samples in an embodiment of the present invention;
[0019] Figure 3 is a schematic diagram of extracting image content according to an optional model training sample generation method according to an embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of superimposed image content of an optional model training sample generation method according to an embodiment of the present invention;
[0021] Figure 5 is a schematic structural diagram of an optional model training sample generating device according to an embodiment of the present invention;
[0022] Figure 6 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] According to a first aspect of an embodiment of the present invention, a method for generating a model training sample is provided. Optionally, as follows: Figure 1 As shown, the above method includes:
[0026] S102, obtaining an image to be recognized and a background image;
[0027] S104, superimposing the image to be recognized onto the background image to obtain a first image;
[0028] S106, using the target recognition model to recognize the first image to obtain a recognition result, wherein each first image corresponds to a recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image;
[0029] S108, if there is a recognition result with incorrect recognition in the recognition result, extract the image content of the recognition area of the recognition result with incorrect recognition;
[0030] S110, superimposing the extracted image content onto the background image to obtain a first training sample.
[0031] Optionally, the target recognition model in this embodiment can be a model for recognizing the recognition area and type of the image to be recognized in the first image. The first image is input into the target recognition model, and the target recognition model outputs the recognition area and recognition type of the image to be recognized in the first image.
[0032] Optionally, in this embodiment, the background color of the background image may be different colors, may be a pure color or a combination of multiple colors, and the background image may or may not include text, images, etc., which is not limited in this embodiment.
[0033] Optionally, the image to be identified in this embodiment may include at least one of text, images, and shapes. For example, the image to be identified may include animal photos, shapes such as squares and triangles, or text, and the text may be any font, artistic characters, etc.
[0034] Optionally, in this embodiment, the image to be identified is superimposed on the background image, and a superimposition point can be selected in the background image. After the superimposition point is selected, the image to be identified is superimposed at the superimposition point. During superimposition, it is ensured that the superimposed image to be identified does not exceed the range of the background image. Figure 2 As shown, the image to be recognized 204 is superimposed on the background image 202 .
[0035] Optionally, the first image in this embodiment may correspond to a first label, and the first label may mark the type and region of the image to be identified in the first image.
[0036] After the target recognition model recognizes the first image, the target recognition model outputs the recognition type and recognition area of the image to be recognized in the first image. If the target recognition model recognizes the image to be recognized in the first image incorrectly, the image content in the recognition area that the target recognition model recognizes incorrectly is extracted. For example, Figure 3 As shown, the background image 302 includes an image 304 to be recognized and content 306 on the background image 302. When the target recognition model is recognizing, the content 306 is mistakenly recognized as a human being, so the content 306 is extracted to obtain the image content.
[0037] The extracted content is superimposed on the background image to obtain the first training sample. Figure 4 As shown, after obtaining the image content, the image content 402 is superimposed on the background image 404 to obtain a first training sample. The first training sample can be used to train the target recognition model. Through this embodiment, through the above method, when the target recognition model recognizes the first image incorrectly, the image content in the recognition area recognized by the target recognition model in the first image can be extracted and superimposed on the background image to obtain the first training sample. The target recognition model is trained using the first training sample, thereby improving the training effect of the training target recognition model.
[0038] As an optional example, the step of superimposing the image to be recognized onto the background image to obtain the first image includes:
[0039] Superimposing each image to be identified onto each background image, and determining each obtained image as a first image; or
[0040] The background image is divided into a target number of parts according to a preset ratio, and each image to be identified is superimposed on each background image in one background image, wherein the target number is the number of images to be identified.
[0041] Optionally, the preset ratio in this embodiment can be a ratio set manually, or it can be a ratio automatically adjusted by the system according to the number of samples. For example, taking the target number as 3 as an example, the preset ratio can be 1:1:1. If the number of background images of a certain type is small, the ratio can be increased, such as adjusted to 1.2:0.8:1. For example, if there are 30,000 background images, they can be divided into 12,000, 8,000 and 10,000. Among the three images to be identified, each image to be identified is superimposed on a background image, and 12,000 first images, 8,000 first images and 10,000 first images are obtained, totaling 30,000 first images.
[0042] Another way to obtain the first image by superposition is to superimpose each image to be identified on each background image. For example, there are 3 images to be identified and 30,000 background images, and each of the 3 images to be identified is superimposed on the 30,000 background images, so that a total of 90,000 first images are obtained.
[0043] As an optional example, the above method further includes:
[0044] In the recognition result, if the recognition type is different from the real type of the image to be recognized or the recognition area is different from the area of the image to be recognized in the first image, it is determined that there is a recognition error in the recognition result.
[0045] Optionally, in this embodiment, since the first image corresponds to a first label, the type and area of the image to be identified in the first image are marked, and after the target recognition model recognizes the first image, the type and area of the image to be identified in the first image are output. If the recognition type in the recognition result is inconsistent with the type in the first label, or the recognition area in the recognition result is different from the area in the first label, it means that the recognition result of the target recognition model is wrong.
[0046] As an optional example, the above method further includes:
[0047] When the ratio of the intersection and union of the recognition area of the recognition result and the area of the image to be recognized in the first image is less than the first threshold, it is determined that the recognition area of the recognition result is different from the area of the image to be recognized in the first image.
[0048] Optionally, in this embodiment, the above-mentioned first threshold value can be a fixed value or a floating value. If the first threshold value is a floating value, the first threshold value can be adjusted according to the resolution / clarity of the image. The higher the resolution / clarity, the higher the comparison accuracy between the recognition area recognized by the target recognition model and the real area of the image to be recognized in the first label, and the larger the first threshold value. If the resolution / clarity is small, there will be a certain error in the comparison between the recognition area recognized by the target recognition model and the real area of the image to be recognized in the first label due to the influence of the resolution / clarity. The first threshold value can be adjusted to avoid the influence of the error. If the ratio of the intersection and union of the recognition area of the image to be recognized obtained by the target recognition model and the real area of the image to be recognized in the first label is less than or equal to the first threshold value, it means that the area of the image to be recognized recognized by the target recognition model is wrong. It means that the recognition area of the recognition result is different from the real area of the image to be recognized in the first image.
[0049] As an optional example, the above-mentioned superimposing the extracted image content onto the background image to obtain the first training sample includes:
[0050] Dividing the image contents into different image content sets according to the difference of the images to be identified in the first image;
[0051] The image content in each image content set is added to the background image to obtain a second image, wherein the second image belongs to the first training sample.
[0052] Optionally, in this embodiment, all image contents can be divided into different image content sets according to the different images to be identified. For example, there are 3 images to be identified, which are superimposed on 10,000 background images respectively to obtain a total of 30,000 first images. Among the 30,000 first images, each image to be identified corresponds to 10,000 first images. After the target recognition model identifies 30,000 first images, if there is a recognition error in the image to be identified, the image content of the recognition area in the recognition result of the recognition error is extracted, and 0-10,000 image contents may be extracted from the 10,000 first images corresponding to each image to be identified in the 30,000 first images. The 0-10,000 image contents are taken as an image content set. Then, for 3 images to be identified, each corresponds to 1 image content set, and the image content set may contain 0-10,000 image contents. For one image to be identified, one or more image contents are obtained from the corresponding image content set, and the image content is added to the background image to obtain a second image. The second image is used as the first training sample.
[0053] As an optional example, the above-mentioned superimposing the extracted image content onto the background image to obtain the first training sample includes:
[0054] Records the area where the image content is located within the background image.
[0055] Optionally, in this embodiment, each first training sample may correspond to a second label, and the second label may record the position of the image content in the first training sample and the type of the image content. When the first training sample is used to train the target recognition model, the second label may also be input into the target recognition model.
[0056] As an optional example, the above method further includes:
[0057] Using the first image and the first training sample as target training samples;
[0058] Use the target training samples to train the object recognition model.
[0059] Optionally, in this embodiment, the first image and the first training sample can be used as a positive sample and a negative sample to train the target recognition model respectively.
[0060] Optionally, in this embodiment, the target recognition model involves classification and detection. Classification and detection: For image classification, the entire image is classified with a single label, while for target detection, the (potentially multiple) targets in the image are located. Image classification input is an image and output is a category label. Target detection is based on image classification and attempts to accurately locate the position of each target in the image. The input is an image, and the output is the category label of each target and the coordinates of each target and the confidence of each target category label.
[0061] For example, there are 20 images to be identified, and the base map (background image) has 200,000 images (without any target class). The 20 images to be identified are pasted on the 200,000 base maps, and the training set (first image) for the detection of the images to be identified is constructed. The first training is performed to obtain the target recognition model baseline model.
[0062] Using the baseline model to detect the first 200,000 images will result in many false positives. The output of the detection task includes not only the category but also the coordinates (predicted recognition area). The image content of the false positive area is cropped according to the coordinate position. Basically, each image to be recognized will have a corresponding false positive area and corresponding image content. The image content corresponding to the image to be recognized is regarded as an image content set, which can be called a negative class.
[0063] The set of 20 first images of the 20 images to be identified can be called the target class (represented by numbers 1-20). At the same time, the areas where each category is misdetected are obtained in the result of the previous step, that is, we have obtained 20 negative classes (represented by mis1-mis20).
[0064] By adding the negative class as the adversarial class of the target class and the misdetected area as the adversarial class, the model can more accurately grasp what the target is.
[0065] The misdetected areas, that is, the 20 negative classes, are then pasted onto the 20w base map. In this way, the coordinates of these misdetected areas can be obtained, so that the network can be accurately told which specific areas on the image are not the desired target class and the adversarial class during the next training.
[0066] The final training set has 20 target classes and 20 adversarial classes, which are then sent to the model for training, completing one iteration.
[0067] Through the above method, the false positive area is cropped and used as the adversarial class of the target class to generate negative sample data. This can accurately tell the algorithm model that a certain area on the image is not the target class, but an adversarial class that is easily confused. The algorithm is more targeted when learning features. In this way, after a round of algorithm iterations, the false positive rate can be effectively reduced and the training effect of the model can be improved.
[0068] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0069] According to another aspect of the embodiment of the present application, a model training sample generating device is also provided. Figure 5 As shown, including:
[0070] An acquisition unit 502 is used to acquire an image to be recognized and a background image;
[0071] A first superimposing unit 504, configured to superimpose the image to be recognized onto the background image to obtain a first image;
[0072] The recognition unit 506 is used to recognize the first image using the target recognition model to obtain a recognition result, wherein each first image corresponds to a recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image;
[0073] An extraction unit 508 is used to extract the image content of the recognition area of the recognition result of the wrong recognition when there is a recognition result of the wrong recognition in the recognition result;
[0074] The second superimposing unit 510 is used to superimpose the extracted image content onto the background image to obtain a first training sample.
[0075] Optionally, the target recognition model in this embodiment can be a model for recognizing the recognition area and type of the image to be recognized in the first image. The first image is input into the target recognition model, and the target recognition model outputs the recognition area and recognition type of the image to be recognized in the first image.
[0076] Optionally, in this embodiment, the background color of the background image may be different colors, may be a pure color or a combination of multiple colors, and the background image may or may not include text, images, etc., which is not limited in this embodiment.
[0077] Optionally, the image to be identified in this embodiment may include at least one of text, images, and shapes. For example, the image to be identified may include animal photos, shapes such as squares and triangles, or text, and the text may be any font, artistic characters, etc.
[0078] Optionally, in this embodiment, the image to be identified is superimposed on the background image, and a superimposition point can be selected in the background image. After the superimposition point is selected, the image to be identified is superimposed at the superimposition point. During superimposition, it is ensured that the superimposed image to be identified does not exceed the range of the background image. Figure 2 As shown, the image to be recognized 204 is superimposed on the background image 202 .
[0079] Optionally, the first image in this embodiment may correspond to a first label, and the first label may mark the type and region of the image to be identified in the first image.
[0080] After the target recognition model recognizes the first image, the target recognition model outputs the recognition type and recognition area of the image to be recognized in the first image. If the target recognition model recognizes the image to be recognized in the first image incorrectly, the image content in the recognition area that the target recognition model recognizes incorrectly is extracted. For example, Figure 3 As shown, the background image 302 includes an image 304 to be recognized and content 306 on the background image 302. When the target recognition model is recognizing, the content 306 is mistakenly recognized as a human being, so the content 306 is extracted to obtain the image content.
[0081] The extracted content is superimposed on the background image to obtain the first training sample. Figure 4As shown, after obtaining the image content, the image content 402 is superimposed on the background image 404 to obtain a first training sample. The first training sample can be used to train the target recognition model. Through this embodiment, through the above method, when the target recognition model recognizes the first image incorrectly, the image content in the recognition area recognized by the target recognition model in the first image can be extracted and superimposed on the background image to obtain the first training sample. The target recognition model is trained using the first training sample, thereby improving the training effect of the training target recognition model.
[0082] As an optional example, the first superimposing unit includes:
[0083] The superposition module is used to superimpose each image to be identified on each background image, and determine each obtained image as the first image; or divide the background image into a target number of parts according to a preset ratio, and superimpose each image to be identified on each background image in one background image, wherein the target number is the number of images to be identified.
[0084] Optionally, the preset ratio in this embodiment can be a ratio set manually, or it can be a ratio automatically adjusted by the system according to the number of samples. For example, taking the target number as 3 as an example, the preset ratio can be 1:1:1. If the number of background images of a certain type is small, the ratio can be increased, such as adjusted to 1.2:0.8:1. For example, if there are 30,000 background images, they can be divided into 12,000, 8,000 and 10,000. Among the three images to be identified, each image to be identified is superimposed on a background image, and 12,000 first images, 8,000 first images and 10,000 first images are obtained, totaling 30,000 first images.
[0085] Another way to obtain the first image by superposition is to superimpose each image to be identified on each background image. For example, there are 3 images to be identified and 30,000 background images, and each of the 3 images to be identified is superimposed on the 30,000 background images, so that a total of 90,000 first images are obtained.
[0086] As an optional example, the above device further includes:
[0087] The first determination unit is used to determine that there is a recognition error in the recognition result when, in the recognition result, the recognition type is different from the real type of the image to be recognized or the recognition area is different from the area of the image to be recognized in the first image.
[0088] Optionally, in this embodiment, since the first image corresponds to a first label, the type and area of the image to be identified in the first image are marked, and after the target recognition model recognizes the first image, the type and area of the image to be identified in the first image are output. If the recognition type in the recognition result is inconsistent with the type in the first label, or the recognition area in the recognition result is different from the area in the first label, it means that the recognition result of the target recognition model is wrong.
[0089] As an optional example, the above device further includes:
[0090] The second determination unit is used to determine that the recognition area of the recognition result is different from the area of the image to be recognized in the first image when the ratio of the intersection and union of the recognition area of the recognition result and the area of the image to be recognized in the first image is less than a first threshold.
[0091] Optionally, in this embodiment, the above-mentioned first threshold value can be a fixed value or a floating value. If the first threshold value is a floating value, the first threshold value can be adjusted according to the resolution / clarity of the image. The higher the resolution / clarity, the higher the comparison accuracy between the recognition area recognized by the target recognition model and the real area of the image to be recognized in the first label, and the larger the first threshold value. If the resolution / clarity is small, there will be a certain error in the comparison between the recognition area recognized by the target recognition model and the real area of the image to be recognized in the first label due to the influence of the resolution / clarity. The first threshold value can be adjusted to avoid the influence of the error. If the ratio of the intersection and union of the recognition area of the image to be recognized obtained by the target recognition model and the real area of the image to be recognized in the first label is less than or equal to the first threshold value, it means that the area of the image to be recognized recognized by the target recognition model is wrong. It means that the recognition area of the recognition result is different from the real area of the image to be recognized in the first image.
[0092] As an optional example, the second superimposing unit includes:
[0093] A division module, used for dividing the image contents into different image content sets according to the difference of the images to be identified in the first image;
[0094] The adding module is used to add the image content in each image content set to the background image to obtain a second image, wherein the second image belongs to the first training sample.
[0095] Optionally, in this embodiment, all image contents can be divided into different image content sets according to the different images to be identified. For example, there are 3 images to be identified, which are superimposed on 10,000 background images respectively to obtain a total of 30,000 first images. Among the 30,000 first images, each image to be identified corresponds to 10,000 first images. After the target recognition model identifies 30,000 first images, if there is a recognition error in the image to be identified, the image content of the recognition area in the recognition result of the recognition error is extracted, and 0-10,000 image contents may be extracted from the 10,000 first images corresponding to each image to be identified in the 30,000 first images. The 0-10,000 image contents are taken as an image content set. Then, for 3 images to be identified, each corresponds to 1 image content set, and the image content set may contain 0-10,000 image contents. For one image to be identified, one or more image contents are obtained from the corresponding image content set, and the image content is added to the background image to obtain a second image. The second image is used as the first training sample.
[0096] As an optional example, the second superimposing unit includes:
[0097] The recording module is used to record the area where the image content is located in the background image.
[0098] Optionally, in this embodiment, each first training sample may correspond to a second label, and the second label may record the position of the image content in the first training sample and the type of the image content. When the first training sample is used to train the target recognition model, the second label may also be input into the target recognition model.
[0099] As an optional example, the above device further includes:
[0100] A determination module, configured to use the first image and the first training sample as target training samples;
[0101] The training module is used to train the target recognition model using target training samples.
[0102] Optionally, in this embodiment, the first image and the first training sample can be used as a positive sample and a negative sample to train the target recognition model respectively.
[0103] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0104] Figure 6 is a structural block diagram of an optional electronic device according to an embodiment of the present application, such as Figure 6As shown, it includes a processor 602, a communication interface 604, a memory 606 and a communication bus 608, wherein the processor 602, the communication interface 604 and the memory 606 communicate with each other through the communication bus 608, wherein,
[0105] Memory 606, used to store computer programs;
[0106] The processor 602 is used to implement the following steps when executing the computer program stored in the memory 606:
[0107] Obtain the image to be identified and the background image;
[0108] Superimposing the image to be recognized onto the background image to obtain a first image;
[0109] Using the target recognition model to recognize the first image, obtaining a recognition result, wherein each first image corresponds to a recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image;
[0110] If there is a recognition result with incorrect recognition in the recognition result, extracting the image content of the recognition area of the recognition result with incorrect recognition;
[0111] The extracted image content is superimposed on the background image to obtain a first training sample.
[0112] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The communication interface is used for communication between the above electronic device and other devices.
[0113] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0114] As an example, the memory 606 may include, but is not limited to, the acquisition unit 502, the first superposition unit 504, the identification unit 506, the extraction unit 508, and the second superposition unit 510 in the request processing device. In addition, other module units in the request processing device may also be included but are not limited to, which will not be repeated in this example.
[0115] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0116] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0117] It can be understood by those skilled in the art that Figure 6 The structure shown is for illustration only. The device for implementing the above request processing method may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 6 The structure of the electronic device is not limited. Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations shown.
[0118] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0119] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned model training sample generation method when executed by a processor.
[0120] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0121] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0122] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers or network devices, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
[0123] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0124] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0127] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for generating model training samples, characterized in that: include: Obtain the image to be identified and the background image; Superimposing the image to be recognized onto the background image to obtain a first image; Using the target recognition model to recognize the first image, to obtain a recognition result, wherein each of the first images corresponds to one recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image; If there is an erroneous recognition result in the recognition results, extracting the image content of the recognition area of the erroneous recognition result; Superimposing the extracted image content onto the background image to obtain a first training sample; The step of superimposing the extracted image content onto the background image to obtain a first training sample includes: dividing the image content into different image content sets according to different images to be identified in the first image; adding one or more image contents in each of the image content sets to the background image to obtain a second image, wherein the second image belongs to the first training sample; Wherein, superimposing the image to be identified onto the background image to obtain the first image comprises: dividing the background image into a target number of portions according to a preset ratio, and superimposing each image to be identified onto each background image in one portion of the background image, wherein the target number is the number of the images to be identified; Among them, superimposing the image to be identified on the background image to obtain the first image includes: selecting a superimposition point from the background image, superimposing the image to be identified at the superimposition point, and ensuring that the superimposed image to be identified does not exceed the range of the background image.
2. The method according to claim 1, characterized in that The method further comprises: In the recognition result, if the recognition type is different from the real type of the image to be recognized or the recognition area is different from the area of the image to be recognized in the first image, it is determined that there is a recognition error in the recognition result.
3. The method according to claim 2, characterized in that The method further comprises: When the ratio of the intersection and union of the recognition area of the recognition result and the area of the image to be recognized in the first image is less than a first threshold, it is determined that the recognition area of the recognition result is different from the area of the image to be recognized in the first image.
4. The method according to claim 1, characterized in that: The step of superimposing the extracted image content onto the background image to obtain a first training sample comprises: The area where the image content is located in the background image is recorded.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: using the first image and the first training sample as target training samples; The target recognition model is trained using the target training samples.
6. A model training sample generation device, characterized in that: include: An acquisition unit, used for acquiring an image to be recognized and a background image; A first superimposing unit, used for superimposing the image to be recognized onto the background image to obtain a first image; a recognition unit, configured to recognize the first image using a target recognition model to obtain a recognition result, wherein each of the first images corresponds to one recognition result, and the recognition result includes a recognition type and a recognition area of the image to be recognized in the first image; An extraction unit, configured to extract the image content of the recognition area of the erroneous recognition result when there is an erroneous recognition result in the recognition result; A second superposition unit, used for superimposing the extracted image content onto the background image to obtain a first training sample; The step of superimposing the extracted image content onto the background image to obtain a first training sample includes: dividing the image content into different image content sets according to different images to be identified in the first image; adding one or more image contents in each of the image content sets to the background image to obtain a second image, wherein the second image belongs to the first training sample; Wherein, superimposing the image to be identified onto the background image to obtain the first image comprises: dividing the background image into a target number of portions according to a preset ratio, and superimposing each image to be identified onto each background image in one portion of the background image, wherein the target number is the number of the images to be identified; Among them, superimposing the image to be identified on the background image to obtain the first image includes: selecting a superimposition point from the background image, superimposing the image to be identified at the superimposition point, and ensuring that the superimposed image to be identified does not exceed the range of the background image.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is executed.
8. An electronic device, comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
Image recognition model training method and device, image recognition method and device, and electronic equipment
CN111476284A
Image training set generation method and model training method based on image data enhancement
CN113361588A