Data index establishment, data retrieval method, device, equipment and storage medium
By segmenting massive data and establishing index tables, the problems of poor stability and low retrieval efficiency of the K-means clustering algorithm are solved, and high-precision and efficient image data retrieval is achieved.
Patent Information
- Application Number
- CN201910883196.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-18
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2039-09-18
AI Technical Summary
The existing K-means clustering algorithm is easily affected by the initial point and has poor stability. Moreover, the feature vector retrieval method based on K-means cannot adapt to massive feature vector data. The retrieval accuracy is low, the calculation amount is large, and it is difficult to meet the retrieval needs of complex data.
Through multiple segment clustering of massive sample data, an index table is established to improve the clustering effect and accuracy, and the pre-established index table is used for efficient retrieval during the data retrieval process.
It improves the accuracy of the clustering center and retrieval accuracy, reduces the amount of calculation, increases the server computing speed, and achieves efficient image data retrieval.
Smart Images

Figure CN110825894B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data index establishment, data retrieval method, device, equipment and storage medium. Background Art
[0002] The existing K-means clustering algorithm (i.e., K-means algorithm) is easily affected by the initial point. When the initial point is not selected properly, the correct clustering result cannot be obtained, and the algorithm stability is poor. In addition, the existing K-means clustering algorithm obtains a quantized result by clustering the entire vector once, and the amount of cluster center data to be expressed is large.
[0003] The feature vector retrieval method based on the above-mentioned K-means clustering algorithm directly obtains the coarse cluster center through one training regardless of the amount of data. This is a static learning process. This feature vector retrieval method cannot adapt to the retrieval of massive feature vector data. When the cluster center is not selected properly, the result of 1vN retrieval (finding the feature vector most similar to the query vector from N feature vectors) has a large deviation, which affects the retrieval accuracy and has low retrieval efficiency. At the same time, as the retrieval object (for example, unstructured data such as images, videos, and music) becomes more complex, the retrieval difficulty increases exponentially, and complex retrieval objects usually need to be represented by multi-dimensional vectors. When there is massive data in the retrieval library, if brute force search is used, multi-dimensional vector operations are performed on the retrieval sample (including multiple comparison objects), the amount of calculation is very large, resulting in too long retrieval time, which makes it difficult to meet user needs. Summary of the invention
[0004] The embodiments of the present invention provide a data index establishment, data retrieval method, device, equipment and storage medium, which pre-segment clustering and indexing of massive sample data for multiple times, thereby improving the clustering effect and the accuracy of cluster centers; at the same time, during the data retrieval process, based on the pre-established index, high-precision and high-efficiency image data retrieval is achieved.
[0005] In a first aspect, a method for establishing a data index is provided, comprising:
[0006] According to the data volume level of the data set, obtaining a segmented clustering model associated with the data volume level;
[0007] Input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer;
[0008] Reading the data sample from the data set, classifying the read data sample into the closest cluster center of the type, and associating N quantizers with the N cluster centers of the type one in a one-to-one correspondence;
[0009] Performing secondary clustering on the data samples associated with each of the quantizers to determine two types of cluster centers and the data samples associated with each of the two types of cluster centers;
[0010] N index tables corresponding to the N quantizers are established; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center.
[0011] In a second aspect, a data retrieval method is provided, wherein the data retrieval method uses the index table obtained by the above-mentioned data index establishment method to perform image data retrieval, comprising:
[0012] Receiving a query request including an image query sample, and obtaining a query vector of the image query sample;
[0013] From all the two-category cluster centers included in the index table, obtain the two-category cluster centers whose distances from the query vector meet a first predetermined condition, and determine the data samples corresponding to the two-category cluster centers that meet the first predetermined condition as image comparison samples;
[0014] Determining a sample distance between the image comparison sample and the image query sample;
[0015] The image comparison samples whose sample distances satisfy the second predetermined condition are displayed on the client as query results of the query request.
[0016] In a third aspect, a data index establishment device is provided, comprising:
[0017] A model matching module, used for acquiring a segmented clustering model associated with a data volume level according to a data volume level of a data set;
[0018] A primary clustering module, used to input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer;
[0019] A data adding module, used for reading the data sample from the data set, classifying the read data sample into the closest cluster center of the type, and associating N quantizers with the N cluster centers of the type in a one-to-one correspondence;
[0020] A secondary clustering module, used for performing secondary clustering on the data samples associated with each of the quantizers, and determining two types of cluster centers and the data samples associated with each of the two types of cluster centers;
[0021] An index establishment module is used to establish N index tables corresponding to the N quantizers; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center.
[0022] In a third aspect, a data retrieval device is provided, comprising:
[0023] A receiving module, configured to receive a query request containing an image query sample and obtain a query vector of the image query sample;
[0024] A data retrieval module, configured to obtain, from all the two-category cluster centers included in the index table, a two-category cluster center whose distance to the query vector satisfies a first predetermined condition, and determine data samples corresponding to the two-category cluster centers satisfying the first predetermined condition as image comparison samples;
[0025] A calculation module, used to determine a sample distance between the image comparison sample and the image query sample;
[0026] The display module is used to display the image comparison samples whose sample distances satisfy the second predetermined condition as query results of the query request on the client.
[0027] In a fifth aspect, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data index establishment method and the above-mentioned data retrieval method when executing the computer-readable instructions.
[0028] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the above-mentioned data index establishment method and the above-mentioned data retrieval method are implemented.
[0029] The data index establishment, data retrieval method, device, equipment and storage medium provided by the present invention, in the process of data index establishment, firstly, according to data sets of different data volume levels, different segmented clustering models are selected to cluster the data samples in the data set once to obtain different first-class cluster centers, and then a quantizer associated with the first-class cluster center is used to perform secondary clustering to obtain different second-class cluster centers, and an index table is obtained based on the different second-class cluster centers, thereby improving the clustering effect and the accuracy of the cluster centers; and in the process of data retrieval, the index table obtained in the process of data index establishment is used to perform image data retrieval, and the fragments of certain data samples can be quickly located through a relatively low-cost coarse query, thereby greatly reducing the number of sample calculations, improving the computing speed of the server, and realizing high-precision and high-efficiency image data retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0031] Figure 1 It is a schematic diagram of an application environment of a data index establishment and data retrieval method in one embodiment of the present invention;
[0032] Figure 2 is a flow chart of a method for establishing a data index in one embodiment of the present invention;
[0033] Figure 3 is a flow chart of step S20 of a method for establishing a data index in one embodiment of the present invention;
[0034] Figure 4 is a flow chart of a data retrieval method in another embodiment of the present invention;
[0035] Figure 5 is a principle block diagram of a data index establishment device in one embodiment of the present invention;
[0036] Figure 6 is a principle block diagram of a data retrieval device in one embodiment of the present invention;
[0037] Figure 7 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] The data index establishment method provided by the present invention can be applied to Figure 1 In an application environment, a client communicates with a server via a network. The client includes, but is not limited to, various personal computers, laptops, smart phones, tablet computers, cameras, and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers.
[0040] In one embodiment, if Figure 2 As shown, a data index establishment method is provided, and the method is applied in Figure 1 The server in the example is used to illustrate the following steps:
[0041] S10, according to the data volume level of the data set, obtaining a segmented clustering model associated with the data volume level.
[0042] Among them, the data volume level can be set according to demand; optionally, the data volume level of the data set can be set to the initial level, the first level, the second level, the third level, the fourth level and the fifth level, and the data volume of the data set corresponding to each data volume level is respectively: 100,000, 200,000, 400,000, 800,000, 1.6 million and 3.2 million. It is understandable that in the process of obtaining the cluster center from the training data, if the data volume level of the data set is higher, the system will occupy more memory and take longer time during the training process, so it is necessary to comprehensively consider the system memory and time consumption to select a data set with a suitable data volume level.
[0043] Specifically, when a data set to be trained is obtained, each data sample in the statistical data set is used to determine the data volume of the data set, and a data volume level corresponding to the data volume is matched from a database, thereby obtaining a segmented clustering model associated with the data volume level from the database. Preferably, each data volume level in the database is pre-associated with and stored with a segmented clustering model.
[0044] S20, input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer.
[0045] That is, in the process of obtaining cluster centers from training data, different segmented clustering models are used to cluster the data samples in the data set according to data sets with different data volume levels to obtain different cluster centers.
[0046] Preferably, a segmented clustering model is used to cluster the data samples in the data set, specifically including the following steps: first, according to the preselected number contained in the segmented clustering model, for example, the preselected number is S, S data samples for clustering are randomly selected from all the input data samples; wherein the preselected number refers to the number of data samples selected by the segmented clustering model from all the input data samples for clustering. For example, for the initial level data set, the amount of data samples contained in the initial level data set is greater than or equal to 100,000, and 100,000 data samples can be selected for clustering; for the first level data set, the amount of data samples contained in the first level data set is greater than or equal to 200,000, and 200,000 data samples can be selected for clustering, etc.
[0047] Secondly, each feature vector of each data sample in the S data samples is obtained; wherein the dimension of the corresponding feature vector in each data sample is the same.
[0048] Again, according to the number of segments included in the segmented clustering model, for example, the number of segments is M, the feature vector of each of the above S data samples is segmented according to the preset dimension to form M segmented vectors corresponding to each feature vector after segmentation, and each segmented vector contains the amount of data of the preset dimension; wherein the number of segments refers to the number of segments into which the segmented clustering model segments the feature vector of each of the S data samples, and the number of segments is preset in the segmented clustering model. It is understandable that the amount of data contained in the segmented vector can be determined according to the preset dimension and the dimension of each feature vector.
[0049] Finally, cluster the segment vectors corresponding to the same segment in each feature vector corresponding to the S data samples, determine the K one-class cluster centers corresponding to each same segment, and then determine and output One-class cluster centers are determined, that is, N one-class cluster centers are determined and output. It can be understood that since each feature vector corresponding to the S data samples is divided into M segments, and since K one-class cluster centers are determined for each segment, a total of One-class cluster centers, at this time, a total of Cluster centers can express K to the power of M cluster centers, and the number of cluster centers of a type corresponding to each segment vector of the same segment and the number of cluster centers of a type output by the segment clustering model have the following relationship: N=M*K.
[0050] S30, reading the data sample from the data set, classifying the read data sample into the closest cluster center, and associating N quantizers with the N cluster centers in a one-to-one correspondence.
[0051] Preferably, a data sample is read from the data set with a preset addition amount, and a cluster center of a class closest to the read data sample is found and added to the quantizer. At this time, all data samples classified into the cluster center of a class are associated with the quantizer; wherein the addition amount refers to the number of data samples read in batches, that is, the number of data samples classified into the cluster center of a class in batches. For example, when the addition amount is 10,000, the distance between 10,000 data samples and each cluster center of a class is calculated, that is, the sum of the squares of the differences between 10,000 data samples and each cluster center of a class is calculated, and a cluster center of a class with the smallest sum of squares of the differences is selected, and it is recorded as the cluster center of a class closest to the distance, and then the 10,000 data samples are classified into the cluster center of a class closest to the distance and added to the quantizer.
[0052] S40, performing secondary clustering on the data samples associated with each of the quantizers to determine two types of cluster centers and the data samples associated with each of the two types of cluster centers.
[0053] That is, all data samples associated with N quantizers are clustered again. For example, when all data samples associated with the quantizer are X, the feature vector of each data sample in the X data samples is obtained; then the feature vector of each data sample in the X data samples is divided according to the dimension, and divided into Segments to form the corresponding segmentation of each feature vector Segment vectors are then clustered for each segment of the X data samples to determine the segment vectors corresponding to each segment. Component cluster centers, thereby determining It is understandable that the secondary clustering method in step S40 can refer to the primary clustering method in step S30.
[0054] S50, establishing N index tables corresponding to the N quantizers; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center.
[0055] It is understandable that N index tables can be established by performing secondary clustering on all data samples associated with N quantizers. After finding the two-class cluster centers, the distance between each data sample associated with each quantizer and each two-class cluster center is calculated, that is, the distance between the original feature vector and each segment center vector (each two-class cluster center corresponds to a segment center vector) is calculated, and each data sample associated with each quantizer is classified into the two-class cluster center with the closest distance. Furthermore, an index table is established based on each two-class cluster center and the original feature vector classified into the two-class cluster center.
[0056] Preferably, in order to further improve the retrieval efficiency and accuracy, three or more clusterings may be performed, that is, after the second clustering, the index is constructed and then the next clustering is performed.
[0057] To sum up, in the process of establishing data indexes, this embodiment first selects different segmented clustering models to cluster the data samples in the data set according to the data sets with different data volume levels, and obtains different first-class cluster centers. Secondly, a secondary clustering is performed using the quantizer associated with the first-class cluster center to obtain different second-class cluster centers, and an index table is obtained based on the different second-class cluster centers. After experimental verification, for data sets with a data volume of more than several million, the clustering effect is better, and the accuracy of the cluster center can be improved by 5%-10%; and this embodiment can further improve the clustering effect through multiple segmented clustering, and can use a smaller set of cluster centers to express a very large set of cluster centers, thereby shortening the retrieval time by at least half, which is conducive to improving the retrieval speed.
[0058] In one embodiment, before step S10, that is, before obtaining the segmented clustering model associated with the data volume level according to the data volume level of the data set, the following steps are included:
[0059] First, the data volume of the data samples contained in the data set is obtained, and the data volume is input into a preset output model; then, the data volume level output by the output model is received, and the data volume level of the data set is determined.
[0060] Preferably, the output model is:
[0061]
[0062] in, is the data volume level; is the level coefficient; is the data volume; is the initial quantity corresponding to the initial level.
[0063] Optionally, is 1, is 100000.
[0064] In summary, this embodiment automatically calculates the data volume level of a data set through an output model, thereby providing output with higher accuracy and efficiency.
[0065] In one embodiment, if Figure 3 As shown, the step S20, i.e., inputting all data samples in the data set into the segmented clustering model and receiving N first-class cluster centers output by the segmented clustering model, specifically includes the following steps:
[0066] S201, using the segmented clustering model, determining a preselected number of the data samples and corresponding feature vectors from all the data samples.
[0067] In this embodiment, S data samples for primary clustering are determined from all data samples according to the preselected number included in the segmented clustering model, for example, the preselected number is S. The preselected number refers to the number of data samples selected by the segmented clustering model from all input data samples for primary clustering.
[0068] Furthermore, the feature extraction model included in the segmented clustering model is used to identify each of the S data samples, and multiple feature elements of each data sample are obtained, and these feature elements are used as vector elements to construct a feature vector for each data sample; for example, when the data samples are image data samples, the image recognition model included in the segmented clustering model is used to identify the image samples, and feature elements such as the number of pixels, grayscale mean, grayscale median, number of sub-regions, and sub-region grayscale mean contained in each image sample are obtained, and a feature vector is constructed based on these feature elements.
[0069] S202: Segment each of the feature vectors according to the dimension by using a segment clustering model to form a segment vector corresponding to each segment in each of the feature vectors.
[0070] In this embodiment, according to the number of segments included in the segmented clustering model, for example, the number of segments is M, the feature vector of each of the above S data samples is segmented according to the dimension to form M segmented vectors corresponding to each feature vector after segmentation.
[0071] S203, clustering the segment vectors corresponding to the same segments in each feature vector using a segment clustering model, and determining K first-class cluster centers corresponding to each segment; K is a positive integer.
[0072] Preferably, first detect whether the number of segmented vectors corresponding to each identical segment (the number of segmented vectors is M) is greater than the number of cluster clusters (the number of cluster clusters is K). When the number of segmented vectors corresponding to each identical segment is greater than the number of cluster clusters, detect whether the number of segmented vectors corresponding to each identical segment is greater than a first threshold, wherein the first threshold is the product of the number of cluster clusters and the minimum storage number contained in each cluster cluster (for example, the minimum storage number is 39); otherwise, issue an alarm message.
[0073] Secondly, when the number of segmented vectors corresponding to each identical segment is greater than the first threshold, detect whether the number of segmented vectors corresponding to each identical segment is greater than the second threshold (for example, the minimum storage number is 256), wherein the second threshold is the product of the number of clusters and the maximum storage number contained in each cluster; otherwise, an alarm message is issued.
[0074] Again, when the number of segmented vectors corresponding to each identical segment is greater than the second threshold, a preset number of segmented vectors are randomly selected for clustering processing by the segmented clustering model, and then K segmented vectors are randomly selected from the preset number of segmented vectors as a class of clustering centers, and the K class of clustering centers are added to the quantizer; otherwise, K segmented vectors are randomly selected directly from the segmented vectors corresponding to each identical segment as a class of clustering centers, and the K class of clustering centers are added to the quantizer.
[0075] Finally, the K one-class cluster centers in the quantizer are used for iteration. That is, the nearest one-class cluster center of each segment vector used for clustering processing by the segment clustering model is found and the distance is calculated, and the K one-class cluster centers are updated according to the calculated distance, and then the quantizer is updated until the number of iterations is greater than the preset iteration threshold. At this time, the K one-class cluster centers corresponding to each segment are determined. It can be understood that when the number of iterations is greater than the preset iteration threshold, the K one-class cluster centers no longer change, or the sum of squares of the errors between each segment vector assigned to each one-class cluster center and the corresponding one-class cluster center is minimized, or no segment vector is reclassified into the K one-class cluster centers.
[0076] S204: Determine N first-class cluster centers output by the segmented clustering model according to the K first-class cluster centers corresponding to each segment.
[0077] That is, by accumulating the K one-class cluster centers corresponding to each segment, we can obtain the N one-class cluster centers output by the segmented clustering model.
[0078] In summary, using the segmented clustering model to cluster the input data samples once reduces the amount of data in a set of cluster centers, thereby reducing memory usage and improving the server's operating speed; at the same time, it has a clustering effect with no isolated points, high compactness, and high separation.
[0079] In one embodiment, if Figure 4 As shown, a data retrieval method is provided, wherein the data retrieval method uses the index table obtained by the data index establishment method described in the above embodiment to retrieve image data, and when the data retrieval method is applied in Figure 1 When the data retrieval method is applied to a server in the data storage medium, the data retrieval method and the data index establishment method can be applied to the same server; and when the data retrieval method is applied to other servers, the data retrieval method and the data index establishment method can be applied to different servers. The data retrieval method comprises the following steps:
[0080] S60: Receive a query request including an image query sample, and obtain a query vector of the image query sample.
[0081] That is, after receiving a query request containing an image query sample, the server uses a preset image recognition model to identify the image query sample, obtains feature elements such as the number of pixels, grayscale mean, grayscale median, number of sub-regions, and sub-region grayscale mean contained in the image query sample, and constructs a query vector based on these feature elements. The query instruction refers to the one sent to the server by the user after entering the image sample in the preset search bar of the client.
[0082] S70, obtaining, from all the second-category cluster centers included in the index table, second-category cluster centers whose distances from the query vector satisfy a first predetermined condition, and determining data samples corresponding to the second-category cluster centers satisfying the first predetermined condition as image comparison samples.
[0083] In this embodiment, if the index tables obtained by the data index establishment method described in the above embodiment are directly stored in the database, then the index tables are directly obtained from the database; if the index tables obtained by the data index establishment method described in the above embodiment are stored on an external server, then the configuration parameters of each index table are first obtained, and then each index table is obtained from the external server according to the access path contained in the configuration parameters.
[0084] After obtaining each index table, by querying each index table, a second-class cluster center whose distance to the query vector meets the first predetermined condition can be determined from all the second-class cluster centers recorded in each index table, and recorded as the selected cluster center.
[0085] In one embodiment, the first predetermined condition is that the distance is less than a first distance threshold. At this time, if the total number of the two types of cluster centers is , calculate the distance between each second-class cluster center (that is, segment center vector) in the index table and the query vector, and for the calculated distances, determine one or more second-class cluster centers that are less than the first distance threshold, and record them as selected cluster centers.
[0086] Furthermore, before recording the selected cluster center, the nearest second-category cluster center is determined from the determined two-category cluster centers and recorded as the selected cluster center; at this time, when the number of determined two-category cluster centers is one, the determined two-category cluster center is the closest two-category cluster center and is recorded as the final selected cluster center; and when the number of determined two-category cluster centers is multiple, the closest two-category cluster center is determined based on the multiple distances calculated and recorded as the final selected cluster center.
[0087] In another embodiment, the first predetermined condition is a predetermined number or a predetermined ratio of the minimum distance. In this case, if the predetermined number is 3, the calculated Among the distances, the three second-class cluster centers with the smallest distances are determined in order of distance from small to large, and recorded as the final selected cluster centers; if the predetermined ratio is 3%, the calculated The distance is 100, and the three two-class cluster centers with the smallest distance are determined in order from small to large.
[0088] It can be understood that after the selected cluster center (the second-class cluster center whose distance to the query vector meets the first predetermined condition) is determined from the index table, the data sample corresponding to the selected cluster center is determined from the index table as the image comparison sample.
[0089] It should be noted that if the index table obtained by indexing using the data indexing method described in the above embodiment is used to retrieve image data, the data set used in the indexing process is a data set containing image data samples, and each index in the index table includes a two-category cluster center and all image data samples associated with the two-category cluster center.
[0090] S80: Determine a sample distance between the image comparison sample and the image query sample.
[0091] That is, the Euclidean distance between the feature vector of the image comparison sample and the query vector of the image query sample can be determined as the sample distance, and the cosine similarity between the feature vector of the image comparison sample and the query vector of the image query sample can also be determined as the sample distance.
[0092] In another embodiment, in order to reduce the amount of calculation and improve the calculation speed, the segment distances corresponding to the image comparison sample and the image query sample in each segment can be calculated, that is, the distances between each segment vector of the image comparison sample and each segment query vector of the image query sample are calculated (a segment vector of an image comparison sample corresponds to a segment query vector of an image query sample), and the sample distance is determined based on each segment distance.
[0093] S90: Display the image comparison samples whose sample distances satisfy a second predetermined condition as query results of the query request on the client.
[0094] In one embodiment, the second predetermined condition is that the sample distance is less than the second distance threshold. At this time, after calculating the sample distances between the image query sample and each image comparison sample in the above step S90, at least one image comparison sample whose sample distance is less than the second distance threshold is determined from all the image comparison samples, and is displayed on the client as the query result of the query request.
[0095] In another embodiment, the second predetermined condition is a predetermined number or a predetermined ratio of samples with the smallest distance. In this case, after the sample distances between the image query sample and each image comparison sample are calculated in the above step S90, the predetermined number or a predetermined ratio of image comparison samples with the smallest distances are determined from all the image comparison samples in the order of the sample distances from small to large, and are displayed on the client as the query result of the query request.
[0096] To summarize, in the data retrieval process, this embodiment uses the index table obtained in the data index establishment process to perform image data retrieval. Through a relatively low-cost coarse query (only a relatively small number of second-class cluster centers are required), the fragments of certain data samples can be quickly located, thereby greatly reducing the number of sample calculations, improving the server's computing speed, and achieving high-precision and high-efficiency image data retrieval.
[0097] In one embodiment, the data retrieval method may also use the index table obtained by the data index establishment method in the above embodiment to perform text data retrieval, specifically comprising the following steps:
[0098] Receive a query request containing a text query sample, obtain a query vector of the text query sample (the query vector can be generated based on a combination of feature elements such as the number of words, word frequency, unit segmentation, and multi-word segmentation in the text query sample); obtain a second-class cluster center whose distance to the query vector meets a third predetermined condition from all the second-class cluster centers contained in the index table, and determine the data sample corresponding to the second-class cluster center that meets the third predetermined condition as a text comparison sample; determine the sample distance between the text comparison sample and the text query sample; and display the audio comparison sample whose sample distance meets a fourth predetermined condition as a query result of the query request on the client.
[0099] It should be noted that if the index table obtained by indexing using the data indexing method described in the above embodiment is used to retrieve text data, the data set used in the indexing process is a data set containing text data samples, and each index in the index table includes a two-category cluster center and all text data samples associated with the two-category cluster center.
[0100] In one embodiment, the data retrieval method can also use the index table obtained by the data index establishment method in the above embodiment to retrieve other data such as music data or video data. The detailed instructions for using the index table obtained by the data index establishment method in the above embodiment to retrieve other data can refer to the detailed instructions for using the index table obtained by the data index establishment method in the above embodiment to retrieve image data or text data.
[0101] In one embodiment, if Figure 5 As shown, a data index establishment device is provided, which corresponds to the data index establishment method in the above embodiment. The data index establishment device includes a model matching module 110, a primary clustering module 120, a data adding module 130, a secondary clustering module 140 and an index establishment module 150. The functional modules are described in detail as follows:
[0102] The model matching module 110 is used to obtain a segmented clustering model associated with the data volume level according to the data volume level of the data set.
[0103] The primary clustering module 120 is used to input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer.
[0104] The data adding module 130 is used to read the data samples from the data set, classify the read data samples into the closest cluster center, and associate N quantizers with the N cluster centers in a one-to-one correspondence.
[0105] The secondary clustering module 140 is used to perform secondary clustering on the data samples associated with each of the quantizers to determine two types of cluster centers and the data samples associated with each of the two types of cluster centers.
[0106] The index establishment module 150 is used to establish N index tables corresponding to the N quantizers; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center.
[0107] In one embodiment, the model matching module 110 includes the following units, and each functional unit is described in detail as follows:
[0108] The input unit is used to obtain the data volume of the data samples contained in the data set and input the data volume into a preset output model.
[0109] The output unit is used to receive the data volume level output by the output model and determine the data volume level of the data set.
[0110] In one embodiment, in the data indexing device, the output model is:
[0111]
[0112] in, is the data volume level; is the level coefficient; is the data volume; is the initial quantity corresponding to the initial level.
[0113] In one embodiment, the primary clustering module 120 includes the following units, and each functional unit is described in detail as follows:
[0114] The vector acquisition unit is used to determine a preselected number of the data samples and corresponding feature vectors from all the data samples by using the segmented clustering model.
[0115] The vector segmentation unit is used to segment each of the feature vectors according to the dimension by using the segmentation clustering model to form a segmentation vector corresponding to each segment in each of the feature vectors.
[0116] The segmented clustering unit is used to cluster the segmented vectors corresponding to each identical segment in each feature vector using a segmented clustering model, and determine K first-class clustering centers corresponding to each segment; K is a positive integer.
[0117] The result determination unit is used to determine the N first-class cluster centers output by the segmented clustering model according to the K first-class cluster centers corresponding to each segment.
[0118] In one embodiment, if Figure 6 As shown, a data retrieval device is provided, which corresponds to the data retrieval method in the above embodiment. The data retrieval device includes a receiving module 160, a data retrieval module 170, a calculation module 180 and a display module 190. The functional modules are described in detail as follows:
[0119] The receiving module 160 is configured to receive a query request including an image query sample and obtain a query vector of the image query sample.
[0120] The data retrieval module 170 is used to obtain the second-category cluster center whose distance to the query vector satisfies a first predetermined condition from all the second-category cluster centers contained in the index table, and determine the data samples corresponding to the second-category cluster centers that meet the first predetermined condition as image comparison samples.
[0121] The calculation module 180 is used to determine the sample distance between the image comparison sample and the image query sample.
[0122] The display module 190 is configured to display the image comparison samples whose sample distances satisfy the second predetermined condition as query results of the query request on the client.
[0123] In one embodiment, in the data retrieval device, the first predetermined condition is that the distance is less than a first distance threshold; and the second predetermined condition is that the sample distance is less than a second distance threshold.
[0124] For the specific definition of the data index establishment device, please refer to the definition of the data index establishment method above, which will not be repeated here. Each module in the above-mentioned data index establishment device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0125] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer-readable instructions and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. When the computer-readable instructions are executed by the processor, a data index establishment method is implemented.
[0126] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the data index establishment method and the data retrieval method in the above-mentioned embodiment are implemented.
[0127] In one embodiment, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the data index establishment method and the data retrieval method in the above embodiment are implemented.
[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0129] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units or modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units or modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0130] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for establishing a data index, It is characterized in that include: According to the data volume level of the data set, obtaining a segmented clustering model associated with the data volume level; Input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer; Reading the data sample from the data set, classifying the read data sample into the closest cluster center of the type, and associating N quantizers with the N cluster centers of the type one in a one-to-one correspondence; Performing secondary clustering on the data samples associated with each of the quantizers to determine two types of cluster centers and the data samples associated with each of the two types of cluster centers; Establishing N index tables corresponding to the N quantizers; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center; Before obtaining the segmented clustering model associated with the data volume level according to the data volume level of the data set, the method includes: Obtaining the data volume of the data samples included in the data set, and inputting the data volume into a preset output model; receiving the data volume level output by the output model, and determining the data volume level of the data set; the data volume levels of the data set are initial level, first level, second level, third level, fourth level and fifth level, and the data volume of the data set corresponding to each data volume level is 100,000, 200,000, 400,000, 800,000, 1.6 million and 3.2 million respectively; The step of inputting all data samples in the data set into the segmented clustering model and receiving N first-class cluster centers output by the segmented clustering model comprises: Determining a preselected number of the data samples and corresponding feature vectors from all the data samples using the segmented clustering model; Using a segmented clustering model to segment each of the feature vectors according to the dimension, so as to form a segmented vector corresponding to each segment in each of the feature vectors; The segmented vectors corresponding to the same segments in each feature vector are clustered using the segmented clustering model to determine K first-class cluster centers corresponding to each segment; K is a positive integer; According to the K cluster centers of the first category corresponding to each segment, the N cluster centers of the first category output by the segmented clustering model are determined.
2. The data indexing method according to claim 1, It is characterized in that The output model is: in, is the data volume level; is the level coefficient; is the data volume; is the initial quantity corresponding to the initial level.
3. A data retrieval method, It is characterized in that The data retrieval method uses the index table obtained by the data index establishment method according to any one of claims 1 to 2 to perform image data retrieval, comprising: Receiving a query request including an image query sample, and obtaining a query vector of the image query sample; From all the two-category cluster centers included in the index table, obtain the two-category cluster centers whose distances from the query vector meet a first predetermined condition, and determine the data samples corresponding to the two-category cluster centers that meet the first predetermined condition as image comparison samples; Determining a sample distance between the image comparison sample and the image query sample; The image comparison samples whose sample distances satisfy the second predetermined condition are displayed on the client as query results of the query request.
4. The data retrieval method according to claim 3, It is characterized in that The first predetermined condition is that the distance is less than a first distance threshold; the second predetermined condition is that the sample distance is less than a second distance threshold.
5. A data indexing device, It is characterized in that include: A model matching module, used for acquiring a segmented clustering model associated with a data volume level according to a data volume level of a data set; A primary clustering module, used to input all data samples in the data set into the segmented clustering model, and receive N first-class cluster centers output by the segmented clustering model; N is a positive integer; A data adding module, used for reading the data sample from the data set, classifying the read data sample into the closest cluster center of the type, and associating N quantizers with the N cluster centers of the type in a one-to-one correspondence; A secondary clustering module, used for performing secondary clustering on the data samples associated with each of the quantizers, and determining two types of cluster centers and the data samples associated with each of the two types of cluster centers; An index establishment module, used for establishing N index tables corresponding to the N quantizers; each of the index tables contains at least one index, and each index includes a two-category cluster center and all the data samples associated with the two-category cluster center; The model matching module comprises: An input unit, used to obtain the data volume of the data samples included in the data set, and input the data volume into a preset output model; an output unit, used to receive the data volume level output by the output model, and determine the data volume level of the data set; the data volume levels of the data set are initial level, first level, second level, third level, fourth level and fifth level, and the data volume of the data set corresponding to each data volume level is 100,000, 200,000, 400,000, 800,000, 1.6 million and 3.2 million respectively; The primary clustering module comprises: A vector acquisition unit, used to determine a preselected number of the data samples and corresponding feature vectors from all the data samples using the segmented clustering model; A vector segmentation unit, used for segmenting each of the feature vectors according to the dimension by using a segmentation clustering model, so as to form a segmentation vector corresponding to each segment in each of the feature vectors; The segmented clustering unit is used to cluster the segmented vectors corresponding to the same segments in each feature vector using the segmented clustering model, and determine K first-class clustering centers corresponding to each segment; K is a positive integer; The result determination unit is used to determine the N first-class cluster centers output by the segmented clustering model according to the K first-class cluster centers corresponding to each segment.
6. A data retrieval device, It is characterized in that The data retrieval device uses the index table obtained by the data index establishment device according to claim 5 to perform image data retrieval, comprising: A receiving module, configured to receive a query request containing an image query sample and obtain a query vector of the image query sample; A data retrieval module, configured to obtain, from all the two-category cluster centers included in the index table, a two-category cluster center whose distance to the query vector satisfies a first predetermined condition, and determine data samples corresponding to the two-category cluster centers satisfying the first predetermined condition as image comparison samples; A calculation module, used to determine a sample distance between the image comparison sample and the image query sample; The display module is used to display the image comparison samples whose sample distances satisfy the second predetermined condition as query results of the query request on the client.
7. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer-readable instructions, the data index establishment method according to any one of claims 1 to 2 and the data retrieval method according to any one of claims 3 to 4 are implemented.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the data index establishment method according to any one of claims 1 to 2 and the data retrieval method according to any one of claims 3 to 4 are implemented.
