Face retrieval method and system based on random forest and density clustering and medium
Through the face retrieval method based on random forest and density clustering, the random forest model and DBSCAN clustering algorithm are used for face feature matching, which solves the problem of low face retrieval accuracy in the existing technology, improves the retrieval accuracy and Reduced implementation costs.
Patent Information
- Application Number
- CN202410404354.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-03
- Publication Date
- 2024-08-23
AI Technical Summary
Existing face retrieval technology has low accuracy when dealing with factors such as different angles, makeup, and occlusion, resulting in reduced model accuracy and recall. Face sample collection and labeling require a large amount of human resources, increasing implementation costs.
A face retrieval method based on random forest and density clustering is used to match facial features through the random forest model and DBSCAN clustering algorithm to reduce errors and improve accuracy.
It improves the accuracy of face retrieval, reduces errors caused by factors such as makeup, angle, and occlusion, reduces the need for face sample collection and labeling, and reduces implementation costs.
Smart Images

Figure CN118537899A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a face retrieval method, system and medium based on random forest and density clustering. Background Art
[0002] There are many application scenarios for quick search of specific people in videos. For example, if you are interested in a public figure and want to know their performance and activities in various videos, you can use the quick search method to find relevant videos. In addition, advertisers can determine the influence of a specific person by the frequency of their appearance in the video.
[0003] In actual application scenarios, face retrieval has the following problems: the same actor in film and television works has very different faces due to clothing, makeup and image PS technology; the face angle problem, the side face, front face, lowered head and raised head face pictures of the same person are very different, which leads to large differences in facial features of the same person; the face integrity problem, due to occlusion and screen distortion, the face display is incomplete. Due to the above situations, the accuracy of face retrieval is often affected, resulting in reduced model accuracy and recall rate. The existing solution is to increase the number of face samples for training, but face sample collection and manual labeling often require a large investment in human resources and take a lot of time, increasing the implementation cost of face retrieval. Summary of the invention
[0004] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.
[0005] To this end, an object of an embodiment of the present invention is to provide a face retrieval method based on random forest and density clustering, which improves the accuracy of face retrieval.
[0006] Another object of an embodiment of the present invention is to provide a face retrieval system based on random forest and density clustering.
[0007] In order to achieve the above technical objectives, the technical solutions adopted by the embodiments of the present invention include:
[0008] On the one hand, an embodiment of the present invention provides a face retrieval method based on random forest and density clustering, comprising the following steps:
[0009] Acquire a video to be retrieved, and perform face detection on the video to be retrieved to obtain multiple face images to be retrieved;
[0010] Extracting features of the face image to be retrieved to obtain multiple face features to be retrieved, and then generating a face fingerprint database based on the face features to be retrieved;
[0011] Acquire a target face image, and perform feature extraction on the target face image to obtain target face features;
[0012] Constructing a random forest model, inputting the face fingerprint database and the target face features into the random forest model, and then matching the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result;
[0013] The random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
[0014] Furthermore, in one embodiment of the present invention, the step of obtaining a video to be retrieved and performing face detection on the video to be retrieved to obtain a plurality of face images to be retrieved specifically includes:
[0015] Obtaining a video to be retrieved, decoding the video to be retrieved, and extracting multiple frames of images to be retrieved;
[0016] The face detection is performed on the image to be retrieved by using a Haar cascade classifier or a face key point detection algorithm, and the detected face area is framed to obtain the face image to be retrieved.
[0017] Furthermore, in one embodiment of the present invention, the step of extracting features from the face image to be retrieved to obtain a plurality of face features to be retrieved, and then generating a face fingerprint database according to the face features to be retrieved specifically includes:
[0018] Performing face alignment on the face image to be retrieved to obtain an aligned image to be retrieved;
[0019] Extracting features of the aligned image to be retrieved by a convolutional neural network to obtain a first high-dimensional face feature vector;
[0020] Performing dimensionality reduction processing on the first high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain the facial features to be retrieved;
[0021] Determine the appearance time and appearance position of the face image to be retrieved in the video to be retrieved, and generate the face fingerprint database according to the face features to be retrieved and the corresponding appearance time and appearance position.
[0022] Further, in one embodiment of the present invention, the step of obtaining a target face image and extracting features from the target face image to obtain target face features specifically includes:
[0023] Acquire multiple target face images, and perform feature extraction on the target face images through a convolutional neural network to obtain a second high-dimensional face feature vector;
[0024] Performing dimensionality reduction processing on the second high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain multiple low-dimensional facial feature vectors;
[0025] Feature fusion is performed on the multiple low-dimensional facial feature vectors to obtain the target facial features.
[0026] Furthermore, in one embodiment of the present invention, the step of constructing a random forest model, inputting the face fingerprint database and the target face features into the random forest model, and then matching the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result specifically includes:
[0027] Constructing a random forest model, determining a plurality of weak classifiers of the random forest model, and determining a similarity threshold of each of the weak classifiers;
[0028] Inputting the face fingerprint database and the target face feature into each of the weak classifiers, calculating the cosine similarity between the target face feature and each of the face features to be retrieved through each of the weak classifiers, and selecting multiple face features to be retrieved whose cosine similarity is greater than or equal to the similarity threshold as corresponding matching face features;
[0029] Density clustering is performed on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each of the weak classifiers;
[0030] The number of occurrences of each of the matching facial features in all the facial feature clusters is determined, and the face retrieval result is determined according to the number of occurrences and the number of the weak classifiers.
[0031] Further, in one embodiment of the present invention, the step of performing density clustering on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each of the weak classifiers specifically includes:
[0032] Density clustering is performed on the matching facial features based on the DBSCAN clustering algorithm to obtain multiple candidate feature clusters and determine the feature density of each candidate feature cluster;
[0033] The candidate feature cluster with the largest feature density is determined as the face feature cluster.
[0034] Furthermore, in one embodiment of the present invention, the face retrieval method further includes a step of pruning the face feature cluster, which specifically includes:
[0035] Determining the maximum diameter of the facial feature cluster, and judging whether the maximum diameter is greater than a preset distance threshold;
[0036] When the maximum diameter is greater than the distance threshold, a square window is generated with the distance threshold as the side length, and the facial feature cluster is slidably intercepted based on the square window and a preset sliding step length to obtain a plurality of intercepted feature clusters;
[0037] The feature density of each of the intercepted feature clusters is determined, and the intercepted feature cluster with the largest feature density is selected as the pruned face feature cluster.
[0038] On the other hand, an embodiment of the present invention provides a face retrieval system based on random forest and density clustering, comprising:
[0039] A face detection module is used to obtain a video to be retrieved, and perform face detection on the video to be retrieved to obtain a plurality of face images to be retrieved;
[0040] A face fingerprint database generation module is used to extract features from the face image to be retrieved, obtain multiple face features to be retrieved, and then generate a face fingerprint database based on the face features to be retrieved;
[0041] A face feature extraction module is used to obtain a target face image and perform feature extraction on the target face image to obtain target face features;
[0042] A facial feature matching module is used to construct a random forest model, input the facial fingerprint database and the target facial features into the random forest model, and then match the target facial features in the facial fingerprint database through the random forest model to obtain a face retrieval result;
[0043] The random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
[0044] On the other hand, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the program is executed by the processor, the face retrieval method based on random forest and density clustering as described above is realized.
[0045] On the other hand, an embodiment of the present invention also provides a storage medium, which is a computer-readable storage medium for computer-readable storage, and stores one or more programs, and the one or more programs can be executed by one or more processors to implement the face retrieval method based on random forest and density clustering as described above.
[0046] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:
[0047] The embodiment of the present invention obtains a video to be retrieved, performs face detection on the video to be retrieved to obtain multiple face images to be retrieved, then performs feature extraction on the face images to be retrieved to obtain multiple face features to be retrieved, and then generates a face fingerprint database based on the face features to be retrieved, then obtains a target face image, performs feature extraction on the target face image to obtain target face features, then constructs a random forest model, inputs the face fingerprint database and the target face features into the random forest model, and then matches the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result, wherein the random forest model includes multiple weak classifiers, and the weak classifiers match face features based on the DBSCAN clustering algorithm. The embodiment of the present invention matches the target face features based on the random forest and DBSCAN clustering algorithms, avoids errors caused by makeup, angles, occlusions, and other factors during face retrieval, and improves the accuracy of face retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solution in the embodiments of the present invention, the following introduction is made to the drawings required for use in the embodiments of the present invention. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solution of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a face retrieval method based on random forest and density clustering provided by an embodiment of the present invention;
[0050] Figure 2 A step flow chart of step S101 provided in an embodiment of the present invention;
[0051] Figure 3 A step flow chart of step S102 provided in an embodiment of the present invention;
[0052] Figure 4 A step flow chart of step S103 provided in an embodiment of the present invention;
[0053] Figure 5 A step flow chart of step S104 provided in an embodiment of the present invention;
[0054] Figure 6 A step flow chart of step S1043 provided in an embodiment of the present invention;
[0055] Figure 7 Another step flow chart of step S1043 provided in an embodiment of the present invention;
[0056] Figure 8 A schematic diagram of the structure of a face retrieval system based on random forest and density clustering provided by an embodiment of the present invention;
[0057] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention;
[0058] Fig.10 A schematic diagram of the structure of a storage medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limitations on the present application. It should be noted that, although the functional module division is performed in the system schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order from the module division in the system schematic diagram or the flow chart. For the step numbers in the following embodiments, they are only set for the convenience of explanation, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0060] In the description of the present invention, the meaning of "a plurality" is two or more. If there is a description of the first or the second, it is only for the purpose of distinguishing the technical features, and it cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, unless otherwise defined, all technical and scientific terms used in this document have the same meaning as those commonly understood by technicians in the technical field of this application. The terms used in this document are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0061] The face retrieval method based on random forest and density clustering provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a set-top box, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the face retrieval method based on random forest and density clustering, etc., but is not limited to the above forms.
[0062] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0063] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0064] like Figure 1 FIG. 1 is a flowchart of a face retrieval method based on random forest and density clustering provided by an embodiment of the present invention, referring to FIG. Figure 1The embodiment of the present invention provides a face retrieval method based on random forest and density clustering, which specifically includes the following steps:
[0065] S101, obtaining a video to be retrieved, and performing face detection on the video to be retrieved to obtain a plurality of face images to be retrieved.
[0066] like Figure 2 FIG. 1 is a flowchart of step S101 provided in an embodiment of the present invention, referring to FIG. Figure 2 As an optional implementation, the step of obtaining a video to be retrieved and performing face detection on the video to be retrieved to obtain a plurality of face images to be retrieved specifically includes:
[0067] S1021, obtaining a video to be retrieved, decoding the video to be retrieved, and extracting multiple frames of images to be retrieved;
[0068] S1022, performing face detection on the image to be retrieved by using a Haar cascade classifier or a face key point detection algorithm, and framing the detected face area to obtain a face image to be retrieved.
[0069] Specifically, the video content is decoded and the I frame image is extracted; the face detection algorithm in computer vision technology, such as Haar cascade classifier, face key point detection, etc., is used to perform face detection on the I frame image, and the detected face is framed to obtain the face image to be retrieved.
[0070] S102, extracting features from the face image to be retrieved to obtain a plurality of face features to be retrieved, and then generating a face fingerprint database based on the face features to be retrieved.
[0071] like Figure 3 FIG. 1 is a flow chart of step S102 provided in an embodiment of the present invention, referring to FIG. Figure 3 As an optional implementation, feature extraction is performed on the face image to be retrieved to obtain multiple face features to be retrieved, and then a face fingerprint database is generated according to the face features to be retrieved. The step specifically includes:
[0072] S1021, performing face alignment on the face image to be retrieved to obtain an aligned image to be retrieved;
[0073] S1022, extracting features from the aligned image to be retrieved by using a convolutional neural network to obtain a first high-dimensional face feature vector;
[0074] S1023, performing dimensionality reduction processing on the first high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain facial features to be retrieved;
[0075] S1024, determining the appearance time and appearance position of the face image to be retrieved in the video to be retrieved, and generating a face fingerprint database according to the face features to be retrieved and the corresponding appearance time and appearance position.
[0076] Specifically, for each detected face, a face alignment operation is performed to ensure that the position and angle of the face on the image are consistent. Common methods include alignment based on feature points and alignment based on geometric transformations. A face feature extraction algorithm is used, such as a convolutional neural network (CNN) in a deep learning model, to process the face-aligned image to extract a high-dimensional feature vector of the face. The high-dimensional feature vector of each face is converted into a compact representation of a fixed length. Common methods include using principal component analysis (PCA) or linear discriminant analysis (LDA) for dimensionality reduction, or passing the feature vector into a neural network to encode it into a vector of a fixed length, thereby obtaining the face features to be retrieved. A face fingerprint database can be generated based on the appearance time and position of the face features to be retrieved and the corresponding image to be retrieved in the video to be retrieved, so that when the corresponding face features to be retrieved are matched later, its appearance time and position in the video to be retrieved can be quickly determined.
[0077] S103: Acquire a target face image, and perform feature extraction on the target face image to obtain target face features.
[0078] like Figure 4 FIG. 1 is a flow chart of step S103 provided in an embodiment of the present invention, referring to FIG. Figure 4 As an optional implementation, the step of obtaining a target face image and extracting features of the target face image to obtain target face features specifically includes:
[0079] S1031, obtaining multiple target face images, and performing feature extraction on the target face images through a convolutional neural network to obtain a second high-dimensional face feature vector;
[0080] S1032, performing dimensionality reduction processing on the second high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain multiple low-dimensional facial feature vectors;
[0081] S1033. Perform feature fusion on multiple low-dimensional facial feature vectors to obtain target facial features.
[0082] Specifically, for the target person, use search engines, social media or other sources to collect as many photos of the person as possible. The diversity of photos will help train the model to recognize the facial features of the person under different expressions, angles and lighting conditions; use the method described above to extract the facial features of all photos; for multiple photos of the same person, fuse the feature vectors extracted from each photo to generate a comprehensive feature vector representing the face. The fusion method can be a simple average or weighted average, or a more complex feature fusion algorithm can be used, which will not be described in detail in the embodiments of the present invention.
[0083] S104, constructing a random forest model, inputting the face fingerprint database and the target face features into the random forest model, and then matching the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result;
[0084] Among them, the random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
[0085] Specifically, random forest is a (parallel) integration algorithm composed of multiple weak classifiers, which belongs to the Bagging type. By combining multiple weak classifiers, the final result is obtained by voting or taking the average, so that the result of the overall model has higher accuracy and generalization performance, and also has good stability.
[0086] When retrieving faces, the matching degree of faces is often obtained by calculating the cosine distance of face feature vectors. The traditional method is to set a fixed threshold. If the matching degree is lower than this threshold, it is considered to be the same face. However, this method is not flexible enough. If the fixed threshold is set too low, the retrieval accuracy is high but many faces will be missed. If it is set too high, the accuracy will be reduced. Therefore, the embodiment of the present invention solves this problem through random forest. The weak classifier of the traditional random forest is a decision tree, which is replaced by DBSCAN here. A threshold is set separately for each weak classifier, and face images are retrieved based on this threshold. Then, the weak classifier is trained based on the retrieved images, and the final data of the face query (data with face matching errors filtered out) is generated by the weak classifier. Finally, each weak classifier votes, and the one with the most votes is used as the final data of successful face matching.
[0087] like Figure 5 FIG. 1 is a flowchart of step S104 provided in an embodiment of the present invention, referring to FIG. Figure 5 As an optional implementation method, a random forest model is constructed, the face fingerprint database and the target face features are input into the random forest model, and then the target face features are matched in the face fingerprint database by the random forest model to obtain the face retrieval result. The step specifically includes:
[0088] S1041, constructing a random forest model, determining multiple weak classifiers of the random forest model, and determining a similarity threshold of each weak classifier;
[0089] S1042, inputting the face fingerprint database and the target face features into each weak classifier, calculating the cosine similarity between the target face features and each face feature to be retrieved through each weak classifier, and selecting multiple face features to be retrieved whose cosine similarity is greater than or equal to a similarity threshold as corresponding matching face features;
[0090] S1043, performing density clustering on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each weak classifier;
[0091] S1044, determining the number of occurrences of each matching facial feature in all facial feature clusters, and determining the face retrieval result according to the number of occurrences and the number of weak classifiers.
[0092] Specifically, the data returned by the face query sometimes often contains other face images. In this case, the embodiment of the present invention clusters the face retrieval data through density clustering, and the cluster with the largest density is used as the data with correct final face matching. Other face data that are not in this cluster are considered outliers and are filtered out as abnormal points.
[0093] The specific process of the algorithm is as follows:
[0094] Related definitions: 1) D: the set of weak classifiers of random forest {d1, d2, d3, ...., dm}, the number of classifiers is m;
[0095] 2) X: face fingerprint database in the video, the database size is n;
[0096] 3) INPUT: face fingerprint to be queried;
[0097] 4) COLLECTION: Query the face data set in X that matches INPUT;
[0098] 5) DBSCAN: A weak classifier of random forest, which filters data with face matching errors based on density clustering algorithm
[0099] 6) DBSCAN_OUTPUT: stores the data returned by DBSCAN, the size is k;
[0100] 8) MATCH_DICT: records the number of matches for each face, where the data type is dict, key = face fingerprint, val = number of successful face matches, and size is t.
[0101] 1. Based on the random forest model, generate m weak classifiers, and the model of the weak classifier is DBSCAN;
[0102] 2. Generate a weak classifier model, and generate a dist (face similarity threshold) for each weak classifier independently, dist = 0.05 + (0.05 / m) * i, where (i is the sequence number of the classifier, n is the number of weak classifiers);
[0103] 3. Traverse X and detect the similarity between each face (x_elemnet) and INPUT (the cosine distance between two face fingerprints). If the similarity is greater than or equal to dist, add x_elemnet to COLLECTION.
[0104] 4. Call DBSCAN to perform density clustering on the generated COLLECTION and generate DBSCAN_OUTPUT;
[0105] 5. Calculate the number of times each face appears in DBSCAN_OUTPUT and save it in MATCH_DICT;
[0106] 6. If all weak classifiers are detected, execute step 7. If not, jump to step 2.
[0107] 7. Traverse the elements of MATCH_DICT. If val is greater than m / 2, add it to the set of successfully matched faces. If it is less than m / 2, it is considered to be noise data and discarded. val is the number of occurrences of each face in MATCH_DICT, and m is the number of weak classifiers. For example, if face C exists in DBSCAN_OUTPUT of 6 weak classifiers, then val is 6.
[0108] like Figure 6 FIG. 1 is a flow chart of step S1043 provided in an embodiment of the present invention, referring to FIG. Figure 6 As an optional implementation, density clustering is performed on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each weak classifier, which specifically includes:
[0109] S10431, performing density clustering on the matching facial features based on the DBSCAN clustering algorithm to obtain multiple candidate feature clusters and determine the feature density of each candidate feature cluster;
[0110] S10432. Determine that the candidate feature cluster with the largest feature density is the face feature cluster.
[0111] Specifically, clusters of various shapes and sizes are found in noisy data. The core idea is to first find points with higher density, and then gradually connect the similar high-density points into one piece, and then generate various clusters. The algorithm is implemented as follows: for each data point as the center, draw a circle with eps as the radius (called the neighborhood eps-neigbourhood), and then count how many points are in this circle, and this number is the density value of the point. Then, the embodiment of the present invention can select a density threshold MinPts, such as the center point of the circle with less than MinPts points in the circle is a low-density point, and the center point of the circle greater than or equal to MinPts is a high-density point (called a core point Core point). If there is a high-density point in the circle of another high-density point, connect the two points, so that many points can be continuously connected in series. Afterwards, if there is a low-density point also in the circle of high-density points, connect it to the nearest high-density point, which is called a boundary point. In this way, all points that can be connected together form a cluster, thereby obtaining the candidate feature cluster of the embodiment of the present invention, and the low-density points that are not in the circle of any high-density points are abnormal points.
[0112] like Figure 7 FIG. 1 is another step flow chart of step S1043 provided in an embodiment of the present invention, referring to FIG. Figure 7 As an optional implementation, the face retrieval method further includes a step of pruning the face feature clusters, which specifically includes:
[0113] S10433, determining the maximum diameter of the facial feature cluster, and judging whether the maximum diameter is greater than a preset distance threshold;
[0114] S10434, when the maximum diameter is greater than the distance threshold, a square window is generated with the distance threshold as the side length, and the face feature cluster is slidably intercepted based on the square window and a preset sliding step length to obtain multiple intercepted feature clusters;
[0115] S10435. Determine the feature density of each intercepted feature cluster, and select the intercepted feature cluster with the largest feature density as the pruned face feature cluster.
[0116] Specifically, the aforementioned density clustering algorithm has a problem, for example: based on the query of face A, faces B and C are detected to match successfully, but B and C do not match, that is: A matches B and C, but B and C do not match. This situation is reflected in the cluster generated by density clustering as the maximum diameter of the cluster (the maximum diameter is the maximum difference of the faces in the cluster) is greater than the threshold of face matching, and further processing is required. In the cluster where the faces are matched successfully, all faces should be matched successfully with each other, which means that there is a matching anomaly between B and C. Therefore, based on the traditional DBSCAN algorithm, after density clustering, the embodiment of the present invention needs to prune the generated maximum cluster, filter the points in the cluster whose distance is greater than the fixed threshold, and generate a cluster whose maximum diameter is less than the fixed threshold of face matching.
[0117] The relevant algorithm process is as follows:
[0118] 1. Perform face retrieval based on the classification threshold, and add faces whose facial feature distance is lower than the threshold to the face matching set;
[0119] 2. Based on the clustering of DBSCAN algorithm, the cluster with the largest density value (each data point is the center, draw a circle with eps as the radius, and then count the number of points in this circle, this number is the density of the point) is selected as the set of faces that are successfully matched. All faces that are not in this cluster with the largest density are abnormal points that report matching errors;
[0120] 3. Return the cluster with the largest density value as the successful face matching data set of the classifier;
[0121] 4. Calculate the maximum diameter of the cluster. If the diameter is greater than the fixed threshold for face matching, prune the cluster and jump to step 5.
[0122] 5. Generate a square window with a length and width equal to the maximum threshold. Slide the generated clusters based on this sliding window. The sliding step size is preset. Calculate the density value in the sliding window and slide it in sequence. The cluster in the window with the largest density value is taken as the final cluster, that is, the set of facial features that the model considers to be the final successful match.
[0123] The above is a description of the method steps of the embodiment of the present invention. It can be understood that the embodiment of the present invention matches the target facial features based on the random forest and DBSCAN clustering algorithms, avoiding errors caused by factors such as makeup, angle, and occlusion during face retrieval, thereby improving the accuracy of face retrieval.
[0124] like Figure 8 FIG. 1 is a schematic diagram of the structure of a face retrieval system based on random forest and density clustering provided by an embodiment of the present invention, referring to FIG. Figure 8, an embodiment of the present invention provides a face retrieval system based on random forest and density clustering, comprising:
[0125] A face detection module is used to obtain a video to be retrieved, and perform face detection on the video to be retrieved to obtain multiple face images to be retrieved;
[0126] A face fingerprint database generation module is used to extract features of a face image to be retrieved, obtain multiple face features to be retrieved, and then generate a face fingerprint database based on the face features to be retrieved;
[0127] A face feature extraction module is used to obtain a target face image and extract features from the target face image to obtain target face features;
[0128] The face feature matching module is used to build a random forest model, input the face fingerprint database and the target face features into the random forest model, and then match the target face features in the face fingerprint database through the random forest model to obtain the face retrieval result;
[0129] Among them, the random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
[0130] The contents of the above method embodiments are all applicable to the present system embodiments. The functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0131] The embodiment of the present invention also provides an electronic device, the electronic device comprising: a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, and when the program is executed by the processor, the above-mentioned face retrieval method based on random forest and density clustering is realized. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0132] like Fig. 9 FIG. 1 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention, referring to FIG. Fig. 9 , an embodiment of the present invention provides an electronic device, including:
[0133] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;
[0134] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the face retrieval method based on random forest and density clustering in the embodiment of the present invention;
[0135] Input / output interface 903, used to implement information input and output;
[0136] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0137] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0138] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0139] like Fig.10 FIG. 1 is a schematic diagram of a storage medium according to an embodiment of the present invention. Fig.10 The embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs 1001, and the one or more programs 1001 can be executed by one or more processors to implement the above-mentioned face retrieval method based on random forest and density clustering.
[0140] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0141] The embodiment of the present invention also discloses a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 1 The method shown.
[0142] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the above-mentioned boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0143] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified to the contrary, one or more of the above-mentioned functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0144] 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 above methods of 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 and other media that can store program codes.
[0145] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0146] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the above-mentioned program is printed, since the above-mentioned program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or processing in other suitable ways as necessary, and then stored in a computer memory.
[0147] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0148] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0149] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0150] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A face retrieval method based on random forest and density clustering, characterized in that: The following steps are involved: Acquire a video to be retrieved, and perform face detection on the video to be retrieved to obtain multiple face images to be retrieved; Extracting features of the face image to be retrieved to obtain multiple face features to be retrieved, and then generating a face fingerprint database based on the face features to be retrieved; Acquire a target face image, and perform feature extraction on the target face image to obtain target face features; Constructing a random forest model, inputting the face fingerprint database and the target face features into the random forest model, and then matching the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result; The random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
2. A face retrieval method based on random forest and density clustering according to claim 1, characterized in that: The step of obtaining a video to be retrieved and performing face detection on the video to be retrieved to obtain a plurality of face images to be retrieved specifically includes: Obtaining a video to be retrieved, decoding the video to be retrieved, and extracting multiple frames of images to be retrieved; The face detection is performed on the image to be retrieved by using a Haar cascade classifier or a face key point detection algorithm, and the detected face area is framed to obtain the face image to be retrieved.
3. The face retrieval method based on random forest and density clustering according to claim 1, characterized in that: The step of extracting features from the face image to be retrieved to obtain a plurality of face features to be retrieved, and then generating a face fingerprint database according to the face features to be retrieved specifically includes: Performing face alignment on the face image to be retrieved to obtain an aligned image to be retrieved; Extracting features of the aligned image to be retrieved by a convolutional neural network to obtain a first high-dimensional face feature vector; Performing dimensionality reduction processing on the first high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain the facial features to be retrieved; Determine the appearance time and appearance position of the face image to be retrieved in the video to be retrieved, and generate the face fingerprint database according to the face features to be retrieved and the corresponding appearance time and appearance position.
4. The face retrieval method based on random forest and density clustering according to claim 1, characterized in that: The step of obtaining a target face image and extracting features from the target face image to obtain target face features specifically includes: Acquire multiple target face images, and perform feature extraction on the target face images through a convolutional neural network to obtain a second high-dimensional face feature vector; Performing dimensionality reduction processing on the second high-dimensional facial feature vector by principal component analysis or linear discriminant analysis to obtain multiple low-dimensional facial feature vectors; Feature fusion is performed on the multiple low-dimensional facial feature vectors to obtain the target facial features.
5. A face retrieval method based on random forest and density clustering according to any one of claims 1 to 4, characterized in that: The step of constructing a random forest model, inputting the face fingerprint database and the target face features into the random forest model, and then matching the target face features in the face fingerprint database through the random forest model to obtain a face retrieval result specifically includes: Constructing a random forest model, determining a plurality of weak classifiers of the random forest model, and determining a similarity threshold of each of the weak classifiers; Inputting the face fingerprint database and the target face feature into each of the weak classifiers, calculating the cosine similarity between the target face feature and each of the face features to be retrieved through each of the weak classifiers, and selecting a plurality of face features to be retrieved whose cosine similarity is greater than or equal to the similarity threshold as corresponding matching face features; Density clustering is performed on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each of the weak classifiers; The number of occurrences of each of the matching facial features in all the facial feature clusters is determined, and the face retrieval result is determined according to the number of occurrences and the number of the weak classifiers.
6. A face retrieval method based on random forest and density clustering according to claim 5, characterized in that: The step of performing density clustering on the matching facial features based on the DBSCAN clustering algorithm to obtain facial feature clusters corresponding to each weak classifier specifically includes: Density clustering is performed on the matching facial features based on the DBSCAN clustering algorithm to obtain multiple candidate feature clusters and determine the feature density of each candidate feature cluster; The candidate feature cluster with the largest feature density is determined as the face feature cluster.
7. The face retrieval method based on random forest and density clustering according to claim 6, characterized in that: The face retrieval method further includes the step of pruning the face feature cluster, which specifically includes: Determining the maximum diameter of the facial feature cluster, and judging whether the maximum diameter is greater than a preset distance threshold; When the maximum diameter is greater than the distance threshold, a square window is generated with the distance threshold as the side length, and the facial feature cluster is slidably intercepted based on the square window and a preset sliding step length to obtain a plurality of intercepted feature clusters; The feature density of each of the intercepted feature clusters is determined, and the intercepted feature cluster with the largest feature density is selected as the pruned face feature cluster.
8. A face retrieval system based on random forest and density clustering, characterized in that: include: A face detection module is used to obtain a video to be retrieved, and perform face detection on the video to be retrieved to obtain a plurality of face images to be retrieved; A face fingerprint database generation module is used to extract features from the face image to be retrieved, obtain multiple face features to be retrieved, and then generate a face fingerprint database based on the face features to be retrieved; A facial feature extraction module is used to obtain a target facial image and perform feature extraction on the target facial image to obtain target facial features; A facial feature matching module is used to construct a random forest model, input the facial fingerprint database and the target facial features into the random forest model, and then match the target facial features in the facial fingerprint database through the random forest model to obtain a face retrieval result; The random forest model includes multiple weak classifiers, and the weak classifiers perform facial feature matching based on the DBSCAN clustering algorithm.
9. An electronic device, characterized in that: The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the steps of the face retrieval method based on random forest and density clustering as described in any one of claims 1 to 7 are realized.
10. A storage medium, the storage medium being a computer-readable storage medium, used for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the face retrieval method based on random forest and density clustering as described in any one of claims 1 to 7.
