Model training method and device, image recognition method and device and computer equipment

By acquiring various types of image features to train the recognition model, the problem of inaccurate blurry image detection in existing technologies has been solved, achieving higher accuracy in image blur judgment.

CN121725263APending Publication Date: 2026-03-24CHENGDU OPPO TELECOMM TECH CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

The accuracy of existing technologies for detecting blurry images still needs improvement, especially when using electronic devices to capture images, it is difficult to accurately determine whether an image is blurry.

Method used

By acquiring a sample image set, including both blurry and sharp images, various types of image features are extracted, such as edge sharpness, gradient magnitude, and local variance. An initial recognition model is then trained to obtain a target recognition model that can identify whether an image is blurry.

Benefits of technology

It improves the accuracy of the recognition model in detecting blurred images, enabling it to learn more image information and improve the precision of image blur judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121725263A_ABST
    Figure CN121725263A_ABST
Patent Text Reader

Abstract

The invention discloses a model training method and device, an image recognition method and device and computer equipment, and the method comprises the steps: obtaining a sample image set which comprises a plurality of sample images, and the plurality of sample images comprise blurred images and clear images; obtaining multiple types of sample image features corresponding to the sample image, wherein each type of sample image feature is an image feature used for representing the fuzzy degree of the sample image; and based on the sample image features, training an initial recognition model to obtain a target recognition model, the target recognition model being used for recognizing whether an input image is a blurred image. The method can improve the accuracy of detecting the blurred image by the recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and more particularly, to a model training method, an image recognition method, an apparatus and a computer device. BACKGROUND

[0002] With the rapid progress of science and technology and living standards, electronic devices (such as smart phones, tablet computers, etc.) have become one of the commonly used electronic products in people's lives. Moreover, the shooting function of electronic devices is also getting stronger and stronger, and non-professionals can also take high-quality images through electronic devices, but users will still produce image blur when using electronic devices to take pictures, so some schemes for detecting blurred images have been produced. However, the accuracy of detecting blurred images in the related art still needs to be improved. SUMMARY

[0003] The present application provides a model training method, an image recognition method, an apparatus and a computer device, which can improve the accuracy of the recognition model in detecting blurred images.

[0004] In a first aspect, the embodiments of the present application provide a model training method, which comprises: obtaining a sample image set, the sample image set comprising a plurality of sample images, the plurality of sample images including blurred images and clear images; obtaining a plurality of types of sample image features corresponding to the sample images, each type of sample image feature being an image feature for characterizing the blur degree of the sample image; training an initial recognition model based on the sample image features to obtain a target recognition model, the target recognition model being used to identify whether an input image is a blurred image.

[0005] In a second aspect, the embodiments of the present application provide an image recognition method, which comprises: obtaining a plurality of types of target image features of a to-be-identified image, each type of target image feature being an image feature for characterizing the blur degree of the to-be-identified image; inputting the plurality of types of target image features into a target recognition model to obtain an identification result output by the target recognition model, the identification result being used to represent whether the to-be-identified image is a blurred image.

[0006] Thirdly, embodiments of this application provide a model training apparatus, the apparatus comprising: a sample image acquisition module, a first feature acquisition module, and a recognition model training module, wherein the sample image acquisition module is used to acquire a sample image set, the sample image set including multiple sample images, the multiple sample images including blurred images and clear images; the first feature acquisition module is used to acquire multiple types of sample image features corresponding to the sample images, each type of sample image feature being an image feature used to characterize the blur degree of the sample image; the recognition model training module is used to train an initial recognition model based on the sample image features to obtain a target recognition model, the target recognition model being used to identify whether the input image is a blurred image.

[0007] Fourthly, embodiments of this application provide an image recognition device, the device comprising: a second feature acquisition module and a fuzzy image recognition module, wherein the second feature acquisition module is used to acquire multiple types of target image features of an image to be recognized, each type of target image feature being an image feature used to characterize the degree of fuzziness of the image to be recognized; the fuzzy image recognition module is used to input the multiple types of target image features into a target recognition model to obtain a recognition result output by the target recognition model, the recognition result being used to characterize whether the image to be recognized is a fuzzy image.

[0008] Fifthly, embodiments of this application provide a computer device, including: one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more application programs are configured to perform the model training method provided in the first aspect or the image recognition method provided in the second aspect.

[0009] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing program code, which can be invoked by a processor to execute the model training method provided in the first aspect or the image recognition method provided in the second aspect.

[0010] The solution provided in this application involves acquiring a sample image set, which includes multiple sample images, including both blurred and sharp images. It then acquires various types of sample image features corresponding to these training images, each type representing the degree of blurriness. Based on these features, an initial recognition model is trained to obtain a target recognition model, which is used to identify whether an input image is blurred. Therefore, by training the model with multiple types of image features representing the degree of blurriness, the resulting recognition model for detecting blurred images can learn more information about the image, thereby improving the accuracy of blurry image detection. Attached Figure Description

[0011] 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.

[0012] Figure 1 A schematic flowchart of a model training method according to an embodiment of this application is shown.

[0013] Figure 2 A schematic flowchart of a model training method according to another embodiment of this application is shown.

[0014] Figure 3 A schematic flowchart of a model training method according to yet another embodiment of this application is shown.

[0015] Figure 4 A schematic flowchart of an image recognition method according to an embodiment of this application is shown.

[0016] Figure 5 A block diagram of a model training apparatus according to an embodiment of this application is shown.

[0017] Figure 6 A block diagram of an image recognition device according to one embodiment of this application is shown.

[0018] Figure 7 This is a block diagram of a computer device for performing a model training method or image recognition method according to an embodiment of this application.

[0019] Figure 8 It is a storage unit in this application embodiment for storing or carrying program code that implements the model training method or image recognition method according to the embodiment of this application. Detailed Implementation

[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0021] Currently, electronic devices are almost ubiquitous in daily life, with camera modules becoming a key feature. Users can take photos and videos instantly, and these images are readily available. Furthermore, users frequently upload these images online to share with others. Electronic devices have largely replaced traditional video cameras for photography.

[0022] When taking photos with electronic devices, natural hand shake or taking photos while moving can cause blurry images. Since users frequently photograph faces, and these facial images are used in various applications, caution is needed before applying them. Therefore, it is essential to inspect the image to determine if it is blurry before use.

[0023] In related technologies, edge detection is usually performed, for example, using the Laplacian operator, to determine whether a face is blurry by using only the edges. These methods usually cannot accurately determine whether the entire face image is blurry.

[0024] To address the aforementioned problems, the inventors have proposed a model training method, image recognition method, apparatus, and computer device as provided in the embodiments of this application. By training the model with various types of image features characterizing the blurriness of the sample images, the resulting recognition model for detecting blurred images can learn more information from the images, thereby improving the accuracy of the recognition model in detecting blurred images. The specific model training method will be described in detail in subsequent embodiments.

[0025] The model training method provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0026] Please see Figure 1 , Figure 1 A schematic flowchart of a model training method provided in one embodiment of this application is shown. The following will focus on... Figure 1 The process shown will be explained in detail. The model training method may specifically include the following steps:

[0027] Step S110: Obtain a sample image set, which includes multiple sample images, including blurred images and clear images.

[0028] In the embodiments of this application, the above sample image set includes both blurry images and clear images. Blurry images can be used as positive samples for training a recognition model that recognizes blurry images, while clear images can be used as negative samples for training a recognition model that recognizes blurry images.

[0029] In some implementations, the computer device can acquire a large number of the above-mentioned blurry and clear images from an open-source image library to construct the above-mentioned sample image set; of course, it can also acquire a large number of the above-mentioned blurry and clear images through a camera to construct the sample image set.

[0030] In one possible implementation, the computer device can acquire a raw image set including multiple sharp images, and then blur a portion of the sharp images in the raw image set to obtain a sample image set. Understandably, since the proportion of severely blurred images in real-world scenes is small and insufficient for training, a sufficient number of blurred sample images can be obtained by constructing blurred images.

[0031] Optionally, the size of the sharp images in the original image set can be adjusted so that each sharp image has a fixed size. Then, blurring can be added to the sharp images to turn them into blurred images. Gaussian blur, average blur, or other techniques can be used to add different degrees of blurring to the sharp images.

[0032] In the above implementation, Gaussian blur is achieved by convolving the image with a Gaussian filter (convolution kernel), which smooths out the image details. The calculation of each element value is based on the Gaussian formula: Where x and y are the integer distances from the current position to the center of the convolution kernel, and σ is the standard deviation. The formula indicates that the closer to the center point, the greater the impact on the pixel value; the larger the Gaussian kernel dimension, the greater the blurring; and the convolution kernel size is an odd number.

[0033] In the above implementation, the mean blurring uses convolution kernels with all elements being equal, and the resulting pixel value is the average of the pixel values ​​within the radius of the surrounding convolution kernels. It does not consider the relationships between pixels, does not involve functional distribution, and achieves blurring directly through pixel averaging.

[0034] Of course, there is no limit to the specific method of blurring a clear image. For example, median filtering blur, sampling blur, mosaic blur, and other methods can also be used to blur a clear image.

[0035] In one possible implementation, the target recognition model to be trained in this embodiment can be a model for identifying whether a face image is a blurry face image. In this application scenario, all sample images in the above sample image set can be face images. When acquiring this sample image set, an original image set including multiple clear portraits can be acquired; for the clear portraits in the original image set, face detection can be performed to obtain clear face images; for the obtained clear face images, blurring processing can be performed to obtain blurry face images.

[0036] Optionally, a face detection algorithm can be used to detect the bounding box containing the face in a clear portrait; then, the bounding box can be cropped to obtain the clear face image. The face detection algorithm can include common object detection algorithms, such as the YOLO (You Only Look Once) series of algorithms, CenterNet, etc., or dedicated face detection algorithms, such as Multi-task Cascaded Convolutional Networks (MTCNN), CenterFace, Progressive Calibration Network (PCN), etc., without limitation.

[0037] In some implementations, each sample image in the above sample image set can be labeled with a fuzzy label. This fuzzy label can be a binary label used to characterize whether the sample image is a fuzzy image. For example, a fuzzy image in the sample image set can be labeled "1", and a non-fuzzy image (i.e., a clear image) in the sample image set can be labeled "0".

[0038] In some implementations, to ensure the model training effect, the number of blurred images and the number of clear images in the above sample image set can meet a preset ratio condition. For example, the ratio of the number of blurred images to the number of clear images can be 7:3.

[0039] Step S120: Obtain multiple types of sample image features corresponding to the sample image, where each type of sample image feature is an image feature used to characterize the blur level of the sample image.

[0040] In this embodiment, after obtaining the above sample image set, various types of sample image features corresponding to the sample images can be acquired. These sample image features are all image features used to characterize the degree of blurriness of the sample images, so as to be used as image features for blur detection in binary classification by the recognition model. By acquiring various types of sample image features, the recognition model can learn more information about the image during the model training process, thereby improving the accuracy of the recognition model in detecting blurry images.

[0041] In some implementations, the various types of sample image features can be image features that reflect the degree of blur in an image, such as edge sharpness, gradient magnitude, local variance, and local standard deviation. These types of sample image features can be understood as image features of different dimensions. In this way, the recognition model can learn information from different dimensions that reflect the degree of blur in the sample image, thereby improving the recognition accuracy of the trained target recognition model.

[0042] Step S130: Based on the features of the sample image, train the initial recognition model to obtain the target recognition model, which is used to identify whether the input image is a blurry image.

[0043] In this embodiment of the application, after obtaining the above-mentioned multiple types of sample image features corresponding to the sample images in the above sample image set, the initial recognition model can be trained based on the multiple types of sample image features corresponding to these sample images, thereby obtaining the trained target recognition model. The trained target recognition model can be used to output a recognition result that characterizes whether the input image is a blurry image based on the input image.

[0044] In some implementations, since the target recognition model needs to identify whether the input image is blurry, that is, the target recognition task is a binary classification task, the initial recognition model can be a binary classification model. Optionally, the initial recognition model can be a Logistic Regression model, Support Vector Machine (SVM), Decision Tree, Random Forest, Gradient Boosting Machines (GBM), Neural Networks, K-Nearest Neighbors (KNN), Naive Bayes, etc. Of course, the specific model type is not limited in this embodiment.

[0045] In some embodiments, the computer device executing the model training method provided in this application can be a server. That is, the server can execute steps S110 to S130 above to obtain the required target recognition model. After training the target recognition model, the trained target recognition model can be stored. The server can also distribute the trained target recognition model to electronic devices so that the electronic devices can use the target recognition model to identify whether an image is a blurry image.

[0046] The model training method provided in this application involves acquiring a sample image set, which includes multiple sample images, including both blurred and sharp images. It then acquires various types of sample image features corresponding to these images, each type representing the degree of blurriness. Based on these features, an initial recognition model is trained to obtain a target recognition model, which is used to identify whether an input image is blurred. Thus, by training the model with various types of image features representing the degree of blurriness of the sample images, the resulting recognition model for detecting blurred images can learn more information about the image, thereby improving the accuracy of the recognition model in detecting blurred images.

[0047] Please see Figure 2 , Figure 2 A schematic flowchart of a model training method provided in another embodiment of this application is shown. The following will focus on... Figure 2 The process shown will be explained in detail. The model training method may specifically include the following steps:

[0048] Step S210: Obtain a sample image set, which includes multiple sample images, including blurred images and clear images.

[0049] In this embodiment, step S210 can be referred to the content of the foregoing embodiments, and will not be repeated here.

[0050] Step S220: Obtain multiple types of sample image features corresponding to the sample image through multiple feature extraction methods. Each type of sample image feature corresponds one-to-one with the multiple feature extraction methods. Each type of sample image feature is an image feature used to characterize the blur degree of the sample image.

[0051] In this embodiment of the application, the computer device can obtain various types of sample image features corresponding to the sample images in the acquired sample image set through various feature extraction methods. According to each feature extraction method, a type of sample image feature corresponding to the sample image can be obtained.

[0052] In one possible implementation, the computer device can obtain the edge intensity of the sample image based on the Laplacian operator, and use it as the sample image feature corresponding to the sample image.

[0053] In this implementation, the Laplacian operator can be used to calculate the second derivative (second difference) for sample images. For digital images, the formula for the second derivative is:

[0054]

[0055] For discrete images, the second-order difference formula is:

[0056]

[0057] Alternatively, use other extended Laplace kernels, such as:

[0058]

[0059] Optionally, the sample image can be convolved based on the Laplacian kernel described above, resulting in a 64-bit signed floating-point number. This 64-bit signed floating-point number is then converted to an 8-bit unsigned integer. The average value of the 8-bit signed integer is then calculated to obtain the edge intensity of the current image. The edge intensity reflects the degree of blurriness of the image; a higher edge intensity value indicates a sharper image, while a lower edge intensity value indicates a blurrier image.

[0060] In one possible implementation, the ratio of the target singular value corresponding to the sample image to the sum of all singular values ​​is obtained by singular value decomposition and used as the sample image feature corresponding to the sample image.

[0061] In this embodiment, the sample image can be represented as an (N, N) matrix, denoted as A, by using singular value decomposition. Singular value decomposition is then performed on matrix A to obtain U, S, and V, respectively, with the formula: A = U * S * V.

[0062] Here, S is the singular value decomposition of matrix A, in which only the diagonal elements are non-zero, and the rest of the pixels are zero. The values ​​of the diagonal elements are sorted in reverse order, so only the larger eigenvalues ​​are retained to represent the features of the entire image; U is the left singular value, and V is the right singular value.

[0063] Optionally, the first N valid feature values ​​can be taken as target singular values, and then the sum of the N valid feature values ​​(i.e. all singular values) can be obtained as the first sum, and the sum of all feature values ​​can be calculated as the second sum; then the ratio of the first sum to the second sum can be obtained as the sample image feature corresponding to this image.

[0064] In one possible implementation, the sum of the squares of the grayscale differences between two adjacent pixels in the horizontal direction of the sample image can also be obtained as the sample image feature corresponding to the sample image.

[0065] In this implementation, sample image features can be obtained using a gradient function, such as the Brenner gradient function. Specifically, this is achieved by calculating the sum of the squares of the gray-level differences between two adjacent pixels in the horizontal direction of the sample image. The calculation formula is as follows:

[0066] Df=∑ x ∑ y |f(x+2,y)-f(x,y)| 2

[0067] Here, f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated Df, the larger the value of Df, the clearer the image; the smaller the value of Df, the blurrier the image.

[0068] In one possible implementation, the differences between grayscale values ​​of different image regions in the sample image can also be obtained, and the sum of the absolute values ​​of the differences or the sum of the products of the differences can be obtained as the sample image features corresponding to the sample image.

[0069] Optionally, the difference between gray values ​​in different regions of the sample image can be calculated using a gray-level difference function, such as the SMD gray-level difference function, and the sum of the absolute values ​​of the differences can be used as the sample image feature corresponding to the sample image. The calculation formula is as follows:

[0070] Df=∑ x ∑ y ||f(x+1,y)-f(x,y)|+|f(x,y+1)-f(x,y)||.

[0071] Here, f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated Df, the larger the value of Df, the clearer the image; the smaller the value of Df, the blurrier the image.

[0072] Optionally, the difference between gray values ​​in different image regions of the sample image can be calculated using a gray-level difference product function, such as the SMD2 gray-level difference product function. The sum of the products of the absolute values ​​of these differences can then be used as the sample image feature corresponding to the sample image. The calculation formula is as follows:

[0073] Df=∑ x ∑ y ||f(x+1,y)-f(x,y)|*|f(x,y+1)-f(x,y)||

[0074] Here, f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated Df, the larger the value of Df, the clearer the image; the smaller the value of Df, the blurrier the image.

[0075] In one possible implementation, the sum of the squares of the differences between each pixel value and the average pixel value in the grayscale image corresponding to the sample image can also be obtained as the sample image feature corresponding to the sample image.

[0076] In this implementation, the average pixel value u of the grayscale image corresponding to the sample image can be calculated using a variance function, and then the sum of squares of the differences between each pixel value and the average pixel value can be calculated, as shown in the following formula:

[0077]

[0078] Where f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated S... 2 S 2 The larger the value of S, the clearer the image; 2 The smaller the value, the blurrier the image.

[0079] In one possible implementation, the sum of squares of the gradient values ​​of the pixels in the grayscale image corresponding to the sample image can also be obtained as the sample image feature corresponding to the sample image.

[0080] In this implementation, the gradient of grayscale pixel values ​​in the corresponding grayscale image of the sample image can be calculated; the clearer the image, the greater the gradient change should be. Then, the squares of the gradient values ​​in the horizontal and vertical directions are calculated, and the sum is obtained. The formula is as follows:

[0081] Df=∑ x ∑ y (f(x+1,y)-f(x,y)) 2 +(f(x,y+1)-f(x,y)) 2

[0082] Where f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated Df, the larger the value of Df, the clearer the image; the smaller the value of Df, the blurrier the image.

[0083] In one possible implementation, the focus feature value corresponding to the sample image can also be obtained as the sample image feature corresponding to the sample image.

[0084] In this implementation, the average pixel value *u* of the grayscale image corresponding to the sample image can be calculated using a focusing function, such as the Vollath focusing function. Then, the product of the pixel values ​​of adjacent pixels in the horizontal direction is calculated, and the difference between the sum of these products and the sum of the squares of the average value is calculated to obtain the final focusing feature value. The calculation formula is as follows:

[0085] Df=∑ x ∑ y f(x+1,y)*f(x,y)-∑ x ∑ y u*u

[0086] Where f(x,y) is the gray value of the sample image at pixel (x,y). For the calculated Df, the larger the value of Df, the clearer the image; the smaller the value of Df, the blurrier the image.

[0087] In one possible implementation, the information entropy value corresponding to the sample image can also be obtained as the sample image feature corresponding to the sample image.

[0088] In this implementation, the grayscale image corresponding to the sample image can be measured using an information entropy function, such as the Entropy information entropy function, in an informational representation. The calculation formula is as follows:

[0089]

[0090] Where, p i Let L be the probability of a pixel appearing when its grayscale value is i, and L be the total number of grayscale levels (usually equal to 256). If the grayscale values ​​of an image are uniformly distributed, the larger its information entropy value, the clearer the image; if the grayscale values ​​of an image are concentrated within a specific range, the smaller its information entropy value, the blurrier the image.

[0091] In this embodiment, sample image features can be obtained through at least two of the above feature extraction methods, thereby obtaining at least two types of sample image features. Furthermore, the specific method for obtaining the above sample image features is not limited; for example, other types of image features that can characterize the blur level of an image can also be obtained through other methods.

[0092] In the above implementation, for each sample image, sample image features can be obtained through the above methods, thereby obtaining multiple types of sample image features corresponding to each sample image. The multiple types of sample image features obtained in this way constitute the feature dimension. A label dimension can also be added to these sample image features to record positive and negative samples. Specifically, the added labels can be the labels corresponding to the sample images, i.e., labels representing positive samples of blurred images and labels representing negative samples of sharp images. The sample image features obtained above can be stored in various specified file formats, such as CSV files, for use in subsequent input recognition models.

[0093] Step S230: Based on the features of the sample image, train the initial recognition model to obtain the target recognition model, which is used to identify whether the input image is a blurry image.

[0094] In this embodiment, step S230 can be found in other embodiments and will not be repeated here.

[0095] The model training method provided in this application extracts various types of image features that characterize the blurriness of sample images through multiple feature extraction methods. Then, the model is trained based on these image features, so that the recognition model for detecting blurred images can learn more information about the image, thereby improving the accuracy of the recognition model in detecting blurred images.

[0096] Please see Figure 3 , Figure 3 A schematic flowchart of a model training method provided in another embodiment of this application is shown. The following will focus on... Figure 3 The process shown will be explained in detail. The model training method may specifically include the following steps:

[0097] Step S310: Obtain a sample image set, which includes multiple sample images, including blurred images and clear images.

[0098] Step S320: Obtain multiple types of sample image features corresponding to the sample image, where each type of sample image feature is an image feature used to characterize the blur level of the sample image.

[0099] In the embodiments of this application, steps S310 and S320 can be referred to the content of the foregoing embodiments, and will not be repeated here.

[0100] Step S330: Input the sample image features into the initial recognition model to obtain the classification result output by the initial recognition model.

[0101] In this embodiment of the application, when a target recognition model is trained based on various types of sample image features obtained from the sample image, the sample image features can be input into the initial recognition model to obtain the classification result output by the initial recognition model.

[0102] In some implementations, the target recognition model can be a binary classification model, which can be used to determine the probability that the input image is a blurry image based on the input image. This probability represents the likelihood that the input image is a blurry image; the higher the probability, the greater the likelihood that the input image is a blurry image. Therefore, the probability output by the target recognition model can indicate whether the input image is a blurry image.

[0103] In some implementations, since multiple types of sample image features are obtained for the sample image, i.e., multiple dimensions of image features are obtained, when the sample image features are input into the initial recognition model, the multiple types of sample image features can be fused into target image features; then the target image features are input into the initial recognition model to obtain the classification result output by the initial recognition model.

[0104] Step S340: Based on the classification result and the fuzzy label annotated on the sample image, determine the classification loss value, wherein the fuzzy label is used to characterize whether the sample image is a fuzzy image.

[0105] In this embodiment, after obtaining the classification result output by the initial recognition model for the input sample image features, the classification loss value corresponding to the initial recognition model can be determined based on the classification result and the labels annotated with the sample image features. Specifically, the classification loss value corresponding to the initial recognition model can be determined based on the difference between the classification result and the labels annotated with the sample image features.

[0106] In some implementations, for positive samples (i.e., blurry sample images), their corresponding sample image features can be labeled with a first label, and for negative samples (i.e., clear sample images), their corresponding sample image features can be labeled with a second label. The first label characterizes the image as blurry, and the second label characterizes the image as not blurry. When determining the classification loss value corresponding to the initial recognition model based on the classification result output by the initial recognition model for the input sample image features and the labels labeled on the sample image features, the loss value can be determined separately for the sample image features corresponding to positive samples and the sample image features corresponding to negative samples. Specifically, the positive sample loss value can be determined based on the classification result corresponding to the sample image features corresponding to the positive samples and the first label labeled on the sample image features corresponding to the positive samples; the negative sample loss value can be determined based on the classification result corresponding to the sample image features corresponding to the negative samples and the second label labeled on the sample image features corresponding to the negative samples; and the classification loss value corresponding to the initial recognition model can be determined based on the positive sample loss value and the negative sample loss value. Optionally, the L2 loss calculation method can be used to determine the above positive sample loss value and negative sample loss value. In addition, when determining the above classification loss value based on the positive sample loss value and the negative sample loss value, the positive sample loss value and the negative sample loss value can be weighted and summed according to the weights corresponding to the positive sample loss value and the negative sample loss value, so as to obtain the above classification loss value.

[0107] Step S350: Based on the classification loss value, iteratively train the initial recognition model to obtain the trained target recognition model.

[0108] In this embodiment of the application, after determining the classification loss value corresponding to the initial recognition model, the initial recognition model can be iteratively trained based on the classification loss value to obtain the final target recognition model.

[0109] In some implementations, the model parameters of the initial recognition model can be adjusted based on the calculated classification loss value; return to step S330, and repeat steps S330 to S350 until the training termination condition is met, and the trained target recognition model is obtained.

[0110] The process involves inputting the features of each sample image into the initial recognition model to obtain the classification result for each sample image. Then, based on the classification result and the labeled value, a classification loss value is determined. The model parameters of the initial recognition model are adjusted according to the calculated classification loss value, completing one epoch. Then, the process returns to step S330 to complete the next epoch, repeating this process to complete multiple epochs. An epoch refers to the number of times all sample state information is used; simply put, the epoch value represents how many times the entire dataset is processed. One epoch is equivalent to training once using all the sample images' various features.

[0111] In some implementations, the Adam optimizer can be used to iteratively update the initial recognition model based on the classification loss value, reducing the classification loss value each time until the total loss value converges. The model at this point is then saved, resulting in the trained target recognition model. The Adam optimizer combines the advantages of AdaGra (Adaptive Gradient) and RMSProp optimization algorithms, comprehensively considering the first moment estimation (mean of the gradient) and the second moment estimation (uncentered variance of the gradient) to calculate the update step size. The training termination conditions for iterative training can include: reaching the target number of iterations; or the classification loss value meeting a set condition.

[0112] Optionally, the convergence condition is to minimize the classification loss value, using an initial learning rate of 1e-3, with the learning rate decaying cosinely with the number of steps, and a batch size of 512. After training for several epochs, convergence is considered complete. Here, batch size can be understood as a batch processing parameter, and its limit is the total number of samples in the training set.

[0113] Optionally, satisfying the set condition for the total loss value may include: the total loss value being less than a set threshold. Of course, the specific set condition is not a limitation.

[0114] In some implementations, the sample images in the above sample image set can be divided according to a target ratio of training data to test data, for example, a target ratio of 8:2. When training the above target recognition model, steps S330 to S350 can be performed using the training data. After training the target recognition model, the target recognition model can be tested using test data. If the accuracy of the target recognition model obtained in the test is greater than the target accuracy, the target recognition model can be used to identify whether an image is a blurry image. The target accuracy can be 70%, 80%, etc. Through the above methods, the accuracy of the target recognition model in identifying whether an image is a blurry image can be guaranteed. Of course, the target recognition model can also be evaluated by determining indicators such as precision, recall, and the harmonic value of precision and recall based on the number of positive and negative examples identified.

[0115] The model training method provided in this application uses various types of image features to characterize the blurriness of the sample image to train the model. The resulting recognition model for detecting blurred images can learn more information about the image, thereby improving the accuracy of the recognition model in detecting blurred images.

[0116] Please see Figure 4 , Figure 4 A flowchart illustrating an image recognition method provided in another embodiment of this application is shown. This image recognition method is applied to the aforementioned electronic device, and will be discussed below. Figure 4 The process shown will be described in detail. The image recognition method may specifically include the following steps:

[0117] Step S410: Obtain multiple types of target image features of the image to be identified, where each type of target image feature is an image feature used to characterize the degree of blur of the image to be identified.

[0118] In this application embodiment, for the target recognition model trained in the foregoing embodiments, this application embodiment provides a method for recognizing blurred images using the target recognition model. When recognizing blurred images using the target recognition model, multiple types of target image features corresponding to the image to be recognized can be obtained. These target image features are all image features used to characterize the degree of blur of the image to be recognized, so as to be used as image features for blur detection in binary classification by the target recognition model.

[0119] The target image features mentioned above can be the same image features as the sample image features in the aforementioned embodiments. The specific method for obtaining the target image features can be found in the method for obtaining the sample image features in the aforementioned embodiments, and will not be repeated here.

[0120] Step S420: Input the various types of target image features into the target recognition model to obtain the recognition result output by the target recognition model. The recognition result is used to characterize whether the image to be recognized is a blurry image.

[0121] In this embodiment of the application, after obtaining the above-mentioned target image features of various types, the target image features of various types can be input into the above target recognition model, so as to obtain the recognition result output by the target recognition model. The recognition result is used to characterize whether the image to be recognized is a blurry image.

[0122] In some application scenarios, the above target recognition model can be used to detect whether a face image is blurry. For example, in an application scenario where the eyes of a person in a face image are detected as closed, and the image with closed eyes is processed to make the eyes open, if the face image itself is blurry, detecting whether the eyes are closed is not very meaningful. Therefore, the image recognition method provided in this application can be used to identify whether a face image selected from the album or image set of an electronic device is blurry using the above target recognition model. If the face image is blurry, then detecting whether the eyes are closed is not necessary; if the face image is not blurry, then detecting whether the eyes are closed can be performed, and then the image with closed eyes can be processed. Of course, the image recognition method provided in this application can also be applied to other scenarios, such as pedestrian removal, image enhancement, and image high-definition processing.

[0123] The model training method provided in this application obtains multiple types of image features corresponding to the image to be identified, which are used to characterize the degree of blur of the image. Then, the multiple types of image features are input into the target recognition model to obtain the recognition result of the blurred image output by the target recognition model. Since the target recognition model can use multiple types of image features to characterize the degree of blur of the image when identifying whether the image to be identified is blurred, the accuracy of blurred image recognition can be improved.

[0124] Please see Figure 5This diagram illustrates a structural block diagram of a model training device 500 according to an embodiment of this application. The model training device 500 utilizes the aforementioned electronic equipment and includes: a sample image acquisition module, a first feature acquisition module 520, and a recognition model training module 530. The sample image acquisition module 510 acquires a set of sample images, including multiple sample images, among which are blurred and clear images. The first feature acquisition module 520 acquires various types of sample image features corresponding to the sample images, each type of sample image feature being an image feature characterizing the degree of blur of the sample image. The recognition model training module 530 trains an initial recognition model based on the sample image features to obtain a target recognition model, which is used to identify whether an input image is a blurred image.

[0125] In some implementations, the first feature acquisition module 520 can be specifically used to acquire multiple types of sample image features corresponding to the sample image through multiple feature extraction methods, wherein each type of sample image feature corresponds one-to-one with the multiple feature extraction methods.

[0126] In one possible implementation, the multiple types of sample image features include sample image features obtained through at least two of the following feature extraction methods:

[0127] Based on the Laplacian operator, the edge intensity of the sample image is obtained as the sample image feature corresponding to the sample image.

[0128] The ratio of the target singular value to the sum of all singular values ​​of the sample image is obtained by using singular value decomposition, and is used as the sample image feature corresponding to the sample image.

[0129] The sum of the squares of the grayscale differences between two adjacent pixels in the horizontal direction of the sample image is obtained as the sample image feature corresponding to the sample image.

[0130] The differences between grayscale values ​​in different image regions of the sample image are obtained, and the sum of the absolute values ​​of the differences or the sum of the products of the differences are obtained as the sample image features corresponding to the sample image.

[0131] The sum of squares of the differences between each pixel value and the average pixel value in the grayscale image corresponding to the sample image is obtained and used as the sample image feature corresponding to the sample image.

[0132] The sum of squared gradient values ​​of pixel values ​​in the grayscale image corresponding to the sample image is obtained and used as the sample image feature corresponding to the sample image.

[0133] Obtain the focusing feature value corresponding to the sample image, and use it as the sample image feature corresponding to the sample image;

[0134] Obtain the information entropy value corresponding to the sample image, and use it as the sample image feature corresponding to the sample image.

[0135] In some implementations, the recognition model training module 530 may be specifically used to: input the features of the sample image into the initial recognition model to obtain the classification result output by the initial recognition model; determine a classification loss value based on the classification result and the fuzzy label annotated on the sample image, wherein the fuzzy label is used to characterize whether the sample image is a fuzzy image; and perform iterative training on the initial recognition model based on the classification loss value to obtain a trained target recognition model.

[0136] In one possible implementation, the recognition model training module 530 can also be used to fuse the various types of sample image features into target image features; input the target image features into the initial recognition model to obtain the classification result output by the initial recognition model.

[0137] In some implementations, the sample image acquisition module 510 may be specifically used to: acquire an original image set including multiple clear images; and blur some of the clear images in the original image set to obtain the sample image set.

[0138] Please see Figure 6 This diagram illustrates a structural block diagram of an image recognition device 600 according to an embodiment of this application. The image recognition device 600 utilizes the aforementioned electronic device and includes: a second feature acquisition module 610 and a blurred image recognition module 620. The second feature acquisition module 610 acquires multiple types of target image features of the image to be recognized, each type of target image feature being an image feature characterizing the degree of blurriness of the image to be recognized. The blurred image recognition module 620 inputs the multiple types of target image features into a target recognition model to obtain a recognition result output by the target recognition model, the recognition result being used to characterize whether the image to be recognized is a blurred image.

[0139] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0140] In the several embodiments provided in this application, the coupling between modules can be electrical, mechanical, or other forms of coupling.

[0141] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0142] In summary, the solution provided in this application acquires a sample image set, which includes multiple sample images, including both blurred and sharp images. It then acquires various types of sample image features corresponding to these training images, each type representing the degree of blurriness. Based on these features, an initial recognition model is trained to obtain a target recognition model, which is used to identify whether an input image is blurred. Therefore, by training the model with various types of image features representing the degree of blurriness of the sample images, the resulting recognition model for detecting blurred images can learn more information about the image, thereby improving the accuracy of the recognition model in detecting blurred images.

[0143] Please refer to Figure 7 This diagram illustrates a structural block diagram of a computer device according to an embodiment of this application. The computer device 100 can be a server, PC, laptop, smartphone, tablet, smartwatch, e-reader, or other device capable of running applications. The computer device 100 in this application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications can be stored in the memory 120 and configured to be executed by the one or more processors 110, and the one or more applications are configured to perform the methods described in the foregoing method embodiments.

[0144] Processor 110 may include one or more processing cores. Processor 110 connects to various parts within the electronic device 100 using various interfaces and lines, and performs various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 110 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 110 and may be implemented separately using a communication chip.

[0145] The memory 120 may include random access memory (RAM) or read-only memory (ROM). The memory 120 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the electronic device 100 during use (such as phonebook data, audio and video data, chat log data, etc.).

[0146] Please refer to Figure 8 This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable medium 800 stores program code that can be called by a processor to execute the methods described in the above method embodiments.

[0147] The computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has storage space for program code 810 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 810 may be compressed, for example, in a suitable form.

[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A model training method, characterized in that, The method includes: Obtain a sample image set, which includes multiple sample images, including blurred images and clear images; Obtain multiple types of sample image features corresponding to the sample image, where each type of sample image feature is an image feature used to characterize the blur level of the sample image; Based on the features of the sample images, the initial recognition model is trained to obtain a target recognition model, which is used to identify whether the input image is a blurry image.

2. The method according to claim 1, characterized in that, The acquisition of multiple types of sample image features corresponding to the sample image includes: By using multiple feature extraction methods, various types of sample image features corresponding to the sample image are obtained, and each type of sample image feature corresponds one-to-one with the multiple feature extraction methods.

3. The method according to claim 2, characterized in that, The various types of sample image features include sample image features obtained through at least two of the following feature extraction methods: Based on the Laplacian operator, the edge intensity of the sample image is obtained as the sample image feature corresponding to the sample image. The ratio of the target singular value to the sum of all singular values ​​of the sample image is obtained by using singular value decomposition, and is used as the sample image feature corresponding to the sample image. The sum of the squares of the grayscale differences between two adjacent pixels in the horizontal direction of the sample image is obtained as the sample image feature corresponding to the sample image. The differences between grayscale values ​​in different image regions of the sample image are obtained, and the sum of the absolute values ​​of the differences or the sum of the products of the differences are obtained as the sample image features corresponding to the sample image. The sum of squares of the differences between each pixel value and the average pixel value in the grayscale image corresponding to the sample image is obtained and used as the sample image feature corresponding to the sample image. The sum of squared gradient values ​​of pixel values ​​in the grayscale image corresponding to the sample image is obtained and used as the sample image feature corresponding to the sample image. Obtain the focusing feature value corresponding to the sample image, and use it as the sample image feature corresponding to the sample image; Obtain the information entropy value corresponding to the sample image, and use it as the sample image feature corresponding to the sample image.

4. The method according to claim 1, characterized in that, The step of training the initial recognition model based on the sample image features to obtain the target recognition model includes: The sample image features are input into the initial recognition model to obtain the classification result output by the initial recognition model; Based on the classification results and the fuzzy labels annotated on the sample images, a classification loss value is determined, wherein the fuzzy labels are used to characterize whether the sample images are fuzzy images; Based on the classification loss value, the initial recognition model is iteratively trained to obtain the trained target recognition model.

5. The method according to claim 4, characterized in that, The step of inputting the sample image features into the initial recognition model to obtain the classification result output by the initial recognition model includes: The features of the various types of sample images are fused into the target image features; The target image features are input into the initial recognition model to obtain the classification result output by the initial recognition model.

6. The method according to any one of claims 1-5, characterized in that, The acquisition of the sample image set includes: Obtain a raw image set containing multiple clear images; The sample image set is obtained by blurring some of the clear images in the original image set.

7. An image recognition method, characterized in that, The method includes: Multiple types of target image features are obtained from the image to be identified, and each type of target image feature is an image feature used to characterize the blur degree of the image to be identified; The various types of target image features are input into the target recognition model to obtain the recognition result output by the target recognition model. The recognition result is used to characterize whether the image to be recognized is a blurry image.

8. A model training device, characterized in that, The device includes: a sample image acquisition module, a first feature acquisition module, and a recognition model training module, wherein... The sample image acquisition module is used to acquire a sample image set, which includes multiple sample images, including blurred images and clear images. The first feature acquisition module is used to acquire multiple types of sample image features corresponding to the sample image, and each type of sample image feature is an image feature used to characterize the blur degree of the sample image; The recognition model training module is used to train the initial recognition model based on the features of the sample image to obtain the target recognition model, which is used to identify whether the input image is a blurry image.

9. An image recognition device, characterized in that, The device includes: a second feature acquisition module and a fuzzy image recognition module, wherein... The second feature acquisition module is used to acquire multiple types of target image features of the image to be identified, and each type of target image feature is an image feature used to characterize the blur degree of the image to be identified; The fuzzy image recognition module is used to input the various types of target image features into the target recognition model to obtain the recognition result output by the target recognition model. The recognition result is used to characterize whether the image to be recognized is a fuzzy image.

10. A computer device, characterized in that, include: One or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method as described in any one of claims 1-7.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains program code that can be invoked by a processor to execute the method as described in any one of claims 1-7.