Image correction model training methods, image correction methods, equipment and storage media

By constructing a benchmark image and using a neural network to train inversion recognition information, the problem of high computational cost in existing image correction methods is solved, and an efficient image correction process is achieved.

CN115908970BActive Publication Date: 2026-03-06深圳开鸿数字产业发展有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211387880.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-03
Publication Date
2026-03-06
Estimated Expiration
2042-11-03

AI Technical Summary

Technical Problem

Existing image correction methods are computationally intensive and prone to errors, especially with large documents or complex layouts, resulting in low efficiency.

Method used

By acquiring feature information from the original image, a baseline image is constructed, and multiple rotated images are obtained by rotating at random angles within the rotation range. The inversion recognition information is then trained using a neural network, simplifying the image correction process.

Benefits of technology

This significantly reduces the computational load and complexity of image correction, while improving its accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115908970B_ABST
    Figure CN115908970B_ABST
Patent Text Reader

Abstract

This application discloses an image correction model training method, image correction method, device, and storage medium. The model training method includes: acquiring feature information of an original image and acquiring a reference image corresponding to the original image; rotating the original image to obtain multiple rotated images, acquiring the inversion information of the rotated images, and constructing training samples from the multiple rotated images and their inversion information, along with the corresponding reference image; training a first preset neural network for predicting the inversion recognition information of the rotated images using the training samples; after training, inputting the rotated images into a second preset neural network to obtain a first corrected image; inputting the rotated images into the converged first preset neural network to obtain the inversion recognition information of the rotated images; obtaining a second corrected image based on the inversion recognition information and the first corrected image; completing the training of the second preset neural network to obtain an image correction model. Therefore, the complexity of the image correction model is reduced by recognizing the inversion information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image correction model training method, an image correction method, an apparatus, and a storage medium. Background Technology

[0002] With the rapid development of image recognition technology, various image recognition technologies have emerged one after another. In order to obtain higher text recognition accuracy and precision, traditional optical character recognition (OCR) technology based on deep learning has been widely used. However, due to various reasons, images may sometimes be skewed to a certain extent, and tilt image correction has become a necessary step in subsequent image processing.

[0003] Currently, methods for correcting tilted images generally employ projection transformation. This involves projecting the text to be corrected from multiple angles and then calculating the tilt angle from the resulting multiple projection images. Because this requires projecting the entire image and generating projections from several directions, the computational workload is significantly increased. Furthermore, the larger the document size and the more complex the layout, the more prone it is to errors. Summary of the Invention

[0004] This application discloses an image correction model training method, an image correction method, a computer device, and a storage medium, which solves the problem of excessive computational load in existing image correction methods.

[0005] Firstly, this application provides a method for training an image correction model, including:

[0006] Obtain feature information from the original image, and obtain a reference image corresponding to the original image based on the feature information of the original image;

[0007] The original image is rotated at random angles within a rotation range to obtain multiple rotated images. The inversion information of the rotated images is obtained based on the rotation angle of the rotated images. The multiple rotated images, the inversion information of the rotated images, and the reference image corresponding to the rotated images constitute training samples.

[0008] The training samples are used to train a first preset neural network. The first preset neural network performs feature comparison between the rotated image and the corresponding reference image to obtain the inversion recognition information of the rotated image. The inversion recognition information of the rotated image and the inversion information of the rotated image are calculated as a first loss function to determine whether the first preset neural network has converged.

[0009] The rotated image is input into a second preset neural network to obtain a first corrected image. The rotated image is then input into the converged first preset neural network to obtain inversion recognition information of the rotated image. A second corrected image is obtained based on the inversion recognition information and the first corrected image. A second loss function is calculated between the second corrected image and the original image.

[0010] If the second loss function satisfies the preset convergence condition, training stops, and the image correction model is obtained.

[0011] Secondly, this application provides an image correction method, including:

[0012] Acquire the image to be corrected and its feature information;

[0013] The image to be corrected and its feature information are input into a pre-constructed image correction model to obtain a corrected image. The image correction model is trained by the image correction model training method described in any one of claims 1-7.

[0014] Thirdly, embodiments of this application also provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable by the processor, the memory storing a strategy model, wherein when the computer program is executed by the processor, it implements the image correction model training method as described above, or implements the image correction method as described above.

[0015] Fourthly, embodiments of this application also provide a computer-readable storage medium for storing a computer program, which, when executed by a processor, causes the processor to implement the image correction model training method as described above, or to implement the image correction method as described above.

[0016] This application provides an image correction model training method, an image correction method, a computer device, and a storage medium. The proposed image correction model training method obtains a corresponding reference image based on the feature information of the original image, and rotates the original image at random angles within a rotation range to obtain multiple rotated images. These multiple rotated images, the inversion information of the rotated images, and the corresponding reference images are used as training samples to train a first preset neural network for calculating the inversion recognition information of the rotated images. After the first preset neural network is trained, a second preset neural network is trained to complete the image correction model training. The proposed image correction model training method can reduce the complexity and computational load of the image correction model by improving the accuracy of the inversion recognition information of the rotated images, significantly simplifying the image correction process.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic flowchart illustrating the steps of the image correction model training method provided in the embodiments of this application;

[0020] Figure 2 This is a schematic flowchart illustrating the steps of the reference image acquisition method provided in the embodiments of this application;

[0021] Figure 3 This is a schematic diagram of a method for acquiring a rotated image provided in an embodiment of this application;

[0022] Figure 4 This is a schematic diagram of an inverted information acquisition method provided in an embodiment of this application;

[0023] Figure 5 This is a schematic diagram of a method for obtaining inverted identification information provided in an embodiment of this application;

[0024] Figure 6 This is a schematic diagram of a second corrected image acquisition method provided in an embodiment of this application;

[0025] Figure 7 This is a schematic flowchart illustrating the steps of an image correction method provided in this application embodiment;

[0026] Figure 8 This is a schematic block diagram of a computer device provided in an embodiment of this application.

[0027] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Detailed Implementation

[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0029] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0030] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0031] It should be understood that, in order to clearly describe the technical solutions of the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with essentially the same function and effect. For example, the first identification model and the second identification model are only used to distinguish different callback functions and do not limit their order. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" do not necessarily mean they are different.

[0032] It should also be understood that the term "and / or" as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0033] To facilitate understanding of the embodiments of this application, some terms involved in the embodiments of this application will be briefly explained below.

[0034] 1. OCR: OCR refers to the process by which electronic devices (such as scanners or digital cameras) examine printed characters on paper, determine their shapes by detecting dark and light patterns, and then translate the shapes into computer text using character recognition methods. In other words, for printed characters, it uses optical methods to convert the text in a paper document into a black-and-white dot matrix image file, and then uses recognition software to convert the text in the image into text format for further editing by word processing software. How to correct errors or utilize auxiliary information to improve recognition accuracy is the most important research direction of OCR, leading to the development of Intelligent Character Recognition (ICR).

[0035] The main indicators for evaluating the performance of an OCR system include: rejection rate, false recognition rate, recognition speed, user interface friendliness, product stability, ease of use, and feasibility.

[0036] 2. Image tilt correction: Image tilt can be divided into two cases. One is planar tilt, in which case the camera is parallel to the object and the image only needs to be rotated to complete the correction. The other is Z-axis tilt, in which case the camera is at a certain angle to the object and the image needs to be transformed by perspective and then rotated to complete the correction.

[0037] The key to image tilt correction lies in automatically detecting the tilt direction and tilt angle based on image features. For planar tilt, the image boundary is first found using an edge (contour) detection algorithm, then the tilt angle is found using any algorithm such as Radon transform (a projection-based method), Hough transform, or linear regression, and finally, affine transformation is used for rotation. For Z-axis tilt, the image boundary is first found using an edge contour detection algorithm, then perspective transformation is used to project points on the view plane onto the real plane, and finally, affine transformation is used for rotation.

[0038] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0039] Currently, methods for correcting tilted images generally employ projection transformation. This involves projecting the text to be corrected from multiple angles and then calculating the tilt angle from the resulting multiple projection images. Because this requires projecting the entire image and generating projections from several directions, the computational workload is significantly increased. Furthermore, the larger the document size and the more complex the layout, the more prone it is to errors.

[0040] To address the aforementioned issues, embodiments of this application provide an image correction model training method, an image correction method, an apparatus, and a storage medium. By acquiring the inversion recognition information of a rotated image, the calculation of image correction can be simplified, and a corresponding corrected image can be generated, significantly simplifying the image correction process.

[0041] Please see Figure 1 , Figure 1 This is a schematic flowchart illustrating the steps of the image correction model training method provided in this application embodiment. This image correction model training method can be specifically applied to computer devices, such as servers or computing devices including GPUs.

[0042] like Figure 1 As shown, the image correction model training method specifically includes steps S101 to S105.

[0043] S101. Obtain the feature information of the original image, and obtain the reference image corresponding to the original image based on the feature information of the original image.

[0044] Specifically, the feature information of the original image includes the feature information of the iconic elements in the original image. A reference image corresponding to the original image is obtained based on the feature information of the original image. The feature information of the obtained reference image is the same as the feature information of the iconic elements in the original image. That is, the reference image includes at least the iconic elements in the original image, and the orientation of the iconic elements in the reference image is positive. By obtaining a reference image with positively oriented iconic elements, the feature information in the original image can be more directly reflected, which is convenient for the subsequent training of the image correction model.

[0045] For example, the original image can be a landscape image, a text image, or an object image. By selecting distinctive feature information from the original image, training can be performed on any type of original image. In the embodiments of this application, the type of original image is not limited.

[0046] It should be noted that when the original image is a landscape image, the feature information of the original image refers to the most recognizable scenery information; the feature information of the original image refers to the scenery information with the largest area in the image; and the feature information of the original image refers to the scenery information with the largest number in the image. By setting the feature information of landscape images, complex landscape images can be simplified, thus simplifying the subsequent image correction training process.

[0047] When the original image is a text image, the feature information of the original image refers to all the text information in the image; the feature information of the original image refers to the text information with the largest font size in the image; and the feature information of the original image refers to the text information that appears most frequently in the image. By setting the feature information of text images, images with dense text can be simplified, thus simplifying the subsequent image correction training process.

[0048] In some embodiments, a reference image corresponding to the original image is obtained based on the feature information of the original image. (See [link to relevant documentation]). Figure 2 , Figure 2 This is a schematic flowchart illustrating the steps of the reference image acquisition method provided in the embodiments of this application.

[0049] like Figure 2 As shown, the reference image acquisition method specifically includes steps S101a to S101c.

[0050] S101a. Based on the feature information of the original image, query the preset benchmark image library for an image that matches the feature information, and use the image that matches the feature information as the benchmark image corresponding to the original image.

[0051] S101b: Query the corresponding preset information in the reference image library based on the feature information of the original image.

[0052] S101c: Obtain the image corresponding to the preset information, and use the image as the reference image of the original image.

[0053] It should be noted that the benchmark image library contains multiple images with prominent features arranged in a positive orientation, and each image is marked with preset information about the prominent features it contains. By querying the corresponding preset information in the benchmark image library based on the feature information of the original image, the image corresponding to the preset information can be obtained as the benchmark image. By establishing a benchmark image library containing multiple images with prominent features arranged in a positive orientation, and querying the corresponding preset information in the benchmark image library based on the feature information of the original image, benchmark images with the same prominent features as the original image can be quickly obtained, which is convenient for the subsequent training of the image correction model.

[0054] For example, in some embodiments, the benchmark image library is pre-constructed manually before model training. This is achieved by selecting multiple source images including iconic elements and constructing the benchmark image library with preset information about the images and their corresponding iconic elements. New images and their corresponding preset information can be added to the benchmark image library at any time during subsequent use. Continuously improving the content of the benchmark image library also expands the recognition range of the constructed image correction model.

[0055] S102. Rotate the original image at random angles within the rotation range to obtain multiple rotated images. Obtain the inversion information of the rotated images based on the rotation angle of the rotated images. Combine the multiple rotated images, the inversion information of the rotated images, and the reference image corresponding to the rotated images to form training samples.

[0056] Specifically, the rotation range of the original image is [-180°, 180°]. The original image is rotated at random angles within [-180°, 180°] to obtain multiple rotated images, and the rotation angles corresponding to the rotated images are obtained. The inversion information of the rotated images can be obtained from the rotation angles, that is, whether the rotated image is inverted from the original image after being rotated at the corresponding rotation angle. The multiple rotated images, the inversion information of the rotated images, and the reference images corresponding to the rotated images constitute training samples.

[0057] In some embodiments, such as Figure 3 As shown, Figure 3This is a schematic diagram of a method for acquiring rotated images provided in an embodiment of this application. The method involves rotating the original image within a rotation range at random angles to obtain multiple rotated images. This includes dividing the rotation angle range into multiple sub-rotation ranges based on rotation interval angles; and sequentially rotating the original image within each of these sub-rotation ranges at random angles to obtain multiple rotated images. By dividing the image into multiple rotation interval angles and sequentially rotating the original image within each interval angle, a large number of rotated images can be obtained within each interval angle, providing a large number of training samples for subsequent image correction model training.

[0058] For example, such as Figure 3 As shown, within the rotation range, the rotation angle is divided into sub-rotation range 1, sub-rotation range 2, sub-rotation range 3, sub-rotation range 4... sub-rotation range n according to the rotation interval angle. The original image is rotated at random angles within sub-rotation range 1, sub-rotation range 2, sub-rotation range 3, sub-rotation range 4... sub-rotation range n to obtain sub-rotated image 1, sub-rotated image 2, sub-rotated image 3, sub-rotated image 4... sub-rotated image n. Assuming the rotation interval angle is 45°, the rotation range can be divided into 8 sub-rotation ranges: sub-rotation range 1 is [-180°, -135°), sub-rotation range 2 is [-132°, -90°), sub-rotation range 3 is [-90°, -45°), sub-rotation range 4 is [-45°, 0°), sub-rotation range 5 is [0°, 45°), sub-rotation range 6 is [45°, 90°), sub-rotation range 7 is [90°, 135°), and sub-rotation range 8 is [135°, 180°]. By rotating the original image sequentially within sub-rotation ranges 1 to 8 at random angles, we can obtain sub-rotated image 1, sub-rotated image 2, sub-rotated image 3, sub-rotated image 4, sub-rotated image 5, sub-rotated image 6, sub-rotated image 7, and sub-rotated image 8.

[0059] Specifically, inversion information is a numerical representation of whether a rotated image is inverted from the original image. When a rotated image is inverted from the original image, the rotation angle of the landmark elements in the rotated image is too large, and the landmark elements in the original image are inverted. By using numerical representation of the inversion information of the rotated image, the training of the image correction model can be simplified.

[0060] In some embodiments, such as Figure 4 As shown, Figure 4This is a schematic diagram of a method for obtaining inversion information according to an embodiment of this application. The method obtains inversion information of a rotated image based on its rotation angle. This includes obtaining the rotation angles of multiple rotated images and comparing these rotation angles with a range of inversion angles. If the rotation angle of the rotated image is within the range of inversion angles, a preset first coefficient is used as the inversion information of the second image. If the rotation angle of the second image is not within the range of inversion angles, a preset second coefficient is used as the inversion information of the second image. By using the first and second coefficients to represent the inversion information of the image, the inversion status of the image can be directly and concisely represented.

[0061] For example, assuming the inversion angle range is [-180°, 0°), the first coefficient is 1 and the second coefficient is 0, that is, if there is a rotation angle of the rotated image within the inversion angle range, the inversion information of the rotated image is 1, and similarly, if there is a rotation angle of the rotated image outside the inversion angle range, the inversion information of the rotated image is 0.

[0062] S103. Train a first preset neural network using the training samples. The first preset neural network performs feature comparison between the rotated image and the corresponding reference image to obtain the inversion recognition information of the rotated image. Calculate a first loss function between the inversion recognition information of the rotated image and the inversion information of the rotated image to determine whether the first preset neural network has converged.

[0063] Specifically, a neural network is an algorithmic mathematical model that mimics the behavioral characteristics of animal neural networks to perform distributed parallel information processing. Neural networks rely on the complexity of the system, adjusting the weight parameters connecting a large number of neurons to achieve a fit between the output and the desired result. The first neural network model used to predict the inversion recognition information of rotated images takes as input multiple rotated images, the inversion information of the rotated images, and the corresponding reference image, and outputs the predicted inversion recognition information.

[0064] Multiple rotated images, their inversion information, and the corresponding reference image from the training sample data are input into the first neural network model to be trained, resulting in a trained first neural network model. When predicting the inversion information of the rotated image, the inversion information can be determined based on the prediction results output by the first neural network model.

[0065] Specifically, the first preset neural network compares the features of the rotated image with the corresponding reference image. Since the landmark elements in the original image have also been rotated according to the rotation angle of the rotated image, and the corresponding reference image has a landmark element placed in the correct orientation, the inversion recognition information of the rotated image can be obtained by comparing the features of the rotated landmark element in the rotated image with the landmark element placed in the correct orientation in the reference image.

[0066] In some embodiments, such as Figure 5 As shown, Figure 5 This is a schematic diagram of a method for obtaining inversion recognition information provided in an embodiment of this application. The method involves comparing the features of a rotated image with those of a corresponding reference image to obtain inversion recognition information. This includes extracting multiple rotation feature points from the rotated image and multiple reference feature points from the reference image; obtaining the similarity coefficient between the distribution of the multiple rotation feature points and the distribution of the multiple reference feature points; and using the similarity coefficient as the inversion recognition information of the rotated image. By comparing the features of multiple rotation feature points of the rotated image with those of the reference image, inversion recognition information can be obtained based on the similarity coefficient of the feature points, thus effectively determining whether the rotated image is inverted.

[0067] For example, the similarity coefficient between the rotation feature points of the rotated image and the reference feature points of the reference image can be calculated by obtaining the vectors of the rotation feature points and the reference feature points and using Euclidean distance, as shown in the following formula:

[0068]

[0069] In the formula, L (Ri,Si) R is the similarity coefficient, with n rotating feature points and n reference feature points. i S represents the vector of the i-th reference feature point. i The vector representing the i-th rotated feature point.

[0070] It should be noted that, in order to unify the training of the first neural network model, the range of the similarity coefficient between the rotated feature point and the reference feature point of the reference image should be consistent with the range of inverted and non-inverted information. When the similarity coefficient between the rotated feature point and the reference feature point of the reference image is larger, it indicates that the deviation between the rotated image and the reference image is larger.

[0071] In some embodiments, the first loss function for calculating the predicted action information and the first-level label, and the predicted action direction information and the second-level label, is calculated using cross-entropy loss, as shown in the following formula:

[0072] -(ylog(p)+(1-y)log(1-p))

[0073] In the formula, y represents the inversion information corresponding to the rotated image, and p represents the inversion recognition information predicted by the first neural network model. By calculating the values ​​of the inversion recognition information of the rotated image and the inversion information corresponding to the rotated image, the accuracy of the prediction information of the first neural network model can be well reflected.

[0074] S104. Input the rotated image into a second preset neural network to obtain a first corrected image. Input the rotated image into the converged first preset neural network to obtain inversion recognition information of the rotated image. Obtain a second corrected image based on the inversion recognition information and the first corrected image. Calculate a second loss function between the second corrected image and the original image.

[0075] Specifically, the first neural network model used to predict the inversion recognition information of the rotated image and the second neural network model used to generate the first corrected image are the image correction models generated in this application. The second neural network model takes the rotated image as input and outputs the first corrected image, and obtains the second corrected image based on the first corrected image and the inversion recognition information generated by the constructed first neural network model.

[0076] In some embodiments, to improve training efficiency, an Adaptive Moment Estimation (Adam) optimizer is used during training. By calculating the gradient of the loss function in each iteration, the parameters are updated, thereby improving training quality.

[0077] In some embodiments, the second loss function between the second corrected image and the original image is calculated using the Manhattan distance (L1 distance), as shown in the following formula:

[0078]

[0079] Where L l1 (,) represents the value of the second loss function, a1 and a2 represent the pixel sets of the original image and the corresponding second corrected image, respectively, and n a Let a1(k) and a2(k) represent the number of pixels, and let a1(k) and a2(k) represent the value of the k-th pixel, where k∈{1,…,n} a}

[0080] In some embodiments, such as Figure 6 As shown, Figure 6This is a schematic diagram of a second corrected image acquisition method provided in an embodiment of this application. A second preset neural network obtains a first rotation recognition angle of the rotated image, and rotates the rotated image according to the first rotation recognition angle to obtain a first corrected image; a second rotation recognition angle is obtained according to inversion recognition information, and the first corrected image is rotated according to the second rotation recognition angle to obtain a second corrected image; wherein, the first rotation recognition angle is located in the positive range of the rotation range, which is [0°, 180°]. By obtaining the inversion information, the correction range of the second preset neural network can be halved, significantly reducing the computational load and network complexity of the image correction model.

[0081] For example, in some embodiments, if the inversion recognition information output by the first preset recognition angle after training is greater than the inversion threshold, then the rotated image is inverted based on the corresponding original image, and the second rotation recognition angle is 180°; if the inversion recognition information output by the first preset recognition angle after training is less than or equal to the inversion threshold, then the rotated image is not inverted based on the corresponding original image, and the second rotation recognition angle is 0°. Assuming the inversion threshold is 0.6, and the inversion recognition information obtained after the rotated image is input to the first preset neural network is 0.7, then the second rotation recognition angle of the rotated image is 180°, and the first rotation recognition angle output by the second preset neural network is 50°. Therefore, the rotated image is first rotated by 50° to obtain the first corrected image, and then rotated by 180° based on the rotated image to obtain the final second corrected image.

[0082] In some embodiments, the training samples further include the rotation angle of the rotated image; after obtaining the second corrected image based on the inversion recognition information and the first corrected image, the method further includes obtaining the correction angle of the second corrected image, calculating a third loss function of the correction angle and the rotation angle, and stopping training if both the third loss function and the second loss function satisfy a preset convergence condition, thereby obtaining the image correction model. By adding the rotation angle dimension to determine the convergence of the second preset neural network, the accuracy of the image correction model can be improved more comprehensively.

[0083] For example, in some embodiments, the third loss function is calculated using invariant loss, as shown in the following expression:

[0084] L Inv (w1, w2) = (w1 - w2) 2

[0085] Where L Inv (w1, w2) represents the invariance loss value, where w1 and w2 represent the rotation angle and correction angle, respectively.

[0086] S105. If the second loss function satisfies the preset convergence condition, stop training and obtain the image correction model.

[0087] Specifically, the preset convergence condition can be convergence when the value of the second loss function is less than a preset value, or convergence when the value of the second loss function fluctuates within a preset range. When the second loss function meets the preset convergence condition, training stops and the completed image correction is obtained.

[0088] This application provides an image correction model training method. It obtains a corresponding reference image based on the feature information of the original image, and rotates the original image at random angles within a rotation range to obtain multiple rotated images. These multiple rotated images, their inversion information, and the corresponding reference image are used as training samples to train a first preset neural network for calculating the inversion recognition information of the rotated images. After the first preset neural network is trained, a second preset neural network is trained to complete the image correction model training. The proposed image correction model training method can reduce the complexity and computational load of the image correction model by improving the accuracy of predicting the inversion information of the rotated images, significantly simplifying the image correction process.

[0089] Please refer to Figure 7 , Figure 7 This is a schematic flowchart illustrating the steps of an image correction method provided in an embodiment of this application. This image calibration method can be applied to computer devices, which may be servers or terminal devices, such as computers, mobile phones, or tablets.

[0090] like Figure 7 As shown, the method for calling this model includes steps S201 to S202.

[0091] S201. Obtain the image to be corrected and its feature information;

[0092] S202. Input the image to be corrected and its feature information image into a pre-constructed image correction model to obtain the corrected image. The image correction model is trained by the image correction model training method provided in the embodiments of this application.

[0093] Specifically, by obtaining the feature information of the iconic elements of the image to be corrected, the image to be corrected and its feature information are used as input to the constructed image correction model. The image correction model can obtain the reference image corresponding to the image to be corrected based on the feature information of the image to be corrected, and complete the correction of the image to be corrected.

[0094] In some embodiments, the user can select feature information corresponding to the image to be corrected through the interface provided by the image correction model; in other embodiments, the user can input feature information corresponding to the image to be corrected through the interface provided by the image correction model. The method for obtaining the feature information corresponding to the image to be corrected is not limited herein.

[0095] This application provides an image correction method that inputs the image to be corrected and its feature information into a constructed image correction model, and outputs a corrected image. Using the image correction method provided in this application can improve the accuracy of the image correction model.

[0096] Please see Figure 8 , Figure 8 This is a schematic block diagram of a computer device provided in an embodiment of this application.

[0097] like Figure 8 As shown, the computer device may include a processor, memory, and a network interface. The processor, memory, and network interface are connected via a system bus, such as an I2C (Inter-integrated Circuit) bus.

[0098] Specifically, the processor can be a microcontroller unit (MCU), a central processing unit (CPU), or a digital signal processor (DSP), etc.

[0099] Specifically, the storage device can be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a portable hard drive, etc.

[0100] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0101] The processor is configured to run a computer program stored in memory, and to perform the following steps when executing the computer program:

[0102] Obtain feature information from the original image, and obtain a reference image corresponding to the original image based on the feature information of the original image;

[0103] The original image is rotated at random angles within a rotation range to obtain multiple rotated images. The inversion information of the rotated images is obtained based on the rotation angle of the rotated images. The multiple rotated images, the inversion information of the rotated images, and the reference image corresponding to the rotated images constitute training samples.

[0104] The training samples are used to train a first preset neural network. The first preset neural network performs feature comparison between the rotated image and the corresponding reference image to obtain the inversion recognition information of the rotated image. The inversion recognition information of the rotated image and the inversion information of the rotated image are calculated as a first loss function to determine whether the first preset neural network has converged.

[0105] The rotated image is input into a second preset neural network to obtain a first corrected image. The rotated image is then input into the converged first preset neural network to obtain inversion recognition information of the rotated image. A second corrected image is obtained based on the inversion recognition information and the first corrected image. A second loss function is calculated between the second corrected image and the original image.

[0106] If the second loss function satisfies the preset convergence condition, training stops, and the image correction model is obtained.

[0107] In some embodiments, obtaining a reference image corresponding to the original image based on the feature information of the original image is specifically implemented as follows: based on the feature information of the original image, querying an image matching the feature information in a preset reference image library, and using the image matching the feature information as the reference image corresponding to the original image; querying corresponding preset information in the reference image library based on the feature information of the original image; obtaining an image corresponding to the preset information, and using the image as the reference image of the original image.

[0108] In some embodiments, obtaining the inversion information of the rotated image based on the rotation angle of the rotated image is specifically implemented as follows: obtaining the rotation angles of multiple rotated images, comparing the rotation angles of the rotated images with the range of inversion angles; if the rotation angle of the rotated image is within the range of inversion angles, using a preset first coefficient as the inversion information of the second image; if the rotation angle of the second image is not within the range of inversion angles, using a preset second coefficient as the inversion information of the second image.

[0109] In some embodiments, the second preset neural network obtains a first rotation recognition angle of the rotated image based on the rotated image, rotates the rotated image based on the first rotation recognition angle to obtain the first corrected image; obtains a second rotation recognition angle based on the inversion recognition information, rotates the first corrected image based on the second rotation recognition angle to obtain the second corrected image; wherein, the first rotation recognition angle is located in the positive range of the rotation range, and the positive range is [-180°, 180°].

[0110] In some embodiments, the training samples further include the rotation angle of the rotated image; after obtaining the second corrected image based on the inversion recognition information and the first corrected image, the following is further implemented: obtaining the correction angle of the second corrected image, calculating a third loss function of the correction angle and the rotation angle, and if both the third loss function and the second loss function satisfy the preset convergence condition, stopping the training to obtain the image correction model.

[0111] In some embodiments, the processor is configured to run a computer program stored in a memory, and when executing the computer program, implement the following steps: acquiring an image to be corrected and feature information of the image to be corrected; inputting the image to be corrected and the feature information of the image to be corrected into a pre-constructed image correction model to obtain a corrected image, wherein the image correction model is trained by any of the image correction model training methods provided in the embodiments of this application.

[0112] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the computer device described above can be referred to the corresponding process in the aforementioned file transfer method embodiments, and will not be repeated here.

[0113] This application also provides a computer-readable storage medium storing a computer program, which includes program instructions. The processor executes these program instructions to implement the steps of the image correction model training method provided in the above embodiments. For example, when the computer program is loaded by the processor, it can perform the following steps:

[0114] Obtain feature information from the original image, and obtain a reference image corresponding to the original image based on the feature information of the original image;

[0115] The original image is rotated at random angles within a rotation range to obtain multiple rotated images. The inversion information of the rotated images is obtained based on the rotation angle of the rotated images. The multiple rotated images, the inversion information of the rotated images, and the reference image corresponding to the rotated images constitute training samples.

[0116] The training samples are used to train a first preset neural network. The first preset neural network performs feature comparison between the rotated image and the corresponding reference image to obtain the inversion recognition information of the rotated image. The inversion recognition information of the rotated image and the inversion information of the rotated image are calculated as a first loss function to determine whether the first preset neural network has converged.

[0117] The rotated image is input into a second preset neural network to obtain a first corrected image. The rotated image is then input into the converged first preset neural network to obtain inversion recognition information of the rotated image. A second corrected image is obtained based on the inversion recognition information and the first corrected image. A second loss function is calculated between the second corrected image and the original image.

[0118] If the second loss function satisfies the preset convergence condition, training stops, and the image correction model is obtained.

[0119] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0120] The computer-readable storage medium can be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or memory of the computer device. Alternatively, it can be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the computer device.

[0121] Since the computer program stored in the computer-readable storage medium can execute the training method of any image correction model provided in the embodiments of this application, or implement any image correction method provided in the embodiments of this application, it can achieve the beneficial effects that any image correction model training method and image correction method provided in the embodiments of this application can achieve, as detailed in the preceding embodiments, and will not be repeated here.

[0122] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The above descriptions are merely specific implementations of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for training an image correction model, characterized in that, The method comprises: obtaining feature information of an original image, and obtaining a reference image corresponding to the original image according to the feature information of the original image; rotating the original image at random angles within a rotation range to obtain a plurality of rotated images, and obtaining overturn information of the rotated images according to rotation angles of the rotated images, which comprises: obtaining rotation angles of the plurality of rotated images, comparing the rotation angles of the rotated images with an overturn angle range; if the rotation angle of the rotated image is within the overturn angle range, a preset first coefficient is taken as the overturn information of the rotated image; if the rotation angle of the rotated image is not within the overturn angle range, a preset second coefficient is taken as the overturn information of the rotated image, and the plurality of rotated images, the overturn information of the rotated images and the reference images corresponding to the rotated images constitute training samples; training a first preset neural network by using the training samples, the first preset neural network performing feature comparison between the rotated images and the corresponding reference images to obtain overturn identification information of the rotated images, which comprises: extracting a plurality of rotation feature points of the rotated images and a plurality of reference feature points of the reference images; obtaining a similarity coefficient between the distribution of the plurality of rotation feature points and the distribution of the plurality of reference feature points, the similarity coefficient being taken as the overturn identification information of the rotated images, and calculating a first loss function of the overturn identification information of the rotated images and the overturn information of the rotated images to determine whether the first preset neural network converges; inputting the rotated images into a second preset neural network to obtain a first corrected image, inputting the rotated images into the first preset neural network which has converged to obtain the overturn identification information of the rotated images, obtaining a second corrected image according to the overturn identification information and the first corrected image, and calculating a second loss function of the second corrected image and the original image; if the second loss function meets a preset convergence condition, stopping training to obtain the image correction model.

2. The method of claim 1, wherein, The method comprises: dividing the rotation angle range into a plurality of sub-rotation ranges according to a rotation interval angle; rotating the original image at random angles within the plurality of sub-rotation ranges to obtain the plurality of rotated images.

3. The method of claim 1, wherein, The method comprises: querying an image matching the feature information from a preset reference image library according to the feature information of the original image, and taking the image matching the feature information as the reference image corresponding to the original image; querying preset information corresponding to the original image from the reference image library according to the feature information of the original image; obtaining an image corresponding to the preset information, and taking the image as the reference image of the original image.

4. The method of claim 1, wherein The second preset neural network obtains a first rotation recognition angle of the rotated image according to the rotated image, and obtains the first corrected image by rotating the rotated image according to the first rotation recognition angle; obtain a second rotation recognition angle according to the inversion recognition information, and obtain the second corrected image by rotating the first corrected image according to the second rotation recognition angle; The first rotation recognition angle is located in a positive range of the rotation range, and the positive range is [0°, 180°].

5. The method of claim 1, wherein, The training sample further includes a rotation angle of the rotated image; after the second corrected image is obtained according to the inversion recognition information and the first corrected image, the following steps are further included: obtain a correction angle of the second corrected image, calculate a third loss function of the correction angle and the rotation angle, and if the third loss function and the second loss function both satisfy the preset convergence condition, stop training to obtain the image correction model.

6. An image correction method characterized by, including: obtain a to-be-corrected image and feature information of the to-be-corrected image; input the to-be-corrected image and the feature information of the to-be-corrected image into a pre-constructed image correction model to obtain a corrected image, the image correction model being trained by the image correction model training method of any one of claims 1-5.

7. A computer device, comprising: The computer device includes a processor, a memory, and a computer program stored on the memory and executable by the processor, and the memory stores a policy model, wherein when the computer program is executed by the processor, the image correction model training method of any one of claims 1-5 is implemented; or, the image correction method of claim 6 is implemented.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to make the processor implement the image correction model training method of any one of claims 1-5; or, the image correction method of claim 6 is implemented.

Citation Information

Patent Citations

  • Text image inclination correction method and device and image processing equipment

    CN110188747A

  • Certificate image correction method, device and equipment, and storage medium

    CN111860489A