WO2020098110A1 - 图像特征值的搜索方法、装置、电子设备及存储介质 - Google Patents

图像特征值的搜索方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2020098110A1
WO2020098110A1 PCT/CN2018/124832 CN2018124832W WO2020098110A1 WO 2020098110 A1 WO2020098110 A1 WO 2020098110A1 CN 2018124832 W CN2018124832 W CN 2018124832W WO 2020098110 A1 WO2020098110 A1 WO 2020098110A1
Authority
WO
WIPO (PCT)
Prior art keywords
feature value
sub
query
searched
image feature
Prior art date
Application number
PCT/CN2018/124832
Other languages
English (en)
French (fr)
Inventor
戴世稳
Original Assignee
深圳云天励飞技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳云天励飞技术有限公司 filed Critical 深圳云天励飞技术有限公司
Publication of WO2020098110A1 publication Critical patent/WO2020098110A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/53Querying
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the field of image search technology, and in particular, to an image feature value search method, device, electronic device, and storage medium.
  • the similarity search tool Faiss is the best similarity search algorithm library, but when the amount of data continues to increase, for example: image feature value data reaches tens of billions, even hundreds of billions, similarity search tool Faiss search Speed will still face huge challenges. It can be seen that in the current image feature value search technology, due to the rapid expansion of the data volume, the search speed is still not fast.
  • the main purpose of the present invention is to provide an image feature value search method, device, electronic device, and storage medium, to solve the problem that the search speed is still not fast due to the rapid expansion of data volume in the current image feature value search technology.
  • the first aspect of the embodiments of the present invention provides an image feature value search method, including:
  • the query vector is segmented to obtain multiple query sub-vectors, and the multiple query sub-vectors and the pre-obtained multiple sub-vectors Space one-to-one correspondence;
  • the sample image feature value and each pending The steps to search for the asymmetric distance between image feature values include:
  • the method further includes:
  • the feature value of the to-be-searched image is segmented to obtain multiple sub-segments of the feature value of the to-be-searched image; wherein, the multiple sub-segments One-to-one correspondence with the multiple subspaces;
  • a clustering algorithm is used to cluster all sub-segments existing in the subspace to obtain multiple clustering centers;
  • the coding of the clustering center is used as the quantization coding of the sub-segments clustered under the clustering center, and the quantization codings of all sub-segments are stored in the plurality of index objects.
  • the step of performing a parallel search from a plurality of index objects used to store the plurality of image feature values to be searched based on all the obtained asymmetric distances to obtain the target image feature values further includes :
  • the image feature value to be searched corresponding to the target asymmetric distance is determined, and the The image feature value to be searched is used as the target image feature value.
  • a second aspect of an embodiment of the present invention provides an image feature value search device, including:
  • the first division module is used to obtain multiple query sub-vectors by segmenting the query vector when obtaining the query vector for searching the target image feature value matching the sample image feature value, the multiple queries
  • the subvectors correspond to multiple subspaces obtained in advance;
  • a calculation module used to calculate the distance from each query sub-vector in the plurality of query sub-vectors to all cluster centers in the sub-space corresponding to the query sub-vector, the cluster center passes the memory of the sub-space Clustering the sub-segments of multiple image features to be searched;
  • An obtaining module configured to obtain the feature value of the sample image and each to-be-searched according to the distance from each query sub-vector of the plurality of query sub-vectors to all cluster centers in the subspace corresponding to the query sub-vector Asymmetrical distance between image feature values;
  • the search module is configured to perform a parallel search from a plurality of index objects used to store the plurality of image feature values to be searched based on all the asymmetric distances obtained to obtain the target image feature value.
  • a third aspect of the embodiments of the present invention provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor.
  • the processor implements the computer program when the processor executes the computer program. Steps in the search method of image feature values.
  • a fourth aspect of the embodiments of the present invention provides a computer-readable storage medium that stores a computer program, which when executed by a processor implements the steps in the above-described image feature value search method.
  • the query vector is segmented to obtain multiple query sub-vectors, and the multiple query sub-vectors are different from the previously obtained multiple
  • the subspaces are in one-to-one correspondence; calculate the distance from each query subvector in the plurality of query subvectors to all cluster centers in the subspace corresponding to the query subvector.
  • the cluster centers pass the subspace All sub-segments of the plurality of image feature values to be searched in the cluster are obtained by clustering; according to each query sub-vector of the plurality of query sub-vectors to all cluster centers in the sub-space corresponding to the query sub-vector Distance to obtain the asymmetric distance between the feature value of the sample image and the feature value of each image to be searched; based on all the obtained asymmetric distances, from multiple indexes used to store the feature values of the multiple image to be searched Perform parallel search in the object to obtain the target image feature value.
  • the query vector is divided into query sub-vectors.
  • the query vector with higher dimensions is subdivided, which is the same as the feature value of the image to be searched into multiple sub-segments during the data storage stage.
  • Vectors and sub-segments are more conducive to improving the similarity accuracy of the search;
  • the asymmetric distance can directly ensure that the calculated distance is closer to the sample image because the distance between the sample image feature value and the quantized image feature value to be searched is calculated directly
  • the true distance between the feature value and the feature value of the image to be searched can also improve the accuracy of the search; parallel search from multiple index objects that store less data is performed than searching from an index object that stores a large amount of data The efficiency is much higher, so that when the amount of data continues to increase, the search speed of the image feature value can also be increased.
  • FIG. 1 is a schematic flowchart of an image feature value search method according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of an example of a scenario provided by an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of another image feature value search method according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of another scenario example provided by an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of an image feature value search device according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of another image feature value search device according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of another image feature value search device according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of another image feature value search device according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of another image feature value search device according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of another image feature value search device according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of an image feature value search method according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • the query vector is segmented to obtain multiple query subvectors, and the multiple query subvectors are obtained Multiple subspaces correspond to each other.
  • all image feature values refer to image feature values with higher dimensions, for example, 128 dimensions.
  • a large amount of feature value data can be used for pattern training to form a spatial segmentation, clustering, and quantization coding mode, and finally an index object index based on product quantization is obtained.
  • the feature value of the sample image may be a given feature value, or may be a feature value extracted from a given image.
  • the target image feature value is obtained from the pre-stored image feature value to be searched, and matches the search result of the sample image feature value.
  • the query vector used to search for the target image feature value may be pre-built or It's only built when searching. If the query vector is obtained, then according to the process of pattern training, the query vector is first segmented to obtain multiple query sub-vectors of the query vector, and the multiple query sub-vectors correspond one-to-one to the multiple sub-spaces described above. For example, if the query vector is divided into two query sub-vectors, then query sub-vector No. 1 corresponds to sub-space No. 1 and query sub-vector No. 2 corresponds to sub-space No. 2.
  • each of the image feature values to be searched in the plurality of image feature values to be searched includes multiple sub-segments with the same number of query subvectors, and each The segments also correspond one-to-one to the above-mentioned multiple subspaces.
  • one of the image feature values to be searched has 2 sub-segments, namely sub-segment 1 and sub-segment 2, corresponding sub-segment 1 corresponds to subspace 1 and sub-segment 2 corresponds to 2 Within the subspace. It should be noted that, due to the large number of image feature values to be searched, there are also a large number of sub-segments in each sub-space.
  • a clustering center is a clustering algorithm in which a large number of sub-segments of the image feature value to be searched exist in the subspace, and the number of clustering centers in each subspace is the same.
  • the distance between each query subvector and all cluster centers in its corresponding subspace needs to be calculated.
  • the No. 1 query subvector corresponds to the No. 1 subspace, and all sub-segments in the No. 1 subspace are clustered to obtain 256 cluster centers. Then, it is necessary to separately calculate the No. 1 query subvector to the 256 cluster centers.
  • Distance; correspondingly, the query subvector No. 2 also needs to calculate its distance to all cluster centers in the subspace No. 2.
  • the distance from each query subvector to all clustering centers in the subspace corresponding to the query subvector can be used to obtain the sample image feature value and each to be searched through operation
  • the asymmetric distance between the image feature values can of course also be a symmetric distance, and the specific calculation method is not limited here.
  • what actually needs to be calculated in the present invention is the distance from the query vector x to the feature value y of all images to be searched, but since the number of feature values y of the image to be searched may be over one hundred million, the image to be searched The number of code words q (y) corresponding to the index value of the feature value y is much less.
  • the asymmetric distance or symmetric distance between the feature value of the sample image and the feature value of each image to be searched is used to represent the similarity between the two, and the smaller the distance, the higher the similarity.
  • the above-mentioned index object may be pre-built and used to store the quantization coding of multiple sub-segments of each image feature to be searched. Since the number of image feature values to be searched is extremely large, it can be known The quantization coding of all the sub-segments of the image feature value to be searched is also extremely large. Therefore, a data threshold can be set for each index object, for example: the data threshold can be 100 million. When the quantization code saved in the initially created index object reaches the data threshold, a new index object is created for the unsaved quantization The code is saved, and eventually multiple index objects mentioned above will be obtained.
  • search method for image feature values provided by the embodiments of the present invention may be implemented based on some search tools or algorithm libraries for searching similarity media files, for example, the similarity search tool Faiss proposed by the Facebook artificial intelligence research team.
  • the query vector when a query vector for searching a target image feature value matching a sample image feature value is obtained, the query vector is segmented to obtain multiple query sub-vectors, and the multiple query sub-vectors
  • the vectors correspond one-to-one with multiple subspaces obtained in advance; the distance between each query subvector in the multiple query subvectors to all cluster centers in the subspace corresponding to the query subvector is calculated, and the cluster centers Obtained by clustering a plurality of sub-segments of image feature values to be searched in the subspace; according to each query subvector in the plurality of query subvectors into a subspace corresponding to the query subvector Obtain the asymmetric distance between the feature value of the sample image and the feature value of each image to be searched from the distance of all cluster centers; according to all the asymmetric distances obtained, multiple Perform parallel search in the index object of the image feature value to obtain the target image feature value.
  • the query vector is divided into query sub-vectors.
  • the query vector with higher dimensions is subdivided, which is the same as the feature value of the image to be searched into multiple sub-segments during the data storage stage.
  • Vectors and sub-segments are more conducive to improving the similarity accuracy of the search; the asymmetric distance can directly ensure that the calculated distance is closer to the sample image because the distance between the sample image feature value and the quantized image feature value to be searched is calculated directly
  • the true distance between the feature value and the feature value of the image to be searched can also improve the accuracy of the search; parallel search from multiple index objects that store less data is performed than searching from an index object that stores a large amount of data The efficiency is much higher, so that when the amount of data continues to increase, the search speed of the image feature value can also be increased.
  • FIG. 3 is a schematic flowchart of another image feature value search method according to an embodiment of the present invention. As shown in FIG. 3, the method includes the following steps:
  • the query vector when a query vector used to search for a target image feature value that matches a sample image feature value is obtained, the query vector is segmented to obtain multiple query sub-vectors, and the multiple query sub-vectors and the pre-obtained Multiple subspaces correspond to each other.
  • this step is to construct a query vector for searching the feature value of the target image in advance, so that the query vector can be directly obtained during feature value search, and then segmented.
  • step S22 has been described in the above embodiment, and is also applicable to this embodiment, and no more description will be given here.
  • Step S23 further includes:
  • each sub-segment of a feature value of the image to be searched in the corresponding sub-space there is a cluster center to which it belongs.
  • a complete image feature to be searched has 4 sub-segments, the cluster center of sub-segment 1 in sub-space 1 is 24, and sub-segment 2 is in sub-space 2
  • the cluster center to which it belongs is No. 8, the cluster center to which the sub-segment 3 belongs in the sub-space No. 3 is 222, and the cluster center to which the sub-segment No. 4 belongs to the sub-space No. 4 is No. 155, then, it is necessary to confirm the cluster centers to which the four sub-segments of the complete image feature value to be searched belong: No. 24, No. 8, No. 222, and No. 155.
  • S232 Determine the distance from each query subvector in the plurality of query subvectors to the cluster center to which each subsegment belongs in the subspace where the subsegment is located;
  • S233 Perform a sum operation on all the determined distances to obtain the asymmetric distance between the feature value of the sample image and the feature value of the image to be searched.
  • 1, 2, 3, and 4 query subvectors of a query vector correspond to subspace 1, subspace 2, subspace 3, and subspace 4, respectively.
  • Determine the distance from No. 1 query subvector to No. 24 cluster center in No. 1 subspace, No. 2 query subvector to No. 8 cluster center in No. 2 subspace, No. 3 query subvector to No. 3 subspace The distance from cluster center No. 222 and the distance from query sub-vector No. 4 to cluster center No. 155 in subspace No. 4, and then sum the four confirmed distances to obtain the sample image feature value and a pending Search for asymmetric distances between image feature values.
  • step S24 has been described in the above embodiment, and is also applicable to this embodiment, so no more description is provided here.
  • the The method before the step of calculating the distance from each query subvector in the plurality of query subvectors to all cluster centers in the subspace corresponding to the query subvector, the The method also includes:
  • the feature value of the to-be-searched image is segmented to obtain multiple sub-segments of the feature value of the to-be-searched image; wherein, the multiple sub-segments One-to-one correspondence with the multiple subspaces;
  • a clustering algorithm is used to cluster all sub-segments existing in the subspace to obtain multiple clustering centers;
  • the coding of the clustering center is used as the quantization coding of the sub-segments clustered under the clustering center, and the quantization codings of all sub-segments are stored in the plurality of index objects.
  • the present invention when storing a large number of image feature values to be searched, it is necessary to divide the high-dimensional image feature values to be searched to obtain a subspace and a subspace corresponding to the query subvectors.
  • each sub-space there are a large number of sub-segments of the image feature value to be searched.
  • a clustering algorithm is used to cluster all the sub-segments to obtain multiple clustering centers. Then, the sub-segments in each sub-space are quantized and encoded, and stored in the index object.
  • N 128-dimensional image feature values to be searched are divided into 4 32-dimensional sub-segments, and 4 sub-spaces are obtained at the same time.
  • cluster in each subspace cluster all the sub-segments in the subspace to obtain 256 cluster centers, and then use the coding of the cluster center to approximate the clustering to this Decimal quantization coding of the sub-segments in the clustering center to obtain the quantization coding matrix of the 4 sub-segments of all image features to be searched.
  • the quantization codes of the four sub-segments of the first image feature value to be searched among the N image features to be searched are 124, 56, 132, and 222, respectively.
  • the quantization codes of all sub-segments of the image feature value to be searched are stored in the index object. Since the set of quantization codes of all the sub-segments constitutes a codebook, it can be understood that each index object has a Codebook.
  • the clustering in each subspace is performed independently, and each subspace starts clustering at the same time, which greatly improves the clustering speed and saves all quantization codes in multiple index objects instead of one index object , Relatively reducing the amount of data in each index object.
  • the parallel search is performed from a plurality of index objects used to store the plurality of image feature values to be searched according to all the obtained asymmetric distances to obtain the target image feature value
  • the steps include:
  • multiple search threads are used to perform parallel search from a plurality of index objects for storing the plurality of image feature values to be searched to obtain the target image feature value.
  • multiple search threads and multiple index objects may be one-to-one searches, and the specific correspondence relationship is not limited herein.
  • the search speed is obviously faster than searching from an index object with a large amount of data.
  • the parallel search is performed from a plurality of index objects used to store the plurality of image feature values to be searched according to all the obtained asymmetric distances to obtain the target image feature value
  • the steps also include:
  • the image feature value to be searched corresponding to the target asymmetric distance is determined, and the The image feature value to be searched is used as the target image feature value.
  • each feature value of the image to be searched corresponds to a preset identification number (ID), for example, as shown in FIG.
  • ID a preset identification number
  • the quantization codes of the segments are 124, 56, 132, and 222, respectively, then the preset ID number of the feature value of the image to be searched may be 1, and the N feature values of the image to be searched have N preset ID numbers.
  • a preset number of target asymmetric distances with a small distance value are selected in ascending order, for example: 100 or 200; from multiple index objects, the The quantization coding of the multiple sub-segments of the image feature value to be searched corresponding to the preset number of target asymmetric distances can be determined from the quantization coding of the multiple sub-segments of the image feature value to be searched and Its preset ID number takes all the determined image feature values of the image to be searched as the target image feature value, and returns their preset ID number as the search result to the search user.
  • the quantization codes of the multiple sub-segments of the image feature value to be searched corresponding to the preset number of target asymmetric distances are obtained from multiple index objects, and the target image feature values and their values are determined according to the quantization codes of the sub-segments
  • the preset ID number not only improves the search speed, but also returns the search results with higher similarity to the user.
  • the step of clustering all sub-segments existing in the subspace by using a clustering algorithm to obtain multiple clustering centers includes:
  • K-means clustering algorithm is used to cluster all the sub-segments existing in the subspace to obtain multiple clustering centers.
  • the K-Means clustering algorithm is used for clustering of sub-segments, and the clustering speed is faster and more suitable for large-scale data sets.
  • FIG. 5 is a schematic structural diagram of an image feature value search device according to an embodiment of the present invention. As shown in FIG. 5, the device 5 includes:
  • the first division module 51 is used to obtain multiple query sub-vectors by segmenting the query vector when acquiring the query vector for searching the target image feature value matching the sample image feature value
  • the query subvectors correspond to multiple subspaces obtained in advance;
  • the calculation module 52 is configured to calculate the distance from each query subvector in the plurality of query subvectors to all cluster centers in the subspace corresponding to the query subvector.
  • the cluster centers pass the subspace Clustering all sub-segments of multiple image features to be searched in the memory;
  • the obtaining module 53 is configured to obtain the feature value of the sample image and each pending according to the distance from each query subvector in the plurality of query subvectors to all cluster centers in the subspace corresponding to the query subvector Search for the asymmetric distance between the image feature values;
  • the search module 54 is configured to perform a parallel search from a plurality of index objects used to store the plurality of image feature values to be searched according to all the obtained asymmetric distances to obtain the target image feature value.
  • the obtaining module 53 includes:
  • the first determining unit 531 is configured to perform the following operations for each of the image feature values of the plurality of image features to be searched: determining each sub-segment of the plurality of sub-segments of the image feature value of the to-be-searched The clustering center in the subspace where the subsection is located;
  • the second determining unit 532 is configured to determine the distance from each query subvector of the plurality of query subvectors to the clustering center to which each subsegment belongs in the subspace in which the subsegment is located;
  • the arithmetic unit 533 is configured to perform a sum operation on all the determined distances to obtain the asymmetric distance between the feature value of the sample image and the feature value of the image to be searched.
  • the device 5 further includes:
  • the second segmentation module 55 is configured to segment the feature value of the image to be searched for each feature value of the image to be searched to obtain a plurality of children of the feature value of the image to be searched Segment; wherein, the plurality of sub-segments correspond to the plurality of sub-spaces in one-to-one correspondence;
  • the clustering module 56 is configured to perform the following operations for each of the plurality of subspaces: use a clustering algorithm to cluster all subsections existing in the subspace to obtain multiple clustering centers;
  • the storage module 57 is configured to use the code of the cluster center as the quantization code of the sub-segments clustered under the cluster center, and store the quantization codes of all sub-segments in the plurality of index objects.
  • the search module 54 includes:
  • the searching unit 541 is configured to perform a parallel search from multiple index objects for storing the multiple image feature values to be searched using multiple search threads based on all the asymmetric distances acquired to obtain the target image feature value.
  • the search module 54 further includes:
  • the selecting unit 542 is configured to select a preset number of target asymmetric distances from all the obtained asymmetric distances in the order of asymmetry distance from small to large;
  • the obtaining unit 543 is configured to perform parallel search from a plurality of index objects used to store the plurality of image feature values to be searched to obtain quantization of a plurality of sub-segments of the image feature value to be searched corresponding to the target asymmetric distance coding;
  • the third determining unit 544 is configured to determine the feature value of the image to be searched corresponding to the target asymmetric distance according to the quantization coding of the plurality of sub-segments of the feature value of the image to be searched corresponding to the target asymmetric distance.
  • the feature value of the image to be searched corresponding to the target asymmetric distance is used as the target image feature value.
  • the clustering module 56 includes:
  • the clustering unit 561 is configured to cluster all sub-segments existing in the subspace by using a K-means clustering algorithm to obtain multiple clustering centers.
  • FIG. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 11, it includes: a memory 1102, a processor 1101, and a memory that can be stored on the memory Computer program 1103 running on.
  • the processor 1101 is used to call the computer program 1103 stored in the memory 1102 and perform the following steps:
  • the query vector When a query vector used to search for a target image feature value matching a sample image feature value is obtained, the query vector is segmented to obtain a plurality of query sub-vectors, and the plurality of query sub-vectors and the previously obtained Space one-to-one correspondence;
  • the processor 1101 executes the method according to the distance from each query subvector in the plurality of query subvectors to all cluster centers in the subspace corresponding to the query subvector to obtain the sample image feature value
  • the steps of the asymmetric distance from the feature value of each image to be searched include:
  • processor 1101 is also used for:
  • the feature value of the to-be-searched image is segmented to obtain multiple sub-segments of the feature value of the to-be-searched image; wherein, the multiple sub-segments One-to-one correspondence with the multiple subspaces;
  • a clustering algorithm is used to cluster all sub-segments existing in the subspace to obtain multiple clustering centers;
  • the coding of the clustering center is used as the quantization coding of the sub-segments clustered under the clustering center, and the quantization codings of all sub-segments are stored in the plurality of index objects.
  • the processor 1101 executes the parallel search from a plurality of index objects used to store the plurality of image feature values to be searched according to all the obtained asymmetric distances to obtain the target image feature value
  • the steps include:
  • multiple search threads are used to perform parallel search from a plurality of index objects for storing the plurality of image feature values to be searched to obtain the target image feature value.
  • the processor 1101 executes a step of performing parallel search from a plurality of index objects for storing the plurality of image feature values to be searched according to all the obtained asymmetric distances to obtain the target image feature value, Also includes:
  • the image feature value to be searched corresponding to the target asymmetric distance is determined, and the The image feature value to be searched is used as the target image feature value.
  • the processor 1101 executes the clustering algorithm to cluster all sub-segments existing in the subspace, and the steps of obtaining multiple clustering centers include:
  • K-means clustering algorithm is used to cluster all the sub-segments existing in the subspace to obtain multiple clustering centers.
  • the electronic device 11 may be a mobile phone, a computer, a notebook computer, a tablet computer, a palmtop computer, a wearable device, or the like.
  • the electronic device 11 may include, but is not limited to, a processor 1101, a memory 1102.
  • a person skilled in the art may understand that the schematic diagram is only an example of the electronic device 11 and does not constitute a limitation on the electronic device 11, and may include more or less components than the illustration, or a combination of certain components, or different component.
  • Embodiments of the present invention also provide a computer-readable storage medium that stores a computer program, which when executed by a processor implements the steps in the above-described image feature value search method.
  • the computer program of the computer-readable storage medium includes computer program code
  • the computer program code may be in a source code form, an object code form, an executable file, or some intermediate form, and the like.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electrical carrier signals, telecommunications signals and software distribution media, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Image Analysis (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种图像特征值的搜索方法、装置、电子设备及存储介质,该方法包括:在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应(S11);计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到(S12);根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离(S13);根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值(S14)。该方法能够在数据量继续增大的情况下,提高图像特征值的搜索速度。

Description

图像特征值的搜索方法、装置、电子设备及存储介质
本申请要求于2018年11月12日提交中国专利局,申请号为201811341714.3、发明名称为“图像特征值的搜索方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及图像搜索技术领域,尤其涉及一种图像特征值的搜索方法、装置、电子设备及存储介质。
背景技术
随着互联网络的普及,多媒体资源以爆炸式的增长姿态在网上呈现,这无疑为旺盛的数据搜索需求提供了便利,但是在过亿级的数据量中快速地搜索到相关数据,仍是图像搜索领域迫切想解决的问题。目前,Facebook(脸书)人工智能研究团队提出的一种新设计,实现了比之前最佳的GPU(Graphics Processing Unit,图形处理器)方法更快的最近邻搜索,它就是相似性搜索工具Faiss,是比以乘积量化为基础的暴力计算、近似和压缩域搜索更加优化的设计,并且将被应用到不同的相似性搜索场景中。虽然,相似性搜索工具Faiss是当今最优秀的相似性搜索算法库,但当数据量继续增大时,例如:图像特征值数据达到百亿级,甚至千亿级,相似性搜索工具Faiss的搜索速度仍将面临巨大的挑战。可见,目前的图像特征值搜索技术中,由于数据量的急速膨胀,导致搜索速度仍然不快。
发明内容
本发明的主要目的在于提供一种图像特征值的搜索方法、装置、电子设备及存储介质,以解决目前的图像特征值搜索技术中,由于数据量的急速膨胀,导致搜索速度仍然不快的问题。
为实现上述目的,本发明实施例第一方面提供了一种图像特征值的搜索方法,包括:
在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所 有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到;
根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
可选的,所述根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离的步骤包括:
分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:
确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
可选的,在所述计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离的步骤之前,所述方法还包括:
分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,对该待搜索图像特征值进行切分得到该待搜索图像特征值的多个子段;其中,所述多个子段与所述多个子空间一一对应;
针对所述多个子空间中的每一子空间,执行以下操作:
采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心;
将所述聚类中心的编码作为聚类在该聚类中心下的子段的量化编码,并将所有子段的量化编码保存在所述多个索引对象中。
可选的,所述根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,还包括:
按照非对称距离从小至大的顺序,从获取到的所有非对称距离中选取预设数量的目标非对称距离;
从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码;
根据与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,确定出与所述目标非对称距离对应的待搜索图像特征值,将与所述目标非对称距离对应的待搜索图像特征值作为所述目标图像特征值。
本发明实施例第二方面提供了一种图像特征值的搜索装置,包括:
第一切分模块,用于在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
计算模块,用于计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到;
获取模块,用于根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
搜索模块,用于根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
本发明实施例第三方面提供了一种电子设备,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,该处理器执行计算机程序时实现上述的图像特征值的搜索方法中的步骤。
本发明实施例第四方面提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述的图像特征值的搜索方法中的步骤。
本发明的上述方案至少包括以下有益效果:
通过在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的所有子段进行聚类得到;根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图 像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。这样将查询向量切分为查询子向量,实际上是将维度较高的查询向量细分化,与数据存储阶段将待搜索图像特征值切分为多个子段相同,越细分化的查询子向量和子段,越有利于提高搜索的相似精度;而非对称距离由于是直接计算样本图像特征值与经过量化后的待搜索图像特征值之间的距离,能够确保计算出的距离更接近样本图像特征值与待搜索图像特征值之间的真实距离,同样能够提高搜索的准确性;从多个存储较少数据的索引对象中展开并行搜索,比从一个存有大量数据的索引对象中单独搜索效率高很多,从而在数据量继续增大的情况下,也能够提高图像特征值的搜索速度。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种图像特征值的搜索方法的流程示意图;
图2为本发明实施例提供的一种场景举例示意图;
图3为本发明实施例提供的另一种图像特征值的搜索方法的流程示意图;
图4为本发明实施例提供的另一种场景举例示意图;
图5为本发明实施例提供的一种图像特征值的搜索装置的结构示意图;
图6为本发明实施例提供的另一种图像特征值的搜索装置的结构示意图;
图7为本发明实施例提供的另一种图像特征值的搜索装置的结构示意图;
图8为本发明实施例提供的另一种图像特征值的搜索装置的结构示意图;
图9为本发明实施例提供的另一种图像特征值的搜索装置的结构示意图;
图10为本发明实施例提供的另一种图像特征值的搜索装置的结构示意图;
图11为本发明实施例提供的一种电子设备的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
本发明说明书、权利要求书和附图中出现的术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。此外,术语“第一”、“第二”和“第三”等是用于区别不同的对象,而并非用于描述特定的顺序。
下面将结合相关附图和举例来对本方案的具体实施例进行说明,但举例并不对本发明的实施例造成限定。
请参见图1,图1为本发明实施例提供的一种图像特征值搜索方法的流程示意图,如图1所示,包括以下步骤:
S11,在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应。
其中,在本发明的具体实施例中,所有的图像特征值均是指维度较高的图像特征值,例如:128维。另外,在进行目标图像特征值搜索之前,可采用大量特征值数据进行模式训练,形成一个空间切分、聚类、量化编码的模式,最终得到基于乘积量化的索引对象index。
另外,在特征值搜索阶段,样本图像特征值可以是给定的特征值,也可以是从给定的图像中提取出的特征值。目标图像特征值是从预先存储的待搜图像特征值中获取的,与样本图像特征值相匹配的搜索结果,用于搜索目标图像特征值的查询向量可以是预先构建好的,也可以是在搜索时才构建的。若获取到该查询向量,则按照模式训练的过程,首先将该查询向量进行切分,得到该查询向量的多个查询子向量,该多个查询子向量一一对应到上述的多个子空间。例如,查询向量切分有2个查询子向量,那么1号查询子向量对应1号子空间、2号查询子向量对应2号子空间。
S12,计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的所有子段进行聚类得到。
其中,在本发明的具体实施例中,多个待搜索图像特征值中的每一待搜索图像特征值均包括与查询子向量数量相同的多个子段,每一待搜索图像特征值的多个子段同样一一对应到上述多个子空间中。例如,其中一个待搜索图像特征值有2个子段,分别是1号子段、2号子段,相应的1号子段对应存在于1号子空间内、2号子段对应存在于2号子空间内。需要说明的是,由于待搜索图像特征值数量庞大,所以每一子空间内同样存在大量的子段。
聚类中心,是存在于子空间内的大量待搜索图像特征值的子段通过聚类算法聚类而成,且每一子空间内聚类中心的数量相同。在对查询向量按照样本训练模式切分之后,需要计算每一查询子向量到其对应的子空间内所有聚类中心的距离。例如,1号查询子向量对应1号子空间,1号子空间内的所有子段被聚类得到256个聚类中心,那么,需要分别计算1号查询子向量到这256个聚类中心的距离;相应的,2号查询子向量同样需要计算其到2号子空间内所有聚类中心的距离。
S13,根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离。
其中,在本发明的具体实施例中,上述每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,可用于通过运算获取到样本图像特征值与每一待搜索图像特征值之间的非对称距离,当然也可以是对称距离,而具体采用哪种运算方式,此处并不作任何限定。如图2所示,本发明中实际上需要计算的是查询向量x到所有待搜索图像特征值y的距离,但由于待搜索图像特征值y的数量可能是过亿级的,而待搜索图像特征值y的索引值所对应的码字q(y)数量却要少得多,使用查询向量x到q(y)的距离代替查询向量x到待搜索图像特征值y的距离,这就是非对称距离的计算。非对称距离在计算样本图像特征值到预先存储的待搜索图像特征值之间的距离时,不需要对样本图像特征值自身进行量化,而是直接计算样本图像特征值到量化了的待搜索图像特征值之间的距离,它比对称距离计算方式更直接,可以确保计算出的距离更接近于真实距离,从而提高搜索的精度。
需要说明的是,样本图像特征值与每一待搜索图像特征值之间的非对称距离或对称距离,用于表示二者之间的相似度,距离越小,表示相似度越高。
S14,根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
其中,在本发明的具体实施例中,上述索引对象可以是预先构建的,用于存储每一待搜索图像特征值的多个子段的量化编码,由于待搜索图像特征值的数量极其庞大,可知,所有待搜索图像特征值的子段的量化编码也是极多的。因此,可为每一索引对象设置一数据阈值,例如:该数据阈值可以是1亿,当最初创建的索引对象中保存的量化编码达到该数据阈值时,则新建一个索引对象对未保存的量化编码进行保存,最终会得到多个上述的索引对象。
另外,由于所有量化编码被保存在多个索引对象中,那么,就可以根据获取到的所有 非对称距离,从多个索引对象中展开并行搜索,获得上述的目标图像特征值作为搜索结果。例如,根据获得的非对称距离,从第一个索引对象中搜索到10个待搜索图像特征值,从第二个索引对象中搜索到15个待搜索图像特征值,则可把搜索到的25个待搜索图像特征值作为目标图像特征值。
上述方法中,由于是根据计算得到的样本图像特征值与每一待搜索图像特征值之间的非对称距离,从多个索引对象中展开并行搜索,这样的搜索方式,显然比从一个存有海量数据的索引对象中单独搜索效率高很多。
需要说明的是,本发明实施例提供的图像特征值的搜索方法可以基于一些搜索工具或搜索相似度媒体文件算法库实现,例如,Facebook人工智能研究团队提出的相似性搜索工具Faiss。
本发明实施例中,通过在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到;根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。这样将查询向量切分为查询子向量,实际上是将维度较高的查询向量细分化,与数据存储阶段将待搜索图像特征值切分为多个子段相同,越细分化的查询子向量和子段,越有利于提高搜索的相似精度;而非对称距离由于是直接计算样本图像特征值与经过量化后的待搜索图像特征值之间的距离,能够确保计算出的距离更接近样本图像特征值与待搜索图像特征值之间的真实距离,同样能够提高搜索的准确性;从多个存储较少数据的索引对象中展开并行搜索,比从一个存有大量数据的索引对象中单独搜索效率高很多,从而在数据量继续增大的情况下,也能够提高图像特征值的搜索速度。
请参见图3,图3为本发明实施例提供的另一种图像特征值的搜索方法的流程示意图,如图3所示,包括以下步骤:
S21,在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应。
其中,在本发明的具体实施例中,该步骤是预先构建好用于搜索目标图像特征值的查询向量,以便于特征值搜索时可直接获取该查询向量,然后对其进行切分。
S22,计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的所有子段进行聚类得到。
其中,步骤S22的具体实施方式在上述实施例中已有相关说明,同样也适用于本实施例,此处便不再作过多的描述。
S23,根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离。
其中,步骤S23的具体实施方式在上述实施例中已有相关说明,同样也适用于本实施例,此处便不再作过多的描述。步骤S23进一步包括:
S231,分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
其中,在本发明的具体实施例中,由于数据存储阶段对每一子空间内的子段进行了聚类,所以一个的待搜索图像特征值的每个子段在其对应所在的子空间内都有一个所属的聚类中心。例如,一个完整的待搜索图像特征值有4个子段,1号子段在其所在的1号子空间内所属的聚类中心是24号,2号子段在其所在的2号子空间内所属的聚类中心是8号,3号子段在其所在的3号子空间内所属的聚类中心是222号,4号子段在其所在的4号子空间内所属的聚类中心是155号,那么,就需要确认出上述完整的待搜索图像特征值的4个子段所属的聚类中心:24号、8号、222号以及155号。
S232,确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
S233,对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
其中,在本发明的具体实施例中,确认出上述每一待搜索图像特征值的多个子段中的每一子段,在该子段所在的子空间内所属的聚类中心后,根据步骤S22中计算出的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,分别确定出每一查询子向量到对应的每一子段所属的聚类中心的距离,通过求和运算的方式得到样本图像特征值 与该待搜索图像特征值之间的非对称距离。还是以步骤S231中的例子进行说明,一条查询向量的1、2、3、4个查询子向量,分别对应1号子空间、2号子空间、3号子空间、4号子空间,那么分别确定出1号查询子向量到1号子空间中24号聚类中心的距离、2号查询子向量到2号子空间中8号聚类中心的距离、3号查询子向量到3号子空间中222号聚类中心的距离及4号查询子向量到4号子空间中155号聚类中心的距离,然后对确认出的四个距离进行求和运算,便得到样本图像特征值与一个待搜索图像特征值之间的非对称距离。
S24,根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
同样的,步骤S24的具体实施方式在上述实施例中已有相关说明,同样也适用于本实施例,此处便不再作过多的描述。
作为一种可选的实施方式,在所述计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离的步骤之前,所述方法还包括:
分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,对该待搜索图像特征值进行切分得到该待搜索图像特征值的多个子段;其中,所述多个子段与所述多个子空间一一对应;
针对所述多个子空间中的每一子空间,执行以下操作:
采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心;
将所述聚类中心的编码作为聚类在该聚类中心下的子段的量化编码,并将所有子段的量化编码保存在所述多个索引对象中。
其中,在本发明的具体实施例中,在对海量待搜索图像特征值存储时,需要将高维的待搜索图像特征值进行切分,得到与上述查询子向量一一对应的子空间及子段,每一子空间内都有大量待搜索图像特征值的子段。在每一子空间内采用聚类算法对所有子段进行聚类,得到多个聚类中心,之后,对每一子空间内的子段进行量化编码,并将其保存在索引对象中。
如图4所示,将N个128维的待搜索图像特征值切分为4个32维的子段,同时得到4个子空间。针对4个子空间中的每一子空间,在每个子空间内进行聚类,将子空间内的所有子段聚类得到256个聚类中心,然后用聚类中心的编码近似表示聚类到该聚类中心的子段的十进制量化编码,得到所有待搜索图像特征值的4个子段的量化编码矩阵。如图4所示右侧的矩阵,可以理解为N个待搜索图像特征值中,第一个待搜索图像特征值的4个子段的量化 编码分别是124、56、132、222。按照这种形式将所有待搜索图像特征值的子段的量化编码保存在索引对象中,由于所有子段的量化编码的集合构成一个码本,所以可以理解为每个索引对象中都保存有一个码本。
该实施方式中,每个子空间内的聚类是独立进行的,各个子空间同时开始聚类,大大提高了聚类速度,将所有量化编码保存在多个索引对象中,而不是一个索引对象中,相对减少了每个索引对象中的数据量。
作为一种可选的实施方式,所述根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,包括:
根据获取到的所有非对称距离,采用多搜索线程从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
该实施方式中,多搜索线程与多个索引对象可以是一对一搜索,具体的对应关系此处不作任何限定。采用多搜索线程从数据量相对较小的多个索引对象中并行搜索,搜索速度显然快于从一个数据量较大的索引对象中搜索。
作为一种可选的实施方式,所述根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,还包括:
按照非对称距离从小至大的顺序,从获取到的所有非对称距离中选取预设数量的目标非对称距离;
从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码;
根据与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,确定出与所述目标非对称距离对应的待搜索图像特征值,将与所述目标非对称距离对应的待搜索图像特征值作为所述目标图像特征值。
其中,在本发明的具体实施例中,每个待搜索图像特征值都对应有一个预设身份标识号码(ID),例如,如图4所示,一个完整的待搜索图像特征值的4个子段的量化编码分别是124、56、132、222,那么这个待搜索图像特征值的预设身份标识号码可能就是1,N个待搜索图像特征值就有N个预设身份标识号码。根据上述获取到的所有非对称距离的大小,按照从小到大的顺序选取距离值小的预设数量个目标非对称距离,例如:100个或200个;从多个索引对象中,获取与上述预设数量个目标非对称距离对应的待搜索图像特征值的多 个子段的量化编码,由得到的待搜索图像特征值的多个子段的量化编码,便能确定出该待搜索图像特征值以及它的预设身份标识号码,将确定出的所有待搜索图像特征值作为目标图像特征值,并将它们的预设身份标识号码作为搜索结果返回给搜索用户。
该实施方式中,从多个索引对象中获取与预设数量个目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,根据子段的量化编码确定出目标图像特征值及其预设身份标识号码,不仅提高了搜索速度,还能够将相似度更高的搜索结果返回给用户。
作为一种可选的实施方式,所述采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心的步骤包括:
采用K-means聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心。
该实施方式中,采用K-Means聚类算法进行子段的聚类,聚类速度更快、而且更加适合大规模数据集。
本实施例中,在图1所示的实施例的基础上增加了多种可选的实施方式,针对图像特征值数据量继续增大的情况,仍能提高搜索速度。
请参见图5,图5为本发明实施例提供的一种的图像特征值的搜索装置的结构示意图,如图5所示,该装置5包括:
第一切分模块51,用于在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
计算模块52,用于计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的所有子段进行聚类得到;
获取模块53,用于根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
搜索模块54,用于根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
可选的,如图6所示,所述获取模块53包括:
第一确定单元531,用于分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
第二确定单元532,用于确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
运算单元533,用于对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
可选的,如图7所示,所述装置5还包括:
第二切分模块55,用于分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,对该待搜索图像特征值进行切分得到该待搜索图像特征值的多个子段;其中,所述多个子段与所述多个子空间一一对应;
聚类模块56,用于针对所述多个子空间中的每一子空间,执行以下操作:采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心;
存储模块57,用于将所述聚类中心的编码作为聚类在该聚类中心下的子段的量化编码,并将所有子段的量化编码保存在所述多个索引对象中。
可选的,如图8所示,所述搜索模块54包括:
搜索单元541,用于根据获取到的所有非对称距离,采用多搜索线程从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
可选的,如图9所示,所述搜索模块54还包括:
选取单元542,用于按照非对称距离从小至大的顺序,从获取到的所有非对称距离中选取预设数量的目标非对称距离;
获取单元543,用于从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码;
第三确定单元544,用于根据与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,确定出与所述目标非对称距离对应的待搜索图像特征值,将与所述目标非对称距离对应的待搜索图像特征值作为所述目标图像特征值。
可选的,如图10所示,所述聚类模块56包括:
聚类单元561,用于采用K-means聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心。
请参见图11,图11为本发明实施例提供的一种电子设备的结构示意图,如图11所示,包括:存储器1102、处理器1101及存储在所述存储器上并可在所述处理器上运行的计算机程序1103。
其中,处理器1101用于调用存储器1102存储的计算机程序1103,执行如下步骤:
在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的所有子段进行聚类得到;
根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
可选的,处理器1101执行所述根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离的步骤包括:
分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:
确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
可选的,处理器1101还用于:
分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,对该待搜索图像特征值进行切分得到该待搜索图像特征值的多个子段;其中,所述多个子段与所述多个子空间一一对应;
针对所述多个子空间中的每一子空间,执行以下操作:
采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心;
将所述聚类中心的编码作为聚类在该聚类中心下的子段的量化编码,并将所有子段的量化编码保存在所述多个索引对象中。
可选的,处理器1101执行的所述根据获取到的所有非对称距离,从多个用于存储所述 多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,包括:
根据获取到的所有非对称距离,采用多搜索线程从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
可选的,处理器1101执行根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,还包括:
按照非对称距离从小至大的顺序,从获取到的所有非对称距离中选取预设数量的目标非对称距离;
从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码;
根据与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,确定出与所述目标非对称距离对应的待搜索图像特征值,将与所述目标非对称距离对应的待搜索图像特征值作为所述目标图像特征值。
可选的,处理器1101执行所述采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心的步骤包括:
采用K-means聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心。
即,在本发明的具体实施例中,电子设备11的处理器1101执行计算机程序1103时实现上述的图像特征值的搜索方法中的步骤,从而在数据量继续增大的情况下,也能够提高图像特征值的搜索速度。
示例性的,上述电子设备11可以是手机、计算机、笔记本电脑、平板电脑、掌上电脑及可穿戴设备等。电子设备11可包括但不仅限于处理器1101、存储器1102。本领域技术人员可以理解,所述示意图仅仅是电子设备11的示例,并不构成对电子设备11的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件。
需要说明的是,由于电子设备11的处理器1101执行计算机程序1103时实现上述的图像特征值的搜索方法中的步骤,因此上述图像特征值的搜索方法的所有实施例均适用于该电子设备11,且均能达到相同或相似的有益效果。
本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述的图像特征值的搜索方法中的步骤。
即,在本发明的具体实施例中,计算机可读存储介质的计算机程序被处理器执行时实现上述的图像特征值的搜索方法中的步骤,从而在数据量继续增大的情况下,也能够提高 图像特征值的搜索速度。
示例性的,计算机可读存储介质的计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。
需要说明的是,由于计算机可读存储介质的计算机程序被处理器执行时实现上述的图像特征值的搜索方法中的步骤,因此图像特征值的搜索方法中的所有实施例均适用于该计算机可读存储介质,且均能达到相同或相似的有益效果。
以上对本发明实施例进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。

Claims (10)

  1. 一种图像特征值的搜索方法,其特征在于,所述方法包括:
    在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
    计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到;
    根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
    根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离的步骤包括:
    分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:
    确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
    确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
    对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
  3. 根据权利要求1所述的方法,其特征在于,在所述计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离的步骤之前,所述方法还包括:
    分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,对该待搜索图像特征值进行切分得到该待搜索图像特征值的多个子段;其中,所述多个子段与所述多个子空间一一对应;
    针对所述多个子空间中的每一子空间,执行以下操作:
    采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心;
    将所述聚类中心的编码作为聚类在该聚类中心下的子段的量化编码,并将所有子段的量化编码保存在所述多个索引对象中。
  4. 根据权利要求1所述的方法,其特征在于,所述根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,包括:
    根据获取到的所有非对称距离,采用多搜索线程从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
  5. 根据权利要求3所述的方法,其特征在于,所述根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值的步骤,还包括:
    按照非对称距离从小至大的顺序,从获取到的所有非对称距离中选取预设数量的目标非对称距离;
    从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码;
    根据与所述目标非对称距离对应的待搜索图像特征值的多个子段的量化编码,确定出与所述目标非对称距离对应的待搜索图像特征值,将与所述目标非对称距离对应的待搜索图像特征值作为所述目标图像特征值。
  6. 根据权利要求3所述的方法,其特征在于,所述采用聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心的步骤包括:
    采用K-means聚类算法对存在于该子空间内的所有子段进行聚类,得到多个聚类中心。
  7. 一种图像特征值的搜索装置,其特征在于,包括:
    第一切分模块,用于在获取到用于搜索与样本图像特征值匹配的目标图像特征值的查询向量时,对所述查询向量进行切分得到多个查询子向量,所述多个查询子向量与预先得到的多个子空间一一对应;
    计算模块,用于计算所述多个查询子向量中的每一查询子向量到与该查询子向量对应的子空间中所有聚类中心的距离,所述聚类中心通过对所述子空间内存在的多个待搜索图像特征值的子段进行聚类得到;
    获取模块,用于根据所述多个查询子向量中的每一查询子向量到与该查询子向量对应 的子空间中所有聚类中心的距离,获取所述样本图像特征值与每一待搜索图像特征值之间的非对称距离;
    搜索模块,用于根据获取到的所有非对称距离,从多个用于存储所述多个待搜索图像特征值的索引对象中进行并行搜索,获得所述目标图像特征值。
  8. 根据权利要求7所述的装置,其特征在于,所述获取模块包括:
    第一确定单元,用于分别针对所述多个待搜索图像特征值中的每一待搜索图像特征值,执行以下操作:确定该待搜索图像特征值的多个子段中的每一子段在该子段所在的子空间内所属的聚类中心;
    第二确定单元,用于确定所述多个查询子向量中的每一查询子向量,到所述每一子段在该子段所在的子空间内所属的聚类中心的距离;
    运算单元,用于对确定出的所有距离进行求和运算,得到所述样本图像特征值与该待搜索图像特征值之间的非对称距离。
  9. 一种电子设备,其特征在于,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如权利要求1至6中任一项所述的图像特征值的搜索方法中的步骤。
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至6中任一项所述的图像特征值的搜索方法中的步骤。
PCT/CN2018/124832 2018-11-12 2018-12-28 图像特征值的搜索方法、装置、电子设备及存储介质 WO2020098110A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811341714.3 2018-11-12
CN201811341714.3A CN111177438B (zh) 2018-11-12 2018-11-12 图像特征值的搜索方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020098110A1 true WO2020098110A1 (zh) 2020-05-22

Family

ID=70646050

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/124832 WO2020098110A1 (zh) 2018-11-12 2018-12-28 图像特征值的搜索方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN111177438B (zh)
WO (1) WO2020098110A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307035A (zh) * 2020-11-26 2021-02-02 深圳云天励飞技术股份有限公司 一种特征值id的管理方法、装置、电子设备及存储介质
CN113065011A (zh) * 2021-03-17 2021-07-02 北京沃东天骏信息技术有限公司 图片的确定方法和装置
CN116796021A (zh) * 2023-08-28 2023-09-22 上海任意门科技有限公司 图像检索方法、系统、电子设备和介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111797259A (zh) * 2020-07-10 2020-10-20 杭州慕锐科技有限公司 一种针对有褶皱形变的图像快速搜索方法
CN113918598A (zh) * 2021-10-21 2022-01-11 深圳云天励飞技术股份有限公司 一种乘积量化搜索方法、装置、终端和存储介质
CN114817717A (zh) * 2022-04-21 2022-07-29 国科华盾(北京)科技有限公司 搜索方法、装置、计算机设备和存储介质

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103336795A (zh) * 2013-06-09 2013-10-02 华中科技大学 基于多特征的视频索引方法
CN108733780A (zh) * 2018-05-07 2018-11-02 浙江大华技术股份有限公司 一种图片搜索方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016037844A1 (en) * 2014-09-09 2016-03-17 Thomson Licensing Method and apparatus for image retrieval with feature learning
CN106326288B (zh) * 2015-06-30 2019-12-03 阿里巴巴集团控股有限公司 图像搜索方法及装置
CN105117407B (zh) * 2015-07-27 2019-03-26 电子科技大学 一种基于聚类的距离方向直方图的图像检索方法
CN106886553B (zh) * 2016-12-27 2020-07-28 浙江宇视科技有限公司 一种图像检索方法及服务器
CN107766492B (zh) * 2017-10-18 2020-07-31 北京京东尚科信息技术有限公司 一种图像搜索的方法和装置
CN108241745B (zh) * 2018-01-08 2020-04-28 阿里巴巴集团控股有限公司 样本集的处理方法及装置、样本的查询方法及装置

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103336795A (zh) * 2013-06-09 2013-10-02 华中科技大学 基于多特征的视频索引方法
CN108733780A (zh) * 2018-05-07 2018-11-02 浙江大华技术股份有限公司 一种图片搜索方法及装置

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ANONYMITY, ANNS, 16 April 2017 (2017-04-16), pages 1 - 4, Retrieved from the Internet <URL:https://memoiry.me/2017/04/16/ANNS> *
ZHOU, LING: "Research on Locally Features Aggregating and Indexing Algorithm in Large-scale Image Retrieval", CHINESE MASTER S THESES FULL-TEXT DATABASE, INFORMATION SCIENCE & TECHNOLOGY, 15 July 2012 (2012-07-15), pages 22 - 33, ISSN: 1674-0246 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307035A (zh) * 2020-11-26 2021-02-02 深圳云天励飞技术股份有限公司 一种特征值id的管理方法、装置、电子设备及存储介质
CN112307035B (zh) * 2020-11-26 2024-01-05 深圳云天励飞技术股份有限公司 一种特征值id的管理方法、装置、电子设备及存储介质
CN113065011A (zh) * 2021-03-17 2021-07-02 北京沃东天骏信息技术有限公司 图片的确定方法和装置
CN113065011B (zh) * 2021-03-17 2024-01-16 北京沃东天骏信息技术有限公司 图片的确定方法和装置
CN116796021A (zh) * 2023-08-28 2023-09-22 上海任意门科技有限公司 图像检索方法、系统、电子设备和介质
CN116796021B (zh) * 2023-08-28 2023-12-05 上海任意门科技有限公司 图像检索方法、系统、电子设备和介质

Also Published As

Publication number Publication date
CN111177438A (zh) 2020-05-19
CN111177438B (zh) 2023-05-12

Similar Documents

Publication Publication Date Title
WO2020098110A1 (zh) 图像特征值的搜索方法、装置、电子设备及存储介质
Baranchuk et al. Revisiting the inverted indices for billion-scale approximate nearest neighbors
CN105912611B (zh) 一种基于cnn的快速图像检索方法
Wu et al. Multiscale quantization for fast similarity search
Gordo et al. Asymmetric distances for binary embeddings
Aly et al. Indexing in large scale image collections: Scaling properties and benchmark
Wei et al. Projected residual vector quantization for ANN search
Rafailidis et al. A unified framework for multimodal retrieval
EP3191980A1 (en) Method and apparatus for image retrieval with feature learning
CN111368133A (zh) 一种视频库的索引表建立方法、装置、服务器及存储介质
Chiu et al. Learning to index for nearest neighbor search
Zhang et al. Beyond explicit codebook generation: Visual representation using implicitly transferred codebooks
US20230123941A1 (en) Multiscale Quantization for Fast Similarity Search
CN114238329A (zh) 向量相似度计算方法、装置、设备及存储介质
CN111177435A (zh) 一种基于改进pq算法的cbir方法
Ozan et al. K-subspaces quantization for approximate nearest neighbor search
Li et al. Sub-selective quantization for learning binary codes in large-scale image search
Sun et al. Search by detection: Object-level feature for image retrieval
Takahashi et al. Mixture of subspaces image representation and compact coding for large-scale image retrieval
Wu et al. Codebook-free compact descriptor for scalable visual search
Zhou et al. Angular deep supervised vector quantization for image retrieval
Gao et al. Efficient view-based 3-D object retrieval via hypergraph learning
CN110209895B (zh) 向量检索方法、装置和设备
Magliani et al. Landmark recognition: From small-scale to large-scale retrieval
Lv et al. Pf-face: A parallel framework for face classification and search from massive videos based on spark

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18940264

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18940264

Country of ref document: EP

Kind code of ref document: A1