A classification method, apparatus, device and computer readable storage medium

By using a custom loss function and conjugate gradient descent method, the influence of features on the classification model is enhanced, solving the problems of slow classification speed and low accuracy in existing technologies, and achieving fast and high-accuracy image classification.

CN115527054BActive Publication Date: 2026-05-22CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
Filing Date
2021-06-24
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

Existing classification methods such as SVM and BP neural networks suffer from problems such as insensitivity to outliers, slow classification speed, and low classification accuracy, making it difficult to meet the requirements of fast classification and high accuracy.

Method used

A custom loss function is used to enhance the impact of features on the classification model. Preset values ​​that are opposites of each other are used to increase the difference between features. Combined with the conjugate gradient descent method, the model can converge quickly and achieve fast and high-accuracy classification of images to be classified.

Benefits of technology

By using a custom loss function and conjugate gradient descent, the classification time was shortened and the classification accuracy was improved, achieving fast and high-accuracy image classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115527054B_ABST
    Figure CN115527054B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a classification method, device and equipment and a computer readable storage medium. The method comprises: obtaining an image to be classified and a pre-trained classification model, wherein the classification model is trained by a target self-defined loss function, and the self-defined loss function is used to enhance the influence of features on the classification model; performing classification processing on the image to be classified by using the classification model to obtain a classification result of the image to be classified; and outputting the classification result of the image to be classified. By increasing the influence of features on the model, a classification result with high accuracy can be obtained. Furthermore, the classification time is shortened by using the self-defined loss function, so that a classification result with high accuracy can be obtained in a short time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning, and includes, but is not limited to, a classification method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] As an emerging storage medium, cloud computing and cloud storage are gradually taking on more and more traditional business functions, such as providing collaborative office and resource sharing functions for government, education and other institutions.

[0003] For example, in the education sector, teachers assign homework via the cloud, and students take photos of their completed assignments and upload them to the cloud for teachers to grade. Due to the large volume of assignments sent and received, the photos are often poorly categorized and become disorganized. Furthermore, the default arrangement of cloud storage is insufficient to meet the need for categorization by subject, further hindering teachers' grading process.

[0004] Among the relevant algorithms, Support Vector Machine (SVM) is insensitive to outliers, and multilayer feedforward (BP) neural networks trained by backpropagation have slow convergence speed, resulting in slow classification speed and low classification accuracy.

[0005] Therefore, related technologies suffer from a lack of classification and a cumbersome, complex structure. Even with classification algorithms such as SVM and BP, slow classification speed and low accuracy remain. Thus, a classification method that is both fast and accurate is urgently needed. Summary of the Invention

[0006] In view of the above, embodiments of this application provide a classification method, apparatus, device, and computer-readable storage medium.

[0007] The technical solution of this application embodiment is implemented as follows:

[0008] This application provides a classification method, including:

[0009] The image to be classified and the pre-trained classification model are obtained. The classification model is trained using a target custom loss function, which is used to enhance the influence of features on the classification model.

[0010] Using the classification model, the image to be classified is classified to obtain the classification result of the image to be classified;

[0011] Output the classification result of the image to be classified.

[0012] This application provides a sorting device, the device comprising:

[0013] The acquisition module is used to acquire the image to be classified and the pre-trained classification model. The classification model is trained by a target custom loss function, which is used to enhance the influence of features on the classification model.

[0014] The classification module is used to classify the image to be classified using the classification model, and obtain the classification result of the image to be classified.

[0015] The output module is used to output the classification result of the image to be classified.

[0016] This application embodiment provides a sorting device, the sorting device comprising:

[0017] Processor; and

[0018] Memory for storing computer programs that can run on the processor;

[0019] The computer program implements the above classification method when executed by a processor.

[0020] This application provides a computer-readable storage medium storing computer-executable instructions configured to perform the above-described classification method.

[0021] This application provides a classification method, apparatus, device, and computer-readable storage medium. First, an image to be classified and a pre-trained classification model are obtained. The classification model is trained using a custom loss function, which enhances the influence of features on the classification model. Next, the image to be classified is input into the classification model to perform classification processing, obtaining a classification result. Finally, the classification result is output. By enhancing the influence of features on the classification model, the classification time is shortened, thereby achieving rapid classification of the image and improving the classification accuracy. Attached Figure Description

[0022] In the accompanying drawings (which are not necessarily drawn to scale), similar reference numerals may describe similar parts in different views. The drawings illustrate, by way of example and not limitation, the various embodiments discussed herein.

[0023] Figure 1 This is a schematic diagram illustrating an implementation process of the classification method provided in an embodiment of this application;

[0024] Figure 2A schematic diagram illustrating another implementation flow of the classification method provided in the embodiments of this application;

[0025] Figure 3 This is a schematic diagram illustrating an implementation process of a method for determining a custom loss function provided in an embodiment of this application.

[0026] Figure 4 This is a schematic diagram illustrating an implementation process of a method for obtaining sample image prediction and classification information provided in an embodiment of this application.

[0027] Figure 5 This is a schematic diagram illustrating an implementation process of the method for determining a target region provided in an embodiment of this application;

[0028] Figure 6 A schematic diagram illustrating an implementation flow of a method for obtaining a pre-trained classification model provided in an embodiment of this application;

[0029] Figure 7 A schematic diagram illustrating another implementation of the classification method provided in this application embodiment;

[0030] Figure 8 This is a schematic diagram illustrating another implementation flow of the classification method provided in the embodiments of this application;

[0031] Figure 9 This is a schematic diagram of the composition structure of the sorting device provided in the embodiments of this application;

[0032] Figure 10 This is a schematic diagram of the composition structure of the classification device provided in the embodiments of this application. Detailed Implementation

[0033] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0034] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0035] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0037] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0038] 1) Loss Function: A loss function (also called a cost function) is a function that maps the values ​​of a random event or its related random variables to non-negative real numbers to represent the "risk" or "loss" of that random event. In applications, the loss function is often used as a learning criterion in relation to optimization problems; that is, the model is solved and evaluated by minimizing the loss function. For example, it is used for parameter estimation in statistics and machine learning, for risk management and decision-making in macroeconomics, and for optimal control theory in control theory.

[0039] 2) SVM (Simplified Vector Machine) is a type of generalized linear classifier that performs binary classification on data using supervised learning. Its decision boundary is the hyperplane with the maximum margin calculated from the training samples. SVM uses a hinge loss function to calculate empirical risk and incorporates a regularization term into the solution system to optimize structural risk, making it a classifier with sparsity and robustness. SVM can perform nonlinear classification using kernel methods, and is one of the common kernel learning methods, finding applications in pattern recognition problems such as facial recognition and text classification.

[0040] 3) BP neural network is a multilayer feedforward neural network trained according to the error backpropagation algorithm. It is the most widely used neural network. BP neural network is a multilayer feedforward network trained by error backpropagation (abbreviated as error backpropagation). Its algorithm is called BP algorithm. Its basic idea is gradient descent method. It uses gradient search technology to minimize the mean square error between the actual output value and the expected output value of the network.

[0041] The basic BP algorithm consists of two processes: forward propagation of the signal and backward propagation of the error. That is, the error output is calculated from input to output, while the weights and thresholds are adjusted from output to input. During forward propagation, the input signal acts on the output node through the hidden layer, undergoes a nonlinear transformation, and generates the output signal. If the actual output does not match the expected output, the backward propagation process begins. Backpropagation propagates the output error layer by layer back to the input layer, distributing the error among all units in each layer. The error signals obtained from each layer are used as the basis for adjusting the weights of each unit. By adjusting the connection strength between the input node and the hidden layer nodes, the connection strength between the hidden layer nodes and the output node, and the threshold, the error is reduced along the gradient direction. After repeated learning and training, the network parameters (weights and thresholds) corresponding to the minimum error are determined, and training stops. At this point, the trained neural network can automatically process similar input information to obtain the information with the minimum output error after nonlinear transformation.

[0042] 4) Convolutional Neural Networks (CNNs) are a type of feedforward neural network that includes convolutional computation and has a deep structure. They are one of the representative algorithms of deep learning. CNNs have representation learning capabilities and can classify input information in a translation-invariant manner according to their hierarchical structure; therefore, they are also known as "translation-invariant artificial neural networks".

[0043] Convolutional neural networks are built by mimicking the visual perception mechanism of biological organisms. They can perform supervised and unsupervised learning. The shared parameters of the convolutional kernels in their hidden layers and the sparsity of the interlayer connections enable convolutional neural networks to learn gridded features, such as pixels and audio, with relatively low computational cost, stable results, and no additional feature engineering requirements on the data.

[0044] To address the problems existing in related technologies, this application provides a classification method. This method can be implemented by a computer program, which, when executed, completes each step of the classification method. In some embodiments, the computer program can be executed by a processor in a classification device. Figure 1 This is a schematic diagram illustrating an implementation flow of the classification method provided in an embodiment of this application, such as... Figure 1 As shown, the method includes:

[0045] Step S101: Obtain the image to be classified and the pre-trained classification model.

[0046] Here, the pre-trained classification model is trained using a custom loss function, which enhances the influence of features on the classification model. The classification model can be categorized as a linear or non-linear model; further subcategories include decision tree, selection tree, and evidence-based classification models, among others.

[0047] In this embodiment, a custom loss function can be determined using sample images and preset values, where the preset values ​​include a first value and a second value that are opposites of each other. Thus, by using the first and second values, which are opposites of each other, the distinction between features is increased, thereby further amplifying the influence of features on the classification model, ultimately achieving fast and highly accurate classification of the images to be classified.

[0048] In this embodiment, the image to be classified can be obtained from a dedicated server or a general-purpose server, or from a primary server or a backup server. The image to be classified can be student assignments, employee summary reports, student ID photos, scenic spot photos, etc. Generally, the classification result includes at least two results, but for a specific image to be classified, that image corresponds to one classification result. Therefore, it is necessary to classify the image to be classified using a classification model to determine the type of the image.

[0049] Step S102: Using the classification model, classify the image to be classified to obtain the classification result of the image to be classified.

[0050] Here, the image to be classified is input into the classification model, which will sequentially identify the image region corresponding to the target region, extract features from the target region to obtain feature data, and use the feature data to classify the image to be classified, and finally obtain the classification result of the image to be classified.

[0051] In this embodiment, target regions can be identified using algorithms such as Maximum Stable Extremal Regions (MSER) ​​and edge detection. These target regions can be regions containing text, graphics, or even human portraits. Furthermore, feature data of the target region can be extracted through dimensionality reduction, centering, and whitening. The target region identification algorithm and feature extraction process in this embodiment are merely illustrative; other methods can certainly be used to implement target region identification and feature extraction, and this embodiment does not limit the scope of the application.

[0052] Step S103: Output the classification result of the image to be classified.

[0053] Here, the classification results of the image to be classified can be presented in the form of voice, text, images, etc., and the classification results are finally output by the classification device. For example, the classification results can be output through the microphone of the classification device, and the text or image classification results can also be displayed through the display device of the classification device.

[0054] This application provides a classification method. First, an image to be classified and a pre-trained classification model are obtained. This classification model is trained using a custom loss function, which enhances the influence of features on the classification model. Next, the image to be classified is input into the classification model, which sequentially identifies target regions containing text, extracts features from these target regions to obtain feature data, and uses this feature data to classify the image. Thus, the classification model classifies the image to obtain a classification result. Finally, the classification result is output. By enhancing the influence of features on the classification model, the classification time is shortened, thereby achieving rapid classification of the image and improving its classification accuracy.

[0055] Based on the above embodiments, this application further provides a classification method, such as... Figure 2 As shown, before performing step S101, the method may further perform the following steps S201 to S204:

[0056] Step S201: Obtain a preset classification model, sample images, and label information of the sample images.

[0057] Here, the preset classification model can be a linear classification model or a non-linear classification model; the preset classification model can also be a decision tree classification model, a selection tree classification model, an evidence classification model, etc. Sample images can be student assignments, employee summary reports, student ID photos, tourist attraction photos, etc. The label information of the sample images must at least include the type of the sample image. For example, when the sample image is a student assignment, the type of the sample image can at least include the subject corresponding to the assignment; when the sample image is an employee summary report, the sample image can at least include the department to which the employee belongs.

[0058] Step S202: Determine a custom loss function based on the sample image and preset values.

[0059] The preset values ​​include a first value and a second value that are opposites of each other. For example, in one case, the first value can be 1 and the second value can be -1; in another case, the first value can also be 2 and the second value can be -2. This is merely an illustrative example and does not limit the first and second values. Based on this, by using a positive and a negative preset value, the difference between features can be increased, thereby amplifying the influence of features on the model, simplifying classification calculations, shortening the classification time of the preset classification model, and improving the classification accuracy of the preset classification model. Taking the 0-1 Bernoulli distribution as an example, in this embodiment, the preset value can be used to convert the 0-1 Bernoulli distribution into a -1-1 Bernoulli distribution, thereby increasing the distribution space and amplifying the influence of features on the model.

[0060] When implementing step S202, as follows Figure 3 As shown, this can be achieved through the following steps S2021 to S2023:

[0061] Step S2021: Obtain a regularization term containing unknown coefficients and weight factors, and use the regularization term as the first function.

[0062] Here, during classification, the regularization term helps prevent overfitting in the classification model. By adjusting the regularization term, the best fit of the classification model can be achieved. The weight factors refer to the weight factors of the feature data in the preset classification model, and the unknown coefficients are used to minimize the value of the custom loss function through parameter tuning. In this embodiment, the sum of squares of all weight factors is first obtained, and then the product of this sum of squares and the unknown coefficients is obtained to obtain the regularization term. Finally, the obtained regularization term is used as the first function.

[0063] Step S2022: Set the preset value as the coefficient of the feature data of the sample image, and determine the second function based on the feature data and the coefficient of the feature data.

[0064] Here, taking the sigmoid loss function as an example, for each feature data, the preset value is first used as the coefficient of the feature data in the sample image, and then the sigmoid equation is used to perform operations on the feature data containing the coefficients; then the logarithm is taken; finally, the sum of each feature data is obtained and the opposite number is calculated, thus obtaining the second function.

[0065] Step S2023: Determine the custom loss function based on the first function and the second function.

[0066] In this embodiment, the sum of the first function and the second function can be used as a custom loss function. In this way, the weight factor can be determined by determining the minimum value of the custom loss function, and the classification model can be further determined.

[0067] Through steps S2021 to S2023 above, a regularization term containing unknown coefficients and weight factors is obtained. This regularization term minimizes the value of the custom loss function by using the unknown coefficients, ultimately preventing overfitting in the classification model and achieving a suitable best fit. This regularization term is thus used as the first function. Furthermore, preset values, which are opposites of each other, are used as coefficients for the feature data in the sample images, and a second function is determined based on this. Finally, a custom loss function is obtained based on the first and second functions, thereby increasing the influence of features on the model and simplifying classification calculations.

[0068] Step S203: Input the sample image into the preset classification model to obtain the predicted classification information of the sample image.

[0069] When implementing step S203, as follows Figure 4 As shown, this can be achieved through the following steps S2031 to S2033:

[0070] Step S2031: Determine the target region containing text in the sample image.

[0071] When implementing step S2031, as follows Figure 5 As shown, this can be achieved through the following steps S311 to S315:

[0072] Step S311: Perform grayscale processing on the sample image to obtain a grayscale sample image.

[0073] Here, the obtained sample image is a color image, where each pixel in the color image is represented by different proportions of red, green, and blue (RGB). For each pixel, the R, G, and B values ​​are set to be equal, that is, R = G = B for each pixel, thus achieving grayscale processing of the sample image. Color is then represented as a grayscale color, where the value of R = G = B is called the grayscale value. Therefore, each pixel in a grayscale image only needs one byte to store the grayscale value (also known as the intensity value or brightness value), with a grayscale range of 0 to 255.

[0074] Step S312: Obtain a set of grayscale thresholds that increase within a preset range.

[0075] Here, the preset range does not exceed 0 to 255. The preset range can be set to 0 to 255, and the grayscale threshold can be set to a value within the preset range. Multiple grayscale thresholds can be obtained, for example, 20 or 50 grayscale thresholds can be obtained to form a grayscale threshold set.

[0076] Step S313: Binarize the grayscale sample images sequentially based on each grayscale threshold in ascending order to obtain multiple binarized sample images.

[0077] Here, the grayscale thresholds in the grayscale threshold set are sorted in ascending order. Starting with the first smallest grayscale threshold, the grayscale sample image is binarized. Pixels in the grayscale sample image that are less than or equal to the grayscale threshold are set to 0, and pixels that are greater than the grayscale threshold are set to 255, thus completing one binarization operation. Then, the grayscale sample image is binarized based on the second grayscale threshold, and this process is repeated until the grayscale sample image is binarized based on each grayscale threshold.

[0078] Step S314: Compare the gray values ​​of all binarized sample images with the grayscale sample image to obtain the disconnected regions within a preset area of ​​the sample image, and obtain the rate of change of the disconnected regions.

[0079] Here, the preset area can be 2 square centimeters, 4 square centimeters, etc., and this preset area can be a default value or a custom setting. This application embodiment does not limit this. A non-connected region refers to a region within the preset area where two points are separated by a solid line.

[0080] The gray values ​​of each gray sample image and the gray values ​​of each binarized sample image are analyzed one by one, and the gray value change rate of each disconnected region is obtained.

[0081] Step S315: The region corresponding to the rate of change being less than a preset threshold is determined as the target region.

[0082] Here, the preset threshold can be 20%, 30%, etc. Taking a target area that includes text as an example, since the grayscale threshold of the text area is consistent and the grayscale value is relatively high, the grayscale threshold of the text area will be greater than the grayscale threshold for a period of time as the grayscale threshold increases. Only when the grayscale threshold equals the grayscale threshold corresponding to the text will the grayscale value corresponding to the text area change. That is, the change rate of the text area is the smallest. Therefore, the area with the smallest change rate is determined as the target area that includes the text.

[0083] Through steps S311 to S315 above, the sample image is processed to obtain a grayscale sample image; then, a set of grayscale thresholds that increase within a preset range is obtained, and the grayscale thresholds are sorted in ascending order. Starting from the first smallest grayscale threshold, the grayscale sample images are binarized sequentially to obtain multiple binarized sample images; finally, the grayscale values ​​before and after binarization are analyzed and compared to obtain the grayscale value change rate of non-connected regions, and the regions with a change rate less than a preset threshold are identified as target regions containing text, thereby determining the target regions and preparing for subsequent classification.

[0084] Step S2032: Extract features from the region image corresponding to the target region to obtain feature data of the target region.

[0085] Here, feature extraction methods include histogram of oriented gradients, scale-invariant feature transformation, local binary pattern, etc. Feature extraction can also be achieved through dimensionality reduction, centering, and whitening. Through feature extraction, feature data of the image can be obtained, which can reflect the characteristics of the image.

[0086] Step S2033: Use the feature data to classify the sample image to obtain the predicted classification information of the sample image.

[0087] Here, taking linear regression classification as an example, we first obtain the predicted value corresponding to the feature data through a linear model, and then map the predicted value to the sigmoid function to obtain the corresponding probability, thus completing the conversion from value to probability. Finally, we determine the predicted classification information through the probability, that is, the classification information obtained through linear regression.

[0088] Through steps S2031 to S2033 above, the sample image is first processed into grayscale to obtain a grayscale sample image. When the target region is text in the image, the grayscale sample image is binarized based on each grayscale value in the grayscale threshold set, in ascending order, to obtain a binarized sample image. By analyzing and comparing the grayscale sample image and each binarized sample image, the target region containing text in the sample image is determined. Next, feature extraction is performed on the region image corresponding to the target region to obtain feature data. Finally, the sample image is classified using the feature data to obtain predicted classification information for the sample image. Thus, rapid classification of the sample image is achieved based on the feature data.

[0089] Step S204: Train the preset classification model based on the predicted classification information, the label information, and the custom loss function to obtain the classification model.

[0090] When implementing step S204, as follows Figure 6 As shown, this can be achieved through the following steps S2041 to S2043:

[0091] Step S2041: Obtain the gradient function of the custom loss function.

[0092] Here, the purpose of obtaining the gradient function is to determine the values ​​of the unknown coefficients and weight factors when the custom loss function reaches its minimum. Specifically, the gradient function of the custom loss function is calculated by taking the partial derivative of the custom loss function along the direction of the weight factors.

[0093] Step S2042: Determine the minimum value of the gradient function, and determine the third value of the unknown coefficient and the fourth value of the weight factor based on the minimum value.

[0094] Here, when the type represented by the predicted classification information is consistent with the type represented by the label information, the classification is considered successful, and the gradient value corresponding to the successful classification is retained. Then, the minimum value of the gradient function can be determined by the conjugate gradient descent method. Further, the next step size can be calculated by linear search, and the next gradient change value can be determined. Then, the next gradient value can be determined, and so on, until the minimum gradient value is found. In general, this minimum value is close to 0.

[0095] Based on the minimum value of the gradient function, the values ​​of the unknown coefficients and the weight factors in the gradient function can be further calculated. Here, the unknown coefficients are the third value, and the weight factors are the fourth value.

[0096] Step S2043: Determine the fourth value as the weight factor of the feature data to obtain the classification model.

[0097] Here, the fourth value of the weighting factor is used as the weighting factor for the feature data, which is equivalent to determining the parameter information in the preset classification model, thereby obtaining the classification model. Taking the linear model Z... i =ω i *X i For example, the fourth value corresponds to the parameter ω in the linear model. i , where X i Z represents the feature data of the image to be classified. i This is the predicted value for the image to be classified. This is achieved by assigning the fourth value to ω. i Thus, a classification model is obtained.

[0098] Through steps S2041 to S2043 above, the gradient function of the custom loss function is obtained, the minimum value of the gradient function is determined, and based on the minimum value, the third value of the unknown coefficients and the fourth value of the weight factor are determined. Finally, the fourth value is determined as the weight factor of the feature data to obtain the accurate weight factor, thereby further obtaining the classification model.

[0099] In this embodiment, through steps S201 to S204, a pre-set classification model, sample images, and label information of the sample images are first obtained. The pre-set classification model includes weight factors for feature data with undetermined values. Next, feature data of the sample images is obtained by performing grayscale processing, binarization, and feature extraction on the sample images. The first and second values, which are opposites of each other, are determined as coefficients of the feature data. A regularization term is also obtained. A custom loss function is determined based on the feature data containing coefficients and the regularization term. The sample data is input into the pre-set classification model to obtain predicted classification information for the sample images. If the type represented by the predicted classification information matches the type represented by the label information, the gradient function of the custom loss function is obtained. The minimum value of the gradient function is determined, and a fourth value of the weight factors is further determined. Finally, the fourth value is determined as the weight factor of the feature data, thereby obtaining the classification model. By using a custom loss function, the influence of features on the classification model can be increased, shortening the classification time of the model and achieving higher accuracy in classification results.

[0100] In some embodiments, after performing step S103, the method may further perform the following steps S104 and S105 (not shown in the figures):

[0101] Step S104: Based on the classification results and the preset correspondence table, determine the target storage location corresponding to the image to be classified.

[0102] Here, the preset correspondence table stores the relationship between image type and storage location. Taking student homework as an example, when the homework is "Chinese homework," the corresponding target storage location can be the folder "D-->Homework-->Chinese"; when the homework is "Math homework," the corresponding target storage location can be the folder "D-->Homework-->Math," and so on. The correspondence between other types of homework and their corresponding storage locations follows the same settings. In this way, through the classification results and the preset correspondence table, the images to be classified can be automatically and quickly stored, thereby improving storage speed and ensuring that the images to be classified are stored systematically, facilitating user access to the classified images.

[0103] Step S105: Store the image to be classified in the target storage location.

[0104] In this embodiment of the application, by step S104 and step S105, the target storage location corresponding to the image type represented by the classification result is determined from the preset correspondence table, and then the image to be classified is stored in the target location. In this way, the image to be classified is automatically and quickly stored, thereby improving the storage speed and storing the image to be classified in a regular manner. At the same time, it also facilitates the user's access operation of the image to be classified.

[0105] Based on the above embodiments, this application further provides an image classification method based on logistic regression. With the booming development of cloud computing, more and more traditional businesses are being empowered in the cloud. Cloud storage, as an emerging storage medium, provides convenience for collaborative work and resource sharing in government and education. Taking the education field as an example, teachers can use cloud storage software such as cloud drives to distribute, collect, and grade assignments in the cloud. Especially during the pandemic, teachers posted assignments in the cloud, and students took photos and uploaded them for teachers to grade, a method that was widely used. However, due to the large volume of assignments sent and received, the photos obtained lacked classification and were cluttered. In addition, the default cloud drive sorting order could not meet the requirement that assignments be classified by "subject," which would make grading difficult for teachers.

[0106] Therefore, simple and fast text-image classification technology has become a solution to this difficult problem. Traditional algorithms such as logistic regression, linear regression, and SVM can achieve simple binary classification, while neural network algorithms such as BP neural networks and CNN neural networks can also classify text-images.

[0107] Among relevant classification algorithms, various methods are already quite mature. Take traditional SVM and BP neural networks as examples. The core of SVM lies in finding the optimal splitting surface for binary classification. The optimal splitting surface is the maximum value that minimizes the distance between the support vectors and the hyperplane. It has high accuracy under small sample conditions through fine-tuning, but its drawback is that it only moves the points closest to the splitting hyperplane as far away as possible, making it insensitive to outliers. The core of BP networks is the backpropagation algorithm, which has high computational requirements and a slow convergence of the optimal solution, making it unsuitable for image classification scenarios.

[0108] In summary, the SVM method has three main drawbacks: First, the SVM loss equation is based on hinge loss and does not provide a posterior; second, the optimal splitting hyperplane is insensitive to outliers and has generally low classification accuracy; and third, in multi-class classification, to achieve higher accuracy, it is necessary to "increase the dimension" through the kernel function, which is computationally time-consuming in the case of small samples.

[0109] On the other hand, the BP neural network method has the following three drawbacks: First, the stability requirement for BP network training is very small, so gradient descent makes training very slow; second, the optimal value obtained may be a local optimum rather than a global optimum, which still needs to be processed and improved; third, the learning rate is difficult to set, requiring repeated parameter tuning and large computational load.

[0110] It can be seen that both of these approaches share a common drawback: they cannot obtain a relatively high accuracy result in a short period of time.

[0111] This application provides a classification algorithm based on logistic loss, which can quickly regress a classifier capable of multi-classifying text and images in a small sample size. Although it is also based on logistic loss, it increases the influence of features on the model by transforming the 0-1 Bernoulli distribution to a -1-1 distribution, thereby obtaining a better classification expectation. In addition, based on the idea of ​​conjugate gradient descent, it quickly converges to the optimal solution, thus achieving fast classification for the entire classifier.

[0112] In some embodiments, such as Figure 7 As shown, the classification algorithm for this logical loss can be implemented through the following steps S701 to S704:

[0113] Step S701: Obtain the images to be categorized.

[0114] Here, the images to be categorized can be student assignments, employee year-end summaries, etc.

[0115] Step S702: Input the image to be classified into the trained classifier.

[0116] Here, the classifier can be a linear classifier where the model parameters satisfy a linear relationship, or a nonlinear classifier where the model parameters satisfy a nonlinear relationship.

[0117] Step S703: Obtain the classification result of the image to be classified.

[0118] Taking student homework as an example, the classification results can be one of the following homework types: Chinese homework, math homework, and English homework.

[0119] Step S704: Based on the classification results and the preset relationship table, store the image to be classified to the target storage location.

[0120] Through steps S701 to S704 above, the image to be classified is input into the trained classifier, and the classification result of the image to be classified can be obtained. Based on the classification result, the image to be classified is stored in the corresponding target location, realizing automatic classification and storage, and improving the classification speed of the image to be classified.

[0121] In some embodiments, before step S701, a step of obtaining a trained classifier may also be performed. For example, using feature data as feature vectors, such as... Figure 8 As shown, the trained classifier can be obtained through the following steps S801 to S808:

[0122] Step S801: Obtain sample images.

[0123] Step S802: Convert the sample image to grayscale to obtain a grayscale sample image.

[0124] Step S803: Obtain the text from the grayscale sample image.

[0125] Here, text in an image can be extracted using the MSER method. MSER is a method for obtaining the most stable region when binarizing an image using different grayscale thresholds, thus distinguishing text regions from non-text regions and obtaining the corresponding black and white regions in the thresholded image. The process of obtaining the MSER for an image includes: setting multiple grayscale thresholds, with 256 values ​​ranging from 0 to 255, and binarizing these images. That is, for a grayscale image, the threshold increases sequentially from 0 to 255. The increase in threshold is similar to the rise of water level in a watershed algorithm. The region with the maximum value where the rate of change of black and white areas is less than a certain area threshold during multiple threshold changes is the MSER. If multiple MSER regions are obtained, further processing is required. Regions that are too large or too small, or whose rate of change is too large or too small, are cleaned to obtain stable and effective MSER regions, which are the text regions. Then, a spatial mapping function is used to correct the text and segment the image containing the complete text.

[0126] Step S804: Extract features from the text region.

[0127] Here, step S804 (not shown in the figure) can be achieved through the following steps S8041 to S8044:

[0128] Step S8041: Transform the vector in the two-dimensional space into a one-dimensional space to adapt it to the classifier.

[0129] Step S8042: Subtract the mean of each feature to center the input dataset.

[0130] Step S8043: Use singular value decomposition to center the dataset.

[0131] Obtain the singular values ​​of the left singular matrix, the right singular matrix, and X^TX, respectively. This result can be used for subsequent principal component analysis (PCA).

[0132] Step S8044, Zero-phase Component Analysis (ZCA) whitening data.

[0133] Here, PCA whitening is performed, so X is defined as a dataset matrix with rows as sample columns as features, and V is the covariance matrix X. T The eigenvectors of X, λ is a diagonal matrix, where the diagonal elements are the eigenvectors of X. T The eigenvalues ​​of X. PCA whitening uses X*V to obtain the rotation matrix Xrot, and multiplies each eigenvalue by... To obtain the unit difference. Where X PCAwhiten The definition is shown in formula (1):

[0134]

[0135] ZCA whitening is in X PCAwhiten Based on this, another rotation is performed to make the target normal phase as close as possible to the original input data. X can be obtained through the following formula (2). ZCAwhiten :

[0136] X ZCAwhiten =X PCAwhiten *V T Formula (2);

[0137] This gives us the whitened dataset, and all dimensions of the dataset have been preserved. Next, we add an intercept to each sample.

[0138] Step S805: Determine a custom loss function based on the logistic regressor.

[0139] Since the embodiments of this application are based on logistic regression to construct a classifier, where logistic regression is essentially a linear classifier that distinguishes between two categories, the embodiments of this application aim to calculate a weight that maximizes the estimated probability, which is equivalent to calculating the minimum loss for performing the best output estimate. As defined, binary classification is distinguished based on the sigmoid equation, where the sigmoid equation is shown in formula (3):

[0140]

[0141] Based on this, an arbitrary weight vector w is set, and a linear model Z is established. i =X i +ω i , where X i and ω i The probability can be rewritten from the sigmoid equation in formula (3) as the following formula (4):

[0142]

[0143] Assuming the variables follow a Bernoulli distribution from 0 to 1, the probability equation can be rewritten as the following formula (5):

[0144]

[0145] Considering that each variable is independent, the log-likelihood value is obtained, as shown in formula (6). The loss function equation loss(w) can be written as a negative log-likelihood value:

[0146]

[0147] By using the sigmoid equation z in formula (4) i Replace p(x) in equation (6) i Considering the distribution of y values, a simplified formula (7) can be derived:

[0148]

[0149] From formula (7), we can see that the only difference between the upper and lower formulas is the sign of the sigmoid function within the parentheses. Therefore, in the implementation, the value of y is not distributed from 0 to 1, but rather the values ​​-1 and 1 are assigned to y, which makes the calculation more direct and convenient. In other words, the label (Y = -1) is specified under the condition of the previous label (Y = 0). Therefore, by combining these ideas and adding a rule term to avoid overfitting, the loss function equation can be simplified to formula (8):

[0150]

[0151] To calculate the variable that minimizes the loss function, we need to calculate the gradient. Finding the gradient essentially means finding the partial derivative of a given function. When calculating the gradient, the original equation can be described as formula (9):

[0152]

[0153] In this embodiment, the equation can also be simplified by replacing y(0,1) with y(-1,1), and the new equation can be described as formula (10):

[0154]

[0155] Once the custom loss function is obtained through formula (10), the problem is then transformed into minimizing the loss function, i.e., obtaining a local optimum.

[0156] Step S806: Obtain the gradient function of the custom loss function.

[0157] Assumption This is the gradient value that we ultimately need to minimize. Let... when If the step size α is not equal to the set target value (which can be assumed to be 0), this embodiment of the application can use a linear search to calculate the step size α. k and X k+1 Let it be the following formula (11):

[0158] X k+1 =X k +α k P k Formula (11);

[0159] Obtain X k+1 Next, calculate the next gradient change value in the following formula (12):

[0160]

[0161] In addition, another parameter β is set to modify the search path to ensure that the new gradient direction is perpendicular to the previous one, where β is represented by formula (13):

[0162]

[0163] Then, the next gradient value p k+1 This can be expressed as formula (14):

[0164]

[0165] Step S807: Obtain the minimum value of the gradient function and determine the target weight coefficient.

[0166] This process is repeated from formula (11) to formula (14) until the optimal gradient is calculated, that is, the minimum value of the gradient is calculated. In practical applications, sometimes the new conjugate direction goes too far, so the loss function stops decreasing. Therefore, it is necessary to readjust the direction to be opposite to the gradient direction, so as to restart the conjugate descent process.

[0167] In some embodiments, the step size αk can be calculated by backtracking search.

[0168] Step S808: Set the target weight coefficients to the weight coefficients of the feature vectors in the classifier model to obtain the trained classifier.

[0169] In some embodiments, this logistic loss-based classification algorithm also follows a one-to-one classification approach, where two distinct labels are selected from the entire dataset each time to train the classifier. The total number of classifiers is (number of labels * (number of labels - 1) / 2)). The number of labels can be determined based on the classification requirements. When predicting the label of a new sample, all classifiers are used to predict the new sample, with each classifier voting for a label. The prediction result is the label with the most votes.

[0170] However, when calculating votes, it's possible for an even number of labels to appear. Therefore, there's another matrix to store the sum of probabilities for each label; it's sigmoid(x*ω+b), which calculates the average probability for each label. Finally, the average probability for each label is summed with the number of votes, and the label with the highest value is selected as the prediction.

[0171] Taking student homework classification as an example, teachers can appropriately expand the time dimension of homework collected from various subjects to achieve better classification results. For instance, using a semester's worth of historical homework as samples, and inputting it into the model trainer program corresponding to the algorithm mentioned above, the output model can be directly used later. After receiving a new batch of homework, teachers can directly run the classification algorithm service to output the homework for each subject to the corresponding designated directory. This classification service can be integrated into the existing services of the cloud drive as a microservice to realize classification services and timely insertion. In their spare time, teachers can also use the new homework data to train the existing model to increase the model's stability and accuracy.

[0172] Here, taking feature data as feature vectors as an example, the specific encoding implementation of training the model can be carried out in the following four steps:

[0173] Step 1: Import the sample work, convert it to grayscale, and then call the MSER library function to segment the text image;

[0174] Step 2: After standardizing the image data, call Singular Value Decomposition (SVD) to obtain the feature vector V, encode it with formula (2) to obtain the PCA whitening value, multiply it by the transpose of V to obtain the ZCA whitening data, and the data preprocessing is completed.

[0175] Step 3: Encode the loss function formula according to the user-defined loss function formula;

[0176] Step 4: Based on the custom gradient descent formula, set the learning rate and step size, calculate and iterate to obtain the optimal value of the loss function, and output the corresponding model file.

[0177] Write another classification program, based on the obtained model file, and use the label weight method in formula (5) to classify the input images to be classified and output them to the corresponding directory.

[0178] Through steps S801 to S808, grayscale sample images are obtained by converting the sample data to grayscale, and then text is extracted from these images, with features extracted from the text regions. Next, a custom loss function is determined based on a logistic regressor, and its gradient function is obtained. The minimum value of the gradient function is determined, and the target weight coefficients are further determined. Finally, the target weight coefficients are set as the weight coefficients of the feature vectors in the classifier model, thus obtaining a trained classifier. This allows for rapid regression of a classifier capable of multi-classifying text and images in a small sample size. Although based on logistic loss, the method transforms the 0-1 Bernoulli distribution to a -1-1 distribution, increasing the influence of features on the model and accelerating classification to achieve better classification expectations. Furthermore, based on the idea of ​​conjugate gradient descent, the optimal solution is quickly converged, enabling rapid insertion of the entire classifier.

[0179] Based on the foregoing embodiments, this application provides a classification device. The modules and units included in the device can be implemented by a processor in a computer device; of course, they can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0180] This application embodiment further provides a sorting device, Figure 9 This is a schematic diagram of the composition structure of the classification device provided in the embodiments of this application, such as... Figure 9 As shown, the sorting device 900 includes:

[0181] The acquisition module 901 is used to acquire the image to be classified and the pre-trained classification model. The classification model is trained by a target custom loss function, which is used to enhance the influence of features on the classification model.

[0182] The classification module 902 is used to classify the image to be classified using the classification model to obtain the classification result of the image to be classified.

[0183] The output module 903 is used to output the classification result of the image to be classified.

[0184] In some embodiments, the acquisition module 901 is further configured to acquire a preset classification model, sample images, and label information of the sample images; the classification device 900 further includes:

[0185] The first determining module is used to determine a custom loss function based on the sample image and preset values, wherein the preset values ​​include a first value and a second value that are opposites of each other;

[0186] The input module is used to input the sample image into the preset classification model to obtain the predicted classification information of the sample image;

[0187] The training module is used to train the preset classification model based on the predicted classification information, the label information, and the custom loss function to obtain the classification model.

[0188] In some embodiments, the determining module includes:

[0189] The first acquisition unit is used to acquire a regularization term containing unknown coefficients and weight factors, and to use the regularization term as a first function;

[0190] The setting unit is used to set the preset value as the coefficient of the feature data of the sample image, and to determine the second function based on the feature data and the coefficient of the feature data;

[0191] The first determining unit is used to determine the custom loss function based on the first function and the second function.

[0192] In some embodiments, the input module includes:

[0193] The second determining unit is used to determine the target region containing text in the sample image;

[0194] An extraction unit is used to extract features from the region image corresponding to the target region to obtain feature data of the target region;

[0195] A classification unit is used to classify the sample image using the feature data to obtain the predicted classification information of the sample image.

[0196] In some embodiments, the second determining unit includes:

[0197] The grayscale subunit is used to perform grayscale processing on the sample image to obtain a grayscale sample image.

[0198] Get sub-units, used to obtain a set of grayscale thresholds that increase within a preset range;

[0199] The binarization subunit is used to binarize the grayscale sample image sequentially based on each grayscale threshold in ascending order to obtain multiple binarized sample images;

[0200] The comparison subunit is used to compare the gray values ​​of all binarized sample images with the grayscale sample image, obtain the non-connected regions within a preset area of ​​the sample image, and obtain the rate of change of the non-connected regions.

[0201] A sub-unit is defined to identify the region corresponding to the rate of change being less than a preset threshold as the target region.

[0202] In some embodiments, the training module includes:

[0203] The second acquisition unit is used to acquire the gradient function of the custom loss function;

[0204] The third determining unit is used to determine the minimum value of the gradient function, and to determine the third value of the unknown coefficient and the fourth value of the weight factor based on the minimum value;

[0205] The fourth determining unit is used to determine the fourth value as a weighting factor of the feature data to obtain the classification model.

[0206] In some embodiments, the sorting device 900 further includes:

[0207] The second determining module is used to determine the target storage location corresponding to the image to be classified based on the classification result and a preset correspondence table, wherein the preset correspondence table stores the correspondence between image type and storage location;

[0208] A storage module is used to store the image to be classified in the target storage location.

[0209] It should be noted that the description of the classification device in this application is similar to the description of the method embodiment described above, and has similar beneficial effects. For technical details not disclosed in this device embodiment, please refer to the description of the method embodiment in this application for understanding.

[0210] It should be noted that, in the embodiments of this application, if the above-mentioned classification method is implemented in the form of software functional modules and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0211] Accordingly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the classification method provided in the above embodiments.

[0212] This application provides a sorting device. Figure 10 This is a schematic diagram of the composition structure of the classification device provided in the embodiments of this application, such as... Figure 10 As shown, the classification device 1000 includes: a processor 1001, at least one communication bus 1002, a user interface 1003, at least one external communication interface 1004, and a memory 1005. The communication bus 1002 is configured to enable communication between these components. The user interface 1003 may include a display screen, and the external communication interface 1004 may include standard wired and wireless interfaces. The processor 1001 is configured to execute a program of a classification method stored in the memory to implement the classification method provided in the above embodiment.

[0213] The descriptions of the classification devices and storage media embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the classification device and storage media embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0214] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0215] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0216] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0217] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0218] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0219] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0220] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an AC to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0221] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included 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 classification method, characterized in that, The method includes: The image to be classified and a pre-trained classification model are obtained, and the classification model is trained in the following manner: Obtain a preset classification model, sample images, and label information of the sample images; Obtain the regularization term containing unknown coefficients and weight factors, and use the regularization term as the first function; The preset value is set as the coefficient of the feature data of the sample image, and the second function is determined based on the feature data and the coefficient of the feature data; A custom loss function is determined based on the first function and the second function. The preset value includes a first value and a second value that are opposites of each other. The custom loss function is used to enhance the influence of features on the classification model. The sample image is input into the preset classification model to obtain the predicted classification information of the sample image; The preset classification model is trained based on the predicted classification information, the label information, and the custom loss function to obtain the classification model. The gradient function of the custom loss function is obtained when the type represented by the predicted classification information is consistent with the type represented by the label information, and the minimum value of the gradient function is obtained by performing conjugate gradient descent. Using the classification model, the image to be classified is classified to obtain the classification result of the image to be classified; Output the classification result of the image to be classified.

2. The method according to claim 1, characterized in that, The step of inputting the sample image into the preset classification model to obtain the predicted classification information of the sample image includes: Identify the target region containing text in the sample image; Feature extraction is performed on the region image corresponding to the target region to obtain the feature data of the target region; The sample image is classified using the feature data to obtain the predicted classification information of the sample image.

3. The method according to claim 2, characterized in that, Determining the target region containing text in the sample image includes: The sample image is processed to obtain a grayscale sample image; Obtain a set of grayscale thresholds that increase within a preset range; In ascending order, the grayscale sample images are binarized sequentially based on each grayscale threshold to obtain multiple binarized sample images; By comparing the gray values ​​of all binarized sample images with those of the grayscale sample image, the disconnected regions within a preset area of ​​the sample image are obtained, and the rate of change of the disconnected regions is acquired. The region corresponding to the rate of change being less than a preset threshold is determined as the target region.

4. The method according to claim 1, characterized in that, The step of training the preset classification model based on the predicted classification information, the label information, and the custom loss function to obtain the classification model includes: Obtain the gradient function of the custom loss function; Determine the minimum value of the gradient function, and based on the minimum value, determine the third value of the unknown coefficient and the fourth value of the weight factor; The fourth value is determined as the weight factor of the feature data to obtain the classification model.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Based on the classification results and the preset correspondence table, the target storage location corresponding to the image to be classified is determined, wherein the preset correspondence table stores the correspondence between image type and storage location; The image to be classified is stored in the target storage location.

6. A sorting device, characterized in that, The device includes: An acquisition module is used to acquire the image to be classified and a pre-trained classification model. The classification model is trained as follows: acquiring a preset classification model, sample images, and label information of the sample images; acquiring a regularization term containing unknown coefficients and weight factors, and using the regularization term as a first function; setting preset values ​​as coefficients of the feature data of the sample images, and determining a second function based on the feature data and the coefficients of the feature data; determining a custom loss function based on the first function and the second function, wherein the preset values ​​include a first value and a second value that are opposites of each other, and the custom loss function is used to enhance the influence of features on the classification model; inputting the sample images into the preset classification model to obtain the predicted classification information of the sample images; training the preset classification model based on the predicted classification information, the label information, and the custom loss function to obtain the classification model, wherein the gradient function of the custom loss function is obtained when the type represented by the predicted classification information is consistent with the type represented by the label information, and the minimum value of the gradient function is obtained by performing conjugate gradient descent. The classification module is used to classify the image to be classified using the classification model to obtain the classification result of the image to be classified. The output module is used to output the classification result of the image to be classified.

7. A sorting device, characterized in that, The device includes: Processor; and Memory for storing computer programs that can run on the processor; When the computer program is executed by a processor, it implements the classification method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions configured to perform the classification method according to any one of claims 1 to 5.