Horse image recognition method based on class center SVM and near-end SVM
By combining the method of class center SVM and proximal SVM to recognize horse images, the problem of low recognition accuracy in the existing technology is solved, higher recognition accuracy and generalization ability are achieved, and it is suitable for the field of horse image recognition.
Patent Information
- Application Number
- CN202410754934.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-03
AI Technical Summary
Due to weak generalization ability and low accuracy, existing horse image recognition technology is difficult to effectively identify the diversity of horses, resulting in low recognition accuracy.
Using a combination method based on class center SVM and proximal SVM, the most relevant samples of each category are obtained through class center SVM, and the proximal SVM is used for kernel function fitting to improve the separation between classes and form a CCPSVM model to achieve more accuracy Horse image recognition.
It improves the accuracy and recognition accuracy of horse image recognition, overcomes the shortcomings of traditional SVM, has higher recognition accuracy and better generalization ability, and is suitable for large sample problems.
Smart Images

Figure CN118587740A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of horse image recognition, and in particular to a horse image recognition method based on class center SVM and proximal SVM. Background Art
[0002] Horses are valuable and should be kept safely on a farm or in a riding club. Therefore, image recognition of horses is very important in many areas, such as farm management, riding clubs, and robot detection. In terms of farm keeping, using algorithms to identify horses on a farm can provide valuable information about each horse, helping farmers to better manage the herd. For example, algorithms can be developed to monitor the condition of each horse, detect diseases, etc., and track the movement and behavior of animals. This information is very important for managing the herd. In equestrian clubs, algorithms can be used to automatically catalog and organize large amounts of information and images related to horses. This can save time and energy and provide more consistent and accurate results than manual work. In addition, algorithms can help with tasks such as identifying specific breeds and individual horses, and can be used to manage the club's horse inventory, track the performance of individual horses, and monitor the health and welfare of club horses. Using algorithms to identify horses allows robots to respond appropriately to the presence of horses. For example, using algorithms to distinguish horses from other objects, robots can move around horses safely. This improves the efficiency and safety of robots and prevents them from harming horses or the environment.
[0003] Patent application CN101030259A discloses a method and device for providing an SVM classifier and using the SVM classifier to identify vehicle images. The method classifies training samples according to multiple vehicle identification features, trains the SVM classifiers respectively, obtains each SVM classifier corresponding to the multiple features, extracts the features of the image to be identified when performing vehicle image recognition, assigns the image to be identified to the SVM classifier corresponding to the feature, and identifies the vehicle image. The training time of the classifier can be shortened, and the recognition rate and real-time performance of vehicle image recognition can be improved. Patent application CN109657708A discloses a workpiece identification device and method based on image recognition-SVM learning model, including: an image acquisition unit, a recognition unit and a robot, the image acquisition unit is used to obtain the image of the workpiece to be detected, and is connected to the recognition unit data; the recognition unit is used to extract the workpiece feature vector in the image, and then classify the workpiece to be detected using the SVM learning model classifier, output the classification result, and is connected to the robot control; the robot is used to classify the workpiece to be detected according to the classification result. The device can identify and grasp the predetermined target in a relatively complex environment, and is not affected by translation, scale and rotation geometric changes. The above patent application uses standard SVM for image recognition, and the recognition accuracy is limited.
[0004] The value of horses makes horse image recognition widely used in fields such as agriculture and sports events. In these scenarios, it is very important to identify horses. Despite the importance of horse image recognition, the current horse image recognition technology is limited by weak generalization ability and low accuracy due to the variety of horses' appearance and characteristics. Summary of the invention
[0005] The purpose of the present invention is to provide a horse image recognition method based on class center SVM and proximal SVM.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A horse image recognition method based on class center SVM and proximal SVM includes the following steps:
[0008] Acquire horse image data, perform preprocessing, input into a pre-trained CCPSVM model, and output a recognition result, wherein the CCPSVM model includes a class-centered SVM classifier and a proximal SVM classifier;
[0009] The CCPSVM model training process includes:
[0010] Obtain horse image dataset and perform preprocessing;
[0011] Based on the preprocessed horse image dataset, the class center of each category is calculated, and the class center SVM classifier is trained using a linear kernel to obtain the most relevant horse image data samples in each category, wherein each class center is assigned a label of the corresponding category;
[0012] The most relevant horse image data samples in each category are used as training samples for the proximal SVM classifier and a polynomial kernel is selected to train the proximal SVM classifier to complete the CCPSVM model training process.
[0013] Furthermore, the horse image dataset includes RGB horse images and corresponding black-and-white human-ground images, and the preprocessing steps in the training process include:
[0014] Segmenting the RGB horse image into sub-images, restoring the segmented sub-images to black and white outline images, and determining whether the sub-images contain horses;
[0015] All black and white outline images and corresponding black and white person-ground images are filled to a consistent size.
[0016] Furthermore, the RGB horse image is segmented into sub-images using a SLIC image segmentation method.
[0017] Furthermore, the CCPSVM model realizes classification and recognition of horse image data through a decision boundary, and the decision boundary is:
[0018] w T (xc)+b=0
[0019] In the formula, w is the weight vector, c is the adjusted class center obtained by the class center SVM, and b is the bias term. Further, the evaluation judgment function of the output recognition result is:
[0020] f(x new )=sign(w T (x new -c)+b
[0021] In the formula, f(x new ) is x new The evaluation function, x new is the input horse image data, f(x new ) is positive, then x new belongs to the positive class, f(x new ) is a negative value, then x new Belongs to the negative class, w is the weight vector, c is the adjusted class center obtained by the class center SVM, and b is the bias term.
[0022] Furthermore, the class center based SVM classifier maximizes the distance between two class centers by seeking a hyperplane with a maximized margin, thereby obtaining the most relevant horse image data samples in each class, wherein the expression of the margin is:
[0023] margin=min[d(x),y=-1]+min[d(x),y=+1]
[0024]
[0025] Where margin is the margin, d(x) is the distance from point x to the hyperplane, y is the label, w is the weight vector, and b is the bias term.
[0026] Furthermore, the objective function used in the training process of the class-centered SVM classifier is:
[0027]
[0028] sty i (w·x i +b)+ξ i >0,ξ i ≥0,i=1,...,n
[0029] Where w is the weight vector, ξ iis a slack variable used to allow some misclassification, C is a penalty parameter, and y i ∈{-1,+1} is the corresponding class label, b is the bias term, x i is the i-th input data vector, and n is the number of data vectors.
[0030] Furthermore, the objective function used in the training process of the proximal SVM classifier is:
[0031]
[0032] stD(K(A,A′)Du-eγ)+γ=e
[0033] Where w is the weight vector, u is the dual multiplier, γ is the regularization parameter, C is the penalty parameter, R is the p-dimensional real space, n is the n points in R, D is the n×n matrix, K(A,A′) is the nonlinear kernel, A is the n×p matrix, and e is the unit vector.
[0034] Furthermore, the optimization objective function of the CCPSVM model is:
[0035]
[0036] In the formula, ||w|| 2 is the L2 criterion of the weight vector w, C is the penalty parameter used to control the trade-off between maximizing the margin and minimizing the classification error, λ is the regularization parameter used to control the smoothness of the adjusted class center, c is the adjusted class center obtained by the class center SVM, is the initial guess of the cluster center, x i is the i-th input data vector, y i is the corresponding binary label and b is the bias term.
[0037] Furthermore, the KKT condition is used to solve the optimal values of w, b and c in the optimization objective function of the CCPSVM model, and the specific steps include:
[0038] The Lagrangian function and KKT condition are obtained based on the optimization objective function of the CCPSVM model, which are:
[0039] Lagrangian function function:
[0040]
[0041] KKT Conditions:
[0042]
[0043] Complementary slackness of the KKT dual problem:
[0044]
[0045] The partial derivatives of the Lagrangian function with respect to w, b and c are set to zero, and the optimal values of w, b and c are solved:
[0046] Fixedness:
[0047]
[0048] Therefore, we have:
[0049]
[0050] Complementary slack:
[0051] α i [y i (w T (x i -c)+b)-1+x i ]=0
[0052] β i x i =0
[0053]
[0054] Where L(w,b,c,α,β,γ) is the Lagrangian function, w is the weight vector, C is the penalty parameter, b is the bias term, c is the adjusted class center obtained by the class center SVM, and α is i , β i and γ i is the Lagrange multiplier of the inequality constraint, x i is the slack variable for the ith data point, y i is the corresponding binary label, |w|| 2 is the L2 criterion of the weight vector, λ is the regularization parameter, is an initial guess for the class center.
[0055] Compared with the prior art, the present invention has the following beneficial effects:
[0056] (1) The class center-based SVM classifier in the present invention can help identify the most relevant samples in each class for horse image data, thereby better separating the classes. The proximal SVM classifier is then used to further improve the class separation of each class of horse images by fitting the kernel function. Compared with the traditional SVM, the present invention overcomes the shortcomings of the traditional SVM and has higher recognition accuracy.
[0057] (2) The class center-based SVM classifier of the present invention uses the class center vector to construct the objective function, which is a quadratic programming problem and can improve the interval maximization for horse images, resulting in clearer class separation and more accurate classification results.
[0058] (3) The proximal SVM classifier of the present invention uses an approximate gradient method to solve the optimization problem. Compared with the SVM using a convex quadratic programming algorithm for solving the problem, the proximal SVM classifier improves the speed, reduces the calculation time, and has excellent generalization ability when classifying large sample problems, and can achieve the best horse image classification effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0060] Figure 2 Schematic diagram of the separation hyperplane of the standard SVM of the present invention;
[0061] Figure 3 A sample of horse images in the data set of the present invention;
[0062] Figure 4 It is a scatter plot of the original data characteristics of the present invention;
[0063] Figure 5 This is a graph showing the accuracy comparison results of different SVM models of the present invention;
[0064] Figure 6 This is a comparison result diagram of evaluation indicators of different SVM models of the present invention. DETAILED DESCRIPTION
[0065] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0066] This embodiment provides a method for horse image recognition based on class-center SVM and proximal SVM, the goal of which is to improve the performance of the CCPSVM (Class-Center and Proximal Support Vector Machin, based on class-center SVM and proximal SVM) model by using an additional class-center SVM step on the output of radial proximal SVM (Support Vector Machine). This model combines the advantages of the proximal SVM classifier and the class-center SVM classifier to improve the accuracy of horse image recognition. Figure 1 As shown, the method includes three steps:
[0067] S1, the preprocessing step, mainly creates a dataset after segmenting the horse images according to the SLIC image segmentation algorithm.
[0068] S2, the modeling step, is to combine the class-centric SVM classifier and the proximal SVM classifier using a two-stage approach to form the CCPSVM model, that is, firstly, the class-centric SVM classifier is used to select the most relevant samples, and then the proximal SVM classifier is applied on the selected samples.
[0069] S3, model training step, obtain the training set data, put it into the model, and then run the model to compare the loss value and actual value based on the standard SVM model and this method model (CCPSVM). Then update the network parameters based on the comparison results. After the training is completed, the network parameters are fixed and the test set is used for prediction to evaluate the accuracy of the model.
[0070] The above steps are as follows:
[0071] S1. Preprocessing step.
[0072] This step of identifying the target involves processing and analyzing the images to determine if they contain parts of horses. The input images will be received in the form of folders containing RGB (color) images and corresponding people-ground (black and white) images. The goal is to cut the color horse pictures into smaller sub-pictures, restore the cut pictures to black and white outlines, and determine if they contain horses. The preprocessing process also includes padding each picture to a consistent size and splitting the dataset into training and test sets.
[0073] S2. Modeling steps.
[0074] This step is the main invention point, and a new algorithm model - CCPSVM (based on class-centric SVM classifier and proximal SVM classifier) is established. This part is the background knowledge about support vector machine, proximal support vector machine classifier and class-centric support vector machine modeling. It describes the core innovative class-centric proximal support vector machine classifier algorithm of this article in more detail, including parameter optimization and related algorithms, and analyzes the advantages and disadvantages of these methods as well as improvement methods.
[0075] The following is an introduction to the standard SVM method and the proximal support vector machine based on the class center of this algorithm:
[0076] 1. Standard Support Vector Machine
[0077] The standard SVM method can be used for two-class classification. Therefore, SVM is mainly designed to solve quadratic programming problems, that is, to solve quadratic equations. After continuous improvement, the model kernel function, model parameters and model training algorithm have been studied and further expanded. Classification is achieved by maximizing the interval between samples. Figure 2 As shown, the solid line is the decision boundary, ω T x+b=0 is the separating hyperplane, and the dotted line is the interval boundary, which falls on ω T x+b=1 and ω T The points above x+b=-1 represent support vectors.
[0078] The hyperplane can be represented by the function f(x) = ω T ·x+b represents, where the parameter w is the normal vector and b is the intercept. The support vector machine is looking for the maximum interval between the two boundary endpoints or extreme dividing lines, so that when there is a slight error in the boundary position, it can better classify points of different categories, thereby reducing the chance of misclassification. When the function is equal to 0, it means that x is a point on the hyperplane; when the function is greater than 0, the data point corresponding to x is y=1; when the function is less than 0, the data point corresponding to x is y=-1. The value of y can be any value, and it is marked as -1 and 1 to describe the positive and negative examples more clearly and intuitively. At the same time, this division also allows y*f(x)>0 to hold. When the negative sample is represented by 0, y*f(x) is 0.
[0079] Any hyperplane is described by the following formula:
[0080] ω T x+b=0
[0081] After expanding the point (x, y) in the two-dimensional space to the n-dimensional space, the point x=(x1,x2,...,x n ) to the straight line ω T The distance of x+b=0 is and
[0082] According to the concept of support vector, we can know that the distance from the support vector to the hyperplane is d.
[0083]
[0084] Since ||w||d is a positive number, it is set to 1 for the convenience of derivation and without affecting the optimization of the function. Combining the two equations, we can get y(w T x+b)≥1, the distance from each support vector to the hyperplane is:
[0085]
[0086] Because y(ω Tx+b)>1>0, we can get y(ω T x+b)=|ω T ·x+b|, so the above distance formula can be changed to:
[0087]
[0088] Without affecting the objective function, maximize this distance and multiply the formula by 2 to get:
[0089]
[0090] Since the support vector y(ω T ·x+b)=1, the distance formula can be changed to: And it can be converted into min2||w||. In order to find the root of ||w|| after calculation, the previous formula is changed to: min without affecting the objective function of the optimization problem, and finally the optimization problem is obtained.
[0091] The method of solving the problem by support vector machine generally has the following six steps: selecting decision boundary, listing objective function, optimizing objective function, solving optimization target, solving soft interval problem and changing kernel function. Support vector machine algorithms can be divided into three categories: standard algorithm, improved algorithm and extended algorithm. Standard algorithms include: linear SVM, nonlinear SVM and numerical solution; improved algorithms include: tilted data improvement algorithm, probabilistic SVM, multi-classification SVM, least squares SVM, structured SVM and multi-core SVM; extended algorithms include: support vector regression, support vector clustering and semi-supervised SVM. The design of large-scale training samples will consume a lot of machine memory and computing time. The improved method proposed at present has a significant improvement effect on this problem. Since the classic support vector machine algorithm only gives an algorithm for two categories of classification, in order to solve the classification accuracy of multi-classification problems, researchers have combined the advantages of other algorithms to form a combined classifier with complementary advantages for multi-classification problems.
[0092] With the deepening of support vector machine research, its ideas have been widely used in the fields of pattern recognition and regression estimation, including: pattern recognition applications such as face recognition, speech recognition, character recognition and image recognition. Of course, there are also a large number of applications on regression estimation: estimation of nonlinear systems, predictive modeling and control, etc.
[0093] 2. Support vector machine classifier based on class center and proximal support vector machine classifier (method of this embodiment)
[0094] Compared with other learning methods, SVM has many advantages and is widely applicable and practical. However, it is mainly used for small sample problems. For large-scale data, it is slow, time-consuming, and has limited computational capacity. The main difference between the proximal support vector machine classifier and SVM is that the proximal support vector machine classifier uses the proximal gradient method to solve the optimization problem, while the SVM uses the quadratic programming algorithm.
[0095] The proximal support vector machine (PSVM) classifier is based on optimization theory and no longer needs to solve the original convex quadratic programming problem. It only needs to solve the linear equations that partition the samples and transform it into a conventional least squares problem. Compared with the traditional SVM, PSVM improves the speed, reduces the calculation time, is simpler and faster when solving the classifier, and inherits excellent generalization ability when classifying large sample problems. Then, find the optimal hyperplane that can minimize the clustering error of the two types of samples, and separate the two parallel planes with the maximum distance of different sample points to achieve the best classification effect.
[0096] The Proximal Support Vector Machine (PSVM) classifier method is an extension of the standard Support Vector Machine (SVM) method and was developed to accommodate situations where the data points cannot be linearly separated and the decision hyperplanes for the two classes do not need to be parallel to each other. The PSVM method was developed to accommodate such situations. When using the PSVM method, the bias term is changed to a vector, called a unique vector, and the weight vector is changed to a matrix, called a weight matrix. Both of these changes are made to replace the weight vector.
[0097] The main difference of PSVM is that the boundary plane is transformed into a "proximal" plane and pushed as far as possible. In order to extend to nonlinear classifiers, Fung and Mangasarian et al. modified the constraints of the above optimization problem as follows:
[0098]
[0099] stD(K(A,A′)Du-eγ)+γ=e
[0100] Where K(A, A') is a kernel function, in particular an n×n matrix. This embodiment replaces the original variable w with an equivalent w=A'Du. For the linear case, K(A, A')=AA'.
[0101] These two parts together form what are called unique vectors and weight matrices, respectively. The unique vectors and weight matrices are the main tools used to define a set of decision hyperplanes in the input space, one for each class. This is achieved by using unique vectors. The decision hyperplanes for two classes do not have to be parallel to each other; instead, they may cross each other. The standard SVM method is compared with the PSVM method in terms of accuracy. The PSVM method has been used to analyze data from various real-world datasets, and experimental results show that the PSVM method outperforms the standard SVM method. The proximal support vector machine (PSVM) classifier method can be extended to the case of k-class classification (k>2); in this case, the method will be called a multi-class proximal support vector machine classifier. In the MPSVM method, the unique vectors are replaced by a matrix called a class center matrix and the weight vectors are replaced by a three-dimensional array called a weight array. Both matrices are called weight arrays. These two matrices are collectively called class center matrices. The class center matrix and the weight array are the main definition tools used to define a set of decision hyperplanes in the input space, one for each class. This is achieved by using the class center matrix. In some cases, it is acceptable for the decision hyperplanes of different classes to overlap with each other.
[0102] The Proximal SVM classifier, like the SVM, is used in machine learning to classify data into different categories. Since the Proximal Gradient Method is more computationally efficient than the traditional quadratic programming algorithm used by the SVM, it is particularly useful for large, sparse datasets.
[0103] The Class Centered Support Vector Machine (CSVM) classifier is a type of SVM that defines the decision boundary between two classes based on the average value or "center" of the points in each class. In this type of SVM, instead of using a single point as the support vector, the decision boundary is defined based on the average value of the points in each class, which are called "class centers." The class centers are used as support vectors to construct the decision boundary.
[0104] The CSVM method is a modification of the standard Support Vector Machine (SVM) method proposed by Vapnik et al. The CSVM method places great emphasis on the construction of the objective function during the development of the objective function. This is achieved by utilizing the two class center vectors, which are the average vectors of the two classes. Both the CSVM method and the SVM method (in standard form) have an objective function, but the objective function of the CSVM method is different from that of the SVM method. The objective function of the standard SVM method is a linear programming problem, while the objective function of the CSVM method is a quadratic programming problem. Here is a comparison of the objective functions of the two methods. In contrast, the objective function of the standard SVM method is constructed using unique vectors. This is because the objective function of the CSVM method uses class center vectors. The SVM method was further developed into the CSVM. The SVM method was compared with the CSVM method in terms of accuracy, and the comparison results showed that the CSVM method was more accurate than the SVM method. The CSVM method was developed to analyze data from various real-world datasets.
[0105] Given a training data set {(x1,y1),(x2,y2),...,(,)}, where x i is the i-th input vector, y i ∈{-1,+1} are the corresponding class labels, and the class-centered SVM classifier tries to find the hyperplane with the maximum margin that separates the two classes.
[0106] The definition of the hyperplane is as follows: w·xb=0, where w is the weight vector and b is the bias term. The distance between point x and the hyperplane can be calculated as:
[0107]
[0108] where ||w|| is the Euclidean value of the weight vector w. The class-centered SVM classifier seeks the hyperplane that maximizes the margin, where the margin is defined as the distance between the hyperplane and the nearest point to each class, which is:
[0109] margin=min[d(x),y=-1]+min[d(x),y=+1]
[0110] Where d(x) is the distance from point x to the hyperplane. The class center SVM classifier can be expressed as an optimization problem:
[0111]
[0112] sty i (w·x i +b)+ξ i >0,ξ i ≥0,i=1,...,n
[0113] Where C is a hyperparameter that controls the trade-off between maximizing the margin and minimizing the classification error; ξ i is a slack variable used to allow for some misclassification. The solution to the optimization problem gives the weight vector w and the bias term b, and by evaluating the sign of wxb, new data points can be classified.
[0114] Combining the class-centric SVM classifier with the proximal SVM classifier can be achieved by adding a regularization penalty term to the class-centric SVM classifier objective function, which is similar to the proximal SVM classifier. In this algorithm, the data labels are binary, +1 represents the positive class and -1 represents the negative class. The decision boundary is given by the formula:
[0115] w T (xc)+b=0
[0116] Where w is the weight vector, b is the bias term, x is the input data vector, and c is the adjusted class center. new The predicted label for can be obtained by evaluating the sign of the discriminant function:
[0117] f(x new )=sign(w T (x new -c)+b
[0118] If f(x new ) is positive, then x new Belongs to the positive class; if f(x new ) is a negative value, then x new Belongs to the negative value class. The optimization objective function of the combination algorithm is:
[0119]
[0120] Among them, ||w|| 2 is the L2 criterion of the weight vector, C is the penalty parameter used to control the trade-off between maximizing the margin and minimizing the classification error, λ is the regularization parameter used to control the smoothness of the adjusted class center, c is the adjusted class center obtained by the class center SVM, is the initial guess of the cluster center, x i is the i-th input data vector, y i are the corresponding binary labels.
[0121] The first term in the optimization function aims to maximize the difference between the two classes, the second term penalizes deviations from the decision boundary, and the third term regularizes the adjusted class center to be close to the initial guess of the class center.
[0122] In order to solve the optimal values of the original variables w, b and c using the Karush-Kuhn-Tucker (KKT) condition, this embodiment needs to derive the Lagrangian function and KKT equation of the optimization problem:
[0123]
[0124] Among them, α i , β i and γ i is the Lagrange multiplier of the inequality constraint, x i is the slack variable for the ith data point.
[0125] The KKT condition for the optimization problem is:
[0126]
[0127] Complementary slackness of the KKT dual problem:
[0128]
[0129] In order to solve w, b and c, this embodiment can set the partial derivatives of Lagrangian with respect to each variable to zero, and then solve for the optimal value:
[0130] Fixedness:
[0131]
[0132] Therefore, we have:
[0133]
[0134] Complementary slack:
[0135] α i [y i (w T (x i -c)+b)-1+x i ]=0
[0136] β i x i =0
[0137]
[0138] After using the KKT equation to find the optimal values of w, b, and c, we can use the decision function to predict the label of the new data point:
[0139] f(x)=w T (xc)+b
[0140] If f(x)>0, the predicted level is +1, otherwise the predicted level is -1.
[0141] The method of this embodiment uses a radial basis function with a regularization parameter to check the input training data to train a class center SVM classifier. The decision function of the training model is calculated on the input training data and reshaped into a column vector. The class center SVM classifier attempts to find a hyperplane separating two classes in the feature space, and the decision boundary is located at the center of the two class centers. The proximal SVM classifier takes the output of the class center SVM classifier as input and tries to find a sparse weight vector to separate the two classes in the input space. The decision function of the proximal SVM classifier is a linear combination of the input features and the learned weight vector. The specific steps are: first, a class-centered SVM is trained on the training data, and then the training data is used to extract features that help distinguish different categories, and the class center of each class is calculated using the average value of the feature vector of the class sample. The SVM classifier is trained using a linear check of the class center, where each class center is assigned a label of the corresponding class. Then a class-centered SVM is used to select the most relevant samples. The class center SVM is used to predict the category of each sample in the training set and the test set. For each category, the k samples with the highest predicted probability belonging to that category are selected. These samples are the most representative samples of the class. Then train the proximal SVM classifier on the selected samples. Use the selected samples as training data for the proximal SVM classifier. Train the SVM classifier with a polynomial kernel on the selected samples. Evaluate the performance of the combined SVM.
[0142] The RBF (Radial Basis Function) kernel classifier provides a nonlinear mapping from the input space to the prediction score space, while the proximal SVM classifier learns a linear decision boundary in the prediction score space. This algorithm can improve classification performance when the RBF kernel SVM itself is not sufficient to capture the underlying patterns in the data.
[0143] 3. Model training steps.
[0144] The experimental training data set and test data set were established. The SVM training was performed by selecting a suitable kernel function to form a classifier model file. The improved SVM model steps were similar, and the evaluation results of the two models were finally calculated. The horse image detection was also tested and the results were analyzed, and the horse image recognition method was improved to make the recognition results more accurate.
[0145] 3.1 Experimental Preparation
[0146] All experiments in this embodiment were implemented in Python 3.9.7, Anaconda 3.0, and Jupyter notebook 6.4.8, installed on a PC equipped with an Intel Core processor (3.0 GHz) and 8G memory, and the system was Windows 10. The model was mainly built and trained using modules such as Skimage, Sklearn, and Pytorch in Python under the Anaconda platform.
[0147] 3.2 Characteristics of horse images
[0148] Although there are some data sets containing horse images, the recognition accuracy of horse images is not high enough. These recognition experiments are all from data sets (such as Figure 3 ), in reality, the recognition rate may be lower due to the quality of the dataset itself, including the characteristics of the algorithm and the horse images. The quality of horse images is affected by many factors. Horse images can be identified by a number of physical attributes. Horse breeds can be identified by physical characteristics such as the horse's body shape, color, and coat color. Horses have obvious markings on their coats, such as white spots, stripes, or shapes, which can be used for identification. Body shape refers to the overall shape and conformation of the horse's body. This includes the length and shape of the head, neck, and legs, the shape and length of the back, and the overall size and conformation of the body. Horses can be identified by the different ways they move. This includes differences in gaits, such as walking, trotting, and cantering, and differences in leg movements. Mane and Tail A horse's mane and tail can also be used as features, and they vary in length, thickness, and color.
[0149] These features help the algorithm identify individual horses and horse breeds, and are also useful for managing information and images of horses in equestrian club settings.
[0150] 3.3 Image Preprocessing
[0151] The task of identifying horses in images involves processing and analyzing images to determine whether they contain horse parts. The folder of input images contains RGB (color) images and corresponding people-ground (black and white) images. The goal of the task is to cut the color horse image into smaller sub-images, restore the cut image to a black and white outline image, and determine whether it contains a horse.
[0152] With the continuous advancement of computer vision technology, image segmentation algorithms, as a hot topic in the field of computer vision, effectively simplify the processing, description and understanding of video frame images by dividing the pixels in the video frame into different subsets, laying the foundation for studying other visual tasks. At present, image segmentation algorithms have been widely used in complex environment human target detection, national defense detection, medical image processing, agricultural scientific research, remote sensing image processing and other fields. Although traditional segmentation techniques, such as threshold segmentation and cluster segmentation, can perform accurate segmentation at the pixel level, they all have certain defects. At present, researchers have proposed many different image superpixel segmentation methods. R.Achanta et al. proposed the SLIC (Simple Linear Iterative Clustering) superpixel algorithm, and verified the superiority of the SLIC algorithm in efficiency and segmentation effect by comparing the efficiency and segmentation effect of different algorithms. Therefore, the present embodiment uses the SLIC algorithm to segment color images here.
[0153] 3.4 Experimental Results Analysis
[0154] After the SLIC algorithm segments the data, the processed color images are restored to black and white images, and supervised labels are annotated to form a data set, which is divided into a test set and a training set.
[0155] The support vector machine configuration is as follows:
[0156] Training set: 70% number of samples 21631
[0157] Test set: 30% samples 9271
[0158] Cross validation folds: 10
[0159] Sliding window: 1,2,3,4,5
[0160] Kernel functions: linear, multi-kernel, sigmoid, rbf
[0161] Parameters: C, G
[0162] Parameter optimization method: grid search method
[0163] First, the training set of original data. The characteristic scatter plot of the original data used in this embodiment is as follows: Figure 4 Then different kernel functions were trained, and the performance results of the SVM models of several kernel functions are shown in Tables 1, 2, 3 and 4.
[0164] It can be seen that the accuracy of the linear kernel function SVM model is 66.28%, the accuracy of the rbf kernel function SVM model is 78.27%, the accuracy of the polynomial kernel function SVM model is 65.95%, and the accuracy of the sigmoid kernel function SVM model is 60.04%. From the evaluation indicators, it can be seen that in the standard SVM model, the recognition accuracy of the rbf kernel function and the linear kernel function is better, among which the rbf kernel function SVM model has the best recognition effect, with an accuracy of about 78%, the recognition accuracy of the linear kernel function is second, and the recognition accuracy of the sigmoid kernel function SVM model is the worst.
[0165] Table 1 Evaluation results of SVM model with rbf kernel function
[0166] rbf Accuracy Recall f1 value Sample size 0 0.7 0.78 0.74 3513 1 0.86 0.8 0.83 5758 accuracy 0.79 9271 Macro average 0.78 0.79 0.78 9271 Weighted average 0.8 0.79 0.79 9271
[0167] Table 2 Evaluation results of SVM model with linear kernel function
[0168] Linear Accuracy Recall f1 value Sample size 0 0.56 0.52 0.54 3513 1 0.72 0.75 0.73 5758 accuracy 0.66 9271 Macro average 0.64 0.63 0.64 9271 Weighted average 0.66 0.66 0.66 9271
[0169] Table 3 Evaluation results of SVM model with sigmoid kernel function
[0170] Sigmoid Accuracy Recall f1 value Sample size 0 0.47 0.43 0.45 3543 1 0.67 0.71 0.69 5728 accuracy 0.60 9271 Macro average 0.57 0.57 0.57 9271 Weighted average 0.59 0.60 0.60 9271
[0171] Table 4 Evaluation results of SVM model with polynomial kernel function
[0172]
[0173]
[0174] The CCPSVM algorithm combines the class-centric SVM algorithm and the proximal SVM algorithm. This example uses the SVC class in the sklearn.svm module to train a class-centric SVM model on the training data. The decision function method is then used to obtain the predicted output scores of the SVM model on the training data and reshape them into a column vector. The CCPSVM method includes two steps: (1) fitting a class-centric SVM model to the training data to obtain a predicted score; (2) fitting a proximal SVM classifier model to the predicted score and the true label of the training data. Finally, the final predicted value of the test data is obtained and evaluated.
[0175] 3.5 Comparison of CCPSVM and Standard SVM Model Evaluation
[0176] The following are commonly used evaluation criteria for machine learning models. In the field of machine learning, indicators such as precision, recall, F1 score, and support are commonly used to evaluate the performance of classification models. These indicators are used because they can comprehensively evaluate the performance of the model and help identify its strengths and weaknesses. By evaluating the model based on these indicators, it is easier to understand the performance of the model in different categories, the balance between precision and recall, and the generalization of the model to new data. In addition to the standard SVM, this embodiment also evaluates the performance of the proximal support vector machine classifier and the class center-based support vector machine classifier on the data set. The following table 5, Figure 5 and Figure 6 The results of various SVM models under the above indicators are shown.
[0177] Table 5 Accuracy results of various SVM models
[0178] Model accuracy Standard SVM (linear kernel) 0.66 Standard SVM (sigmoid kernel) 0.60 Standard SVM (rbf kernel) 0.78 Standard SVM (core clustering) 0.65 CCPSVM 0.79 Class-centered SVM 0.59 Proximal SVM 0.56
[0179] As shown in the figure, among all the trained SVM models, the CCPSVM model that combines the class-centric SVM and proximal SVM classifier methods performs best. CCPSVM outperforms other models in accuracy and some evaluation indicators. Some standard SVMs with optimal kernel functions and optimal parameters may be able to approach the performance of CCPSVM, which shows that the excellence of this new method depends on the data set and the specific problem to be solved.
[0180] Class-centric SVM can help identify the most relevant samples in each class, thereby achieving better inter-class separation. However, if the class-centric SVM is inaccurate, it may select irrelevant samples, thus affecting the performance of the entire method. The proximal SVM classifier can further improve the degree of inter-class separation by fitting different kernel functions. However, if the degree of the kernel function is too high, it will lead to overfitting and reduce the generalization performance. In general, the combination method of class-centric SVM and proximal SVM classifier is very useful for datasets with complex class structures and unbalanced class distributions, while traditional support vector machines may have difficulty achieving high accuracy. Therefore, it is always very important to carefully evaluate different methods and problems on a given dataset to determine which method is most effective. The evaluation results of this embodiment on the dataset show that the CCPSVM model has the best effect in image recognition. The above results show that the CCPSVM model proposed in this embodiment works well and is more promising than other traditional SVM algorithms. The results of this example are expected to improve the accuracy and efficiency of applications such as farm management, riding clubs, and robot detection. It can also promote the development of innovative applications of horse image recognition and provide valuable insights into the challenges and limitations of this field, which will have a positive impact on various applications related to horse image recognition.
[0181] In summary, the method of this embodiment first creates a dataset by segmenting horse images according to the SLIC image segmentation algorithm. Then, a two-stage method is used to combine the class-centric SVM classifier and the proximal SVM classifier to form a CCPSVM model, that is, firstly the class-centric SVM is used to select the most relevant samples, and then the proximal SVM classifier is applied on the selected samples. Finally, the performance of CCPSVM and standard SVM is evaluated on the data set performance. The accuracy of the new algorithm on the horse picture recognition dataset reached 79%, which is better than other traditional support vector machine algorithms.
[0182] In addition, the results show that the embodiments of the present invention provide a useful reference for further development in the field of animal image recognition, and the method can also be applied to other related fields, such as other types of image recognition and classification. At the same time, the method can also be combined with other advanced deep learning methods such as neural networks to improve accuracy and efficiency. Using a machine learning algorithm based on a class center support vector machine classifier and a proximal support vector machine classifier can provide higher accuracy and efficiency for image recognition tasks, and the model has broad application prospects.
[0183] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
[0184] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The schemes in the embodiments of the present invention may be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.
[0185] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0186] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0187] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0188] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0189] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A horse image recognition method based on class center SVM and proximal SVM, characterized in that: The following steps are involved: Acquire horse image data, perform preprocessing, input into a pre-trained CCPSVM model, and output a recognition result, wherein the CCPSVM model includes a class-centered SVM classifier and a proximal SVM classifier; The CCPSVM model training process includes: Obtain horse image dataset and perform preprocessing; Based on the preprocessed horse image dataset, the class center of each category is calculated, and the class center SVM classifier is trained using a linear kernel to obtain the most relevant horse image data samples in each category, wherein each class center is assigned a label of the corresponding category; The most relevant horse image data samples in each category are used as training samples for the proximal SVM classifier and a polynomial kernel is selected to train the proximal SVM classifier to complete the CCPSVM model training process.
2. The horse image recognition method based on class center SVM and proximal SVM according to claim 1 is characterized in that: The horse image dataset includes RGB horse images and corresponding black-and-white human-ground images. The preprocessing steps in the training process include: Segmenting the RGB horse image into sub-images, restoring the segmented sub-images to black and white outline images, and determining whether the sub-images contain horses; All black and white outline images and corresponding black and white person-ground images are filled to a consistent size.
3. The horse image recognition method based on class center SVM and proximal SVM according to claim 2 is characterized in that: The RGB horse image is segmented into sub-images using the SLIC image segmentation method.
4. The horse image recognition method based on class center SVM and proximal SVM according to claim 1 is characterized in that: The CCPSVM model achieves classification and recognition of horse image data through a decision boundary, and the decision boundary is: w T (x-c)+b=0 Where w is the weight vector, c is the adjusted class center obtained by the class center SVM, and b is the bias term.
5. The horse image recognition method based on class center SVM and proximal SVM according to claim 1 is characterized in that: The evaluation function of the output recognition result is: f(x new )=sign(w T (x new -c)+b In the formula, f(x new ) is x new The evaluation function, x new is the input horse image data, f(x new ) is positive, then x new Belongs to the positive class, f(x new ) is a negative value, then x new Belongs to the negative class, w is the weight vector, c is the adjusted class center obtained by the class center SVM, and b is the bias term.
6. The horse image recognition method based on class center SVM and proximal SVM according to claim 1, characterized in that: The class center based SVM classifier maximizes the distance between two class centers by seeking a hyperplane with a maximized margin, thereby obtaining the most relevant horse image data sample in each class, wherein the expression of the margin is: margin=min[d(x),y=-1]+min[d(x),y=+1] Where margin is the margin, d(x) is the distance from point x to the hyperplane, y is the label, w is the weight vector, and b is the bias term.
7. The horse image recognition method based on class center SVM and proximal SVM according to claim 1, characterized in that: The objective function used in the training process of the class-centered SVM classifier is: s.t.y i (w·x i +b)+ξ i >0,ξ i ≥0,i=1,...,n Where w is the weight vector, ξ i is a slack variable used to allow some misclassification, C is a penalty parameter, and y i ∈{-1,+1} is the corresponding class label, b is the bias term, x i is the i-th input data vector, and n is the number of data vectors.
8. The horse image recognition method based on class center SVM and proximal SVM according to claim 1, characterized in that: The objective function used in the proximal SVM classifier training process is: stD(K(A,A′)Du-eγ)+γ=e Where w is the weight vector, u is the dual multiplier, γ is the regularization parameter, C is the penalty parameter, R is the p-dimensional real space, n is the n points in R, D is the n×n matrix, K(A,A′) is the nonlinear kernel, A is the n×p matrix, and e is the unit vector.
9. The horse image recognition method based on class center SVM and proximal SVM according to claim 1, characterized in that: The optimization objective function of the CCPSVM model is: In the formula, ||w|| 2 is the L2 criterion of the weight vector w, C is the penalty parameter used to control the trade-off between maximizing the margin and minimizing the classification error, λ is the regularization parameter used to control the smoothness of the adjusted class center, c is the adjusted class center obtained by the class center SVM, is the initial guess of the cluster center, x i is the i-th input data vector, y i is the corresponding binary label and b is the bias term.
10. The horse image recognition method based on class center SVM and proximal SVM according to claim 9, characterized in that: The KKT condition is used to solve the optimal values of w, b and c in the optimization objective function of the CCPSVM model. The specific steps include: The Lagrangian function and KKT condition are obtained based on the optimization objective function of the CCPSVM model, which are: Lagrangian function function: KKT Conditions: Complementary slackness of the KKT dual problem: The partial derivatives of the Lagrangian function with respect to w, b and c are set to zero, and the optimal values of w, b and c are solved: Fixedness: Therefore, we have: Complementary slack: α i [y i (w T (x i -c)+b)-1+x i ]=0 β i x i =0 Where L(w,b,c,α,β,γ) is the Lagrangian function, w is the weight vector, C is the penalty parameter, b is the bias term, c is the adjusted class center obtained by the class center SVM, and α is i , β i and γ i is the Lagrange multiplier of the inequality constraint, x i is the slack variable for the ith data point, y i is the corresponding binary label, |w|| 2 is the L2 criterion of the weight vector, λ is the regularization parameter, is an initial guess for the class center.
