CN111382287A - Picture searching method and device, storage medium and electronic equipment - Google Patents

Picture searching method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN111382287A
CN111382287A CN201811643673.3A CN201811643673A CN111382287A CN 111382287 A CN111382287 A CN 111382287A CN 201811643673 A CN201811643673 A CN 201811643673A CN 111382287 A CN111382287 A CN 111382287A
Authority
CN
China
Prior art keywords
picture
vector
searched
search result
candidate
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201811643673.3A
Other languages
Chinese (zh)
Inventor
王玉波
刘清炼
刘建伦
陈培琴
张健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Uniview Technologies Co Ltd
Original Assignee
Zhejiang Uniview Technologies Co Ltd
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 Zhejiang Uniview Technologies Co Ltd filed Critical Zhejiang Uniview Technologies Co Ltd
Priority to CN201811643673.3A priority Critical patent/CN111382287A/en
Publication of CN111382287A publication Critical patent/CN111382287A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the application discloses a picture searching method and device, a storage medium and electronic equipment. The method comprises the following steps: acquiring a search request of a picture to be searched; compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched; selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture; and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture. By executing the technical scheme provided by the application, the effect of searching the picture with the picture can be realized at low cost and quickly.

Description

Picture searching method and device, storage medium and electronic equipment
Technical Field
The embodiment of the application relates to the technical field of image processing, in particular to a picture searching method and device, a storage medium and electronic equipment.
Background
With the advent of AI (Artificial Intelligence) technology in recent years, fast searching of target pictures has become an important requirement in the industry under the situation of a rapid increase in picture and video data.
In the prior art, searching pictures by using pictures usually includes extracting attributes and characteristic information of searched pictures, and then performing comparison search from a massive picture library. The mainstream scheme applied in searching the graph includes two types: CPU (central Processing Unit) memory computation and GPU (Graphics Processing Unit) computation. Both of these solutions have their own disadvantages, i.e. the CPU memory cost is low, but the calculation speed is slow, and when the data size is larger and larger, the machine must be increased continuously to ensure the search speed. GPUs, while very fast in computation, typically have a small memory, a limited amount of data that can be stored, and are expensive. Therefore, how to search for a picture quickly and reduce the cost becomes a technical problem to be solved in the field.
Disclosure of Invention
The embodiment of the application provides a picture searching method and device, a storage medium and electronic equipment, which can realize the effect of searching pictures with pictures at low cost and quickly.
In a first aspect, an embodiment of the present application provides a method for searching an image, where the method includes:
acquiring a search request of a picture to be searched;
compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
Further, before obtaining the search request of the picture to be searched, the method further includes:
performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture;
clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers;
and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture.
Further, compressing the original feature vector of the picture to be searched to obtain a compressed vector of the picture to be searched, including:
carrying out dimensionality reduction segmentation on the original characteristic vector of the picture to be searched to obtain a short vector of the picture to be searched;
and determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center which is closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched.
Further, selecting a first-level search result picture from the candidate pictures according to the picture compression vector to be searched and the candidate picture compression vectors, including:
determining the similarity between each candidate picture compression vector and the picture compression vector to be searched by adopting an asymmetric distance algorithm;
and determining a first-level search result picture according to the similarity.
Further, before determining the first-level search result picture according to the similarity, the method further includes:
determining the number of first-level search result pictures;
correspondingly, according to the similarity, determining a first-level search result picture comprises:
and determining the first-level search result pictures according to the similarity and the number of the first-level search result pictures.
Further, selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture, including:
according to the first-stage search result picture, acquiring an original feature vector of the first-stage search result picture from original feature vectors of all candidate pictures;
and comparing the original characteristic vector of the picture to be searched with the original characteristic vector of the first-stage search result picture to determine a second-stage search result picture.
Further:
selecting a first-level search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector through a GPU; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures through a CPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
In a second aspect, an embodiment of the present application further provides an apparatus for searching for a picture, where the apparatus includes:
the search request acquisition module is used for acquiring a search request of a picture to be searched;
the original characteristic vector compression module is used for compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
the first-stage search module is used for selecting a first-stage search result picture from all candidate pictures according to the picture compression vector to be searched and all candidate picture compression vectors; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and the second-stage searching module is used for selecting a second-stage searching result picture from the first-stage searching result pictures according to the original characteristic vector of the picture to be searched and the original characteristic vector of the first-stage searching result picture.
Further, the apparatus further includes a candidate picture compression module, where the candidate picture compression module is specifically configured to:
performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture;
clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers;
and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture.
Further, the original feature vector compression module comprises:
the short vector determining unit is used for performing dimensionality reduction segmentation on the original characteristic vector of the picture to be searched to obtain a short vector of the picture to be searched;
and the compression unit is used for determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched.
Further, the first-level search module comprises:
the similarity determining unit is used for determining the similarity between each candidate picture compression vector and the picture compression vector to be searched by adopting an asymmetric distance algorithm;
and the first-level search result determining unit is used for determining a first-level search result picture according to the similarity.
Further, the first-level search module further includes:
the first-level search result quantity determining unit is used for determining the quantity of the first-level search result pictures;
correspondingly, the first-level search result determining unit is specifically configured to:
and determining the first-level search result pictures according to the similarity and the number of the first-level search result pictures.
Further, the second-level search module is specifically configured to:
according to the first-stage search result picture, acquiring an original feature vector of the first-stage search result picture from original feature vectors of all candidate pictures;
and comparing the original characteristic vector of the picture to be searched with the original characteristic vector of the first-stage search result picture to determine a second-stage search result picture.
Further:
selecting a first-level search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector through a GPU; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures through a CPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements a picture searching method according to an embodiment of the present application.
In a fourth aspect, an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable by the processor, where the processor executes the computer program to implement the picture searching method according to the embodiment of the present application.
According to the technical scheme provided by the embodiment of the application, a search request of a picture to be searched is obtained; compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched; selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture; and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture. By adopting the technical scheme provided by the application, the effect of searching the images with the images can be realized at low cost and quickly.
Drawings
Fig. 1 is a flowchart of a method for searching a picture according to an embodiment of the present application;
FIG. 2 is a schematic diagram of vector compression according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for searching a picture according to a second embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a picture searching apparatus according to a third embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some of the structures related to the present application are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the steps as a sequential process, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1 is a flowchart of a picture searching method provided in an embodiment of the present application, where the present embodiment is applicable to a case of searching pictures with pictures, and the method may be executed by a picture searching apparatus provided in an embodiment of the present application, where the apparatus may be implemented by software and/or hardware, and may be integrated in an electronic device such as a client, a server, and an intelligent terminal.
As shown in fig. 1, the picture searching method includes:
and S110, acquiring a search request of the picture to be searched.
The picture to be searched can be a picture acquired by a user through a camera, and can also be a picture selected in an album or other paths. The search request may be a request generated after a user inputs a picture in an interface for inputting a picture to be searched. In this embodiment, a search request may be determined by obtaining a picture to be searched, and a search operation of the picture to be searched may be performed according to the search request. The search work can be executed by the intelligent terminal, and can also be executed by the interaction between the client terminal and the server which specially conduct the picture search. In this embodiment, the processing may be performed in the smart terminal, and specifically, the processing may be performed in a CPU or a GPU of the smart terminal.
Because the existing scheme of searching the image by using the image is to compare the image to be searched with all candidate images, the data volume is large, and when the image is searched in the GPU, the GPU has high calculation speed on the high-dimensional characteristics of the image, but needs to expand the storage capacity of the GPU, so the price is high; when searching in the CPU, the CPU memory distributed cluster is adopted to store and search the nearest hot spot data. When the graph is searched, all the Slave nodes of the cluster perform concurrent computation, the Slave nodes return the most similar Top N records, and are aggregated and sequenced at the Master node, and finally the Master node returns the most similar Top N records, so that the efficiency of searching the graph with the graph is influenced because the searching speed is low.
S120, compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched.
The original feature vector of the picture to be searched and the original feature vector of each candidate picture in the candidate gallery may be vectors of a specific dimension, for example, both may be vectors of 128 dimensions, and the vectors of the specific dimension are used to determine content information of the picture. In this embodiment, the vector of a specific dimension may be split and compressed in an equipartition manner. For example, the short vectors may be divided into 8 short vectors of 16 dimensions and then compressed. The specific compression mode is various, and the compression can be performed in an artificial intelligence mode, which is not limited in this embodiment. After compression, the picture compression vector to be searched and each candidate picture compression vector can be obtained. The advantage of this setting is that can avoid carrying out meticulous contrast directly to the picture of specific dimension, can improve computational efficiency.
In this embodiment, the original feature vectors of the candidate pictures may be compressed first, and when a picture search application is received, the original feature vectors of the pictures to be searched are compressed according to the compression method, so that the advantage of the arrangement is that the original feature vectors of the candidate pictures are prevented from being compressed each time a search request is received, the workload is saved, and the picture search efficiency can be improved.
In this embodiment, each candidate picture may be specified by the user according to the user's requirement, or may be set by default in the system, and may include a picture library, a video library, and pictures in other paths, where each frame of picture of each video in the video library may be used as one candidate picture. The method has the advantages that the range of each candidate picture can be determined according to the requirements of the user, a targeted search range can be provided for the user, the use experience of the user is improved, and meanwhile the work efficiency of searching the picture by using the picture can also be improved.
In this embodiment, optionally, before obtaining the search request of the picture to be searched, the method further includes: performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture; clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers; and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture.
In this embodiment, optionally, compressing the original feature vector of the picture to be searched to obtain a compressed vector of the picture to be searched includes: carrying out dimensionality reduction segmentation on the original characteristic vector of the picture to be searched to obtain a short vector of the picture to be searched; and determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center which is closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched.
In this embodiment, optionally, compressing the original feature vector of the picture to be searched and the original feature vectors of the candidate pictures in the candidate image library to obtain the compressed vector of the picture to be searched and the compressed vectors of the candidate pictures includes: performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture; clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers; and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture. After receiving the search picture request, performing vector compression on the picture to be searched in the same way, specifically, performing dimension reduction segmentation on the original feature vector of the picture to be searched to obtain a short vector of the picture to be searched; and determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center which is closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched. The method has the advantages that the compressed vector of the picture to be searched is determined by the distance and the serial number of the clustering centers obtained by the candidate picture clustering algorithm, the vector compression is performed in the same mode as the candidate picture compression mode, the determination of the first-stage search and the second-stage search in the subsequent steps is facilitated, and the picture searching accuracy is guaranteed.
Fig. 2 is a schematic diagram of vector compression according to an embodiment of the present application.
The vector compression is realized by adopting a product quantization algorithm, and a D (D in fig. 2 is 128 dimensions) dimension feature vector is divided into M short vectors (M in fig. 2 is 8), and the dimension D of each short vector is D/M;
the following languages can be specifically adopted for implementation:
Figure BDA0001931583250000101
Figure BDA0001931583250000111
the transpose of the/vtrain is the original 128-dimensional vector, of which vs is one subvector.
Then, all the short vectors of the corresponding dimensionality are clustered by using a k-means clustering algorithm, the number of clustering centers is nlist, and the clustering centers are numbered from 0 to nlist-1.
The following languages can be specifically adopted for implementation:
kmeans(vs,ks,labelssub,
TermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,50,0.001),
3,KMEANS_PP_CENTERS,centers);
the quantization process calculates the distance of each short vector from the nearest cluster center (L2 in the language below). The compression process is to replace the short vector by the number of the cluster center with the short vector nearest to the cluster center, and the original vector is compressed into a compressed vector consisting of M index values.
The following languages can be specifically adopted for implementation:
Figure BDA0001931583250000112
as shown in FIG. 2, wherein d1,d2...d8Expressed as: 8 16-dimensional short vectors of 128-dimensional segmentation; q. q.s1,q2...q8Expressed as: 256 clustering centers corresponding to each dimension short vector; q. q.s1(d1),q2(d2)...q8(d8) Expressed as: the serial number of the corresponding clustering center after each short vector is quantized; because each one-dimensional short vector has 256 cluster centers, the maximum index value is 255, and 8 bits can be stored. Therefore, a 128-dimensional feature vector is compressed to 8bit by 8-64 bit, while the original feature vector is 128 by 4-512 bit (assuming that each dimension is of float type), and the storage capacity of the compressed vector is 8 times that of the original vector.
After determining the compression vectors of the candidate pictures in the above manner, the compression vectors of the pictures to be searched can be determined in the same manner, and the clustering centers and the numbers thereof can be selected in the same manner as described above. The method has the advantages that after the compressed vectors are determined in a uniform mode, the result picture searched by the compressed vectors is close to the picture to be searched. The method not only accelerates the searching speed and saves the space required by data processing, but also can ensure the accuracy of searching the images by the images.
S130, selecting a first-level search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; and compressing the candidate image compression vectors to obtain original feature vectors of the candidate images.
In this embodiment, optionally, selecting a first-level search result picture from the candidate pictures according to the picture compression vector to be searched and the candidate picture compression vectors includes: determining the similarity between each candidate picture compression vector and the picture compression vector to be searched by adopting an asymmetric distance algorithm; and determining a first-level search result picture according to the similarity.
The first stage of search stores vectors compressed by a product quantization algorithm, and data meeting conditions can be quickly searched by an asymmetric distance algorithm. The advantage of this arrangement is that the searching efficiency of the picture can be improved. However, since the compressed vectors are stored in the first search, the similarity (distance) calculated using the compressed vectors has an error. In order to return correct data to the client, the primary search return result set is expanded in the scheme, and if the client requires Top N results, the number of the results returned by the primary search is N × R, so that all the accurate Top N results are ensured to be in the N × R results. In this embodiment, by using an asymmetric distance algorithm, candidate pictures whose similarity to a compressed vector of a picture to be searched is greater than a similarity threshold can be obtained, or ranking from large to small can be performed according to the similarity, and then a first-level search result picture is determined according to the ranking result.
When the number of candidate pictures with the similarity greater than the similarity threshold with the compressed vector of the picture to be searched exceeds N × R, the candidate pictures can be arranged according to the magnitude relation of the distances between the short vectors of the candidate pictures and the cluster center, and specifically, the candidate pictures with the similarity greater than the similarity threshold with the compressed vector of the picture to be searched can be arranged in the order from small to large, so that the candidate pictures with the N × R similarity closest to the picture to be searched are selected from all the candidate pictures with the similarity greater than the similarity threshold with the compressed vector of the picture to be searched. If the number of candidate pictures with the compressed vector similarity greater than the similarity threshold value with the picture to be searched is less than N R, the candidate pictures with the compressed vector similarity greater than the similarity threshold value with the picture to be searched can be used as output results.
In this embodiment, optionally, before determining the first-level search result picture according to the similarity, the method further includes: determining the number of first-level search result pictures; correspondingly, according to the similarity, determining a first-level search result picture comprises: and determining the first-level search result pictures according to the similarity and the number of the first-level search result pictures.
In this embodiment, the number of first-level search result pictures may be determined to be R times the number of N desired by the user. Therefore, the number of the first-level search result pictures can be determined according to the picture search precision requirement of the user, and if the precision requirement of the user search result is higher, R can be properly enlarged, so that the number of the first-level search result pictures is larger, and more accurate search results which meet the requirements better can be obtained in subsequent search.
S140, selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
After the first-stage search result picture is determined by the compressed vector, the original feature vector of the first-stage search result picture can be obtained and is finely compared with the original feature vector of the picture to be searched. And obtaining final second-level search result pictures which can be top N pieces.
In this embodiment, optionally, selecting a second-level search result picture from the first-level search result picture according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture, includes: according to the first-stage search result picture, acquiring an original feature vector of the first-stage search result picture from original feature vectors of all candidate pictures; and comparing the original characteristic vector of the picture to be searched with the original characteristic vector of the first-stage search result picture to determine a second-stage search result picture.
After the first-stage search returns N × R pieces of data, the corresponding N × R original feature vectors can be directly obtained to be accurately compared with the original feature vectors in the search conditions, and finally Top N records meeting the conditions are returned. At the moment, the calculated amount of the second-stage search is N R, and is greatly reduced compared with tens of millions of base libraries.
According to the technical scheme provided by the embodiment of the application, a search request of a picture to be searched is obtained; compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched; selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture; and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture. By adopting the technical scheme provided by the application, the effect of searching the images with the images can be realized at low cost and quickly.
Example two
Fig. 3 is a flowchart of a picture searching method according to a second embodiment of the present application. The present embodiment is optimized based on the above embodiments.
As shown in fig. 3, the picture searching method includes:
s310, obtaining a search request of the picture to be searched.
S320, compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched.
S330, selecting a first-level search result picture from each candidate picture through a CPU or a GPU according to the picture compression vector to be searched and each candidate picture compression vector; and compressing the candidate image compression vectors to obtain original feature vectors of the candidate images.
S340, selecting a second-level search result picture from the first-level search result pictures through a CPU or a GPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
The first-level search and the second-level search can be carried out in the CPU or the GPU, so that the method has the advantages that the first-level search and the second-level search can be flexibly set in the CPU or the GPU, the images can be searched in an appropriate mode, the calculation speed can be increased, and the working performance of the terminal is not influenced.
In this embodiment, preferably, a first-level search result picture is selected from the candidate pictures by the GPU according to the picture compression vector to be searched and the candidate picture compression vectors; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture; and selecting a second-level search result picture from the first-level search result pictures through a CPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
The method has the advantages that the original characteristic vectors of the pictures are compressed, the space occupied by the first-stage search is not huge like the space occupied by the first-stage search directly, the first-stage search can be carried out through the GPU, the characteristic of high searching speed of the GPU can be fully embodied, in the second-stage search process, compared with candidate pictures in the order of hundreds of millions of orders of magnitude, the data volume is greatly reduced through the searched pictures, the second-stage search is carried out through the CPU, the searching speed cannot be greatly influenced, the operating performance of searching equipment can be ensured, and the effect is very obvious.
On the basis of the above embodiments, the present embodiment provides a scheme for performing the first-level search and the second-level search through the CPU or the GPU, which has the advantages of ensuring the speed of searching the images with the images, reducing the cost, and avoiding the need of increasing the storage space of the GPU to increase the speed of searching the images with the images, thereby causing excessive cost consumption.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a picture searching apparatus according to a third embodiment of the present application. As shown in fig. 4, the picture searching apparatus includes:
a search request obtaining module 410, configured to obtain a search request for a picture to be searched;
an original feature vector compression module 420, configured to compress an original feature vector of the picture to be searched, to obtain a compressed vector of the picture to be searched;
the first-stage search module 430 is configured to select a first-stage search result picture from the candidate pictures according to the picture compression vector to be searched and the candidate picture compression vectors; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
the second-level search module 440 is configured to select a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
According to the technical scheme provided by the embodiment of the application, a search request of a picture to be searched is obtained; compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched; selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture; and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture. By adopting the technical scheme provided by the application, the effect of searching the images with the images can be realized at low cost and quickly.
On the basis of the foregoing technical solutions, optionally, the apparatus further includes a candidate picture compression module, where the candidate picture compression module is specifically configured to:
performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture;
clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers;
and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture.
On the basis of the above technical solutions, optionally, the original feature vector compression module includes:
the short vector determining unit is used for performing dimensionality reduction segmentation on the original characteristic vector of the picture to be searched to obtain a short vector of the picture to be searched;
and the compression unit is used for determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched.
On the basis of the above technical solutions, optionally, the first-level search module includes:
the similarity determining unit is used for determining the similarity between each candidate picture compression vector and the picture compression vector to be searched by adopting an asymmetric distance algorithm;
and the first-level search result determining unit is used for determining a first-level search result picture according to the similarity.
On the basis of the above technical solutions, optionally, the first-level search module further includes:
the first-level search result quantity determining unit is used for determining the quantity of the first-level search result pictures;
correspondingly, the first-level search result determining unit is specifically configured to:
and determining the first-level search result pictures according to the similarity and the number of the first-level search result pictures.
On the basis of the above technical solutions, optionally, the second-stage search module is specifically configured to:
according to the first-stage search result picture, acquiring an original feature vector of the first-stage search result picture from original feature vectors of all candidate pictures;
and comparing the original characteristic vector of the picture to be searched with the original characteristic vector of the first-stage search result picture to determine a second-stage search result picture.
On the basis of the above technical solutions, it is optional:
selecting a first-level search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector through a GPU; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures through a CPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
The product can execute the method provided by any embodiment of the application, and has the corresponding functional module and the beneficial effect of the execution method.
Example four
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, perform a method for searching a picture, the method including:
acquiring a search request of a picture to be searched;
compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
Storage medium-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk, or tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, Lanbas (Rambus) RAM, etc.; non-volatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the computer system in which the program is executed, or may be located in a different second computer system connected to the computer system through a network (such as the internet). The second computer system may provide the program instructions to the computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations, such as in different computer systems that are connected by a network. The storage medium may store program instructions (e.g., embodied as a computer program) that are executable by one or more processors.
Of course, the storage medium provided in the embodiments of the present application includes computer-executable instructions, and the computer-executable instructions are not limited to the above-described operations for searching pictures, and may also perform related operations in the method for searching pictures provided in any embodiment of the present application.
EXAMPLE five
The embodiment of the application provides electronic equipment, and a searching device of pictures provided by the embodiment of the application can be integrated in the electronic equipment. Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present application. As shown in fig. 5, the present embodiment provides an electronic device 500, which includes: one or more processors 520; the storage 510 is configured to store one or more programs, and when the one or more programs are executed by the one or more processors 520, the one or more processors 520 implement the method for searching for a picture provided in an embodiment of the present application, the method includes:
acquiring a search request of a picture to be searched;
compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
Of course, those skilled in the art can understand that the processor 520 may also implement the technical solution of the picture searching method provided in any embodiment of the present application.
The electronic device 500 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 5, the electronic device 500 includes a processor 520, a storage 510, an input 530, and an output 540; the number of the processors 520 in the electronic device may be one or more, and one processor 520 is taken as an example in fig. 5; the processor 520, the storage 510, the input device 530, and the output device 540 in the electronic apparatus may be connected by a bus or other means, and are exemplified by a bus 550 in fig. 5.
The storage device 510 is a computer-readable storage medium, and can be used to store software programs, computer-executable programs, and modules, such as program instructions corresponding to the picture searching method in the embodiment of the present application.
The storage device 510 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the electronic device, and the like. Further, the storage 510 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, storage 510 may further include memory located remotely from processor 520, which may be connected via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 530 may be used to receive input numbers, character information, or voice information, and to generate key signal inputs related to user settings and function control of the electronic apparatus. The output device 540 may include a display screen, speakers, etc.
The electronic equipment provided by the embodiment of the application can realize the effect of searching the image with the image quickly at low cost.
The picture searching device, the storage medium and the electronic device provided in the above embodiments can execute the picture searching method provided in any embodiment of the present application, and have corresponding functional modules and beneficial effects for executing the method. For technical details that are not described in detail in the above embodiments, reference may be made to a picture search method provided in any embodiment of the present application.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present application and the technical principles employed. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims (10)

1. A picture searching method is characterized by comprising the following steps:
acquiring a search request of a picture to be searched;
compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
selecting a first-stage search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
2. The method according to claim 1, wherein before obtaining the search request of the picture to be searched, the method further comprises:
performing dimensionality reduction segmentation on the original feature vector of each candidate picture to obtain a short vector of each candidate picture;
clustering all short vectors of each candidate picture by using a clustering algorithm to obtain a preset number of clustering centers;
and determining the clustering center with the nearest distance of the current short vector of each candidate picture, taking the number of the clustering center with the nearest distance as the vector value of the current short vector of each candidate picture, traversing all the short vectors of each candidate picture, and obtaining the compressed vector of each candidate picture.
3. The method of claim 2, wherein compressing the original feature vector of the picture to be searched to obtain a compressed vector of the picture to be searched comprises:
carrying out dimensionality reduction segmentation on the original characteristic vector of the picture to be searched to obtain a short vector of the picture to be searched;
and determining a cluster center which is closest to the current short vector of the picture to be searched in the cluster centers, traversing all the short vectors of the picture to be searched by taking the number of the cluster center which is closest to the current short vector of the picture to be searched as the vector value of the current short vector of the picture to be searched, and obtaining the compressed vector of the picture to be searched.
4. The method of claim 1, wherein selecting a first-level search result picture from the candidate pictures according to the picture compression vector to be searched and the candidate picture compression vectors comprises:
determining the similarity between each candidate picture compression vector and the picture compression vector to be searched by adopting an asymmetric distance algorithm;
and determining a first-level search result picture according to the similarity.
5. The method of claim 4, wherein prior to determining the first level search result picture based on the similarity, the method further comprises:
determining the number of first-level search result pictures;
correspondingly, according to the similarity, determining a first-level search result picture comprises:
and determining the first-level search result pictures according to the similarity and the number of the first-level search result pictures.
6. The method of claim 1, wherein selecting a second level search result picture from the first level search result pictures according to the original feature vector of the picture to be searched and the original feature vector of the first level search result picture comprises:
according to the first-stage search result picture, acquiring an original feature vector of the first-stage search result picture from original feature vectors of all candidate pictures;
and comparing the original characteristic vector of the picture to be searched with the original characteristic vector of the first-stage search result picture to determine a second-stage search result picture.
7. The method of claim 1, wherein:
selecting a first-level search result picture from each candidate picture according to the picture compression vector to be searched and each candidate picture compression vector through a GPU; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and selecting a second-level search result picture from the first-level search result pictures through a CPU according to the original feature vector of the picture to be searched and the original feature vector of the first-level search result picture.
8. An apparatus for searching a picture, comprising:
the search request acquisition module is used for acquiring a search request of a picture to be searched;
the original characteristic vector compression module is used for compressing the original characteristic vector of the picture to be searched to obtain a compressed vector of the picture to be searched;
the first-stage search module is used for selecting a first-stage search result picture from all candidate pictures according to the picture compression vector to be searched and all candidate picture compression vectors; wherein, the compressed vector of each candidate picture is obtained by compressing the original characteristic vector of each candidate picture;
and the second-stage searching module is used for selecting a second-stage searching result picture from the first-stage searching result pictures according to the original characteristic vector of the picture to be searched and the original characteristic vector of the first-stage searching result picture.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of searching for a picture according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of searching for a picture according to any one of claims 1-7 when executing the computer program.
CN201811643673.3A 2018-12-30 2018-12-30 Picture searching method and device, storage medium and electronic equipment Pending CN111382287A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811643673.3A CN111382287A (en) 2018-12-30 2018-12-30 Picture searching method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811643673.3A CN111382287A (en) 2018-12-30 2018-12-30 Picture searching method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN111382287A true CN111382287A (en) 2020-07-07

Family

ID=71222420

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811643673.3A Pending CN111382287A (en) 2018-12-30 2018-12-30 Picture searching method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111382287A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113111206A (en) * 2021-04-19 2021-07-13 浙江商汤科技开发有限公司 Image searching method and device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107577990A (en) * 2017-08-09 2018-01-12 武汉世纪金桥安全技术有限公司 A kind of extensive face identification method for accelerating retrieval based on GPU
CN108280233A (en) * 2018-02-26 2018-07-13 南京邮电大学 A kind of VideoGIS data retrieval method based on deep learning

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107577990A (en) * 2017-08-09 2018-01-12 武汉世纪金桥安全技术有限公司 A kind of extensive face identification method for accelerating retrieval based on GPU
CN108280233A (en) * 2018-02-26 2018-07-13 南京邮电大学 A kind of VideoGIS data retrieval method based on deep learning

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘正华: "大规模人脸图像检索系统的研究与实现" *
史亚东: "基于Hadoop平台的图像检索方法研究" *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113111206A (en) * 2021-04-19 2021-07-13 浙江商汤科技开发有限公司 Image searching method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111522986B (en) Image retrieval method, device, equipment and medium
US11055570B2 (en) Image processing method and apparatus for implementing image recognition, and electronic device
CN109359725B (en) Training method, device and equipment of convolutional neural network model and computer readable storage medium
CN110321448B (en) Image retrieval method, device and storage medium
CN111177438B (en) Image characteristic value searching method and device, electronic equipment and storage medium
CN112668608B (en) Image recognition method and device, electronic equipment and storage medium
US20220139085A1 (en) Method and apparatus for video frame processing
CN116580257A (en) Feature fusion model training and sample retrieval method and device and computer equipment
CN113987119A (en) Data retrieval method, cross-modal data matching model processing method and device
CN113344016A (en) Deep migration learning method and device, electronic equipment and storage medium
CN114565807A (en) Method and device for training target image retrieval model
CN112329660A (en) Scene recognition method and device, intelligent equipment and storage medium
CN115358397A (en) Parallel graph rule mining method and device based on data sampling
CN113590898A (en) Data retrieval method and device, electronic equipment, storage medium and computer product
CN111709473B (en) Clustering method and device for object features
CN111382287A (en) Picture searching method and device, storage medium and electronic equipment
CN110209895B (en) Vector retrieval method, device and equipment
WO2021012691A1 (en) Method and device for image retrieval
CN111767419A (en) Picture searching method, device, equipment and computer readable storage medium
CN116957041A (en) Method, device and computing equipment for compressing neural network model
CN106886783B (en) Image retrieval method and system based on regional characteristics
CN113901278A (en) Data search method and device based on global multi-detection and adaptive termination
CN116402090B (en) Processing method, device and equipment of neural network calculation graph
CN116932935A (en) Address matching method, device, equipment, medium and program product
CN110019905B (en) Information output method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination