Image recognition method and device
By deforming and enhancing the model training images, the problem of low accuracy of the CRNN model in recognizing deformed text images is solved, and higher recognition accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202110074283.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-20
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-01-20
AI Technical Summary
In existing OCR technology, the CRNN model trained using regular images has low accuracy when recognizing deformed text images and cannot adapt to various deformation situations in practical applications.
The regular images used for model training are deformed to generate an enhanced field image set, and the enhanced field image set and corresponding sample labels are used for model enhancement training to improve the model's recognition ability for deformed images.
The enhanced trained model can be applied to images with various deformations, improving the image recognition accuracy while maintaining the original text recognition level.
Smart Images

Figure CN113762307B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an image recognition method and device. Background Art
[0002] In the application of OCR (Optical Character Recognition) technology, the EAST text detector is often used for text detection. It can detect horizontal and vertical text from multiple angles, output a text box composed of four corner points, process it into a rectangular text image, and then use the CRNN recognition model for text recognition. The recognition accuracy of the CRNN recognition model is related to the degree of deformation of the rectangular text image. However, in existing technologies, the field images used to train recognition models are often relatively regular images in ideal conditions.
[0003] In the process of implementing the present invention, there are at least the following problems in the prior art:
[0004] Since text images processed by the EAST text detector in actual applications usually have certain deformations, the model trained using relatively regular images often cannot recognize images with various deformations in actual applications, resulting in a low image recognition accuracy of the model. Summary of the Invention
[0005] In view of this, an embodiment of the present invention provides an image recognition method and device, which can deform the relatively regular field images in the original data set used for model training to obtain an enhanced field image set, and then perform enhanced training on the model based on the enhanced field image set and the corresponding sample labels in the original data set, and then use the model obtained by the enhanced training for image recognition, so that the enhanced trained model can be applicable to images with various deformations in actual applications, thereby improving the image recognition accuracy of the model.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided an image recognition method, comprising:
[0007] Receive a request for model enhancement training and obtain an original data set in the request;
[0008] Calling a deformation strategy, and performing deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set;
[0009] The enhanced field picture set is used as a training sample of the character recognition model, and the corresponding sample labels in the original data set are used as training labels to perform enhanced training of the model, and then the model obtained by the enhanced training is used for image recognition.
[0010] Optionally, before receiving a request for model enhancement training, the method further includes:
[0011] Generate the request for enhanced training based on the original data set used for training the model at a preset frequency; or
[0012] When it is detected that the recognition accuracy of the model for the image within a preset time period is lower than the accuracy threshold, a request for enhanced training is generated based on the original data set used for training the model.
[0013] Optionally, calling the deformation strategy includes:
[0014] When receiving an enhanced scene instruction, calling a scene strategy configuration table to determine a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table;
[0015] When no enhanced scene instruction is received, a random strategy is called as the deformation strategy.
[0016] Optionally, when determining the deformation strategy corresponding to the enhanced scene from the scene strategy configuration table, the image deformation method in the deformation strategy includes: one or more basic methods in the basic deformation method library, one or more scene methods in the scene simulation deformation method library; the deformation strategy also includes: a scene combination algorithm;
[0017] Furthermore, the deformation processing of the original field image in the original data set includes:
[0018] Sequentially obtain the original field images in the original data set;
[0019] Selecting at least one to-be-executed basic method from the one or more basic methods, and selecting at least one to-be-executed scenario method from the one or more scenario methods, using the scenario combination algorithm;
[0020] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0021] Optionally, when a random strategy is called as the deformation strategy, the image deformation methods in the deformation strategy include: methods in the basic deformation method library and methods in the scene simulation deformation method library; the deformation strategy also includes: a random number generation algorithm, an execution threshold set, and a random combination algorithm;
[0022] Furthermore, the deformation processing of the original field image in the original data set includes:
[0023] Sequentially obtain the original field images in the original data set;
[0024] Obtaining a first random number and a second random number using the random number generation algorithm, and obtaining a first threshold value and a second threshold value from the execution threshold value set;
[0025] When the first random number is greater than the first threshold, selecting at least one basic method to be executed from the basic deformation method library by using the random combination algorithm;
[0026] When the second random number is greater than the second threshold, selecting at least one scene method to be executed from the scene simulation deformation method library by using the random combination algorithm;
[0027] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0028] Optionally, the basic deformation method library includes at least the following deformation methods: random color space transformation method, random boundary clipping method, random scaling method, random basic enhancement method, and random deformation enhancement method;
[0029] The scene simulation deformation method library includes at least the following deformation methods: a seal interference method and a watermark interference method.
[0030] Optionally, the request further includes: an expansion multiple N;
[0031] The deforming the original field images in the original data set to obtain an enhanced field image set includes:
[0032] The original field images in the original data set are copied N times, and the N times number of original field images are deformed to obtain an enhanced field image set.
[0033] According to another aspect of the embodiments of the present invention, there is provided an apparatus for image recognition, comprising:
[0034] A receiving module, configured to receive a request for model enhancement training and obtain an original data set in the request;
[0035] A deformation module is used to call a deformation strategy and perform deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set;
[0036] The training and recognition module is used to use the enhanced field image set as the training sample of the character recognition model, and the corresponding sample labels in the original data set as training labels to perform enhanced training of the model, and then use the model obtained by the enhanced training for image recognition.
[0037] Optionally, before the receiving module receives the request for model enhancement training, the method further includes:
[0038] Generate the request for enhanced training based on the original data set used for training the model at a preset frequency; or
[0039] When it is detected that the recognition accuracy of the model for the image within a preset time period is lower than the accuracy threshold, a request for enhanced training is generated based on the original data set used for training the model.
[0040] Optionally, the deformation module calls a deformation strategy, including:
[0041] When receiving an enhanced scene instruction, calling a scene strategy configuration table to determine a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table;
[0042] When no enhanced scene instruction is received, a random strategy is called as the deformation strategy.
[0043] Optionally, when determining the deformation strategy corresponding to the enhanced scene from the scene strategy configuration table, the image deformation method in the deformation strategy includes: one or more basic methods in the basic deformation method library, one or more scene methods in the scene simulation deformation method library; the deformation strategy also includes: a scene combination algorithm;
[0044] Furthermore, the deformation module performs deformation processing on the original field image in the original data set, including:
[0045] Sequentially obtain the original field images in the original data set;
[0046] Selecting at least one to-be-executed basic method from the one or more basic methods, and selecting at least one to-be-executed scenario method from the one or more scenario methods, using the scenario combination algorithm;
[0047] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0048] Optionally, when a random strategy is called as the deformation strategy, the image deformation methods in the deformation strategy include: methods in the basic deformation method library and methods in the scene simulation deformation method library; the deformation strategy also includes: a random number generation algorithm, an execution threshold set, and a random combination algorithm;
[0049] Furthermore, the deformation module performs deformation processing on the original field image in the original data set, including:
[0050] Sequentially obtain the original field images in the original data set;
[0051] Obtaining a first random number and a second random number using the random number generation algorithm, and obtaining a first threshold value and a second threshold value from the execution threshold value set;
[0052] When the first random number is greater than the first threshold, selecting at least one basic method to be executed from the basic deformation method library by using the random combination algorithm;
[0053] When the second random number is greater than the second threshold, selecting at least one scene method to be executed from the scene simulation deformation method library by using the random combination algorithm;
[0054] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0055] Optionally, the basic deformation method library includes at least the following deformation methods: random color space transformation method, random boundary clipping method, random scaling method, random basic enhancement method, and random deformation enhancement method;
[0056] The scene simulation deformation method library includes at least the following deformation methods: a seal interference method and a watermark interference method.
[0057] Optionally, the request further includes: an expansion multiple N;
[0058] The deformation module performs deformation processing on the original field images in the original data set to obtain an enhanced field image set, including:
[0059] The original field images in the original data set are copied N times, and the N times number of original field images are deformed to obtain an enhanced field image set.
[0060] According to another aspect of an embodiment of the present invention, there is provided an image recognition electronic device, comprising:
[0061] one or more processors;
[0062] a storage device for storing one or more programs,
[0063] When the one or more programs are executed by the one or more processors, the one or more processors implement the image recognition method provided by the present invention.
[0064] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the image recognition method provided by the present invention is implemented.
[0065] An embodiment of the above invention has the following advantages or beneficial effects: because the relatively regular field images in the original data set used for model training are deformed to obtain an enhanced field image set, and then the model is enhanced and trained based on the enhanced field image set and the corresponding sample labels in the original data set, and then the model obtained by the enhanced training is used for image recognition, it overcomes the technical problem in the prior art that the model obtained by training using relatively regular images often cannot recognize images with various deformations in actual applications, resulting in a low image recognition accuracy of the model, thereby achieving the technical effect that the enhanced trained model can be applied to images with various deformations in actual applications, thereby improving the image recognition accuracy of the model.
[0066] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.
[0068] Figure 1 is a schematic diagram of the main process of an image recognition method according to the first embodiment of the present invention;
[0069] Figure 2 This is a schematic diagram of the deformation of a field text image in an actual application scenario of the present invention;
[0070] Figure 3 This is a schematic diagram of field text image samples used for training models in actual application scenarios of the present invention;
[0071] Figure 4 is a schematic diagram of a deformation effect after a random deformation enhancement method is used in an image recognition method according to a second embodiment of the present invention;
[0072] Figure 5 is a schematic flow chart of an image recognition method according to a third embodiment of the present invention;
[0073] Figure 6 is a schematic diagram of main modules of an image recognition device according to a fourth embodiment of the present invention;
[0074] Figure 7 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
[0075] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0076] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled 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 invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0077] Figure 1 FIG. 1 is a schematic diagram of the main process of an image recognition method according to the first embodiment of the present invention. Figure 1 Shown, including:
[0078] Step S101: receiving a request for model enhancement training and obtaining an original data set in the request;
[0079] Step S102: calling a deformation strategy, and performing deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set;
[0080] Step S103: Use the enhanced field image set as training samples of the character recognition model, and use the corresponding sample labels in the original data set as training labels to perform enhanced training of the model, and then use the model obtained by the enhanced training for image recognition.
[0081] The technical solution of the present invention is applied to OCR (Optical Character Recognition) technology. In the prior art, the EAST text detector is often used for text detection, which can detect horizontal and vertical texts at multiple angles, output a text box composed of four corner points, process it into a rectangular text image, and then use the CRNN recognition model to perform text recognition. Among them, the recognition accuracy of the CRNN recognition model is related to the degree of deformation of the rectangular text image, and the field images used to train the recognition model in the prior art are often relatively regular images under ideal conditions; but in actual applications, the text images obtained by using the EAST text detector usually have certain deformations. Figure 2 As shown, Figure 2 This is a schematic diagram of the deformation of field text images in the actual application scenario of the present invention, including the following deformation forms: tilted text, curved text, deformed artistic text, handwritten fonts, and real shooting tilt.
[0082] Moreover, since the CRNN recognition model only recognizes rectangular text images, the text box output by the EAST text detector needs to be transformed in perspective before being sent to the CRNN recognition model for recognition; however, there is a big difference between the ideal text image and the actual perspective-transformed image. Figure 3As shown, Figure 3 This is a schematic diagram of field text image samples used for training models in actual application scenarios of the present invention, wherein image 301 is a relatively regular image under ideal conditions, and image 302 is an image obtained after actual perspective change for model training.
[0083] Therefore, if relatively regular images under ideal conditions are used for model training, the model obtained in this case often cannot recognize images with various deformations in actual applications, which leads to low image recognition accuracy of the model.
[0084] The present invention proposes an image recognition method, which overcomes the technical problem in the prior art that models obtained by using relatively regular pictures for training often cannot recognize pictures with various deformations in actual applications, resulting in a low image recognition accuracy rate of the model, thereby achieving the technical effect that the model after enhanced training can be applied to pictures with various deformations in actual applications, thereby improving the image recognition accuracy rate of the model.
[0085] After the model is enhanced and trained in this solution, its robustness for deformed field recognition can be improved. Moreover, because the field images in the original dataset are deformed and the sample labels in the original dataset are used, the original text recognition level is maintained. In other words, while maintaining the model's field image recognition accuracy in the original test set, its field image recognition accuracy in the enhanced test set is improved.
[0086] In some embodiments, before receiving a request for model enhancement training, the method further includes:
[0087] Generate the request for enhanced training based on the original data set used for training the model at a preset frequency; or
[0088] When it is detected that the recognition accuracy of the model for the image within a preset time period is lower than the accuracy threshold, a request for enhanced training is generated based on the original data set used for training the model.
[0089] The above content can be considered as some methods to trigger model enhancement training. It can be based on a preset frequency to enhance the model at a fixed time point; it can also be triggered when the recognition accuracy of the model is detected to be lower than the accuracy threshold. Enhanced training of the model.
[0090] In some embodiments, calling the deformation strategy includes:
[0091] When receiving an enhanced scene instruction, calling a scene strategy configuration table to determine a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table;
[0092] When no enhanced scene instruction is received, a random strategy is called as the deformation strategy.
[0093] The deformation strategy can be pre-configured and can be related to specific scenarios, such as dim light scenes, seal interference scenes, etc. Since the deformation content in different scenarios may vary greatly, different deformation strategies can be configured for different scenarios.
[0094] In some embodiments, when determining the deformation strategy corresponding to the enhanced scene from the scene strategy configuration table, the image deformation method in the deformation strategy includes: one or more basic methods in the basic deformation method library, one or more scene methods in the scene simulation deformation method library; the deformation strategy also includes: a scene combination algorithm;
[0095] And, the deformation processing of the original field images in the original data set includes: obtaining the original field images in the original data set in sequence; using the scene combination algorithm to select at least one basic method to be executed from the one or more basic methods, and selecting at least one scene method to be executed from the one or more scene methods; based on the corresponding deformation parameters, using the basic method to be executed and the scene method to be executed to deform the original field images.
[0096] In some embodiments, when a random strategy is called as the deformation strategy, the image deformation methods in the deformation strategy include: methods in the basic deformation method library and methods in the scene simulation deformation method library; the deformation strategy also includes: a random number generation algorithm, an execution threshold set, and a random combination algorithm;
[0097] And, the deformation processing of the original field image in the original data set includes: obtaining the original field images in the original data set in sequence; using the random number generation algorithm to obtain a first random number and a second random number, and obtaining a first threshold and a second threshold from the execution threshold set; when the first random number is greater than the first threshold, using the random combination algorithm to select at least one to-be-executed basic method from the basic deformation method library; when the second random number is greater than the second threshold, using the random combination algorithm to select at least one to-be-executed scene method from the scene simulation deformation method library; based on the corresponding deformation parameters, using the to-be-executed basic method and the to-be-executed scene method to perform deformation processing on the original field image.
[0098] The settings in different deformation strategies can take into account actual enhancement requirements, such as:
[0099] In the deformation strategy corresponding to the scene, only one or several corresponding deformation methods can be used; in the random strategy, the proportion of images to be deformed can be controlled by setting the size relationship between the random number and the threshold. A combination algorithm can also be used to combine various deformation methods to enhance the randomness of the deformation.
[0100] Through the above method, a variety of deformable image data can be generated for model training.
[0101] In some embodiments, the basic deformation method library includes at least the following deformation methods: random color space transformation method, random boundary clipping method, random scaling method, random basic enhancement method, and random deformation enhancement method;
[0102] The scene simulation deformation method library includes at least the following deformation methods: a seal interference method and a watermark interference method.
[0103] In the basic deformation method library, the random color space transformation method mainly adjusts the hue, saturation and brightness, and the corresponding parameters can be adjusted to ±0.5 of the original parameters; the random boundary cropping method can randomly cut the upper, lower, left and right boundary pixels of the field to simulate the corner defects in real scenes, and the corresponding parameters can be controlled within 0.05 of each boundary ratio; the random scaling method can be used to stretch the width and height of the original image, destroy the proportion of the original image, and lay the foundation for the formation of different deformation features in the later stage. The corresponding parameters can be controlled at a stretching ratio of about 1.3; the random basic enhancement method can include basic functions of common image enhancement, such as Gaussian blur, random noise, random line interference, etc.; the random deformation enhancement method can include random affine deformation (random_affine), random inclined affine deformation (random_incline_affine), and random elastic deformation (random_elastic_transform).
[0104] Figure 4 FIG. 1 is a schematic diagram of a deformation effect after a random deformation enhancement method is used in an image recognition method according to a second embodiment of the present invention. Figure 4 As shown, picture 401 is the original picture, picture 402 is the picture after random affine deformation, picture 403 is the picture after random tilted affine deformation, and picture 404 is the picture after random elastic deformation.
[0105] In the scene simulation deformation method library, there are methods for making some specific deformations for the scene, such as seal interference in the invoice scene, watermark interference in the e-commerce scene, etc., and you can also flexibly add scene simulation deformation methods according to other scenes.
[0106] In some embodiments, the request further includes: an expansion multiple N;
[0107] The deforming the original field images in the original data set to obtain an enhanced field image set includes:
[0108] The original field images in the original data set are copied N times, and the N times number of original field images are deformed to obtain an enhanced field image set.
[0109] The original field image can be expanded by setting the expansion multiple to obtain more training samples and achieve better training results.
[0110] Figure 5 FIG. 1 is a flow chart of an image recognition method according to a third embodiment of the present invention; FIG. Figure 5 As shown in Figure 1, the deformation method when the random strategy is called as the deformation strategy includes:
[0111] Step S501: Obtain the original field image;
[0112] Step S502: Determine whether the first random number is greater than a first threshold; if so, execute step S503; if not, execute step S504;
[0113] Step S503: Select at least one basic method to be executed from the basic deformation method library to deform the image;
[0114] Step S504: Determine whether the second random number is greater than the second threshold; if so, execute step S505; if not, execute step S506;
[0115] Step S505: Select at least one scene method to be executed from the scene simulation deformation method library to deform the image;
[0116] Step S506: Obtain an enhanced field image.
[0117] Figure 6 FIG. 1 is a schematic diagram of main modules of an image recognition device according to a fourth embodiment of the present invention. Figure 6 As shown, the image recognition device 600 includes:
[0118] Receiving module 601, configured to receive a request for model enhancement training and obtain an original data set in the request;
[0119] The deformation module 602 is configured to call a deformation strategy and perform deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set;
[0120] The training and recognition module 603 is used to use the enhanced field picture set as the training sample of the character recognition model, and the corresponding sample labels in the original data set as training labels to perform enhanced training of the model, and then use the model obtained by the enhanced training for image recognition.
[0121] The present invention proposes an image recognition device, which performs deformation processing on relatively regular field images in the original data set used for model training to obtain an enhanced field image set, and then performs enhancement training on the model based on the enhanced field image set and the corresponding sample labels in the original data set, and then uses the model obtained by the enhanced training for image recognition. Therefore, it overcomes the technical problem in the prior art that the model obtained by using relatively regular images for training is often unable to recognize images with various deformations in actual applications, resulting in a low image recognition accuracy of the model. The technical effect of enabling the enhanced trained model to be applicable to images with various deformations in actual applications is achieved, thereby improving the image recognition accuracy of the model.
[0122] After the model is enhanced and trained in this solution, its robustness for deformed field recognition can be improved. Moreover, because the field images in the original dataset are deformed and the sample labels in the original dataset are used, the original text recognition level is maintained. In other words, while maintaining the model's field image recognition accuracy in the original test set, its field image recognition accuracy in the enhanced test set is improved.
[0123] In some embodiments, before the receiving module receives the request for model enhancement training, the method further includes:
[0124] Generate the request for enhanced training based on the original data set used for training the model at a preset frequency; or
[0125] When it is detected that the recognition accuracy of the model for the image within a preset time period is lower than the accuracy threshold, a request for enhanced training is generated based on the original data set used for training the model.
[0126] The above content can be considered as some methods to trigger model enhancement training. It can be based on a preset frequency to enhance the model at a fixed time point; it can also be triggered when the recognition accuracy of the model is detected to be lower than the accuracy threshold. Enhanced training of the model.
[0127] In some embodiments, the deformation module calls a deformation strategy, including:
[0128] When receiving an enhanced scene instruction, calling a scene strategy configuration table to determine a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table;
[0129] When no enhanced scene instruction is received, a random strategy is called as the deformation strategy.
[0130] The deformation strategy can be pre-configured and can be related to specific scenarios, such as dim light scenes, seal interference scenes, etc. Since the deformation content in different scenarios may vary greatly, different deformation strategies can be configured for different scenarios.
[0131] In some embodiments, when determining the deformation strategy corresponding to the enhanced scene from the scene strategy configuration table, the image deformation method in the deformation strategy includes: one or more basic methods in the basic deformation method library, one or more scene methods in the scene simulation deformation method library; the deformation strategy also includes: a scene combination algorithm;
[0132] Furthermore, the deformation module performs deformation processing on the original field image in the original data set, including:
[0133] Sequentially obtain the original field images in the original data set;
[0134] Selecting at least one to-be-executed basic method from the one or more basic methods, and selecting at least one to-be-executed scenario method from the one or more scenario methods, using the scenario combination algorithm;
[0135] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0136] In some embodiments, when a random strategy is called as the deformation strategy, the image deformation methods in the deformation strategy include: methods in the basic deformation method library and methods in the scene simulation deformation method library; the deformation strategy also includes: a random number generation algorithm, an execution threshold set, and a random combination algorithm;
[0137] Furthermore, the deformation module performs deformation processing on the original field image in the original data set, including:
[0138] Sequentially obtain the original field images in the original data set;
[0139] Obtaining a first random number and a second random number using the random number generation algorithm, and obtaining a first threshold value and a second threshold value from the execution threshold value set;
[0140] When the first random number is greater than the first threshold, selecting at least one basic method to be executed from the basic deformation method library by using the random combination algorithm;
[0141] When the second random number is greater than the second threshold, selecting at least one scene method to be executed from the scene simulation deformation method library by using the random combination algorithm;
[0142] Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
[0143] The settings in different deformation strategies can take into account actual enhancement requirements, such as:
[0144] In the deformation strategy corresponding to the scene, only one or several corresponding deformation methods can be used; in the random strategy, the proportion of images to be deformed can be controlled by setting the size relationship between the random number and the threshold. A combination algorithm can also be used to combine various deformation methods to enhance the randomness of the deformation.
[0145] Through the above method, a variety of deformable image data can be generated for model training.
[0146] In some embodiments, the basic deformation method library includes at least the following deformation methods: random color space transformation method, random boundary clipping method, random scaling method, random basic enhancement method, and random deformation enhancement method;
[0147] The scene simulation deformation method library includes at least the following deformation methods: a seal interference method and a watermark interference method.
[0148] In the basic deformation method library, the random color space transformation method mainly adjusts the hue, saturation and brightness, and the corresponding parameters can be adjusted to ±0.5 of the original parameters; the random boundary cropping method can randomly cut the upper, lower, left and right boundary pixels of the field to simulate the corner defects in real scenes, and the corresponding parameters can be controlled within 0.05 of each boundary ratio; the random scaling method can be used to stretch the width and height of the original image, destroy the proportion of the original image, and lay the foundation for the formation of different deformation features in the later stage. The corresponding parameters can be controlled at a stretching ratio of about 1.3; the random basic enhancement method can include basic functions of common image enhancement, such as Gaussian blur, random noise, random line interference, etc.; the random deformation enhancement method can include random affine deformation (random_affine), random inclined affine deformation (random_incline_affine), and random elastic deformation (random_elastic_transform).
[0149] In the scene simulation deformation method library, there are methods for making some specific deformations for the scene, such as seal interference in the invoice scene, watermark interference in the e-commerce scene, etc., and you can also flexibly add scene simulation deformation methods according to other scenes.
[0150] In some embodiments, the request further includes: an expansion multiple N;
[0151] The deformation module performs deformation processing on the original field images in the original data set to obtain an enhanced field image set, including:
[0152] The original field images in the original data set are copied N times, and the N times number of original field images are deformed to obtain an enhanced field image set.
[0153] The original field image can be expanded by setting the expansion multiple to obtain more training samples and achieve better training results.
[0154] Figure 7 An exemplary system architecture 700 is shown to which the image recognition method or image recognition apparatus according to the embodiment of the present invention can be applied.
[0155] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0156] Users can use terminal devices 701, 702, 703 to interact with server 705 via network 704 to receive or send messages, etc. Various client applications that require image recognition can be installed on terminal devices 701, 702, 703.
[0157] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0158] Server 705 may be a server that provides various services, such as a background management server that provides image recognition support for users using terminal devices 701, 702, and 703. The background management server may analyze and process received data such as image recognition requests, and feed back the processing results to the terminal devices.
[0159] It should be noted that the image recognition method provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the image recognition device is generally provided in the server 705 .
[0160] It should be understood that Figure 7The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0161] Reference below Figure 8 , which shows a schematic structural diagram of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0162] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage unit 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the system 800 are also stored in the RAM 803. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0163] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, and the like; an output section 807 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 808 including a hard disk; and a communication section 809 including a network interface card such as a LAN card or a modem. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 810 as needed, so that computer programs read therefrom can be installed into the storage section 808 as needed.
[0164] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from a removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are performed.
[0165] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0166] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0167] The modules described in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor. For example, a processor may be described as including a receiving module, a deformation module, and a training and recognition module. The names of these modules do not, in some cases, limit the modules themselves.
[0168] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: step S101, receiving a request for model enhancement training, and obtaining the original data set in the request; step S102, calling a deformation strategy, and deforming the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set; step S103, using the enhanced field image set as a training sample for the character recognition model, and using the corresponding sample labels in the original data set as training labels, to perform model enhancement training, and then using the model obtained by the enhanced training for image recognition.
[0169] According to the technical solution of an embodiment of the present invention, since the relatively regular field images in the original data set used for model training are deformed to obtain an enhanced field image set, and then the model is enhanced trained according to the enhanced field image set and the corresponding sample labels in the original data set, and then the model obtained by the enhanced training is used for image recognition, it overcomes the technical problem in the prior art that the model obtained by using relatively regular images for training often cannot recognize images with various deformations in actual applications, resulting in a low image recognition accuracy of the model, thereby achieving the technical effect that the enhanced trained model can be applied to images with various deformations in actual applications, thereby improving the image recognition accuracy of the model.
[0170] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. An image recognition method, characterized in that: include: Receive a request for model enhancement training and obtain the original data set in the request; wherein the request also includes: an expansion multiple N; Calling a deformation strategy, and performing deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set, including: copying the original field images in the original data set to N times, and performing deformation processing on the N times the number of original field images to obtain the enhanced field image set; The enhanced field picture set is used as a training sample of the character recognition model, and the corresponding sample labels in the original data set are used as training labels to perform enhanced training of the model, and then the model obtained by the enhanced training is used for image recognition.
2. The method according to claim 1, characterized in that Before receiving a request for model augmentation training, also include: Generate the request for enhanced training based on the original data set used for training the model at a preset frequency; or When it is detected that the recognition accuracy of the model for the image within a preset time period is lower than the accuracy threshold, a request for enhanced training is generated based on the original data set used for training the model.
3. The method according to claim 1, characterized in that The calling deformation strategy includes: When receiving an enhanced scene instruction, calling a scene strategy configuration table to determine a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table; When no enhanced scene instruction is received, a random strategy is called as the deformation strategy.
4. The method according to claim 3, characterized in that When determining a deformation strategy corresponding to the enhanced scene from the scene strategy configuration table, the image deformation methods in the deformation strategy include: one or more basic methods in the basic deformation method library, one or more scene methods in the scene simulation deformation method library; the deformation strategy also includes: a scene combination algorithm; Furthermore, the deformation processing of the original field image in the original data set includes: Sequentially obtain the original field images in the original data set; Selecting at least one to-be-executed basic method from the one or more basic methods, and selecting at least one to-be-executed scenario method from the one or more scenario methods, using the scenario combination algorithm; Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
5. The method according to claim 3, characterized in that When the random strategy is called as the deformation strategy, the image deformation methods in the deformation strategy include: methods in the basic deformation method library and methods in the scene simulation deformation method library; the deformation strategy also includes: a random number generation algorithm, an execution threshold set, and a random combination algorithm; Furthermore, the deformation processing of the original field image in the original data set includes: Sequentially obtain the original field images in the original data set; Obtaining a first random number and a second random number using the random number generation algorithm, and obtaining a first threshold value and a second threshold value from the execution threshold value set; When the first random number is greater than the first threshold, selecting at least one basic method to be executed from the basic deformation method library by using the random combination algorithm; When the second random number is greater than the second threshold, selecting at least one scene method to be executed from the scene simulation deformation method library by using the random combination algorithm; Based on the corresponding deformation parameters, the original field image is deformed using the to-be-executed basic method and the to-be-executed scenario method.
6. The method according to claim 4 or 5, characterized in that The basic deformation method library includes at least the following deformation methods: random color space transformation method, random boundary clipping method, random scaling method, random basic enhancement method, and random deformation enhancement method; The scene simulation deformation method library includes at least the following deformation methods: a seal interference method and a watermark interference method.
7. An image recognition device, characterized in that: include: A receiving module, configured to receive a request for model enhancement training and obtain an original data set in the request; wherein the request further includes: an expansion multiple N; a deformation module, configured to call a deformation strategy and perform deformation processing on the original field images in the original data set according to the image deformation method and corresponding deformation parameters in the deformation strategy to obtain an enhanced field image set, including: copying the original field images in the original data set to N times, and performing deformation processing on the N times the number of original field images to obtain an enhanced field image set; The training and recognition module is used to use the enhanced field picture set as the training sample of the character recognition model, and the corresponding sample labels in the original data set as the training labels to perform enhanced training of the model, and then use the model obtained by the enhanced training for image recognition.
8. An image recognition electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Image classifier establishing method and image classifier establishing device
CN106815596A