WO2020073497A1 - Chinese language training image generation method and apparatus, computer device, and storage medium - Google Patents

Chinese language training image generation method and apparatus, computer device, and storage medium Download PDF

Info

Publication number
WO2020073497A1
WO2020073497A1 PCT/CN2018/122993 CN2018122993W WO2020073497A1 WO 2020073497 A1 WO2020073497 A1 WO 2020073497A1 CN 2018122993 W CN2018122993 W CN 2018122993W WO 2020073497 A1 WO2020073497 A1 WO 2020073497A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
chinese
scene
transparent
chinese character
Prior art date
Application number
PCT/CN2018/122993
Other languages
French (fr)
Chinese (zh)
Inventor
黄泽浩
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020073497A1 publication Critical patent/WO2020073497A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of image recognition technology, and in particular, to a Chinese training image generation method, device, computer equipment, and storage medium.
  • OCR Optical Character Recognition, optical character recognition
  • OCR recognition technology is currently the most commonly used technology for analyzing and recognizing image files to obtain text and layout information.
  • OCR recognition technology is used to train the image recognition model, it is necessary to manually collect the training images and mark them to form a training set, and then perform model training based on the marked training set, which is time-consuming and labor-intensive.
  • Embodiments of the present application provide a method, device, computer equipment, and storage medium for generating a Chinese training image, to solve the problem that in the current image recognition model training process, training images need to be collected manually and labeled to form a training set, which is time-consuming and labor The problem of high cost.
  • a Chinese training image generation method including:
  • a Chinese training image generation device including:
  • a training image generation request acquisition module configured to acquire a training image generation request, where the training image generation request includes scene application requirements
  • the scene application requirement processing module is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the original background image from the pre-created Chinese character library Chinese characters corresponding to scene application requirements;
  • a first transparent image acquisition module configured to perform transparency processing on the original background image to obtain a first transparent image
  • a second transparent image acquisition module configured to fill the Chinese character on the first transparent image, acquire a second transparent image, use the Chinese character to mark the second transparent image, and acquire the second transparent image
  • the image-to-be-trained acquisition module is used to add noise to the second transparent image, obtain a third transparent image, perform superposition processing on the third transparent image and the original background image, obtain the image to be trained, and convert the The training image is stored in association with the text file.
  • a computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor.
  • the processor executes the computer-readable instructions, the following steps are implemented:
  • One or more non-volatile readable storage media storing computer-readable instructions, which when executed by one or more processors, cause the one or more processors to perform the following steps:
  • the training image generation request acquisition module is used to obtain a training image generation request, and the training image generation request includes scene application requirements;
  • the scene application requirement processing module is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the original background image from the pre-created Chinese character library Chinese characters corresponding to scene application requirements;
  • a first transparent image acquisition module configured to perform transparency processing on the original background image to obtain a first transparent image
  • a second transparent image acquisition module configured to fill the Chinese character on the first transparent image, acquire a second transparent image, use the Chinese character to mark the second transparent image, and acquire the second transparent image
  • the image-to-be-trained acquisition module is used to add noise to the second transparent image, obtain a third transparent image, perform superposition processing on the third transparent image and the original background image, obtain the image to be trained, and convert the The training image is stored in association with the text file.
  • FIG. 1 is a schematic diagram of an application environment of a method for generating Chinese training images in an embodiment of the present application
  • FIG. 2 is a flowchart of a method for generating Chinese training images in an embodiment of the present application
  • FIG. 3 is a specific flowchart of step S20 in FIG. 2;
  • FIG. 4 is a specific flowchart of step S30 in FIG. 2;
  • FIG. 5 is a specific flowchart of step S40 in FIG. 2;
  • FIG. 6 is a schematic diagram of a Chinese training image generation device in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a computer device in an embodiment of the present application.
  • the Chinese training image generation method provided in this application can be applied in the application environment as shown in FIG. 1.
  • the Chinese training image generation method can be applied in a Chinese training image generation tool for automatically generating Chinese training images, saving manual data collection and Mark the time to improve efficiency.
  • Chinese training image generation tools include servers and computer equipment.
  • the computer equipment communicates with the server through the network.
  • the computer device may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
  • the server can be implemented with an independent server.
  • a method for generating a Chinese training image is provided.
  • the method is applied to the server in FIG. 1 as an example for illustration, which includes the following steps:
  • the training image generation request is a request for triggering a Chinese training image generation tool to generate a training image.
  • the scene application requirement refers to the requirement to generate training images of the application in a specific scene.
  • a list of scene types is displayed on the display interface of the Chinese training image generation tool.
  • the list of scene types includes Hong Kong ID cards, second-generation ID cards, airline boarding passes (such as Air China) and the front of each bank card (Such as: Industrial and Commercial Bank of China) and other scene types are convenient for users to choose.
  • the background image library is an image library of background images uploaded or produced in advance by taking pictures.
  • the background image library includes scene images and non-scene images.
  • the scene image refers to the background image applied in a specific scene.
  • the scene images include, but are not limited to, the Hong Kong ID card image, the second-generation ID card image, the airline boarding pass images, and the bank card front images provided by this embodiment.
  • Non-scene images refer to background images applied to non-specific scenes, such as background images of different colors.
  • the original background image is based on the scene application requirements, and the server obtains the background image corresponding to the scene application requirements (such as the second-generation ID card) from the pre-created background image library.
  • the Chinese character library includes commonly used Chinese first-level character libraries, hundred family names and traditional character libraries. If you want to generate a Hong Kong identity card, you can obtain the corresponding traditional Chinese characters from the traditional Chinese character library; if you do not need to generate traditional Chinese characters, you can obtain the corresponding Chinese characters from the Chinese first-level character library. Understandably, Chinese characters include traditional characters or simplified characters. The Chinese characters are based on the scene application requirements, and the Chinese characters corresponding to the application requirements are obtained from the pre-created Chinese character library.
  • the server obtains the original background image corresponding to the scene application demand, that is, the ID card background image, from the pre-created background image library based on the scene application demand,
  • a good Chinese character library can obtain Chinese characters (such as names) corresponding to the application requirements of the scene. This process does not require manual collection of original background images and editing of Chinese characters, saving time and providing technical support for the subsequent generation of training images.
  • Transparency processing includes but is not limited to using pillow library technology for processing.
  • Pillow is an image processing library (PIL: Python Image Library) in the Python tool, which provides extensive file format support and powerful image processing capabilities. It mainly provides image storage, image display, format conversion, and basic image processing operations. The interface can be directly called, which is simple to implement and can effectively save the time of repeated development.
  • S40 Fill the first transparent image with Chinese characters, obtain a second transparent image, mark the second transparent image with Chinese characters, and obtain a text file corresponding to the second transparent image.
  • the second transparent image refers to a transparent image filled with Chinese characters corresponding to scene application requirements in the first transparent image.
  • the text file refers to a label file corresponding to the second transparent image.
  • N N is a positive integer greater than 1 and can be specified by the user
  • the server uses the pillow library technology to randomly select the first transparent image corresponding to the original background image to convert the selected Chinese
  • the word is filled on the selected first transparent image to obtain the second transparent image.
  • the server will use the selected Chinese characters to mark the second transparent image to obtain the text file corresponding to the second transparent image. This process does not require Manual labeling, you can automatically label.
  • S50 Add noise to the second transparent image, obtain the third transparent image, superimpose the third transparent image and the original background image, obtain the image to be trained, and store the image to be trained in association with the text file.
  • the third transparent image is a transparent image after adding noise to the second transparent image.
  • the server randomly selects a predetermined proportion of pixels that need to increase noise, so as to randomly increase noise on the proportion of pixels, so as to increase the robustness of the training image.
  • the third transparent image and the original background image are superimposed to obtain the image to be trained, and the image to be trained is stored in association with the text file to form a training sample, so that the training sample is used for model training, and the step of manual collection is omitted ,Improve efficiency.
  • Superimposition processing refers to the process of superimposing the third transparent image and the original background image into one image, so as to obtain the image to be trained.
  • the imadd function is used to superimpose the third transparent image and the original background image to obtain the image to be trained.
  • the imadd function is a function in computer language used to superimpose images.
  • the types of noise include but are not limited to reflection, interference lines, interference color point, tilt angle (including two tilt methods, each tilt method includes three tilt angles: 0.5, 1 and 1.5), dilation, corrosion and Gaussian blur etc. .
  • the preset ratio is the ratio automatically recommended by the Chinese training image mixing generation tool according to the experience value, and supports user changes. There are two ways to change it: one is to change the proportion of pixels with increased noise; the other is to change and increase The number of pixels of noise.
  • the processing of expansion and corrosion is judged according to the font to be generated, taking the generation of a Hong Kong identity card as an example. For conventional fonts, expansion processing can be selected due to the thinner lines of the conventional font, while for bold fonts, Because the lines are thicker, corrosion treatment can be selected to enhance the clarity of the training image.
  • the server first obtains the training image generation request, so as to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirements in the training image generation request, and create The Chinese characters corresponding to the application requirements of the scene are obtained from the Chinese character library in this database.
  • This process does not require manual collection of original background images and editing of Chinese characters, saving time. Transparency is performed on the original background image to obtain the first transparent image to highlight the effect of increasing noise in subsequent images. Then, fill the first transparent image with Chinese characters to obtain the second transparent image, and at the same time, use the Chinese characters to label the second transparent image to obtain the text file corresponding to the second transparent image.
  • This process does not require manual labeling, that is, The second transparent image can be automatically annotated.
  • add noise to the second transparent image obtain the third transparent image, superimpose the third transparent image and the original background image to obtain the image to be trained, and increase the authenticity of the image to be trained to improve the subsequent use of the image to be trained
  • the recognition accuracy of the model obtained by training is also associated and stored with the text file to form a training sample, so that the training sample is used for training without manual collection, and the efficiency is improved.
  • step S20 that is, based on the scene application requirements, the original background image corresponding to the scene application requirements is obtained from the pre-created background image library, and the pre-created Chinese character library is obtained.
  • Obtain the Chinese characters corresponding to the application requirements of the scene including the following steps:
  • the original background image corresponding to the first application requirement is obtained from the background image library.
  • the original background image includes the scene field, and based on the scene field, according to the preset generation rule, the Chinese characters The Chinese characters corresponding to the scene fields are obtained from the library.
  • the first application requirement refers to generating training images that are applied in specific scenarios, such as second-generation ID card images and bank card front images.
  • the scene application requirement is the first application requirement
  • the original background image corresponding to the first application requirement is obtained from the background image library.
  • the original background image includes a scene field (such as a name), based on the scene field, according to the preset Generate rules to get the Chinese characters corresponding to the scene field from the Chinese character library.
  • the preset generation rule is a rule set in advance for generating attribute values corresponding to each scene field.
  • the server will obtain the second-generation ID card image from the background image library as the original background image based on the first application requirement.
  • Scene fields such as year, month, date, address and ID number.
  • the Chinese characters corresponding to each scene field are obtained from the Chinese character library according to the preset generation rules. This process requires no human intervention and saves labor costs.
  • the preset generation rule of the name field in this embodiment is limited to 10 characters.
  • the corresponding preset generation rule is one of the two characters male / female.
  • the default generation rules are set according to the date format.
  • address data crawled from the existing address database by web crawlers can be used. These address data basically conform to their corresponding preset generation rules.
  • the preset generation rules for ID card numbers are as follows: Since the ID card number structure has a fixed format, the ID number is a combination code of features, consisting of a 17-digit numeric body code and a check code. The arrangement order from left to right is: six-digit address code, eight-digit birth date code, three-digit sequence code and one-digit check code.
  • the address code (first six digits) indicates the administrative division code of the county (city, flag, district) where the permanent residence of the encoding object is located, and shall be implemented in accordance with the provisions of GB / T2260.
  • the region and the region code will be associated first, and then the region and the corresponding region code will be randomly obtained.
  • 7-14 digits are the year and month of birth, randomly generated according to the date format.
  • 15 to 17 bits are sequential codes, which are generated according to the random number generation method.
  • the last digit check code is generated according to the check code rule.
  • the date of birth code indicates the year, month, and day of birth of the coding object, and is implemented in accordance with the provisions of GB / T7408.
  • the sequence code indicates the sequence number assigned to people born in the same year, month, and day within the area identified by the same address code.
  • the odd number of the sequence code is assigned to men, and the even number is assigned to women.
  • the verification code acquisition process includes the following steps:
  • the calculation method of the eighteenth digit is: 1. Multiply the 17 digits of the previous ID number by different coefficients. The coefficients from the first place to the seventeenth place are: 7 9 10 10 5 8 8 4 2 6 3 3 7 9 10 8 5. 2. Add the result of multiplying the 17 digits and the coefficient. 3. Divide the sum by 11, and see what is the remainder? 4. The remainder can only have 11 numbers of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The number of the last ID card corresponding to it is 1 0 0 X 9 9 8 8 5 5 4 3 2. 5. If the remainder is 2, the 18th digit of the ID will be the Roman numeral X. If the remainder is 10, the last number of the ID card is 2.
  • the second application requirement refers to generating training images that are applied in non-specific scenarios, such as Chinese character images. Because this type of Chinese character image is only used to train the OCR Chinese character recognition model in non-specific scenes, the original background image can be randomly obtained directly from the background image library, and the corresponding Chinese character can be randomly obtained from the Chinese character library, which is simple and convenient.
  • the scene application requirement is the first application requirement
  • the original background image corresponding to the first application requirement is obtained from the background image library, so that based on the scene field in the original background image, a preset generation rule is used, Obtain the Chinese characters corresponding to the scene field from the Chinese character library without manual intervention, saving labor costs.
  • the scene application requirement is the second application requirement, it is simple and convenient to randomly obtain the original background image from the direct background image library and randomly obtain the Chinese characters from the Chinese character library.
  • the scene field includes a name field;
  • the Chinese character library includes a hundred family names and a Chinese first-level character library.
  • the Chinese characters corresponding to the scene fields are obtained from the Chinese character library according to the preset generation rules based on the scene fields, which specifically includes:
  • the surnames are obtained sequentially or randomly from the hundred family surnames, and the Chinese characters are obtained sequentially or randomly from the first-class Chinese character library.
  • One is to obtain the surnames from the surnames of the surnames in the order of the surnames, and then obtain the Chinese characters in sequence from the first-class Chinese character library and splice the surnames with the Chinese characters .
  • You can obtain the Chinese characters corresponding to the name field, and improve the efficiency of obtaining the attribute value corresponding to the name field.
  • randomly select the surnames from the surnames as the surnames corresponding to the name field randomly select the Chinese characters from the first-class Chinese character library, and stitch the selected surnames with the Chinese characters to obtain the Chinese characters corresponding to the name field Get the diversity of attribute values corresponding to the name field.
  • the corresponding surnames can also be selected according to the proportion of the number of various surnames currently counted by relevant agencies, and the Chinese characters can be selected from commonly used Chinese characters and randomly combined to ensure the diversity of their combinations. It can improve the authenticity and reliability of the image recognition model obtained by training with the obtained training images.
  • the Chinese character library also includes a traditional character library. If you want to generate a Hong Kong identity card, you do not need to obtain simplified Chinese characters from the Chinese first-level character library. You can directly obtain the corresponding traditional characters from the traditional character library. For the family names, the family names used in step S21 are in simplified Chinese characters. If you want to generate a Hong Kong identity card, you can obtain the family names from the family names in traditional Chinese characters. Splicing, you can get the Chinese characters corresponding to the name field.
  • step S30 the original background image is transparentized to obtain the first transparent image, which specifically includes the following steps:
  • S31 Perform mode conversion on the original background image to obtain a mode image, and the mode image includes color parameters.
  • the mode image refers to a true color image mode with transparency (abbreviated as RGBA mode).
  • RGBA mode a true color image mode with transparency
  • the image mode of the original background image itself is the RGB mode (that is, the color image mode).
  • the size parameter specifies the length and width of the image in pixels.
  • the color parameter is the color parameter used to define the background color of the image (ie, the original background image).
  • RGBA mode is Red (red), Green (green), Blue (blue) and Alpha color space mode, that is, transparency.
  • the server defaults to a transparent background, and the first transparent image is obtained, which is simple to implement and improves the efficiency of generating training images.
  • the server first converts the original background image to obtain a pattern image with transparency.
  • the color parameter in the pattern image By setting the color parameter in the pattern image to empty, the first transparent image is obtained, which is simple to implement and improves the efficiency of generating training images .
  • step S40 the Chinese characters are filled on the first transparent image to obtain the second transparent image, which specifically includes the following steps:
  • the attribute parameters corresponding to the Chinese characters include the position, content, color and font of the Chinese characters to be filled in the first transparent image.
  • This attribute parameter is set in advance according to different scene application requirements. Understandably, if the scenario application requirement is the first application requirement, the setting is performed according to the actual application scenario. For example, if the first application requires a second-generation ID card, the attribute parameters corresponding to the Chinese characters are set according to the text attributes in the actual ID card image to fit the reality and improve the authenticity and reliability of the training image. For example, if the scene application requirement is the second application requirement, you can randomly obtain the attribute parameters corresponding to the Chinese characters.
  • the corresponding font For example, if you want to generate a Chinese character image, you can randomly select the corresponding font from the pre-stored fonts (such as Kai and Song), or Can be customized by the user.
  • the text content, text color, and text position can also be randomly obtained by the server or customized by the user, which improves the practicality of the Chinese training image generation tool.
  • S42 Apply the attribute parameters to the text filling function to fill the first transparent image with Chinese characters and obtain the second transparent image.
  • the server applies the attribute parameters to the text filling function based on the image processing technology (namely, the pillow library technology) to fill the Chinese characters on the first transparent image and obtain the second transparent image.
  • the first parameter (40,10) represents the text position
  • the second parameter u represents the text content
  • the third parameter font represents the text font
  • the fourth parameter fill represents the text color.
  • the server obtains the attribute parameters corresponding to the Chinese characters, so that based on the attribute parameters, the image processing interface provided by the pillow library technology is used to fill the Chinese characters on the first transparent image and obtain the second transparent image. Manual intervention to achieve the purpose of automatically generating training images.
  • a Chinese training image generating device is provided, and the Chinese training image generating device corresponds one-to-one to the Chinese training image generating method in the foregoing embodiment.
  • the Chinese training image generation device includes a training image generation request acquisition module 10, a scene application demand processing module 20, a first transparent image acquisition module 30, a second transparent image acquisition module 40, and a to-be-trained image acquisition module 50 .
  • the detailed description of each functional module is as follows:
  • the training image generation request obtaining module 10 is used to obtain a training image generation request, and the training image generation request includes scene application requirements.
  • the scene application requirement processing module 20 is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the scene application requirement corresponding to the scene application requirement from the pre-created Chinese character library Chinese characters.
  • the first transparent image acquisition module 30 is configured to perform transparency processing on the original background image to acquire the first transparent image.
  • the second transparent image obtaining module 40 is used to fill Chinese characters on the first transparent image, obtain the second transparent image, mark the second transparent image with Chinese characters, and obtain a text file corresponding to the second transparent image.
  • the image-to-be-trained acquisition module 50 is used to add noise to the second transparent image, obtain the third transparent image, superimpose the third transparent image and the original background image, obtain the image to be trained, and store the image to be trained in association with the text file .
  • the scene application requirement processing module includes a first processing unit and a second processing unit.
  • the first processing unit is used to obtain an original background image corresponding to the first application requirement from the background image library if the scene application requirement is the first application requirement, the original background image includes a scene field; based on the scene field, the preset Generate rules to get the Chinese characters corresponding to the scene field from the Chinese character library.
  • the second processing unit is configured to randomly obtain original background images from the background image library and randomly obtain Chinese characters from the Chinese character library if the scene application requirement is the second application requirement.
  • the first processing unit is specifically: based on the name field, sequentially or randomly obtain the surnames from the hundred family surnames, and sequentially or randomly obtain the Chinese characters from the first-class Chinese character library; Corresponding Chinese characters.
  • the first transparent image acquisition module includes an image mode conversion unit and a first transparent image acquisition unit.
  • the image mode conversion unit is used for mode conversion of the original background image to obtain a mode image; the mode image includes color parameters.
  • the first transparent image acquisition unit is configured to set the color parameter of the pattern image to be empty and acquire the first transparent image.
  • the second transparent image acquisition module includes an attribute parameter acquisition unit and a second transparent image acquisition unit.
  • the attribute parameter obtaining unit is used to obtain attribute parameters corresponding to Chinese characters.
  • the second transparent image obtaining unit is used to apply attribute parameters to the text filling function to fill the first transparent image with Chinese characters and obtain the second transparent image.
  • Each module in the above-mentioned Chinese training image generating device may be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above modules may be embedded in the hardware or independent of the processor in the computer device, or may be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 7.
  • the computer device includes a processor, memory, network interface, and database connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer-readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the database of the computer device is used to store data generated or acquired during the execution of the Chinese training image generation method, such as the image to be trained.
  • the network interface of the computer device is used to communicate with external terminals through a network connection. When the computer readable instructions are executed by the processor to implement a Chinese training image generation method.
  • a computer device which includes a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor.
  • the processor implements the computer-readable instructions to implement the The steps of the Chinese training image generation method, such as steps S10-S50 shown in FIG. 2, or the steps shown in FIGS. 3 to 5.
  • the processor implements the functions of each module / unit in the embodiment of the Chinese training image generating device when executing the computer-readable instructions, for example, the function of each module / unit shown in FIG. 6, to avoid repetition, it will not be repeated here .
  • a computer-readable storage medium stores computer-readable instructions, which when executed by a processor, implements the steps of the method for generating a Chinese training image in the foregoing embodiments For example, steps S10-S50 shown in FIG. 2 or steps shown in FIG. 3 to FIG. 5, in order to avoid repetition, they will not be repeated here.
  • the computer-readable instructions when executed by the processor, the functions of each module / unit in the above embodiment of the Chinese training image generation device, such as the functions of each module / unit shown in FIG. 6, are implemented. To avoid repetition, here No longer.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM random access memory
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain (Synchlink) DRAM
  • RDRAM direct RAM
  • DRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

Disclosed are a Chinese language training image generation method and apparatus, a computer device, and a storage medium. The Chinese language training image generation method comprises: obtaining a training image generation request, wherein the training image generation request comprises a scene application requirement; based on the scene application requirement, obtaining an original background image from a precreated background image library; obtaining Chinese characters from a precreated Chinese character library; performing transparent processing on the original background image to obtain a first transparent image; adding the Chinese characters to the first transparent image to obtain a second transparent image, and labeling the second transparent image with Chinese characters to obtain a text file corresponding to the second transparent image; adding a noise point to the second transparent image to obtain a third transparent image, performing superposition on the third transparent image and the original background image to obtain an image to be trained, and storing the image to be trained in association with the text file. This process does not require collection of a training image manually, thereby improving the efficiency.

Description

中文训练图像生成方法、装置、计算机设备及存储介质Chinese training image generation method, device, computer equipment and storage medium
本专利申请以2018年10月11日提交的申请号为201811182135.9,名称为“中文训练图像生成方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。This patent application is based on the Chinese invention patent application filed on October 11, 2018 with the application number 201811182135.9 and titled "Chinese Training Image Generation Method, Device, Computer Equipment, and Storage Media", and claims its priority.
技术领域Technical field
本申请涉及图像识别技术领域,尤其涉及一种中文训练图像生成方法、装置、计算机设备及存储介质。The present application relates to the field of image recognition technology, and in particular, to a Chinese training image generation method, device, computer equipment, and storage medium.
背景技术Background technique
随着信息时代的飞速发展,人工智能技术也被人们逐渐应用到各种实际场景中。其中,OCR(Optical Character Recognition,光学字符识别)技术是目前对图像文件进行分析识别处理,获取文字及版面信息最常用的技术。但在采用OCR识别技术训练图像识别模型时,需要人工收集训练图像并对其进行标注以形成训练集,然后基于标注好的训练集进行模型训练,耗费时间且人力成本高。With the rapid development of the information age, artificial intelligence technology has also been gradually applied to various practical scenarios. Among them, OCR (Optical Character Recognition, optical character recognition) technology is currently the most commonly used technology for analyzing and recognizing image files to obtain text and layout information. However, when the OCR recognition technology is used to train the image recognition model, it is necessary to manually collect the training images and mark them to form a training set, and then perform model training based on the marked training set, which is time-consuming and labor-intensive.
发明内容Summary of the invention
本申请实施例提供一种中文训练图像生成方法、装置、计算机设备及存储介质,以解决目前图像识别模型训练过程中,需要人工收集训练图像并对其进行标注以形成训练集,耗费时间且人力成本高的问题。Embodiments of the present application provide a method, device, computer equipment, and storage medium for generating a Chinese training image, to solve the problem that in the current image recognition model training process, training images need to be collected manually and labeled to form a training set, which is time-consuming and labor The problem of high cost.
一种中文训练图像生成方法,包括:A Chinese training image generation method, including:
获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;Obtain a training image generation request, which includes scene application requirements;
基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library; obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library ;
对所述原始背景图像进行透明化处理,获取第一透明图像;Performing transparency processing on the original background image to obtain a first transparent image;
将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;Filling the first transparent image with the Chinese character, obtaining a second transparent image, using the Chinese character to mark the second transparent image, and obtaining a text file corresponding to the second transparent image;
对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。Adding noise to the second transparent image, obtaining a third transparent image, superimposing the third transparent image and the original background image, obtaining an image to be trained, and associating the image to be trained with the text file storage.
一种中文训练图像生成装置,包括:A Chinese training image generation device, including:
训练图像生成请求获取模块,用于获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;A training image generation request acquisition module, configured to acquire a training image generation request, where the training image generation request includes scene application requirements;
场景应用需求处理模块,用于基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;The scene application requirement processing module is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the original background image from the pre-created Chinese character library Chinese characters corresponding to scene application requirements;
第一透明图像获取模块,用于对所述原始背景图像进行透明化处理,获取第一透明图像;A first transparent image acquisition module, configured to perform transparency processing on the original background image to obtain a first transparent image;
第二透明图像获取模块,用于将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;A second transparent image acquisition module, configured to fill the Chinese character on the first transparent image, acquire a second transparent image, use the Chinese character to mark the second transparent image, and acquire the second transparent image The text file corresponding to the two transparent images;
待训练图像获取模块,用于对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。The image-to-be-trained acquisition module is used to add noise to the second transparent image, obtain a third transparent image, perform superposition processing on the third transparent image and the original background image, obtain the image to be trained, and convert the The training image is stored in association with the text file.
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the following steps are implemented:
获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;Obtain a training image generation request, which includes scene application requirements;
基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library; obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library ;
对所述原始背景图像进行透明化处理,获取第一透明图像;Performing transparency processing on the original background image to obtain a first transparent image;
将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;Filling the first transparent image with the Chinese character, obtaining a second transparent image, using the Chinese character to mark the second transparent image, and obtaining a text file corresponding to the second transparent image;
对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。Adding noise to the second transparent image, obtaining a third transparent image, superimposing the third transparent image and the original background image, obtaining an image to be trained, and associating the image to be trained with the text file storage.
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:One or more non-volatile readable storage media storing computer-readable instructions, which when executed by one or more processors, cause the one or more processors to perform the following steps:
训练图像生成请求获取模块,用于获取训练图像生成请求,所述训练图像生成请求包 括场景应用需求;The training image generation request acquisition module is used to obtain a training image generation request, and the training image generation request includes scene application requirements;
场景应用需求处理模块,用于基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;The scene application requirement processing module is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the original background image from the pre-created Chinese character library Chinese characters corresponding to scene application requirements;
第一透明图像获取模块,用于对所述原始背景图像进行透明化处理,获取第一透明图像;A first transparent image acquisition module, configured to perform transparency processing on the original background image to obtain a first transparent image;
第二透明图像获取模块,用于将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;A second transparent image acquisition module, configured to fill the Chinese character on the first transparent image, acquire a second transparent image, use the Chinese character to mark the second transparent image, and acquire the second transparent image The text file corresponding to the two transparent images;
待训练图像获取模块,用于对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。The image-to-be-trained acquisition module is used to add noise to the second transparent image, obtain a third transparent image, perform superposition processing on the third transparent image and the original background image, obtain the image to be trained, and convert the The training image is stored in association with the text file.
本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。The details of one or more embodiments of the present application are set forth in the following drawings and description, and other features and advantages of the present application will become apparent from the description, drawings, and claims.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application For those of ordinary skill in the art, without paying creative labor, other drawings can also be obtained based on these drawings.
图1是本申请一实施例中中文训练图像生成方法的一应用环境示意图;1 is a schematic diagram of an application environment of a method for generating Chinese training images in an embodiment of the present application;
图2是本申请一实施例中中文训练图像生成方法的一流程图;2 is a flowchart of a method for generating Chinese training images in an embodiment of the present application;
图3是图2中步骤S20的一具体流程图;FIG. 3 is a specific flowchart of step S20 in FIG. 2;
图4是图2中步骤S30的一具体流程图;FIG. 4 is a specific flowchart of step S30 in FIG. 2;
图5是图2中步骤S40的一具体流程图;FIG. 5 is a specific flowchart of step S40 in FIG. 2;
图6是本申请一实施例中中文训练图像生成装置的一示意图;6 is a schematic diagram of a Chinese training image generation device in an embodiment of the present application;
图7是本申请一实施例中计算机设备的一示意图。7 is a schematic diagram of a computer device in an embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地 描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of this application.
本申请提供的中文训练图像生成方法,可应用在如图1的应用环境中,该中文训练图像生成方法可应用在中文训练图像生成工具中,用于自动生成中文训练图像,节省人工收集数据并标注的时间,提高效率。其中,中文训练图像生成工具包括服务器和计算机设备。其中,计算机设备通过网络与服务器进行通信。计算机设备可以但不限于各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。服务器可以用独立的服务器来实现。The Chinese training image generation method provided in this application can be applied in the application environment as shown in FIG. 1. The Chinese training image generation method can be applied in a Chinese training image generation tool for automatically generating Chinese training images, saving manual data collection and Mark the time to improve efficiency. Among them, Chinese training image generation tools include servers and computer equipment. Among them, the computer equipment communicates with the server through the network. The computer device may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server can be implemented with an independent server.
在一实施例中,如图2所示,提供一种中文训练图像生成方法,以该方法应用在图1中的服务器为例进行说明,包括如下步骤:In an embodiment, as shown in FIG. 2, a method for generating a Chinese training image is provided. The method is applied to the server in FIG. 1 as an example for illustration, which includes the following steps:
S10:获取训练图像生成请求,训练图像生成请求包括场景应用需求。S10: Obtain a training image generation request, which includes scene application requirements.
其中,训练图像生成请求是用于触发中文训练图像生成工具生成训练图像的请求。场景应用需求是指生成应用在特定场景下的训练图像的需求。具体地,在中文训练图像生成工具的显示界面上会显示场景类型列表,该场景类型列表包括香港身份证、二代身份证、各航空公司登机牌(如:国航)和各家银行卡正面(如:工商银行)等场景类型,便于用户选择,根据用户选择的场景类型确定场景应用需求,以使服务器获取训练图像生成请求,并根据该训练图像生成请求获取场景应用需求。The training image generation request is a request for triggering a Chinese training image generation tool to generate a training image. The scene application requirement refers to the requirement to generate training images of the application in a specific scene. Specifically, a list of scene types is displayed on the display interface of the Chinese training image generation tool. The list of scene types includes Hong Kong ID cards, second-generation ID cards, airline boarding passes (such as Air China) and the front of each bank card (Such as: Industrial and Commercial Bank of China) and other scene types are convenient for users to choose. Determine the scene application requirements according to the scene type selected by the user, so that the server obtains the training image generation request and obtains the scene application requirements according to the training image generation request.
S20:基于场景应用需求,从预先创建好的背景图像库中获取与场景应用需求相对应的原始背景图像,从预先创建好的中文字库中获取与场景应用需求相对应的中文字。S20: Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library, and obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library.
其中,背景图像库是预先通过拍照上传或制作的背景图像的图像库。该背景图想库包括场景图像和非场景图像。场景图像是指应用在特定场景下的背景图像。场景图像包括但不限于本实施例提供的香港身份证图像、二代身份证图像、各航空公司登机牌图像和各家银行卡正面图像。非场景图像是指应用在非特定场景的背景图像,如不同颜色的背景图像。原始背景图像是服务器基于场景应用需求,从预先创建好的背景图像库中获取与场景应用需求(如二代身份证)对应的背景图像。Among them, the background image library is an image library of background images uploaded or produced in advance by taking pictures. The background image library includes scene images and non-scene images. The scene image refers to the background image applied in a specific scene. The scene images include, but are not limited to, the Hong Kong ID card image, the second-generation ID card image, the airline boarding pass images, and the bank card front images provided by this embodiment. Non-scene images refer to background images applied to non-specific scenes, such as background images of different colors. The original background image is based on the scene application requirements, and the server obtains the background image corresponding to the scene application requirements (such as the second-generation ID card) from the pre-created background image library.
中文字库包括常用的中文一级字库、百家姓和繁体字库。若要生成香港身份证时,可从繁体字库中获取对应的繁体字;若无需生成繁体字,则可从中文一级字库获取对应的中文字。可理解地,中文字包括繁体字或简体字。中文字是服务器基于场景应用需求,从预先创建好的中文字库中获取与应用需求对应的汉字。The Chinese character library includes commonly used Chinese first-level character libraries, hundred family names and traditional character libraries. If you want to generate a Hong Kong identity card, you can obtain the corresponding traditional Chinese characters from the traditional Chinese character library; if you do not need to generate traditional Chinese characters, you can obtain the corresponding Chinese characters from the Chinese first-level character library. Understandably, Chinese characters include traditional characters or simplified characters. The Chinese characters are based on the scene application requirements, and the Chinese characters corresponding to the application requirements are obtained from the pre-created Chinese character library.
本实施例中,若场景用需求为二代身份证,则服务器基于场景应用需求从预先创建好的背景图像库中获取与场景应用需求相对应的原始背景图像即身份证背景图像,从预先创建好的中文字库中获取与场景应用需求相对应的中文字(如姓名),该过程无需人工采集原始背景图像并编辑中文字,节省时间,为后续生成训练图像提供技术支持。In this embodiment, if the scene usage requirement is a second-generation ID card, the server obtains the original background image corresponding to the scene application demand, that is, the ID card background image, from the pre-created background image library based on the scene application demand, A good Chinese character library can obtain Chinese characters (such as names) corresponding to the application requirements of the scene. This process does not require manual collection of original background images and editing of Chinese characters, saving time and providing technical support for the subsequent generation of training images.
S30:对原始背景图像进行透明化处理,获取第一透明图像。S30: Transparency the original background image to obtain the first transparent image.
具体地,为了突出后续对图像增加噪点的效果,需先对背景图像进行透明化处理,获取原始透明图像。透明化处理包括但不限于采用pillow库技术进行处理。其中,Pillow是Python工具里的图像处理库(PIL:Python Image Library),提供广泛的文件格式支持,强大的图像处理能力,主要提供包括图像储存、图像显示、格式转换以及基本的图像处理操作的接口,可直接调用,实现简单,可有效节省重复开发的时间。Specifically, in order to highlight the subsequent effect of adding noise to the image, the background image needs to be transparentized first to obtain the original transparent image. Transparency processing includes but is not limited to using pillow library technology for processing. Among them, Pillow is an image processing library (PIL: Python Image Library) in the Python tool, which provides extensive file format support and powerful image processing capabilities. It mainly provides image storage, image display, format conversion, and basic image processing operations. The interface can be directly called, which is simple to implement and can effectively save the time of repeated development.
S40:将中文字填充到第一透明图像上,获取第二透明图像,采用中文字对第二透明图像进行标注,获取与第二透明图像对应的文本文件。S40: Fill the first transparent image with Chinese characters, obtain a second transparent image, mark the second transparent image with Chinese characters, and obtain a text file corresponding to the second transparent image.
其中,第二透明图像是指在第一透明图像中填充与场景应用需求相对应的中文字的透明图像。文本文件是指与第二透明图像相对应的标注文件。在生成训练图像时,会获取N(N为大于1的正整数,可由用户指定)个原始背景图像,服务器采用pillow库技术随机选取原始背景图像对应的第一透明图像,以将所选取的中文字填充到所选取的第一透明图像上,获取第二透明图像,同时,服务器会采用所选取的中文字对第二透明图像进行标注,获取与第二透明图像对应的文本文件,该过程无需人工标注,即可自动进行标注。The second transparent image refers to a transparent image filled with Chinese characters corresponding to scene application requirements in the first transparent image. The text file refers to a label file corresponding to the second transparent image. When generating a training image, N (N is a positive integer greater than 1 and can be specified by the user) original background images are obtained. The server uses the pillow library technology to randomly select the first transparent image corresponding to the original background image to convert the selected Chinese The word is filled on the selected first transparent image to obtain the second transparent image. At the same time, the server will use the selected Chinese characters to mark the second transparent image to obtain the text file corresponding to the second transparent image. This process does not require Manual labeling, you can automatically label.
S50:对第二透明图像增加噪点,获取第三透明图像,对第三透明图像和原始背景图像进行叠加处理,获取待训练图像,将待训练图像与文本文件关联存储。S50: Add noise to the second transparent image, obtain the third transparent image, superimpose the third transparent image and the original background image, obtain the image to be trained, and store the image to be trained in association with the text file.
其中,第三透明图像为第二透明图像增加噪点后的透明图像。具体地,服务器随机选取预设比例的需要增加噪点的像素点,以对该比例的像素点进行随机增加噪点,以便增加训练图像的鲁棒性。然后,对第三透明图像和原始背景图像进行叠加处理,获取待训练图像,将待训练图像与文本文件关联存储,以形成训练样本,以便采用该训练样本进行模型训练,省去人工采集的步骤,提高效率。叠加处理指将第三透明图像和原始背景图像叠加成一个图像的处理过程,从而获取待训练图像。本实施例中,采用imadd函数对第三透明图像和原始背景图像进行叠加处理,以获取待训练图像。imadd函数是计算机语言中的一个函数,用于对图像进行叠加处理。The third transparent image is a transparent image after adding noise to the second transparent image. Specifically, the server randomly selects a predetermined proportion of pixels that need to increase noise, so as to randomly increase noise on the proportion of pixels, so as to increase the robustness of the training image. Then, the third transparent image and the original background image are superimposed to obtain the image to be trained, and the image to be trained is stored in association with the text file to form a training sample, so that the training sample is used for model training, and the step of manual collection is omitted ,Improve efficiency. Superimposition processing refers to the process of superimposing the third transparent image and the original background image into one image, so as to obtain the image to be trained. In this embodiment, the imadd function is used to superimpose the third transparent image and the original background image to obtain the image to be trained. The imadd function is a function in computer language used to superimpose images.
噪点的类型包括但不限于反光、干扰线条、干扰色点、倾斜角度(包括两种倾斜方式,每种倾斜方式包括三种倾斜角度:0.5,1和1.5)、膨胀、腐蚀以及高斯模糊等类型。以 增加干扰色点为例,随机选取预设比例的像素点,并将该选取的像素点设置为黑色即可完成增加噪点的目的。其中,预设比例是由中文训练图像混合生成工具根据经验值自动推荐的比例,支持用户更改,其更改的方式包括两种:一种是更改增加噪点的像素点的比例;一种是更改增加噪点的像素点数量。本实施例中,对于膨胀和腐蚀的处理根据所要生成的字体进行判断,以生成香港身份证为例,对于常规字体来说,由于常规字体线条较细可选择膨胀处理,而对于粗体字体,由于线条较粗,因此可选择腐蚀处理,以增强训练图像的清晰度。The types of noise include but are not limited to reflection, interference lines, interference color point, tilt angle (including two tilt methods, each tilt method includes three tilt angles: 0.5, 1 and 1.5), dilation, corrosion and Gaussian blur etc. . Taking the example of increasing interference color points, randomly selecting pixels of a preset ratio and setting the selected pixels to black can complete the purpose of increasing noise. Among them, the preset ratio is the ratio automatically recommended by the Chinese training image mixing generation tool according to the experience value, and supports user changes. There are two ways to change it: one is to change the proportion of pixels with increased noise; the other is to change and increase The number of pixels of noise. In this embodiment, the processing of expansion and corrosion is judged according to the font to be generated, taking the generation of a Hong Kong identity card as an example. For conventional fonts, expansion processing can be selected due to the thinner lines of the conventional font, while for bold fonts, Because the lines are thicker, corrosion treatment can be selected to enhance the clarity of the training image.
本实施例中,服务器先获取训练图像生成请求,以便基于训练图像生成请求中的场景应用需求,从预先创建好的背景图像库中获取与场景应用需求相对应的原始背景图像,从预先创建好的中文字库中获取与场景应用需求相对应的中文字,该过程无需人工采集原始背景图像并编辑中文字,节省时间。对原始背景图像进行透明化处理,获取第一透明图像,以突出后续图像增加噪点的效果。然后,将中文字填充到第一透明图像上,获取第二透明图像,同时,采用中文字对第二透明图像进行标注,获取与第二透明图像对应的文本文件,该过程无需人工标注,即可对第二透明图像进行自动标注。最后,对第二透明图像增加噪点,获取第三透明图像,对第三透明图像和原始背景图像进行叠加处理,获取待训练图像,增加待训练图像的真实性,以提高后续采用该待训练图像进行训练所得到的模型的识别准确性。最后,将待训练图像与文本文件关联存储形成训练样本,以便采用该训练样本进行训练,无需人工采集,提高效率。In this embodiment, the server first obtains the training image generation request, so as to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirements in the training image generation request, and create The Chinese characters corresponding to the application requirements of the scene are obtained from the Chinese character library in this database. This process does not require manual collection of original background images and editing of Chinese characters, saving time. Transparency is performed on the original background image to obtain the first transparent image to highlight the effect of increasing noise in subsequent images. Then, fill the first transparent image with Chinese characters to obtain the second transparent image, and at the same time, use the Chinese characters to label the second transparent image to obtain the text file corresponding to the second transparent image. This process does not require manual labeling, that is, The second transparent image can be automatically annotated. Finally, add noise to the second transparent image, obtain the third transparent image, superimpose the third transparent image and the original background image to obtain the image to be trained, and increase the authenticity of the image to be trained to improve the subsequent use of the image to be trained The recognition accuracy of the model obtained by training. Finally, the training image is associated and stored with the text file to form a training sample, so that the training sample is used for training without manual collection, and the efficiency is improved.
在一实施例中,如图3所示,步骤S20中,即基于场景应用需求,从预先创建好的背景图像库中获取与场景应用需求相对应的原始背景图像,从预先创建好的中文字库中获取与场景应用需求相对应的中文字,具体包括如下步骤:In one embodiment, as shown in FIG. 3, in step S20, that is, based on the scene application requirements, the original background image corresponding to the scene application requirements is obtained from the pre-created background image library, and the pre-created Chinese character library is obtained. Obtain the Chinese characters corresponding to the application requirements of the scene, including the following steps:
S21:若场景应用需求为第一应用需求,则从背景图像库中获取与第一应用需求相对应的原始背景图像,原始背景图像包括场景字段,基于场景字段,按照预设生成规则,从中文字库中获取与场景字段相对应的中文字。S21: If the scene application requirement is the first application requirement, the original background image corresponding to the first application requirement is obtained from the background image library. The original background image includes the scene field, and based on the scene field, according to the preset generation rule, the Chinese characters The Chinese characters corresponding to the scene fields are obtained from the library.
其中,第一应用需求是指生成在特定场景下应用的训练图像,如二代身份证图像和银行卡正面图像。具体地,若场景应用需求为第一应用需求,则从背景图像库中获取与第一应用需求相对应的原始背景图像,原始背景图像包括场景字段(如姓名),基于场景字段,按照预设生成规则,从中文字库中获取与场景字段相对应的中文字。预设生成规则是预先设置的用于生成与每一场景字段对应的属性值的规则。例如:若第一应用需求为二代身份证图像,服务器会基于第一应用需求从背景图像库中获取二代身份证图像作为原始背景图 像,由于二代身份证图像中包含姓名、性别、出生年月日、住址以及身份证号等场景字段。基于场景字段,按照预设生成规则从中文字库中,获取与每一场景字段相对应的中文字,该过程无需人工干预,节省人工成本。Among them, the first application requirement refers to generating training images that are applied in specific scenarios, such as second-generation ID card images and bank card front images. Specifically, if the scene application requirement is the first application requirement, the original background image corresponding to the first application requirement is obtained from the background image library. The original background image includes a scene field (such as a name), based on the scene field, according to the preset Generate rules to get the Chinese characters corresponding to the scene field from the Chinese character library. The preset generation rule is a rule set in advance for generating attribute values corresponding to each scene field. For example: if the first application requirement is the second-generation ID card image, the server will obtain the second-generation ID card image from the background image library as the original background image based on the first application requirement. Scene fields such as year, month, date, address and ID number. Based on the scene fields, the Chinese characters corresponding to each scene field are obtained from the Chinese character library according to the preset generation rules. This process requires no human intervention and saves labor costs.
对于姓名这一场景字段来说,由于目前少数民族人群的姓名所包含的字符较长,因此,本实施例中的姓名字段的预设生成规则是限制在10个字符以内。For the scene field of name, since the names of ethnic minority groups currently contain long characters, the preset generation rule of the name field in this embodiment is limited to 10 characters.
对于性别这一场景字段来说,其只能在男/女中随机获取,因此其对应的预设生成规则为男/女这两个字符中的一个。For the scene field of gender, it can only be randomly obtained from male / female, so the corresponding preset generation rule is one of the two characters male / female.
对于出生年月日来说,其预设生成规则根据日期格式设定。For the date of birth, the default generation rules are set according to the date format.
对于住址来说,可采用网络爬虫方式从现有的地址库中爬取到的地址数据,这些地址数据基本上都符合其对应的预设生成规则。For residential addresses, address data crawled from the existing address database by web crawlers can be used. These address data basically conform to their corresponding preset generation rules.
对于身份证号码的预设生成规则如下:由于身份证号码的结构有固定格式,身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码、三位数字顺序码和一位数字校验码。The preset generation rules for ID card numbers are as follows: Since the ID card number structure has a fixed format, the ID number is a combination code of features, consisting of a 17-digit numeric body code and a check code. The arrangement order from left to right is: six-digit address code, eight-digit birth date code, three-digit sequence code and one-digit check code.
地址码(前六位数)表示编码对象常住户口所在县(市、旗、区)的行政区划代码,按GB/T2260的规定执行。本案中会先设置好地区和地区码对应关联,然后随机获取地区以及对应的地区码。7-14位是出生年月,根据日期格式随机生成。15位-17位是顺序码,根据随机数生成方式生成。最后一位校验码,根据校验码规则进行生成。出生日期码表示编码对象出生的年、月、日,按GB/T7408的规定执行,年、月、日代码之间不用分隔符。顺序码表示在同一地址码所标识的区域范围内,对同年、同月、同日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配给女性。The address code (first six digits) indicates the administrative division code of the county (city, flag, district) where the permanent residence of the encoding object is located, and shall be implemented in accordance with the provisions of GB / T2260. In this case, the region and the region code will be associated first, and then the region and the corresponding region code will be randomly obtained. 7-14 digits are the year and month of birth, randomly generated according to the date format. 15 to 17 bits are sequential codes, which are generated according to the random number generation method. The last digit check code is generated according to the check code rule. The date of birth code indicates the year, month, and day of birth of the coding object, and is implemented in accordance with the provisions of GB / T7408. There is no separator between the year, month, and day codes. The sequence code indicates the sequence number assigned to people born in the same year, month, and day within the area identified by the same address code. The odd number of the sequence code is assigned to men, and the even number is assigned to women.
校验码的获取过程包括如下步骤:The verification code acquisition process includes the following steps:
1)十七位数字本体码加权求和公式S=Sum(Ai*Wi),i=0,...,16,先对前17位数字的权求和,其中,Ai:表示第i位置上的身份证号码数字值;Wi:表示第i位置上的加权因子Wi:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 21) The weighted sum formula of the seventeen digit body code S = Sum (Ai * Wi), i = 0, ..., 16, first sum the weights of the first 17 digits, where Ai: indicates the i-th position The digital value of the ID number on the Wi; Wi: indicates the weighting factor at the i-th position Wi: 7 9 9 10 8 5 4 2 1 3 6 7 9 9 10 8 8 4 2
2)取模计算:Y=mod(S,11)。2) Modulus calculation: Y = mod (S, 11).
3)通过取模得到对应的校验码Y:0 1 2 3 4 5 6 7 8 9 10,校验码:1 0 X 9 8 76 5 4 3 2 */3) Get the corresponding check code Y: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 by taking the modulus, and the check code: 1, 0, X, 9, 8, 76, 5, 4, 3, 2 * /
例如,第十八位数字(校验码)的计算方法为:1.将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4。2.将这17位数字和系数相乘的结果相加。3.将加和除以11,看余数是多少?4.余数只可 能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2。5.若余数是2,则会在身份证的第18位数字为罗马数字的Ⅹ。若余数是10,身份证的最后一位号码就是2。For example, the calculation method of the eighteenth digit (check code) is: 1. Multiply the 17 digits of the previous ID number by different coefficients. The coefficients from the first place to the seventeenth place are: 7 9 10 10 5 8 8 4 2 6 3 3 7 9 10 8 5. 2. Add the result of multiplying the 17 digits and the coefficient. 3. Divide the sum by 11, and see what is the remainder? 4. The remainder can only have 11 numbers of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The number of the last ID card corresponding to it is 1 0 0 X 9 9 8 8 5 5 4 3 2. 5. If the remainder is 2, the 18th digit of the ID will be the Roman numeral X. If the remainder is 10, the last number of the ID card is 2.
S22:若场景应用需求为第二应用需求,则从背景图像库中随机获取原始背景图像,从中文字库中随机获取中文字。S22: If the scene application requirement is the second application requirement, the original background image is randomly obtained from the background image library, and the Chinese characters are randomly obtained from the Chinese character library.
其中,第二应用需求是指生成在非特定场景下应用的训练图像,如汉字图像。由于该类型的汉字图像仅仅是用于训练非特定场景下的OCR汉字识别模型,因此可直接从背景图像库中随机获取原始背景图像,从中文字库中随机获取对应的中文字,简单便捷。Among them, the second application requirement refers to generating training images that are applied in non-specific scenarios, such as Chinese character images. Because this type of Chinese character image is only used to train the OCR Chinese character recognition model in non-specific scenes, the original background image can be randomly obtained directly from the background image library, and the corresponding Chinese character can be randomly obtained from the Chinese character library, which is simple and convenient.
本实施例中,若场景应用需求为第一应用需求,则从背景图像库中获取与第一应用需求相对应的原始背景图像,以便基于原始背景图像中的场景字段,按照预设生成规则,从中文字库中获取与场景字段相对应的中文字,无需人工干预,节省人工成本。若场景应用需求为第二应用需求,则从直接背景图像库中随机获取原始背景图像,从中文字库中随机获取中文字,简单便捷。In this embodiment, if the scene application requirement is the first application requirement, the original background image corresponding to the first application requirement is obtained from the background image library, so that based on the scene field in the original background image, a preset generation rule is used, Obtain the Chinese characters corresponding to the scene field from the Chinese character library without manual intervention, saving labor costs. If the scene application requirement is the second application requirement, it is simple and convenient to randomly obtain the original background image from the direct background image library and randomly obtain the Chinese characters from the Chinese character library.
在一实施例中,场景字段包括姓名字段;中文字库包括百家姓和中文一级字库。步骤S21中,即基于场景字段,按照预设生成规则,从中文字库中获取与场景字段相对应的中文字,具体包括:In an embodiment, the scene field includes a name field; the Chinese character library includes a hundred family names and a Chinese first-level character library. In step S21, the Chinese characters corresponding to the scene fields are obtained from the Chinese character library according to the preset generation rules based on the scene fields, which specifically includes:
基于姓名字段,从百家姓中依序或者随机获取姓氏,从中文一级字库中依序或随机获取汉字,将姓氏和汉字拼接,获取与场景字段相对应的中文字。Based on the name field, the surnames are obtained sequentially or randomly from the hundred family surnames, and the Chinese characters are obtained sequentially or randomly from the first-class Chinese character library.
本实施例中,对于姓名字段的生成规则包括两种,一种是从百家姓中依据百家姓的顺序获取姓氏,然后,从中文一级字库中依序获取汉字,将姓氏与汉字拼接,即可获取与姓名字段相对应的中文字,提高获取与姓名字段对应属性值的效率。或者,从百家姓中随机选取百家姓作为姓名字段对应的姓氏,从中文一级字库中随机选取汉字,将选取的姓氏与汉字拼接,即可获取与姓名字段相对应的中文字,提高获取与姓名字段对应属性值的多样性。In this embodiment, there are two generation rules for the name field. One is to obtain the surnames from the surnames of the surnames in the order of the surnames, and then obtain the Chinese characters in sequence from the first-class Chinese character library and splice the surnames with the Chinese characters , You can obtain the Chinese characters corresponding to the name field, and improve the efficiency of obtaining the attribute value corresponding to the name field. Or, randomly select the surnames from the surnames as the surnames corresponding to the name field, randomly select the Chinese characters from the first-class Chinese character library, and stitch the selected surnames with the Chinese characters to obtain the Chinese characters corresponding to the name field Get the diversity of attribute values corresponding to the name field.
进一步地,在实际应用中,也可按照当前相关机构统计的各种姓氏人数所占的比例来选择相对应的姓氏,从常用汉字中选取汉字,随机组合,既保证其组合的多样性,也可提高采用获取的训练图像进行训练所得到的图像识别模型的真实性与可靠性。Further, in practical applications, the corresponding surnames can also be selected according to the proportion of the number of various surnames currently counted by relevant agencies, and the Chinese characters can be selected from commonly used Chinese characters and randomly combined to ensure the diversity of their combinations. It can improve the authenticity and reliability of the image recognition model obtained by training with the obtained training images.
需说明,中文字库中还包括繁体字库,若要生成香港身份证时,则无需从中文一级字库中获取简体字形式的汉字,可直接从繁体字库中获取对应的繁体字。对于百家姓来说步骤S21中所采用的百家姓为简体字形式,若要生成香港身份证时,则可从繁体字形式的百 家姓中获取姓氏,然后,将获取的姓氏与繁体字拼接,即可获取与姓名字段相对应的中文字。It should be noted that the Chinese character library also includes a traditional character library. If you want to generate a Hong Kong identity card, you do not need to obtain simplified Chinese characters from the Chinese first-level character library. You can directly obtain the corresponding traditional characters from the traditional character library. For the family names, the family names used in step S21 are in simplified Chinese characters. If you want to generate a Hong Kong identity card, you can obtain the family names from the family names in traditional Chinese characters. Splicing, you can get the Chinese characters corresponding to the name field.
在一实施例中,如图4所示,步骤S30中,即对原始背景图像进行透明化处理,获取第一透明图像,具体包括如下步骤:In an embodiment, as shown in FIG. 4, in step S30, the original background image is transparentized to obtain the first transparent image, which specifically includes the following steps:
S31:将原始背景图像进行模式转换,获取模式图像,模式图像包括颜色参数。S31: Perform mode conversion on the original background image to obtain a mode image, and the mode image includes color parameters.
其中,模式图像是指带透明度的真彩色图像模式(简称RGBA模式)。需说明,原始背景图像本身所处的图像模式为RGB模式(即彩色图像模式)。具体地,可采用如下方法PIL.Image.new(mode,size,color=0)将原始背景图像的图像模式转化为RGBA模式,其中,mode参数是定义了图像中关于像素的一些属性,如带透明度的真彩色RGBA。size参数是以像素为单位指定图像的长与宽。color参数即颜色参数,用于限定图像(即原始背景图像)的背景色。其中,RGBA模式是Red(红色)、Green(绿色)、Blue(蓝色)和Alpha的色彩空间模式,也就是透明度。Among them, the mode image refers to a true color image mode with transparency (abbreviated as RGBA mode). It should be noted that the image mode of the original background image itself is the RGB mode (that is, the color image mode). Specifically, the following method PIL.Image.new (mode, size, color = 0) can be used to convert the image mode of the original background image to RGBA mode, where the mode parameter defines some attributes of pixels in the image, such as Transparency true color RGBA. The size parameter specifies the length and width of the image in pixels. The color parameter is the color parameter used to define the background color of the image (ie, the original background image). Among them, RGBA mode is Red (red), Green (green), Blue (blue) and Alpha color space mode, that is, transparency.
S32:将模式图像的颜色参数设置为空,获取第一透明图像。S32: Set the color parameter of the mode image to empty, and obtain the first transparent image.
具体地,当图像模式为RGBA模式时,若不指定模式图像的颜色参数,则服务器默认是透明背景,则获取第一透明图像,实现简单,提高训练图像的生成效率。Specifically, when the image mode is the RGBA mode, if the color parameters of the mode image are not specified, the server defaults to a transparent background, and the first transparent image is obtained, which is simple to implement and improves the efficiency of generating training images.
本实施例中,服务器先将原始背景图像进行模式转换,获取带透明度的模式图像,通过将模式图像中的颜色参数设置为空,以获取第一透明图像,实现简单,提高训练图像的生成效率。In this embodiment, the server first converts the original background image to obtain a pattern image with transparency. By setting the color parameter in the pattern image to empty, the first transparent image is obtained, which is simple to implement and improves the efficiency of generating training images .
在一实施例中,如图5所示,步骤S40中,即将中文字填充到第一透明图像上,获取第二透明图像,具体包括如下步骤:In an embodiment, as shown in FIG. 5, in step S40, the Chinese characters are filled on the first transparent image to obtain the second transparent image, which specifically includes the following steps:
S41:获取中文字对应的属性参数。S41: Obtain the attribute parameters corresponding to the Chinese characters.
其中,中文字对应的属性参数包括中文字在第一透明图像中所要填充的位置、文字内容、文字颜色和文字字体等。该属性参数是预先按照不同的场景应用需求设置好的。可理解地,若场景应用需求为第一应用需求则按照实际应用场景进行设置。例如,第一应用需求为二代身份证,则按照实际身份证图像中的文字属性设置中文字对应的属性参数,以贴合实际,提高训练图像的真实性与可靠性。例如,场景应用需求为第二应用需求,则可随机获取中文字对应的属性参数,例如若要生成汉字图像,则可在预先存储的字体(如楷体、宋体)中随机选取相应字体,或者也可由用户自定义。对于文字内容、文字颜色和文字位置也可由服务器随机获取,或者由用户自定义,提高中文训练图像生成工具的实用性。Among them, the attribute parameters corresponding to the Chinese characters include the position, content, color and font of the Chinese characters to be filled in the first transparent image. This attribute parameter is set in advance according to different scene application requirements. Understandably, if the scenario application requirement is the first application requirement, the setting is performed according to the actual application scenario. For example, if the first application requires a second-generation ID card, the attribute parameters corresponding to the Chinese characters are set according to the text attributes in the actual ID card image to fit the reality and improve the authenticity and reliability of the training image. For example, if the scene application requirement is the second application requirement, you can randomly obtain the attribute parameters corresponding to the Chinese characters. For example, if you want to generate a Chinese character image, you can randomly select the corresponding font from the pre-stored fonts (such as Kai and Song), or Can be customized by the user. The text content, text color, and text position can also be randomly obtained by the server or customized by the user, which improves the practicality of the Chinese training image generation tool.
S42:将属性参数应用到文字填充函数中,以将中文字填充到第一透明图像上,获取 第二透明图像。S42: Apply the attribute parameters to the text filling function to fill the first transparent image with Chinese characters and obtain the second transparent image.
具体地,服务器基于属性参数的设置,将属性参数应用到基于图像处理技术(即pillow库技术)的文字填充函数中,以将中文字填充到第一透明图像上,获取第二透明图像。具体地,服务器采用如下文字填充函数“draw.text((40,10),u,font=myfont,fill=fillcolor)”,以基于属性参数,将中文字填充到第一透明图像上,获取透明图像。可理解,“(40,10),u,font=myfont,fill=fillcolor”表示属性参数;draw.text()表示文字填充函数。其中,第一参数(40,10)表示文字位置;第二个参数u表示文字内容;第三个参数font表示文字字体,第四个参数fill表示文字颜色。服务器通过采用如上语句进行自动填充,以获取第二透明图像,无需人工干预,实现自动生成训练图像的目的。Specifically, based on the setting of the attribute parameters, the server applies the attribute parameters to the text filling function based on the image processing technology (namely, the pillow library technology) to fill the Chinese characters on the first transparent image and obtain the second transparent image. Specifically, the server uses the following text filling function "draw.text ((40,10), u, font = myfont, fill = fillcolor)" to fill the first transparent image with Chinese text based on the attribute parameters to obtain transparency image. Understandably, "(40,10), u, font = myfont, fill = fillcolor" means attribute parameters; draw.text () means text fill function. Among them, the first parameter (40,10) represents the text position; the second parameter u represents the text content; the third parameter font represents the text font, and the fourth parameter fill represents the text color. The server automatically fills in the above sentence to obtain the second transparent image without manual intervention, and realizes the purpose of automatically generating the training image.
本实施例中,服务器通过获取中文字对应的属性参数,以便基于属性参数,采用pillow库技术提供的图像处理接口将中文字填充到第一透明图像上,获取第二透明图像,实现简单,无需人工干预,以实现自动生成训练图像的目的。In this embodiment, the server obtains the attribute parameters corresponding to the Chinese characters, so that based on the attribute parameters, the image processing interface provided by the pillow library technology is used to fill the Chinese characters on the first transparent image and obtain the second transparent image. Manual intervention to achieve the purpose of automatically generating training images.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
在一实施例中,提供一种中文训练图像生成装置,该中文训练图像生成装置与上述实施例中中文训练图像生成方法一一对应。如图6所示,该中文训练图像生成装置包括训练图像生成请求获取模块10、场景应用需求处理模块20、第一透明图像获取模块30、第二透明图像获取模块40和待训练图像获取模块50。各功能模块详细说明如下:In an embodiment, a Chinese training image generating device is provided, and the Chinese training image generating device corresponds one-to-one to the Chinese training image generating method in the foregoing embodiment. As shown in FIG. 6, the Chinese training image generation device includes a training image generation request acquisition module 10, a scene application demand processing module 20, a first transparent image acquisition module 30, a second transparent image acquisition module 40, and a to-be-trained image acquisition module 50 . The detailed description of each functional module is as follows:
训练图像生成请求获取模块10,用于获取训练图像生成请求,训练图像生成请求包括场景应用需求。The training image generation request obtaining module 10 is used to obtain a training image generation request, and the training image generation request includes scene application requirements.
场景应用需求处理模块20,用于基于场景应用需求,从预先创建好的背景图像库中获取与场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与场景应用需求相对应的中文字。The scene application requirement processing module 20 is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the scene application requirement corresponding to the scene application requirement from the pre-created Chinese character library Chinese characters.
第一透明图像获取模块30,用于对原始背景图像进行透明化处理,获取第一透明图像。The first transparent image acquisition module 30 is configured to perform transparency processing on the original background image to acquire the first transparent image.
第二透明图像获取模块40,用于将中文字填充到第一透明图像上,获取第二透明图像,采用中文字对第二透明图像进行标注,获取与第二透明图像对应的文本文件。The second transparent image obtaining module 40 is used to fill Chinese characters on the first transparent image, obtain the second transparent image, mark the second transparent image with Chinese characters, and obtain a text file corresponding to the second transparent image.
待训练图像获取模块50,用于对第二透明图像增加噪点,获取第三透明图像,对第三透明图像和原始背景图像进行叠加处理,获取待训练图像,将待训练图像与文本文件关 联存储。The image-to-be-trained acquisition module 50 is used to add noise to the second transparent image, obtain the third transparent image, superimpose the third transparent image and the original background image, obtain the image to be trained, and store the image to be trained in association with the text file .
具体地,场景应用需求处理模块包括第一处理单元和第二处理单元。Specifically, the scene application requirement processing module includes a first processing unit and a second processing unit.
第一处理单元,用于若场景应用需求为第一应用需求,则从背景图像库中获取与第一应用需求相对应的原始背景图像,原始背景图像包括场景字段;基于场景字段,按照预设生成规则,从中文字库中获取与场景字段相对应的中文字。The first processing unit is used to obtain an original background image corresponding to the first application requirement from the background image library if the scene application requirement is the first application requirement, the original background image includes a scene field; based on the scene field, the preset Generate rules to get the Chinese characters corresponding to the scene field from the Chinese character library.
第二处理单元,用于若场景应用需求为第二应用需求,则从背景图像库中随机获取原始背景图像,从中文字库中随机获取中文字。The second processing unit is configured to randomly obtain original background images from the background image library and randomly obtain Chinese characters from the Chinese character library if the scene application requirement is the second application requirement.
具体地,第一处理单元具体为:基于姓名字段,从百家姓中依序或者随机获取姓氏,从中文一级字库中依序或随机获取汉字;将姓氏和汉字拼接,获取与场景字段相对应的中文字。Specifically, the first processing unit is specifically: based on the name field, sequentially or randomly obtain the surnames from the hundred family surnames, and sequentially or randomly obtain the Chinese characters from the first-class Chinese character library; Corresponding Chinese characters.
具体地,第一透明图像获取模块包括图像模式转换单元和第一透明图像获取单元。Specifically, the first transparent image acquisition module includes an image mode conversion unit and a first transparent image acquisition unit.
图像模式转换单元,用于将原始背景图像进行模式转换,获取模式图像;模式图像包括颜色参数。The image mode conversion unit is used for mode conversion of the original background image to obtain a mode image; the mode image includes color parameters.
第一透明图像获取单元,用于将模式图像的颜色参数设置为空,获取第一透明图像。The first transparent image acquisition unit is configured to set the color parameter of the pattern image to be empty and acquire the first transparent image.
具体地,第二透明图像获取模块包括属性参数获取单元和第二透明图像获取单元。Specifically, the second transparent image acquisition module includes an attribute parameter acquisition unit and a second transparent image acquisition unit.
属性参数获取单元,用于获取中文字对应的属性参数。The attribute parameter obtaining unit is used to obtain attribute parameters corresponding to Chinese characters.
第二透明图像获取单元,用于将属性参数应用到文字填充函数中,以将中文字填充到第一透明图像上,获取第二透明图像。The second transparent image obtaining unit is used to apply attribute parameters to the text filling function to fill the first transparent image with Chinese characters and obtain the second transparent image.
关于中文训练图像生成装置的具体限定可以参见上文中对于中文训练图像生成方法的限定,在此不再赘述。上述中文训练图像生成装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific definition of the Chinese training image generating device, please refer to the above definition of the Chinese training image generating method, which will not be repeated here. Each module in the above-mentioned Chinese training image generating device may be implemented in whole or in part by software, hardware, and a combination thereof. The above modules may be embedded in the hardware or independent of the processor in the computer device, or may be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图7所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于用于存储执行中文训练图像生成方法过程中生成或获取的数据,如待训练图像。该计算机设备的网络接口用于与外部的终端通过网络连接通信。 该计算机可读指令被处理器执行时以实现一种中文训练图像生成方法。In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure may be as shown in FIG. 7. The computer device includes a processor, memory, network interface, and database connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer-readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The database of the computer device is used to store data generated or acquired during the execution of the Chinese training image generation method, such as the image to be trained. The network interface of the computer device is used to communicate with external terminals through a network connection. When the computer readable instructions are executed by the processor to implement a Chinese training image generation method.
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现上述实施例中的中文训练图像生成方法的步骤,例如图2所示的步骤S10-S50,或者图3至图5中所示的步骤。或者,处理器执行计算机可读指令时实现中文训练图像生成装置这一实施例中的各模块/单元的功能,例如图6所示的各模块/单元的功能,为避免重复,这里不再赘述。In one embodiment, a computer device is provided, which includes a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor. The processor implements the computer-readable instructions to implement the The steps of the Chinese training image generation method, such as steps S10-S50 shown in FIG. 2, or the steps shown in FIGS. 3 to 5. Or, the processor implements the functions of each module / unit in the embodiment of the Chinese training image generating device when executing the computer-readable instructions, for example, the function of each module / unit shown in FIG. 6, to avoid repetition, it will not be repeated here .
在一实施例中,提供一计算机可读存储介质,该计算机可读存储介质上存储有计算机可读指令,该计算机可读指令被处理器执行时实现上述实施例中中文训练图像生成方法的步骤,例如图2所示的步骤S10-S50,或者图3至图5中所示的步骤,为避免重复,这里不再赘述。或者,该计算机可读指令被处理器执行时实现上述中文训练图像生成装置这一实施例中的各模块/单元的功能,例如图6所示的各模块/单元的功能,为避免重复,这里不再赘述。In an embodiment, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer-readable instructions, which when executed by a processor, implements the steps of the method for generating a Chinese training image in the foregoing embodiments For example, steps S10-S50 shown in FIG. 2 or steps shown in FIG. 3 to FIG. 5, in order to avoid repetition, they will not be repeated here. Alternatively, when the computer-readable instructions are executed by the processor, the functions of each module / unit in the above embodiment of the Chinese training image generation device, such as the functions of each module / unit shown in FIG. 6, are implemented. To avoid repetition, here No longer.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art may understand that all or part of the process in the method of the foregoing embodiments may be completed by instructing relevant hardware through computer-readable instructions, and the computer-readable instructions may be stored in a non-volatile computer In the readable storage medium, when the computer-readable instructions are executed, they may include the processes of the foregoing method embodiments. Wherein, any reference to the memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。Those skilled in the art can clearly understand that, for convenience and conciseness of description, only the above-mentioned division of each functional unit and module is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated by different functional units, Module completion means that the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者 替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still implement the foregoing The technical solutions described in the examples are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application. Within the scope of protection of this application.

Claims (20)

  1. 一种中文训练图像生成方法,其特征在于,包括:A Chinese training image generation method, which is characterized by including:
    获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;Obtain a training image generation request, which includes scene application requirements;
    基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library; obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library ;
    对所述原始背景图像进行透明化处理,获取第一透明图像;Performing transparency processing on the original background image to obtain a first transparent image;
    将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;Filling the first transparent image with the Chinese character, obtaining a second transparent image, using the Chinese character to mark the second transparent image, and obtaining a text file corresponding to the second transparent image;
    对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。Adding noise to the second transparent image, obtaining a third transparent image, superimposing the third transparent image and the original background image, obtaining an image to be trained, and associating the image to be trained with the text file storage.
  2. 如权利要求1所述的中文训练图像生成方法,其特征在于,所述基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字,包括:The Chinese training image generation method according to claim 1, wherein the original background image corresponding to the scene application requirement is obtained from a background image library created in advance based on the scene application requirement; Obtain Chinese characters corresponding to the application requirements of the scene from the pre-created Chinese character library, including:
    若所述场景应用需求为第一应用需求,则从所述背景图像库中获取与所述第一应用需求相对应的原始背景图像,所述原始背景图像包括场景字段;基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字;If the scene application requirement is the first application requirement, an original background image corresponding to the first application requirement is obtained from the background image library, the original background image includes a scene field; based on the scene field, Obtain the Chinese characters corresponding to the scene field from the Chinese character library according to a preset generation rule;
    若所述场景应用需求为第二应用需求,则从所述背景图像库中随机获取原始背景图像,从所述中文字库中随机获取中文字。If the scene application requirement is the second application requirement, the original background image is randomly obtained from the background image library, and the Chinese characters are randomly obtained from the Chinese character library.
  3. 如权利要求2所述的中文训练图像生成方法,其特征在于,所述场景字段包括姓名字段;所述中文字库包括百家姓和中文一级字库;The method for generating a Chinese training image according to claim 2, wherein the scene field includes a name field; the Chinese character library includes a hundred family names and a Chinese first-level character library;
    基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字,包括:Based on the scene field, according to a preset generation rule, obtaining the Chinese character corresponding to the scene field from the Chinese character library includes:
    基于所述姓名字段,从所述百家姓中依序或者随机获取姓氏,从所述中文一级字库中依序或随机获取汉字;Based on the name field, sequentially or randomly obtaining surnames from the hundred family surnames, and sequentially or randomly obtaining Chinese characters from the first-class Chinese character library;
    将所述姓氏和所述汉字拼接,获取与所述场景字段相对应的所述中文字。Join the surname and the Chinese character to obtain the Chinese character corresponding to the scene field.
  4. 如权利要求1所述的中文训练图像生成方法,其特征在于,所述对所述原始背景图像进行透明化处理,获取第一透明图像,包括:The method for generating a Chinese training image according to claim 1, wherein the process of transparentizing the original background image to obtain the first transparent image includes:
    将所述原始背景图像进行模式转换,获取模式图像;所述模式图像包括颜色参数;Performing mode conversion on the original background image to obtain a mode image; the mode image includes color parameters;
    将所述模式图像的颜色参数设置为空,获取所述第一透明图像。Set the color parameter of the mode image to null to obtain the first transparent image.
  5. 如权利要求1所述的中文训练图像生成方法,其特征在于,所述将所述中文字填充到所述第一透明图像上,获取第二透明图像,包括:The method for generating a Chinese training image according to claim 1, wherein the filling the Chinese character on the first transparent image and obtaining the second transparent image includes:
    获取所述中文字对应的属性参数;Obtain the attribute parameters corresponding to the Chinese characters;
    将所述属性参数应用到文字填充函数中,以将所述中文字填充到所述第一透明图像上,获取第二透明图像。The attribute parameter is applied to a text filling function to fill the Chinese text on the first transparent image and obtain a second transparent image.
  6. 一种中文训练图像生成装置,其特征在于,包括:A Chinese training image generating device, characterized in that it includes:
    训练图像生成请求获取模块,用于获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;A training image generation request acquisition module, configured to acquire a training image generation request, where the training image generation request includes scene application requirements;
    场景应用需求处理模块,用于基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;The scene application requirement processing module is used to obtain the original background image corresponding to the scene application requirement from the pre-created background image library based on the scene application requirement; to obtain the original background image from the pre-created Chinese character library Chinese characters corresponding to scene application requirements;
    第一透明图像获取模块,用于对所述原始背景图像进行透明化处理,获取第一透明图像;A first transparent image acquisition module, configured to perform transparency processing on the original background image to obtain a first transparent image;
    第二透明图像获取模块,用于将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;A second transparent image acquisition module, configured to fill the Chinese character on the first transparent image, acquire a second transparent image, use the Chinese character to mark the second transparent image, and acquire the second transparent image The text file corresponding to the two transparent images;
    待训练图像获取模块,用于对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。The image-to-be-trained acquisition module is used to add noise to the second transparent image, obtain a third transparent image, perform superposition processing on the third transparent image and the original background image, obtain the image to be trained, and convert the The training image is stored in association with the text file.
  7. 如权利要求6所述的中文训练图像生成装置,其特征在于,所述场景应用需求处理模块包括:The Chinese training image generating device according to claim 6, wherein the scene application requirement processing module includes:
    第一处理单元,用于若所述场景应用需求为第一应用需求,则从所述背景图像库中获取与所述第一应用需求相对应的原始背景图像,所述原始背景图像包括场景字段;基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字;A first processing unit, configured to obtain an original background image corresponding to the first application requirement from the background image library if the scene application requirement is the first application requirement, the original background image including a scene field ; Based on the scene field, according to a preset generation rule, obtain the Chinese character corresponding to the scene field from the Chinese character library;
    第二处理单元,用于若所述场景应用需求为第二应用需求,则从所述背景图像库中随机获取原始背景图像,从所述中文字库中随机获取中文字。The second processing unit is configured to randomly obtain original background images from the background image library and randomly obtain Chinese characters from the Chinese character library if the scene application requirement is the second application requirement.
  8. 如权利要求6所述的中文训练图像生成装置,其特征在于,所述第二透明图像获取模块包括:The Chinese training image generation device according to claim 6, wherein the second transparent image acquisition module includes:
    属性参数获取单元,用于获取所述中文字对应的属性参数;An attribute parameter obtaining unit, configured to obtain attribute parameters corresponding to the Chinese characters;
    第二透明图像获取单元,用于将所述属性参数应用到文字填充函数中,以将所述中文字填充到所述第一透明图像上,获取第二透明图像。The second transparent image obtaining unit is configured to apply the attribute parameter to a text filling function to fill the Chinese character on the first transparent image and obtain a second transparent image.
  9. 如权利要求6所述的中文训练图像生成装置,其特征在于,所述第一透明图像获取模块包括:The Chinese training image generation device according to claim 6, wherein the first transparent image acquisition module includes:
    图像模式转换单元,用于将所述原始背景图像进行模式转换,获取模式图像;所述模式图像包括颜色参数;An image mode conversion unit, configured to perform mode conversion on the original background image to obtain a mode image; the mode image includes color parameters;
    第一透明图像获取单元,用于将所述模式图像的颜色参数设置为空,获取所述第一透明图像。The first transparent image acquisition unit is configured to set the color parameter of the pattern image to be empty and acquire the first transparent image.
  10. 如权利要求7所述的中文训练图像生成装置,其特征在于,所述场景字段包括姓名字段;所述中文字库包括百家姓和中文一级字库;The Chinese training image generating device according to claim 7, wherein the scene field includes a name field; the Chinese character library includes a hundred family names and a Chinese first-level character library;
    所述第一处理单元具体为:基于所述姓名字段,从所述百家姓中依序或者随机获取姓氏,从所述中文一级字库中依序或随机获取汉字;将所述姓氏和所述汉字拼接,获取与所述场景字段相对应的所述中文字。The first processing unit is specifically: based on the name field, sequentially or randomly obtaining surnames from the hundred family surnames, sequentially or randomly obtaining Chinese characters from the first-class Chinese character library; The Chinese characters are stitched together to obtain the Chinese characters corresponding to the scene field.
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A computer device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that, when the processor executes the computer-readable instructions, it is implemented as follows step:
    获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;Obtain a training image generation request, which includes scene application requirements;
    基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library; obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library ;
    对所述原始背景图像进行透明化处理,获取第一透明图像;Performing transparency processing on the original background image to obtain a first transparent image;
    将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;Filling the first transparent image with the Chinese character, obtaining a second transparent image, using the Chinese character to mark the second transparent image, and obtaining a text file corresponding to the second transparent image;
    对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。Adding noise to the second transparent image, obtaining a third transparent image, superimposing the third transparent image and the original background image, obtaining an image to be trained, and associating the image to be trained with the text file storage.
  12. 如权利要求11所述的计算机设备,其特征在于,所述基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字,包括:The computer device according to claim 11, characterized in that, based on the scene application requirements, the original background image corresponding to the scene application requirements is obtained from a pre-created background image library; The Chinese characters in the Chinese character library corresponding to the application requirements of the scene include:
    若所述场景应用需求为第一应用需求,则从所述背景图像库中获取与所述第一应用需 求相对应的原始背景图像,所述原始背景图像包括场景字段;基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字;If the scene application requirement is the first application requirement, an original background image corresponding to the first application requirement is obtained from the background image library, the original background image includes a scene field; based on the scene field, Obtain the Chinese characters corresponding to the scene field from the Chinese character library according to a preset generation rule;
    若所述场景应用需求为第二应用需求,则从所述背景图像库中随机获取原始背景图像,从所述中文字库中随机获取中文字。If the scene application requirement is the second application requirement, the original background image is randomly obtained from the background image library, and the Chinese characters are randomly obtained from the Chinese character library.
  13. 如权利要求12所述的计算机设备,其特征在于,所述场景字段包括姓名字段;所述中文字库包括百家姓和中文一级字库;The computer device according to claim 12, characterized in that the scene field includes a name field; the Chinese character library includes a hundred family names and a Chinese first-level character library;
    基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字,包括:Based on the scene field, according to a preset generation rule, obtaining the Chinese character corresponding to the scene field from the Chinese character library includes:
    基于所述姓名字段,从所述百家姓中依序或者随机获取姓氏,从所述中文一级字库中依序或随机获取汉字;Based on the name field, sequentially or randomly obtaining surnames from the hundred family surnames, and sequentially or randomly obtaining Chinese characters from the first-class Chinese character library;
    将所述姓氏和所述汉字拼接,获取与所述场景字段相对应的所述中文字。Join the surname and the Chinese character to obtain the Chinese character corresponding to the scene field.
  14. 如权利要求11所述的计算机设备,其特征在于,所述对所述原始背景图像进行透明化处理,获取第一透明图像,包括:The computer device according to claim 11, wherein the transparentizing the original background image to obtain the first transparent image includes:
    将所述原始背景图像进行模式转换,获取模式图像;所述模式图像包括颜色参数;Performing mode conversion on the original background image to obtain a mode image; the mode image includes color parameters;
    将所述模式图像的颜色参数设置为空,获取所述第一透明图像。Set the color parameter of the mode image to null to obtain the first transparent image.
  15. 如权利要求11所述的计算机设备,其特征在于,所述将所述中文字填充到所述第一透明图像上,获取第二透明图像,包括:The computer device according to claim 11, wherein the filling of the Chinese characters on the first transparent image to obtain the second transparent image includes:
    获取所述中文字对应的属性参数;Obtain the attribute parameters corresponding to the Chinese characters;
    将所述属性参数应用到文字填充函数中,以将所述中文字填充到所述第一透明图像上,获取第二透明图像。The attribute parameter is applied to a text filling function to fill the Chinese text on the first transparent image and obtain a second transparent image.
  16. 一种非易失性存储介质,所述非易失性存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如下步骤:A non-volatile storage medium that stores computer-readable instructions, characterized in that the computer-readable instructions are executed by a processor to implement the following steps:
    获取训练图像生成请求,所述训练图像生成请求包括场景应用需求;Obtain a training image generation request, which includes scene application requirements;
    基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字;Based on the scene application requirements, obtain the original background images corresponding to the scene application requirements from the pre-created background image library; obtain the Chinese characters corresponding to the scene application requirements from the pre-created Chinese character library ;
    对所述原始背景图像进行透明化处理,获取第一透明图像;Performing transparency processing on the original background image to obtain a first transparent image;
    将所述中文字填充到所述第一透明图像上,获取第二透明图像,采用所述中文字对所述第二透明图像进行标注,获取与所述第二透明图像对应的文本文件;Filling the first transparent image with the Chinese character, obtaining a second transparent image, using the Chinese character to mark the second transparent image, and obtaining a text file corresponding to the second transparent image;
    对所述第二透明图像增加噪点,获取第三透明图像,对所述第三透明图像和所述原始 背景图像进行叠加处理,获取待训练图像,将所述待训练图像与所述文本文件关联存储。Adding noise to the second transparent image, obtaining a third transparent image, superimposing the third transparent image and the original background image, obtaining an image to be trained, and associating the image to be trained with the text file storage.
  17. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述基于所述场景应用需求,从预先创建好的背景图像库中获取与所述场景应用需求相对应的原始背景图像;从预先创建好的中文字库中获取与所述场景应用需求相对应的中文字,包括:The non-volatile readable storage medium according to claim 16, wherein the original background corresponding to the scene application requirement is obtained from a pre-created background image library based on the scene application requirement Image; obtain Chinese characters corresponding to the application requirements of the scene from the pre-created Chinese character library, including:
    若所述场景应用需求为第一应用需求,则从所述背景图像库中获取与所述第一应用需求相对应的原始背景图像,所述原始背景图像包括场景字段;基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字;If the scene application requirement is the first application requirement, an original background image corresponding to the first application requirement is obtained from the background image library, the original background image includes a scene field; based on the scene field, Obtain the Chinese characters corresponding to the scene field from the Chinese character library according to a preset generation rule;
    若所述场景应用需求为第二应用需求,则从所述背景图像库中随机获取原始背景图像,从所述中文字库中随机获取中文字。If the scene application requirement is the second application requirement, the original background image is randomly obtained from the background image library, and the Chinese characters are randomly obtained from the Chinese character library.
  18. 如权利要求17所述的非易失性可读存储介质,其特征在于,所述场景字段包括姓名字段;所述中文字库包括百家姓和中文一级字库;The non-volatile readable storage medium according to claim 17, wherein the scene field includes a name field; the Chinese character library includes a hundred family names and a Chinese first-level character library;
    基于所述场景字段,按照预设生成规则,从所述中文字库中获取与所述场景字段相对应的所述中文字,包括:Based on the scene field, according to a preset generation rule, obtaining the Chinese character corresponding to the scene field from the Chinese character library includes:
    基于所述姓名字段,从所述百家姓中依序或者随机获取姓氏,从所述中文一级字库中依序或随机获取汉字;Based on the name field, sequentially or randomly obtaining surnames from the hundred family surnames, and sequentially or randomly obtaining Chinese characters from the first-class Chinese character library;
    将所述姓氏和所述汉字拼接,获取与所述场景字段相对应的所述中文字。Join the surname and the Chinese character to obtain the Chinese character corresponding to the scene field.
  19. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述对所述原始背景图像进行透明化处理,获取第一透明图像,包括:The non-volatile readable storage medium according to claim 16, wherein the performing a transparent process on the original background image to obtain the first transparent image includes:
    将所述原始背景图像进行模式转换,获取模式图像;所述模式图像包括颜色参数;Performing mode conversion on the original background image to obtain a mode image; the mode image includes color parameters;
    将所述模式图像的颜色参数设置为空,获取所述第一透明图像。Set the color parameter of the mode image to null to obtain the first transparent image.
  20. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述将所述中文字填充到所述第一透明图像上,获取第二透明图像,包括:The non-volatile readable storage medium according to claim 16, wherein the filling the Chinese character on the first transparent image and obtaining the second transparent image includes:
    获取所述中文字对应的属性参数;Obtain the attribute parameters corresponding to the Chinese characters;
    将所述属性参数应用到文字填充函数中,以将所述中文字填充到所述第一透明图像上,获取第二透明图像。The attribute parameter is applied to a text filling function to fill the Chinese text on the first transparent image and obtain a second transparent image.
PCT/CN2018/122993 2018-10-11 2018-12-24 Chinese language training image generation method and apparatus, computer device, and storage medium WO2020073497A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811182135.9 2018-10-11
CN201811182135.9A CN109255826B (en) 2018-10-11 2018-10-11 Chinese training image generation method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2020073497A1 true WO2020073497A1 (en) 2020-04-16

Family

ID=65046103

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/122993 WO2020073497A1 (en) 2018-10-11 2018-12-24 Chinese language training image generation method and apparatus, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN109255826B (en)
WO (1) WO2020073497A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112489165A (en) * 2020-11-06 2021-03-12 中科云谷科技有限公司 Method, device and storage medium for synthesizing characters

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109858542B (en) * 2019-01-25 2021-03-19 广州云测信息技术有限公司 Character recognition method and device
CN109978044B (en) * 2019-03-20 2021-03-19 广州云测信息技术有限公司 Training data generation method and device, and model training method and device
CN110136225B (en) * 2019-03-29 2023-05-30 北京旷视科技有限公司 Method, apparatus and computer storage medium for generating a sample of written print data
CN111860389A (en) * 2020-07-27 2020-10-30 北京易真学思教育科技有限公司 Data processing method, electronic device and computer readable medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103679208A (en) * 2013-11-27 2014-03-26 北京中科模识科技有限公司 Broadcast and television caption recognition based automatic training data generation and deep learning method
CN104794504A (en) * 2015-04-28 2015-07-22 浙江大学 Graphic pattern text detection method based on deep learning
CN105955687A (en) * 2016-04-29 2016-09-21 华为技术有限公司 Image processing method, apparatus and system
CN106874937A (en) * 2017-01-18 2017-06-20 腾讯科技(上海)有限公司 A kind of character image generation method, device and terminal
CN107393018A (en) * 2017-07-27 2017-11-24 北京中达金桥技术股份有限公司 A kind of method that the superposition of real-time virtual image is realized using Kinect
CN108288064A (en) * 2017-01-09 2018-07-17 北京京东尚科信息技术有限公司 Method and apparatus for generating picture

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302872A (en) * 2015-09-30 2016-02-03 努比亚技术有限公司 Image processing device and method
CN106203291B (en) * 2016-07-01 2019-07-05 昆明理工大学 A method of it is detected based on anatomic element analysis and the scene image words of self-adapting dictionary study
CN106683161B (en) * 2016-12-13 2020-06-05 中国传媒大学 Augmented reality shielding method based on image segmentation and user-defined layer method
CN107491752B (en) * 2017-08-14 2020-11-06 中国石油大学(华东) Deep learning-based method and device for identifying ship board characters in natural scene

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103679208A (en) * 2013-11-27 2014-03-26 北京中科模识科技有限公司 Broadcast and television caption recognition based automatic training data generation and deep learning method
CN104794504A (en) * 2015-04-28 2015-07-22 浙江大学 Graphic pattern text detection method based on deep learning
CN105955687A (en) * 2016-04-29 2016-09-21 华为技术有限公司 Image processing method, apparatus and system
CN108288064A (en) * 2017-01-09 2018-07-17 北京京东尚科信息技术有限公司 Method and apparatus for generating picture
CN106874937A (en) * 2017-01-18 2017-06-20 腾讯科技(上海)有限公司 A kind of character image generation method, device and terminal
CN107393018A (en) * 2017-07-27 2017-11-24 北京中达金桥技术股份有限公司 A kind of method that the superposition of real-time virtual image is realized using Kinect

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112489165A (en) * 2020-11-06 2021-03-12 中科云谷科技有限公司 Method, device and storage medium for synthesizing characters
CN112489165B (en) * 2020-11-06 2024-02-06 中科云谷科技有限公司 Method, device and storage medium for synthesizing characters

Also Published As

Publication number Publication date
CN109255826B (en) 2023-11-21
CN109255826A (en) 2019-01-22

Similar Documents

Publication Publication Date Title
WO2020073497A1 (en) Chinese language training image generation method and apparatus, computer device, and storage medium
US11972201B2 (en) Facilitating auto-completion of electronic forms with hierarchical entity data models
CN110276366A (en) Carry out test object using Weakly supervised model
CN110059320A (en) Entity relation extraction method, apparatus, computer equipment and storage medium
CN110532811B (en) PDF (Portable document Format) signature method and PDF signature system
CN109815471A (en) Contract text generation method, device, computer equipment and storage medium
WO2021151270A1 (en) Method and apparatus for extracting structured data from image, and device and storage medium
WO2021017272A1 (en) Pathology image annotation method and device, computer apparatus, and storage medium
WO2018090641A1 (en) Method, apparatus and device for identifying insurance policy number, and computer-readable storage medium
US9152619B2 (en) System and method for constructing markup language templates and input data structure specifications
CN110245469A (en) Watermark generation method, watermark analytic method, device and the storage medium of webpage
CN109635878A (en) A kind of painting and calligraphy fidelity identification method and device
CN110209630A (en) DXF file information processing method, device, computer equipment and storage medium
JP2022052716A (en) Query of semantic data from unstructured document
Rahmadi et al. Visual recognition of graphical user interface components using deep learning technique
CN108874392A (en) User's guideline interface generation method and device
CN109190615A (en) Nearly word form identification decision method, apparatus, computer equipment and storage medium
CN112560855A (en) Image information extraction method and device, electronic equipment and storage medium
CN110647350A (en) Interface document generation method and device, computer equipment and storage medium
CN111275436A (en) Method and terminal for processing information
CN115346095A (en) Visual question answering method, device, equipment and storage medium
CN108121693B (en) Slide beautifying method and device
CN112395834B (en) Brain graph generation method, device and equipment based on picture input and storage medium
CN111913873A (en) Picture verification method, device and system and computer readable storage medium
KR20150033027A (en) Method and apparatus for translation management

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18936317

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18936317

Country of ref document: EP

Kind code of ref document: A1