WO2023134068A1 - 数字识别模型的训练方法、装置、设备及存储介质 - Google Patents

数字识别模型的训练方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2023134068A1
WO2023134068A1 PCT/CN2022/089871 CN2022089871W WO2023134068A1 WO 2023134068 A1 WO2023134068 A1 WO 2023134068A1 CN 2022089871 W CN2022089871 W CN 2022089871W WO 2023134068 A1 WO2023134068 A1 WO 2023134068A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
training
output value
neural network
cropping
Prior art date
Application number
PCT/CN2022/089871
Other languages
English (en)
French (fr)
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 WO2023134068A1 publication Critical patent/WO2023134068A1/zh

Links

Images

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Definitions

  • the present application relates to the field of artificial intelligence, in particular to a training method, device, equipment and storage medium for a digital recognition model.
  • the present application provides a training method, device, equipment and storage medium for a digital recognition model, so as to expand training samples and speed up training.
  • the present application provides a method for training a digital recognition model, the method comprising:
  • the neural network is iteratively trained according to the loss function value and the similarity, and when the neural network converges, the neural network is used as a digital recognition model.
  • the present application also provides a training device for a digital recognition model, the device comprising:
  • a sample acquisition module configured to acquire a sample image and a digital label corresponding to the sample image
  • An image cropping module configured to perform image cropping on the sample image, and use the remaining image after image cropping as the first training image
  • a data enhancement module configured to perform data enhancement on the sample image to obtain a second training image
  • a loss calculation module configured to input the first training image and the second training image into the neural network respectively to obtain a first output value corresponding to the first training image and a second output corresponding to the second training image value, and calculate the loss function value of the neural network and the similarity between the first output value and the second output value according to the digital label;
  • a model training module configured to iteratively train the neural network according to the loss function value and the similarity, and use the neural network as a digital recognition model when the neural network converges.
  • the present application also provides a computer device, the computer device includes a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and execute the When a computer program implements:
  • the neural network is iteratively trained according to the loss function value and the similarity, and when the neural network converges, the neural network is used as a digital recognition model.
  • the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor realizes:
  • the neural network is iteratively trained according to the loss function value and the similarity, and when the neural network converges, the neural network is used as a digital recognition model.
  • the present application discloses a training method, device, equipment and storage medium for a digital recognition model.
  • the first training image is obtained by obtaining a sample image and a digital label corresponding to the sample image, and then performing image cropping and data enhancement on the sample image respectively.
  • the second training image input the first training image and the second training image into the neural network respectively, and calculate the loss function value of the neural network and the similarity between the first training image and the second training image according to the digital label, Finally, the neural network is trained according to the loss function value and similarity until the neural network converges, and a digital recognition model is obtained.
  • the sample images are processed in different ways to generate different training images to participate in the training of the neural network to realize the expansion of the training samples.
  • the similarity between different training images is also added to the training of the neural network, which speeds up the neural network. The convergence speed can improve the training speed of the model.
  • Fig. 1 is a schematic flow chart of a training method for a digital recognition model provided in an embodiment of the present application
  • FIG. 2 is a schematic diagram of the steps of cropping a sample image according to an embodiment of the present application
  • Fig. 3a is a schematic diagram showing that the digital type in the sample image provided by the embodiment of the present application is the first type
  • Fig. 3b is a schematic diagram showing that the digital type in the sample image provided by the embodiment of the present application is the second type
  • Fig. 4a is a schematic diagram of cropping a sample image from the left and right ends provided by the embodiment of the present application;
  • Fig. 4b is a schematic diagram of cropping a sample image from the upper and lower ends provided by the embodiment of the present application;
  • FIG. 5 is a schematic flow chart of another training method for a digital recognition model provided by an embodiment of the present application.
  • Fig. 6 is a schematic block diagram of a training device for a digital recognition model provided by an embodiment of the present application.
  • Fig. 7 is a schematic block diagram of another digital recognition model training device provided by the embodiment of the present application.
  • Fig. 8 is a schematic structural block diagram of a computer device provided by an embodiment of the present application.
  • Embodiments of the present application provide a training method, device, computer equipment and storage medium for a digital recognition model.
  • the training method of the digital recognition model can be used for fraudulent insurance behavior of patients and/or doctors, which provides an important reference for quickly finding out fraudulent insurance by patients or doctors.
  • FIG. 1 is a schematic flowchart of a method for training a digital recognition model provided by an embodiment of the present application.
  • the training method of the digital recognition model achieves the purpose of expanding samples through different processing of sample images.
  • the training method of the digital recognition model specifically includes: Step S101 to Step S105.
  • sample images used to train the digit recognition model and digital labels corresponding to the sample images The content of the sample image includes handwritten Roman numerals, and the digital label corresponding to the sample image is expressed as the actual handwritten Roman numerals in the sample image. If the acquired sample image does not have a corresponding digital label, the sample image is labeled.
  • the sample image before performing image cropping and data enhancement on the sample image, the sample image may be preprocessed, and the preprocessing includes one or more of binarization, denoising, normalization, and image thinning. Approach.
  • image cropping can be performed on the sample image, that is, specific region cutout based on prior knowledge, and the remaining image after image clipping is used as the first training image.
  • image cropping By randomly cropping the sample image, the neural network is guided to focus on more features and learn more fully the information in the sample image.
  • Step S102 may include step S1021 and step S1022.
  • the sample image can be processed by Hough Transform and Sobel operator (Sobel) before image cropping.
  • the straight line feature map in the sample image is obtained by using Hough transform, and the contour feature map of the sample image in the horizontal and vertical directions is obtained by Sobel operator processing.
  • the digital type of the sample image can be determined according to the linear feature map and the contour feature map. Among them, the digital type of the sample image includes the first type and the second type, the first type can be a short and wide digital type that occupies more positions in the horizontal direction, such as shown in Figure 3a, and the second type can be a vertical Tall and narrow digit types that occupy more positions on the top, such as that shown in Figure 3b.
  • S1022. Determine an image cropping mode according to the number type, and perform image cropping on the sample image according to the image cropping mode.
  • the corresponding image cropping method can be determined according to the number type, so as to avoid changing the number category in the sample image when image clipping is performed on the sample image.
  • the determining the image cropping method according to the digital type includes: when the digital type is the first type, determining that the image cropping method of the sample image is at the left and right ends of the sample image Perform cropping; when the digital type is the second type, determine the image cropping mode of the sample image as cropping at the upper and lower ends of the sample image.
  • the number type in the sample image is the first type, that is, the short and wide number type
  • image cropping is performed from the left and right ends of the sample image, as shown in FIG. 4a.
  • the digit type in the sample image is the second type, that is, the tall and narrow digit type
  • image cropping is performed from the upper and lower ends of the sample image, as shown in FIG. 4b.
  • the size of the rectangular frame for image cropping may be determined according to the length of the longest straight line in the sample image. According to the Hough transform, the length of the longest line in the sample image can be calculated. When determining the size of the rectangular frame for image cropping, any multiple of the length of the longest line that is greater than 0 and not greater than 1 can be selected. For example, the size of the rectangular frame for image cropping can be 0.25 of the length of the longest line.
  • the performing image cropping on the sample image, and using the remaining image after image cropping as the first training image includes: performing image cropping on the sample image, and performing image cropping on the remaining image after cropping Data enhancement is performed on the image to obtain the first image.
  • Data augmentation is performed on the remaining cropped images, so as to obtain the first image.
  • Data augmentation may include at least one of transforming, rotating, and changing hue.
  • Augmix enhancement with a width of 1 and a depth of 2 can be used to perform data enhancement on the cropped remaining image.
  • data augmentation can include various methods such as transformation, rotation, and color change.
  • Augmix enhancement with a width of 1 and a depth of 3 can be used to perform data enhancement on the sample image, and the image after data enhancement can be used as the second training image.
  • the first training image into the neural network to obtain the first output value of the neural network for the first training image, which is denoted as P M1 .
  • the second training image is input into the neural network to obtain a second output value of the neural network for the second training image, which is denoted as P M2 .
  • the loss function of the neural network can use cross entropy to calculate a loss function value of the neural network based on the digital label corresponding to the sample image and the first output value P M1 of the neural network for the first training image; similarly, based on the digital label corresponding to the sample image
  • the labels and the neural network calculate another loss function value of the neural network for the second output value P M2 of the second training image.
  • the similarity between P M1 and P M2 needs to be calculated according to the first output value P M1 of the neural network for the first training image and the second output value P M2 of the neural network for the second training image.
  • the more similar between PM1 and PM2 the better the prediction effect of the neural network.
  • JS divergence loss can be used to calculate the similarity between PM1 and PM2 .
  • KL is the KL divergence.
  • the neural network is iteratively trained according to the loss function value and similarity.
  • the loss function value and similarity can be given the same weight to participate in the iterative training of the neural network. That is to say, the loss function value and similarity can be multiplied by their respective weights and then added, and the obtained value can be used as the final actual loss value, and the parameters of the neural network can be adjusted based on the loss value. Hours, it is considered that the neural network converges at this time, and the converged neural network is used as a trained number recognition model for the recognition of handwritten Roman numerals.
  • FIG. 5 is a schematic flowchart of another training method for a digital recognition model provided by an embodiment of the present application.
  • the training method of the digital recognition model specifically includes: Step S201 to Step S207.
  • sample images used to train the digit recognition model and digital labels corresponding to the sample images The content of the sample image includes handwritten Roman numerals, and the number label corresponding to the sample image is represented as the actual handwritten Roman numerals in the sample image. If the acquired sample image does not have a corresponding digital label, the sample image is labeled.
  • image cropping can be performed on the sample image, that is, specific region cutout based on prior knowledge, and the remaining image after image clipping is used as the first training image.
  • image cropping By randomly cropping the sample image, the neural network is guided to focus on more features and learn more fully the information in the sample image.
  • the data augmentation may include at least one of transforming, rotating, and changing hue.
  • Augmix enhancement with a width of 1 and a depth of 3 can be used to perform data enhancement on the sample image, and the image after data enhancement can be used as the second training image.
  • S204 Determine a digital position in the sample image, determine a clipping area at the digital position, and clip the clipping area to obtain a clipping area image and a clipped remaining image.
  • the digit position of the digit in the sample image is determined, and then the clipping area is determined according to the digit position, so that the cropped clipping region image includes at least a part of the digit.
  • the position of the number in the sample image can be determined according to the pixel value of each pixel in the sample image, and the position of the number in the sample image can be determined according to the relationship between the pixel value of the pixel in the sample image and the threshold, for example If the pixel value of the pixel in the sample image is less than the threshold, the pixel can be considered as a part of the number.
  • the clipping area can be arbitrarily selected within the digital position, and the clipping area can be cut to obtain the clipped image, that is, the clipping area image, and the remaining image after clipping .
  • a check can be made according to the size of the cropping area image and the size of the sample image, so as to ensure that the characters in the cropping area image do not exceed the range of the picture when pasting.
  • the step of pasting the image of the clipped region on the remaining image after clipping to obtain the third training image includes: Carrying out hole filling to obtain a filled image; pasting the clipping region image on the filled image to obtain a third training image.
  • the inpainting method can be used to fill the void.
  • the step of pasting the clipping region image on the clipped remaining image to obtain the third training image includes: acquiring the pasting position of the clipping region image; determining the clipping region image Whether the paste position of the region image is within the remaining image after cutting; if the paste position of the cut region image is not within the remaining image after cutting, then adjust the paste position of the cut region image.
  • the pasting position includes the surrounding boundary position of the clipping area image, and then determine whether the clipping area image is all within the range of the remaining image after cutting according to the surrounding boundary position, if not If it is within the range of the remaining image after cutting, it is considered that the image in the cutting area exceeds the range of the image at this time, and the pasting position needs to be adjusted until the image in the cutting area is completely within the range of the remaining image after cutting.
  • the coordinate system can be constructed according to the sample image, the boundary coordinates of the pasting position of the cutout area image can be obtained, and the cutout area can be determined by judging the relationship between the boundary coordinates of the cutout area image and the boundary coordinates of the sample image Whether the paste position of the image is within the remaining image after cutting.
  • the second training image is input into the neural network to obtain a second output value of the neural network for the second training image, which is denoted as P M2 .
  • the loss function of the neural network can use cross entropy to calculate a loss function value of the neural network based on the digital label corresponding to the sample image and the first output value P M1 of the neural network for the first training image; similarly, based on the digital label corresponding to the sample image Calculate another loss function value of the neural network for the second output value P M2 of the label and the neural network for the second training image; and, based on the digital label corresponding to the sample image and the third output value P M3 of the neural network for the third training image Compute another loss function value for the neural network.
  • the JS divergence loss can be used to calculate the similarity among P M1 , P M2 and P M3 .
  • KL is the KL divergence.
  • the neural network is iteratively trained according to the loss function value and similarity.
  • the loss function value and similarity can be given the same weight to participate in the iterative training of the neural network. That is to say, the loss function value and similarity can be multiplied by their respective weights and then added, and the obtained value can be used as the final actual loss value, and the parameters of the neural network can be adjusted based on the loss value. Hours, it is considered that the neural network converges at this time, and the converged neural network is used as a trained number recognition model for the recognition of handwritten Roman numerals.
  • the first training image and the second training image are obtained by obtaining the sample image and the digital label corresponding to the sample image, and then image cropping and data enhancement are respectively performed on the sample image, and the second training image is obtained.
  • a training image and a second training image are respectively input into the neural network, and the loss function value of the neural network and the similarity between the first training image and the second training image are calculated according to the digital label, and finally according to the loss function value and the similarity
  • the neural network is trained until the neural network converges to obtain a digital recognition model.
  • the sample images are processed in different ways to generate different training images to participate in the training of the neural network to realize the expansion of the training samples.
  • the similarity between different training images is also added to the training of the neural network, which speeds up the neural network. The convergence speed can improve the training speed of the model.
  • FIG. 6 is a schematic block diagram of a training device for a digital recognition model provided by an embodiment of the present application.
  • the training device for a digital recognition model is used to implement the aforementioned training method for a digital recognition model.
  • the training device for the digital recognition model can be configured in a server or a terminal.
  • the server may be an independent server or a server cluster.
  • the terminal can be an electronic device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device.
  • the digital recognition model training device 300 includes: a sample acquisition module 301 , an image cropping module 302 , a data enhancement module 303 , a loss calculation module 304 and a model training module 305 .
  • a sample acquisition module 301 configured to acquire a sample image and a digital label corresponding to the sample image.
  • the image cropping module 302 is configured to perform image cropping on the sample image, and use the remaining image after image cropping as the first training image.
  • the image cropping module 302 includes a type determining submodule 3021 and a mode determining submodule 3022 .
  • the type determination sub-module 3021 is configured to perform Hough transform and Sobel operator processing on the sample image to determine the digital type of the sample image.
  • the mode determination sub-module 3022 is configured to determine an image cropping mode according to the digital type, and perform image cropping on the sample image according to the image cropping mode.
  • a data enhancement module 303 configured to perform data enhancement on the sample image to obtain a second training image.
  • a loss calculation module 304 configured to input the first training image and the second training image into the neural network to obtain a first output value corresponding to the first training image and a second output value corresponding to the second training image. output value, and calculate the loss function value of the neural network and the similarity between the first output value and the second output value according to the digital label.
  • the model training module 305 is configured to iteratively train the neural network according to the loss function value and the similarity, and use the neural network as a digital recognition model when the neural network converges.
  • FIG. 7 is a schematic block diagram of another digital recognition model training device provided by an embodiment of the present application.
  • the digital recognition model training device is used to implement the aforementioned digital recognition model training method.
  • the training device 400 of the digital recognition model includes: a sample acquisition module 401, an image cropping module 402, a data enhancement module 403, an image cutting module 404, an image pasting module 405, a loss calculation module 406 and a model training module 407 .
  • a sample acquisition module 401 configured to acquire a sample image and a digital label corresponding to the sample image.
  • the image cropping module 402 is configured to perform image cropping on the sample image, and use the remaining image after image cropping as the first training image.
  • a data enhancement module 403 configured to perform data enhancement on the sample image to obtain a second training image.
  • An image clipping module 404 configured to determine a digital position in the sample image, determine a clipping area at the digital position, and clip the clipping area to obtain the clipping area image and the remaining clipped image. image.
  • An image pasting module 405, configured to paste the cut region image on the cut remaining image to obtain a third training image.
  • a loss calculation module 406 configured to input the first training image, the second training image and the third training image into the neural network respectively, to obtain the first output value corresponding to the first training image, the first training image The second output value corresponding to the second training image and the third output value corresponding to the third training image, and calculate the loss function value of the neural network and the first output value and the second output value according to the digital label and the similarity between the third output value.
  • the model training module 407 is configured to iteratively train the neural network according to the loss function value and the similarity, and use the neural network as a digital recognition model when the neural network converges.
  • the training device for the above-mentioned digital recognition model can be realized in the form of a computer program, and the computer program can be run on the computer equipment as shown in FIG. 8 .
  • FIG. 8 is a schematic structural block diagram of a computer device provided by an embodiment of the present application.
  • the computer device can be a server or a terminal.
  • the computer device includes a processor, a memory, and a network interface connected through a system bus, where the memory may include a non-volatile storage medium and an internal memory.
  • Non-volatile storage media can store operating systems and computer programs.
  • the computer program includes program instructions.
  • the processor can be executed to execute any training method of a digital recognition model.
  • the processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
  • the internal memory provides an environment for running the computer program in the non-volatile storage medium.
  • the processor can execute any training method for the digital recognition model.
  • This network interface is used for network communication, such as sending assigned tasks, etc.
  • FIG. 8 is only a block diagram of a partial structure related to the solution of this application, and does not constitute a limitation on the computer equipment to which the solution of this application is applied.
  • the specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the processor is used to run a computer program stored in the memory to implement the following steps:
  • the neural network is iteratively trained according to the loss function value and the similarity, and when the neural network converges, the neural network is used as a digital recognition model.
  • the processor when the processor realizes the image cropping of the sample image, it is used to realize:
  • An image cropping mode is determined according to the number type, and image cropping is performed on the sample image according to the image cropping mode.
  • the digital type of the sample image includes the first type and the second type; when the processor determines the image cropping method according to the digital type, it is used to realize:
  • the number type is the second type, it is determined that the image cropping mode of the sample image is cropping at the upper and lower ends of the sample image.
  • the processor when the processor implements the image cropping of the sample image and uses the remaining image after image cropping as the first training image, it is used to realize:
  • Image cropping is performed on the sample image, and data enhancement is performed on the remaining image after image cropping to obtain the first image, and the data enhancement includes at least one of transforming, rotating, and changing hue.
  • the processor implements the step of inputting the first training image and the second training image into the neural network respectively to obtain the first output value corresponding to the first training image and the second training image.
  • the processor realizes inputting the first training image and the second training image into the neural network respectively, the first output value corresponding to the first training image and the first output value corresponding to the second training image are obtained.
  • the processor when the processor achieves the step of pasting the clipped region image on the clipped remaining image to obtain the third training image, it is configured to:
  • the processor when the processor achieves the step of pasting the clipped region image on the clipped remaining image to obtain the third training image, it is configured to:
  • Embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement the present application.
  • the computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or a memory of the computer device.
  • the computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD ) card, flash card (Flash Card), etc.
  • the computer-readable storage medium may be non-volatile or volatile.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Health & Medical Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Image Analysis (AREA)

Abstract

本申请涉及人工智能和图像识别领域,具体公开了一种数字识别模型的训练方法、装置、设备及存储介质,所述方法包括:获取样本图像和所述样本图像对应的数字标签;对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;对所述样本图像进行数据增强得到第二训练图像;将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。

Description

数字识别模型的训练方法、装置、设备及存储介质
本申请要求于2022年01月14日提交中国专利局、申请号为2022100442016,发明名称为“数字识别模型的训练方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种数字识别模型的训练方法、装置、设备及存储介质。
背景技术
目前,在进行数字识别时大多是对深度神经网络进行训练得到神经网络模型,从而利用得到的神经网络模型实现对数字的识别。但发明人意识到为了保证训练出的分类模型的准确度,往往需要获取大量的训练数据来参与模型的训练,这使得训练的成本较高。
发明内容
本申请提供了一种数字识别模型的训练方法、装置、设备及存储介质,以对训练样本进行扩充并加快训练速度。
第一方面,本申请提供了一种数字识别模型的训练方法,所述方法包括:
获取样本图像和所述样本图像对应的数字标签;
对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
对所述样本图像进行数据增强得到第二训练图像;
将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
第二方面,本申请还提供了一种数字识别模型的训练装置,所述装置包括:
样本获取模块,用于获取样本图像和所述样本图像对应的数字标签;
图像裁剪模块,用于对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
数据增强模块,用于对所述样本图像进行数据增强得到第二训练图像;
损失计算模块,用于将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述 数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
模型训练模块,用于根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
第三方面,本申请还提供了一种计算机设备,所述计算机设备包括存储器和处理器;所述存储器用于存储计算机程序;所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现:
获取样本图像和所述样本图像对应的数字标签;
对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
对所述样本图像进行数据增强得到第二训练图像;
将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
第四方面,本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现:
获取样本图像和所述样本图像对应的数字标签;
对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
对所述样本图像进行数据增强得到第二训练图像;
将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
本申请公开了一种数字识别模型的训练方法、装置、设备及存储介质,通过获取样本图像以及样本图像所对应的数字标签,然后分别对样本图像进行图像裁剪和数据增强,得到第一训练图像和第二训练图像,将第一训练图像和第二训练图像分别输入神经网络中,并根据数字标签来计算神经网络的损失函数值以及第一训练图像和第二训练图像之间的相似度,最终根据损失函数值和相似度对神经网络进行训练,直至神经网络收敛,得到数字识别模型。采用不同的方式对样本图像进行处理生成不同的训练图像参与神经网络的训练,实现对训练样本的扩充,另外,将不同训练图像之间的相似度也加入对神经网络的训练,加快了神经网络的收敛速度,提高模型的训练速度。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作 简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种数字识别模型的训练方法的示意流程图;
图2是本申请实施例提供的对样本图像进行图像裁剪的步骤示意图;
图3a是本申请实施例提供的样本图像中数字类型为第一类型的示意图;
图3b是本申请实施例提供的样本图像中数字类型为第二类型的示意图;
图4a是本申请实施例提供的对样本图像从左右两端进行图像裁剪的示意图;
图4b是本申请实施例提供的对样本图像从上下两端进行图像裁剪的示意图;
图5是本申请实施例提供的另一种数字识别模型的训练方法的示意流程图;
图6是本申请实施例提供的一种数字识别模型的训练装置的示意性框图;
图7是本申请实施例提供的另一种数字识别模型的训练装置的示意性框图;
图8是本申请实施例提供的一种计算机设备的结构示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
本申请的实施例提供了一种数字识别模型的训练方法、装置、计算机设备及存储介质。数字识别模型的训练方法可用于针对患者和/或医生的骗保行为,为快速找出患者或医生骗保提供了重要的参考。
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
请参阅图1,图1是本申请实施例提供的一种数字识别模型的训练方法的示意流程图。该数字识别模型的训练方法通过对样本图像进行不同的处理,达到了扩充样本的目的。
如图1所示,该数字识别模型的训练方法,具体包括:步骤S101至步骤S105。
S101、获取样本图像和所述样本图像对应的数字标签。
获取用于训练数字识别模型的样本图像以及样本图像对应的数字标签。样本图像的内容 中包括手写的罗马数字,样本图像对应的数字标签则表示为该样本图像中实际的手写的罗马数字。若获取到的样本图像没有对应的数字标签,则对样本图像进行标注。
在一些实施例中,在对样本图像进行图像裁剪和数据增强之前,可以先对样本图像进行预处理,预处理包括二值化、去噪、归一化和图像细化等一种或多种处理方法。
S102、对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像。
在得到样本图像后,可以对样本图像进行图像裁剪,也即根据先验知识的特定区域cutout,并且将经过图像裁剪后的剩余图像作为第一训练图像。通过对样本图像的随机裁剪,引导神经网络关注更多特征,更充分地学习样本图像中的信息。
在一实施例中,请参阅图2,为对样本图像进行图像裁剪的步骤示意图。步骤S102可以包括步骤S1021和步骤S1022。
S1021、对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型。
由于在对图像进行随机裁剪的过程中,容易改变样本图像中的数字类别,比如将“Ⅵ”右半边的字符“Ⅰ”剪切掉,使图片变成了“Ⅴ”。因此,为了避免随机裁剪改变样本图像中的数字,可以在进行图像裁剪前,先对样本图像进行霍夫变换(Hough Transform)和索贝尔算子(Sobel)处理。
使用霍夫变换得到样本图像中的直线特征图,使用索贝尔算子处理得出样本图像在水平和竖直方向上的轮廓特征图。根据直线特征图和轮廓特征图即可确定样本图像的数字类型。其中,样本图像的数字类型包括第一类型和第二类型,第一类型可以是水平方向上占据更多位置的短而宽的数字类型,例如图3a所示,第二类型可以是竖直方向上占据更多位置的高而窄的数字类型,例如图3b所示。
S1022、根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
在确定出数字类型后,即可根据数字类型确定相应的图像裁剪方式,避免在对样本图像进行图像裁剪时改变样本图像中的数字类别。
在一实施例中,所述根据所述数字类型确定图像裁剪方式,包括:当所述数字类型为第一类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的左右两端进行裁剪;当所述数字类型为第二类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的上下两端进行裁剪。
如果确定样本图像中的数字类型为第一类型,也即短而宽的数字类型时,则从样本图像的左右两端进行图像裁剪,如图4a所示。如果确定样本图像中的数字类型为第二类型,也即高而窄的数字类型时,则从样本图像的上下两端进行图像裁剪,如图4b所示。
在进行图像裁剪的过程中,图像裁剪的矩形框的大小可以根据样本图像中的最长直线长度来确定。根据霍夫变换可以算出样本图像中的最长直线长度,在确定图像裁剪的矩形框大小时,可以选择最长直线长度的任意大于0且不大于1的倍数,例如图像裁剪的矩形框大小可以为最长直线长度的0.25。
另外,在一实施例中,所述对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像,包括:对所述样本图像进行图像裁剪,并对图像裁剪后的剩余图像进行数据增强,得到第一图像。
在对样本图像进行裁剪后,对裁剪后的剩余图像进行数据增强,从而得到第一图像。数据增强可以包括变换、旋转以及更改色调中的至少一种。在具体实施过程中,可以使用宽度为1,深度为2的Augmix增强对裁剪后的剩余图像进行数据增强。
S103、对所述样本图像进行数据增强得到第二训练图像。
其中,数据增强可以包括变换、旋转以及更改色调等多种方式。例如可以使用宽度为1,、深度为3的Augmix增强对样本图像进行数据增强,将经过数据增强后的图像作为第二训练图像。
S104、将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度。
将第一训练图像输入神经网络中,得到神经网络对于第一训练图像的第一输出值,记为P M1。将第二训练图像输入神经网络中,得到神经网络对于第二训练图像的第二输出值,记为P M2
神经网络的损失函数可以采用交叉熵,基于样本图像对应的数字标签和神经网络对于第一训练图像的第一输出值P M1计算神经网络的一个损失函数值;同样的,基于样本图像对应的数字标签和神经网络对于第二训练图像的第二输出值P M2计算神经网络的另一个损失函数值。
另外,还需要根据神经网络对于第一训练图像的第一输出值P M1以及神经网络对于第二训练图像的第二输出值P M2计算P M1和P M2之间的相似度。P M1和P M2之间越相似,则说明神经网络的预测效果越好。
在具体实施过程中,可以使用JS散度损失来计算P M1和P M2之间的相似度。计算出的JS散度损失值越小,说明P M1和P M2越接近,神经网络的预测效果越好。
Figure PCTCN2022089871-appb-000001
其中,KL为KL散度。
S105、根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
根据损失函数值和相似度对神经网络进行迭代训练,在训练过程中,可以将损失函数值和相似度赋予相同的权重,来参与对神经网络的迭代训练。也即,可以将损失函数值与相似度分别与各自的权重相乘后再相加,将得到的值作为最终实际的损失值,基于该损失值对神经网络的参数进行调整,当损失值最小时,认为此时神经网络收敛,将该收敛的神经网络作为训练的数字识别模型,用于进行手写罗马数字的识别。
请参阅图5,图5是本申请实施例提供的另一种数字识别模型的训练方法的示意流程图。
如图5所示,该数字识别模型的训练方法,具体包括:步骤S201至步骤S207。
S201、获取样本图像和所述样本图像对应的数字标签。
获取用于训练数字识别模型的样本图像以及样本图像对应的数字标签。样本图像的内容中包括手写的罗马数字,样本图像对应的数字标签则表示为该样本图像中实际的手写的罗马数字。若获取到的样本图像没有对应的数字标签,则对样本图像进行标注。
S202、对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像。
在得到样本图像后,可以对样本图像进行图像裁剪,也即根据先验知识的特定区域cutout,并且将经过图像裁剪后的剩余图像作为第一训练图像。通过对样本图像的随机裁剪,引导神经网络关注更多特征,更充分地学习样本图像中的信息。
S203、对所述样本图像进行数据增强得到第二训练图像。
其中,数据增强可以包括变换、旋转以及更改色调中的至少一种。例如可以使用宽度为1,、深度为3的Augmix增强对样本图像进行数据增强,将经过数据增强后的图像作为第二训练图像。
S204、确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像。
确定样本图像中的数字所在的数字位置,然后根据数字位置来确定剪切区域,使得剪切出的剪切区域图像中至少包括数字的一部分。
在具体实施过程中,可以根据样本图像中各个像素点的像素值来确定样本图像中的数字位置,根据样本图像中像素点的像素值与阈值的关系,可以确定样本图像中数字的位置,例如若样本图像中像素点的像素值小于阈值时,可以认为该像素点为数字的一部分。
在确定出数字位置后,即可在数字位置内任意选择剪切区域,并对剪切区域进行剪切,从而得到剪切出的图像,也即剪切区域图像,和剪切后的剩余图像。
S205、将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像。
然后将剪切出的剪切区域图像在剪切后的剩余图像上随机选取任意位置进行粘贴,从而得到第三训练图像。
在粘贴的过程中,需要控制裁剪区域图像中的字符不能够超出样本图像的图像范围。因此,在具体实施过程中,可以根据裁剪区域图像的大小和样本图像的大小做校验,以保证粘贴时裁剪区域图像中的字符不超出图片范围。
在一实施例中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像,包括:对所述剪切后的剩余图像上的所述剪切区域进行空洞填充,得到填充图像;将所述剪切区域图像粘贴在所述填充图像上得到第三训练图像。
在对样本图像进行剪切后,剪切后的剩余图像中在数字位置会出现空洞,因此,需要对剪切所产生的空洞进行空洞填充。在具体实施过程中,可以采用inpainting的方式进行空洞填充。
在完成空洞填充后,得到一个填充完整的填充图像,然后将剪切下的剪切区域图像在填充图像上随机选取任意位置进行粘贴,粘贴后的图像即为第三训练图像。
在一实施例中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训 练图像,包括:获取所述剪切区域图像的粘贴位置;确定所述剪切区域图像的粘贴位置是否在所述剪切后的剩余图像内;若所述剪切区域图像的粘贴位置不在所述剪切后的剩余图像内,则调整所述剪切区域图像的粘贴位置。
获取剪切区域图像的粘贴位置,粘贴位置包括剪切区域图像的四周边界位置,然后根据四周边界位置确定剪切区域图像在粘贴时是否全部在剪切后的剩余图像的范围内,如果不在剪切后的剩余图像的范围内,则认为此时剪切区域图像超出了图像范围,需要对粘贴位置进行调整,直至剪切区域图像完全在剪切后的剩余图像的范围内。
在具体实施过程中,可以根据样本图像来构建坐标系,获取剪切区域图像粘贴位置的边界坐标,通过判断剪切区域图像的边界坐标与样本图像的边界坐标之间的关系,确定剪切区域图像的粘贴位置是否在剪切后的剩余图像内。
S206、将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
将第一训练图像输入神经网络中,得到神经网络对于第一训练图像的第一输出值,记为P M1。将第二训练图像输入神经网络中,得到神经网络对于第二训练图像的第二输出值,记为P M2。将第三训练图像输入神经网络中,得到神经网络对于第二训练图像的第三输出值,记为P M3
神经网络的损失函数可以采用交叉熵,基于样本图像对应的数字标签和神经网络对于第一训练图像的第一输出值P M1计算神经网络的一个损失函数值;同样的,基于样本图像对应的数字标签和神经网络对于第二训练图像的第二输出值P M2计算神经网络的另一个损失函数值;以及,基于样本图像对应的数字标签和神经网络对于第三训练图像的第三输出值P M3计算神经网络的再一个损失函数值。
另外,还需要根据神经网络对于第一训练图像的第一输出值P M1、神经网络对于第二训练图像的第二输出值P M2以及神经网络对于第三训练图像的第三输出值P M3计算P M1、P M2和P M3之间的相似度。P M1、P M2和P M3之间越相似,则说明神经网络的预测效果越好。
在具体实施过程中,可以使用JS散度损失来计算P M1、P M2和P M3之间的相似度。计算出的JS散度损失值越小,说明P M1、P M2和P M3越接近,神经网络的预测效果越好。
Figure PCTCN2022089871-appb-000002
其中,KL为KL散度。
S207、根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
根据损失函数值和相似度对神经网络进行迭代训练,在训练过程中,可以将损失函数值和相似度赋予相同的权重,来参与对神经网络的迭代训练。也即,可以将损失函数值与相似 度分别与各自的权重相乘后再相加,将得到的值作为最终实际的损失值,基于该损失值对神经网络的参数进行调整,当损失值最小时,认为此时神经网络收敛,将该收敛的神经网络作为训练的数字识别模型,用于进行手写罗马数字的识别。
上述实施例提供的数字识别模型的训练方法,通过获取样本图像以及样本图像所对应的数字标签,然后分别对样本图像进行图像裁剪和数据增强,得到第一训练图像和第二训练图像,将第一训练图像和第二训练图像分别输入神经网络中,并根据数字标签来计算神经网络的损失函数值以及第一训练图像和第二训练图像之间的相似度,最终根据损失函数值和相似度对神经网络进行训练,直至神经网络收敛,得到数字识别模型。采用不同的方式对样本图像进行处理生成不同的训练图像参与神经网络的训练,实现对训练样本的扩充,另外,将不同训练图像之间的相似度也加入对神经网络的训练,加快了神经网络的收敛速度,提高模型的训练速度。
请参阅图6,图6是本申请的实施例还提供一种数字识别模型的训练装置的示意性框图,该数字识别模型的训练装置用于执行前述的数字识别模型的训练方法。其中,该数字识别模型的训练装置可以配置于服务器或终端中。
其中,服务器可以为独立的服务器,也可以为服务器集群。该终端可以是手机、平板电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式设备等电子设备。
如图6所示,数字识别模型的训练装置300包括:样本获取模块301、图像裁剪模块302、数据增强模块303、损失计算模块304和模型训练模块305。
样本获取模块301,用于获取样本图像和所述样本图像对应的数字标签。
图像裁剪模块302,用于对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像。
在一实施例中,图像裁剪模块302包括类型确定子模块3021和方式确定子模块3022。
其中,类型确定子模块3021,用于对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型。方式确定子模块3022,用于根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
数据增强模块303,用于对所述样本图像进行数据增强得到第二训练图像。
损失计算模块304,用于将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度。
模型训练模块305,用于根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
请参阅图7,图7是本申请实施例提供的另一种数字识别模型的训练装置的示意性框图,该数字识别模型的训练装置用于执行前述的数字识别模型的训练方法。
如图7所示,数字识别模型的训练装置400包括:样本获取模块401、图像裁剪模块402、数据增强模块403、图像剪切模块404、图像粘贴模块405、损失计算模块406和模型 训练模块407。
样本获取模块401,用于获取样本图像和所述样本图像对应的数字标签。
图像裁剪模块402,用于对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像。
数据增强模块403,用于对所述样本图像进行数据增强得到第二训练图像。
图像剪切模块404,用于确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像。
图像粘贴模块405,用于将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像。
损失计算模块406,用于将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
模型训练模块407,用于根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的数字识别模型的训练装置和各模块的具体工作过程,可以参考前述数字识别模型的训练方法实施例中的对应过程,在此不再赘述。
上述的数字识别模型的训练装置可以实现为一种计算机程序的形式,该计算机程序可以在如图8所示的计算机设备上运行。
请参阅图8,图8是本申请实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以是服务器或终端。
参阅图8,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,其中,存储器可以包括非易失性存储介质和内存储器。
非易失性存储介质可存储操作系统和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种数字识别模型的训练方法。
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种数字识别模型的训练方法。
该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图8中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列 (Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:
获取样本图像和所述样本图像对应的数字标签;
对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
对所述样本图像进行数据增强得到第二训练图像;
将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
在一个实施例中,所述处理器在实现所述对所述样本图像进行图像裁剪时,用于实现:
对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型;
根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
在一个实施例中,所述样本图像的数字类型包括第一类型和第二类型;所述处理器在实现所述根据所述数字类型确定图像裁剪方式时,用于实现:
当所述数字类型为第一类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的左右两端进行裁剪;
当所述数字类型为第二类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的上下两端进行裁剪。
在一个实施例中,所述处理器在实现所述对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像时,用于实现:
对所述样本图像进行图像裁剪,并对图像裁剪后的剩余图像进行数据增强,得到第一图像,所述数据增强包括变换、旋转和更改色调中的至少一种。
在一个实施例中,所述处理器在实现所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度之前,用于实现:
确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像;
将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像;
所述处理器在实现所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所 述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度时,用于实现:
将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
在一个实施例中,所述处理器在实现所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像时,用于实现:
对所述剪切后的剩余图像上的所述剪切区域进行空洞填充,得到填充图像;
将所述剪切区域图像粘贴在所述填充图像上得到第三训练图像。
在一个实施例中,所述处理器在实现所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像时,用于实现:
获取所述剪切区域图像的粘贴位置;
确定所述剪切区域图像的粘贴位置是否在所述剪切后的剩余图像内;
若所述剪切区域图像的粘贴位置不在所述剪切后的剩余图像内,则调整所述剪切区域图像的粘贴位置。
本申请的实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申请实施例提供的任一项数字识别模型的训练方法。
其中,所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。所述计算机可读存储介质可以是非易失性,也可以是易失性。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种数字识别模型的训练方法,其中,所述方法包括:
    获取样本图像和所述样本图像对应的数字标签;
    对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
    对所述样本图像进行数据增强得到第二训练图像;
    将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
    根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
  2. 根据权利要求1所述的数字识别模型的训练方法,其中,所述对所述样本图像进行图像裁剪,包括:
    对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型;
    根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
  3. 根据权利要求2所述的数字识别模型的训练方法,其中,所述样本图像的数字类型包括第一类型和第二类型;所述根据所述数字类型确定图像裁剪方式,包括:
    当所述数字类型为第一类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的左右两端进行裁剪;
    当所述数字类型为第二类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的上下两端进行裁剪。
  4. 根据权利要求1所述的数字识别模型的训练方法,其中,所述对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像,包括:
    对所述样本图像进行图像裁剪,并对图像裁剪后的剩余图像进行数据增强,得到第一图像,所述数据增强包括变换、旋转和更改色调中的至少一种。
  5. 根据权利要求1所述的数字识别模型的训练方法,其中,在所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度之前,所述方法包括:
    确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像;
    将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像;
    所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度,包括:
    将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
  6. 根据权利要求5所述的数字识别模型的训练方法,其中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像,包括:
    对所述剪切后的剩余图像上的所述剪切区域进行空洞填充,得到填充图像;
    将所述剪切区域图像粘贴在所述填充图像上得到第三训练图像。
  7. 根据权利要求5所述的数字识别模型的训练方法,其中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像,包括:
    获取所述剪切区域图像的粘贴位置;
    确定所述剪切区域图像的粘贴位置是否在所述剪切后的剩余图像内;
    若所述剪切区域图像的粘贴位置不在所述剪切后的剩余图像内,则调整所述剪切区域图像的粘贴位置。
  8. 一种数字识别模型的训练装置,其中,包括:
    样本获取模块,用于获取样本图像和所述样本图像对应的数字标签;
    图像裁剪模块,用于对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
    数据增强模块,用于对所述样本图像进行数据增强得到第二训练图像;
    损失计算模块,用于将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
    模型训练模块,用于根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器;
    所述存储器用于存储计算机程序;
    所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现:
    获取样本图像和所述样本图像对应的数字标签;
    对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
    对所述样本图像进行数据增强得到第二训练图像;
    将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
    根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
  10. 根据权利要求9所述的计算机设备,其中,所述对所述样本图像进行图像裁剪,包括:
    对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型;
    根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
  11. 根据权利要求10所述的计算机设备,其中,所述样本图像的数字类型包括第一类型和第二类型;所述根据所述数字类型确定图像裁剪方式,包括:
    当所述数字类型为第一类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的左右两端进行裁剪;
    当所述数字类型为第二类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的上下两端进行裁剪。
  12. 根据权利要求9所述的计算机设备,其中,所述对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像,包括:
    对所述样本图像进行图像裁剪,并对图像裁剪后的剩余图像进行数据增强,得到第一图像,所述数据增强包括变换、旋转和更改色调中的至少一种。
  13. 根据权利要求9所述的计算机设备,其中,在所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度之前,所述方法包括:
    确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像;
    将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像;
    所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度,包括:
    将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
  14. 根据权利要求13所述的计算机设备,其中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像,包括:
    对所述剪切后的剩余图像上的所述剪切区域进行空洞填充,得到填充图像;
    将所述剪切区域图像粘贴在所述填充图像上得到第三训练图像。
  15. 根据权利要求13所述的计算机设备,其中,所述将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像,包括:
    获取所述剪切区域图像的粘贴位置;
    确定所述剪切区域图像的粘贴位置是否在所述剪切后的剩余图像内;
    若所述剪切区域图像的粘贴位置不在所述剪切后的剩余图像内,则调整所述剪切区域图像的粘贴位置。
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现:
    获取样本图像和所述样本图像对应的数字标签;
    对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像;
    对所述样本图像进行数据增强得到第二训练图像;
    将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度;
    根据所述损失函数值和所述相似度对所述神经网络进行迭代训练,并在所述神经网络收敛时,将所述神经网络作为数字识别模型。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述对所述样本图像进行图像裁剪,包括:
    对所述样本图像进行霍夫变换和索贝尔算子处理,确定所述样本图像的数字类型;
    根据所述数字类型确定图像裁剪方式,并根据所述图像裁剪方式对所述样本图像进行图像裁剪。
  18. 根据权利要求17所述的计算机可读存储介质,其中,所述样本图像的数字类型包括第一类型和第二类型;所述根据所述数字类型确定图像裁剪方式,包括:
    当所述数字类型为第一类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的左右两端进行裁剪;
    当所述数字类型为第二类型时,确定所述样本图像的图像裁剪方式为在所述样本图像的上下两端进行裁剪。
  19. 根据权利要求16所述的计算机可读存储介质,其中,所述对所述样本图像进行图像裁剪,将图像裁剪后的剩余图像作为第一训练图像,包括:
    对所述样本图像进行图像裁剪,并对图像裁剪后的剩余图像进行数据增强,得到第一图像,所述数据增强包括变换、旋转和更改色调中的至少一种。
  20. 根据权利要求16所述的计算机可读存储介质,其中,在所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度之前,所述方法包括:
    确定所述样本图像中的数字位置,并在所述数字位置确定剪切区域,对所述剪切区域进行剪切,得到剪切区域图像和剪切后的剩余图像;
    将所述剪切区域图像粘贴在所述剪切后的剩余图像上得到第三训练图像;
    所述将所述第一训练图像和所述第二训练图像分别输入神经网络,得到所述第一训练 图像对应的第一输出值和所述第二训练图像对应的第二输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值和所述第二输出值之间的相似度,包括:
    将所述第一训练图像、所述第二训练图像和所述第三训练图像分别输入神经网络,得到所述第一训练图像对应的第一输出值、所述第二训练图像对应的第二输出值和第三训练图像对应的第三输出值,并根据所述数字标签计算所述神经网络的损失函数值以及所述第一输出值、所述第二输出值和所述第三输出值之间的相似度。
PCT/CN2022/089871 2022-01-14 2022-04-28 数字识别模型的训练方法、装置、设备及存储介质 WO2023134068A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210044201.6 2022-01-14
CN202210044201.6A CN114417992A (zh) 2022-01-14 2022-01-14 数字识别模型的训练方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2023134068A1 true WO2023134068A1 (zh) 2023-07-20

Family

ID=81273041

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/089871 WO2023134068A1 (zh) 2022-01-14 2022-04-28 数字识别模型的训练方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN114417992A (zh)
WO (1) WO2023134068A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014205231A1 (en) * 2013-06-19 2014-12-24 The Regents Of The University Of Michigan Deep learning framework for generic object detection
CN107153810A (zh) * 2016-03-04 2017-09-12 中国矿业大学 一种基于深度学习的手写体数字识别方法及系统
CN111091132A (zh) * 2020-03-19 2020-05-01 腾讯科技(深圳)有限公司 基于人工智能的图像识别方法、装置、计算机设备及介质
CN112529040A (zh) * 2020-11-16 2021-03-19 深圳壹账通智能科技有限公司 模型生成的方法、装置、电子设备及介质
CN113052295A (zh) * 2021-02-27 2021-06-29 华为技术有限公司 一种神经网络的训练方法、物体检测方法、装置及设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014205231A1 (en) * 2013-06-19 2014-12-24 The Regents Of The University Of Michigan Deep learning framework for generic object detection
CN107153810A (zh) * 2016-03-04 2017-09-12 中国矿业大学 一种基于深度学习的手写体数字识别方法及系统
CN111091132A (zh) * 2020-03-19 2020-05-01 腾讯科技(深圳)有限公司 基于人工智能的图像识别方法、装置、计算机设备及介质
CN112529040A (zh) * 2020-11-16 2021-03-19 深圳壹账通智能科技有限公司 模型生成的方法、装置、电子设备及介质
CN113052295A (zh) * 2021-02-27 2021-06-29 华为技术有限公司 一种神经网络的训练方法、物体检测方法、装置及设备

Also Published As

Publication number Publication date
CN114417992A (zh) 2022-04-29

Similar Documents

Publication Publication Date Title
WO2022199583A1 (zh) 图像处理方法、装置、计算机设备和存储介质
WO2020238054A1 (zh) Pdf文档中图表的定位方法、装置及计算机设备
US8718365B1 (en) Text recognition for textually sparse images
CN109344762B (zh) 图像处理方法和装置
WO2023035531A1 (zh) 文本图像超分辨率重建方法及其相关设备
CN110443357B (zh) 卷积神经网络计算优化方法、装置、计算机设备及介质
US20180253852A1 (en) Method and device for locating image edge in natural background
CN110211195B (zh) 生成图像集合的方法、装置、电子设备和计算机可读存储介质
US11302108B2 (en) Rotation and scaling for optical character recognition using end-to-end deep learning
US20210248729A1 (en) Superpixel merging
CN108182457B (zh) 用于生成信息的方法和装置
CN110349161A (zh) 图像分割方法、装置、电子设备、及存储介质
CN111368632A (zh) 一种签名识别方法及设备
CN114359932B (zh) 文本检测方法、文本识别方法及装置
CN114724133B (zh) 文字检测和模型训练方法、装置、设备及存储介质
CN112508005B (zh) 用于处理图像的方法、装置、设备以及存储介质
CN109615620B (zh) 图像压缩度识别方法、装置、设备及计算机可读存储介质
CN109697722B (zh) 用于生成三分图的方法及装置
CN112651399A (zh) 检测倾斜图像中同行文字的方法及其相关设备
WO2023134068A1 (zh) 数字识别模型的训练方法、装置、设备及存储介质
CN116912556A (zh) 图片分类方法、装置、电子设备及存储介质
CN114926322B (zh) 图像生成方法、装置、电子设备和存储介质
CN114511862B (zh) 表格识别方法、装置及电子设备
CN116259064A (zh) 表格结构识别方法、表格结构识别模型的训练方法及装置
WO2023035535A1 (zh) 语义分割网络的训练方法、装置、设备及存储介质