Image index processing method, device, equipment, storage medium and program
By setting the pause query status before the image index collection is updated, the problem of image retrieval system crash is solved, and the real-time and stability of online update and retrieval of image index collection is realized.
Patent Information
- Application Number
- CN202110580683.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-26
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-05-26
AI Technical Summary
In the prior art, the stability of image retrieval performance is low, especially in the process of updating image index sets, which can easily lead to system crashes, affecting real-time and retrieval performance.
By setting the image index set to pause query status before it is updated, locking the image index set is achieved, avoiding the image search process from accessing the failed storage space, and thus performing the update and search process of the image index set online.
It improves the stability of image retrieval performance, ensures the real-time update and retrieval of image index sets, avoids system crashes, and supports concurrent execution of image retrieval process.
Smart Images

Figure CN113326389B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, apparatus, device, storage medium and program for processing image indexes. Background Art
[0002] With the development of Internet technology, the number of images on the Internet is increasing, which has led to the emergence of image retrieval technology. Image retrieval refers to the process of quickly retrieving the images that users need from a massive amount of images.
[0003] Currently, image retrieval technology requires constructing an image index set based on images in an image database. When a user needs to retrieve an image, the image to be retrieved is matched against the images corresponding to each image index in the image index set to determine the target image that matches the image to be retrieved. Whenever an image is added to the database, the image index set needs to be updated.
[0004] However, the inventors discovered during the implementation of this application that the stability of the image retrieval performance in the above-mentioned method is relatively low. Summary of the Invention
[0005] The present application provides an image index processing method, apparatus, device, storage medium and program for improving the stability of image retrieval performance.
[0006] In a first aspect, the present application provides a method for processing an image index, comprising:
[0007] Determining a first image index to be inserted into an image index set, wherein the image index set includes a plurality of image indexes and associations between the plurality of image indexes;
[0008] Determining at least one second image index associated with the first image index in the image index set;
[0009] Setting the image index set to a paused query state, and updating the image index set according to the first image index and the at least one second image index;
[0010] The image index set is set to a searchable state.
[0011] In a possible implementation, updating the image index set according to the first image index and the at least one second image index includes:
[0012] Adding the first image index to the image index set;
[0013] An association relationship between the first image index and each second image index is added to the image index set.
[0014] In a possible implementation, adding an association relationship between the first image index and each second image index in the image index set includes:
[0015] Acquire association relationship information corresponding to each second image index, wherein the association relationship information includes an identifier of an image index associated with the second image index;
[0016] Adding an identifier of the first image index to the association relationship information corresponding to the second image index;
[0017] According to the identifier of the at least one second image index, association relationship information corresponding to the first image index is generated.
[0018] In a possible implementation, setting the image index set to a suspended query state includes:
[0019] Setting the at least one second image index in the image index set to a pause query state;
[0020] Setting the image index set to a queryable state includes:
[0021] The at least one second image index in the image index set is set to a queryable state.
[0022] In a possible implementation, determining at least one second image index associated with the first image index in the image index set includes:
[0023] determining a similarity between a first image corresponding to the first image index and images corresponding to each image index in the image index set;
[0024] At least one second image index is determined in the image index set according to similarities between the first image and images corresponding to each image index in the image index set.
[0025] In one possible implementation, determining at least one second image index in the image index set based on similarity between the first image and images corresponding to each image index in the image index set includes:
[0026] Determine an image index in the image index set, whose corresponding image has a similarity with the first image greater than or equal to a first threshold, as the at least one second image index; or
[0027] The image indexes in the image index set are sorted in descending order of similarity between the first image and the images corresponding to each image index in the image index set, and the first N image indexes after sorting are determined as the at least one second image index, where N is an integer greater than or equal to 1.
[0028] In a possible implementation, the method further includes:
[0029] Determining a first image corresponding to the first image index;
[0030] determining a first storage space for the first image, where the first storage space is independent of storage spaces of images corresponding to respective image indexes in the image index set;
[0031] The first image is stored in the first storage space.
[0032] In a possible implementation, storing the first image in the first storage space includes:
[0033] determining a feature vector corresponding to the first image;
[0034] The feature vector is stored in the first storage space.
[0035] In a second aspect, the present application provides an image index processing device, comprising:
[0036] A first determining module is configured to determine a first image index to be inserted into an image index set, wherein the image index set includes a plurality of image indexes and associations between the plurality of image indexes;
[0037] A second determining module, configured to determine at least one second image index associated with the first image index in the image index set;
[0038] A processing module, configured to set the image index set to a paused query state, and update the image index set according to the first image index and the at least one second image index;
[0039] The processing module is further configured to set the image index set to a searchable state.
[0040] In one possible implementation, the processing module is specifically configured to:
[0041] Adding the first image index to the image index set;
[0042] An association relationship between the first image index and each second image index is added to the image index set.
[0043] In one possible implementation, the processing module is specifically configured to:
[0044] Acquire association relationship information corresponding to each second image index, wherein the association relationship information includes an identifier of an image index associated with the second image index;
[0045] Adding an identifier of the first image index to the association relationship information corresponding to the second image index;
[0046] According to the identifier of the at least one second image index, association relationship information corresponding to the first image index is generated.
[0047] In one possible implementation, the processing module is specifically configured to:
[0048] Setting the at least one second image index in the image index set to a pause query state;
[0049] The at least one second image index in the image index set is set to a queryable state.
[0050] In a possible implementation, the second determining module is specifically configured to:
[0051] determining a similarity between a first image corresponding to the first image index and images corresponding to each image index in the image index set;
[0052] At least one second image index is determined in the image index set according to similarities between the first image and images corresponding to each image index in the image index set.
[0053] In a possible implementation, the second determining module is specifically configured to:
[0054] Determine an image index in the image index set, whose corresponding image has a similarity with the first image greater than or equal to a first threshold, as the at least one second image index; or
[0055] The image indexes in the image index set are sorted in descending order of similarity between the first image and the images corresponding to each image index in the image index set, and the first N image indexes after sorting are determined as the at least one second image index, where N is an integer greater than or equal to 1.
[0056] In a possible implementation, the processing module is further configured to:
[0057] Determining a first image corresponding to the first image index;
[0058] determining a first storage space for the first image, where the first storage space is independent of storage spaces of images corresponding to respective image indexes in the image index set;
[0059] The first image is stored in the first storage space.
[0060] In one possible implementation, the processing module is specifically configured to:
[0061] determining a feature vector corresponding to the first image;
[0062] The feature vector is stored in the first storage space.
[0063] In a third aspect, the present application provides an electronic device comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to implement the method as described in any one of the first aspects.
[0064] In a fourth aspect, the present application provides a computer-readable storage medium, comprising: a computer program, wherein when the computer program is executed by a processor, the method as described in any one of the first aspects is implemented.
[0065] In a fifth aspect, the present application provides a computer program product, comprising: a computer program, which, when executed by a processor, implements the method as described in any one of the first aspects.
[0066] The present application provides a method, apparatus, device, storage medium, and program for processing image indexes. The method includes: determining a first image index to be inserted into an image index set, wherein the image index set includes multiple image indexes and associations between the multiple image indexes; determining at least one second image index in the image index set that has an association with the first image index; setting the image index set to a suspended query state; updating the image index set based on the first image index and the at least one second image index; and setting the image index set to a queryable state. In the above process, by setting the image index set to a suspended query state before updating the image index set, the update process of the image index set is locked, thereby avoiding the problem of system crashes caused by the image retrieval process accessing invalid storage space and improving the stability of image retrieval performance. Furthermore, both the image index set update process and the image retrieval process can be executed online, thereby ensuring the real-time performance of image index set updates and image retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0068] Figure 1 A schematic diagram of a possible system architecture provided in an embodiment of the present application;
[0069] Figure 2 A flowchart of an image index processing method provided in an embodiment of the present application;
[0070] Figure 3 A schematic diagram of an image indexing process provided in an embodiment of the present application;
[0071] Figure 4 A flowchart of another image index processing method provided in an embodiment of the present application;
[0072] Figure 5 A schematic diagram of another image indexing process provided in an embodiment of the present application;
[0073] Figure 6 A schematic diagram of an image storage space provided in an embodiment of the present application;
[0074] Figure 7 A performance diagram of an image retrieval system provided in an embodiment of the present application;
[0075] Figure 8 A schematic diagram of the structure of an image index processing device provided in an embodiment of the present application;
[0076] Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0078] The terms "first," "second," "third," "fourth," and so on (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, method, product, or apparatus.
[0079] Image retrieval is a technology that quickly locates the images a user needs from a vast amount of images. Image retrieval technology requires constructing an image index set based on the images in an image database. When a user requests an image, the image to be retrieved is matched against the images corresponding to the image indices in the image index set to determine the target image that matches the image to be retrieved. Whenever an image is added to the database, the image index set needs to be updated.
[0080] However, during the implementation of this application, the inventors discovered that, using the aforementioned approach, performing image retrieval while building or updating an image index set simultaneously could cause the image retrieval system to crash, impacting the stability of image retrieval performance. Therefore, updating the image index set had to be performed offline, which in turn affected the real-time nature of image index set updates and image retrieval.
[0081] To address the above technical issues, the inventors of this application analyzed the causes of image retrieval system crashes and discovered that: image index sets are stored in a dynamic storage structure, and the process of constructing or updating the image index sets can cause changes in the dynamic storage structure. For example, the dynamic storage structure needs to be expanded and / or the data in the dynamic storage structure needs to be modified. If image retrieval is performed simultaneously, the image retrieval process may access an invalid storage structure when accessing the image index set, causing the image retrieval system to crash.
[0082] However, in actual application scenarios, it is inevitable that the image retrieval process and the image index set update process are concurrent. Therefore, the above-mentioned existing technologies cannot meet the needs of these scenarios.
[0083] To this end, this application provides an image index processing method, apparatus, device, storage medium, and program. By locking the image index set, this method prevents the image retrieval process from accessing invalid storage structures due to image index set updates, thereby preventing image retrieval system crashes. This allows both the image index set update process and the image retrieval process to be executed online, ensuring real-time image retrieval.
[0084] To facilitate understanding, the system architecture involved in the embodiments of the present application is first described.
[0085] Figure 1 For a schematic diagram of a possible system architecture provided in the embodiment of the present application, please see Figure 1 The system architecture includes: a user device and an image retrieval system. The image retrieval system is deployed with an image index set, which includes multiple image indexes. The user device and the image retrieval system are connected via a network.
[0086] See also Figure 1 The user device can send a search request to the image retrieval system, which includes information about the image to be retrieved. After receiving the search request, the image retrieval system searches the image index set, obtains a search result (i.e., the retrieved target image), and sends the search result to the user device.
[0087] Continue to see Figure 1 The user device may also send an update request to the image retrieval system, including information about the image to be inserted. The image retrieval system updates the image index set based on the update request, adding the index of the image to be inserted to the image index set, thereby obtaining an updated image index set. The image retrieval system may also send an update result (e.g., update success or update failure) to the user device.
[0088] It should be noted that Figure 1 The system architecture shown can be applied to a variety of scenarios. For ease of understanding, the following uses an e-commerce scenario as an example.
[0089] In an exemplary scenario, the image retrieval system can be deployed in the server of an e-commerce platform. The image index set includes the index of each product image on the e-commerce platform. The user device that sends the retrieval request to the image retrieval system can be the terminal device corresponding to the buyer user. For example, when the buyer user needs to search for a specified product on the e-commerce platform, the terminal device can be used to send a retrieval request to the image retrieval system, so that the image retrieval system can retrieve the specified product based on the image index set. The user device that sends the update request to the image retrieval system can be the terminal device corresponding to the seller user. For example, when the seller user needs to put a new product on the shelf, the terminal device can be used to send an update request to the image retrieval system, so that the image retrieval system adds the image index of the new product to the image index set.
[0090] In the embodiment of the present application, the image index set update process and the image retrieval process can be performed online, without having to update the image index set offline as in the prior art, thereby ensuring the real-time nature of the image index set update and image retrieval.
[0091] The following specific embodiments are used to describe the technical solution of the present application in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0092] Figure 2 This is a flow chart of a method for processing image indexes provided in an embodiment of the present application. Figure 2 As shown, the method of this embodiment may include:
[0093] S201: Determine a first image index to be inserted into an image index set, where the image index set includes a plurality of image indexes and association relationships between the plurality of image indexes.
[0094] An image index is the index information used to search for an image. Each image corresponds to one image index. An image index can be an image identifier or information calculated by performing some computation on the image. An image index uniquely identifies an image.
[0095] An image index set includes multiple image indices and associations between the multiple image indices. These associations may refer to similarities between images. For example, assuming that image index A and image index B in the image index set have an association, this indicates that the similarity between the image corresponding to image index A and the image corresponding to image index B is greater than or equal to a preset threshold.
[0096] It should be noted that the image index set is a data structure constructed for multiple images in the database. The image index set can have various structural forms, for example, a list structure, a graph structure, etc.
[0097] Optionally, when the image index set adopts a graph structure, the image index set includes multiple nodes and edges connecting different nodes. Each node corresponds to an image index. When an edge exists between two nodes, it indicates that the image indexes corresponding to the two nodes are associated.
[0098] In one example, when it is detected that a first image is newly added to the database, a first image index corresponding to the first image is determined based on the first image, and the first image index is recorded as the image index to be inserted.
[0099] In another example, an update request may be received from a terminal device, the update request including a first image, and a first image index corresponding to the first image is determined based on the first image. The first image index is recorded as the image index to be inserted.
[0100] S202: Determine at least one second image index associated with the first image index in the image index set.
[0101] Exemplarily, the similarity between the first image corresponding to the first image index and the images corresponding to each image index in the image index set can be determined respectively, and then, based on the similarity between the first image and the images corresponding to each image index in the image index set, at least one second image index can be determined in the image index set.
[0102] Optionally, an image index in the image index set whose corresponding image has a similarity with the first image greater than or equal to a first threshold is determined as the at least one second image index. For example, each image index in the image set is traversed, and the similarity between the image corresponding to the image index and the first image is calculated. If the similarity is greater than or equal to the first threshold, the image index is determined as the second image index.
[0103] Optionally, the image indexes in the image index set are sorted in descending order of similarity between the first image and the images corresponding to the image indexes in the image index set, and the first N image indexes after the sorting are determined as the at least one second image index. N is an integer greater than or equal to 1.
[0104] S203: Setting the image index set to a paused query state, and updating the image index set according to the first image index and the at least one second image index.
[0105] S204: Setting the image index set to a searchable state.
[0106] The process of updating the image index set may include: expanding the storage space corresponding to the image index set, and / or modifying the data in the storage space corresponding to the image index set.
[0107] It should be understood that updating the image index set will cause changes in the storage space corresponding to the image index set. If the image retrieval process accesses the storage space corresponding to the image search set at this time, it will access invalid storage space, causing a system crash. Therefore, in this embodiment, before updating the image index set, the image index set is first set to a suspended query state. After the image index set is updated, the image index set is set to a queryable state.
[0108] By setting the image index set to a paused query state, it is equivalent to locking the update process of the image index set, which can avoid image retrieval while the image index set is being updated, thereby avoiding the problem of system crash caused by the image retrieval process accessing invalid storage space.
[0109] In the embodiment of the present application, since the process of determining at least one second image index associated with the first image index in the image index set (i.e., process S202) does not cause a change in the storage space corresponding to the image index set, the image index set is not set to the suspended query state as soon as it is determined that the first image index needs to be inserted. Instead, the image index set is set to the suspended query state only when it is actually necessary to update the image index set. In this way, the time for locking the image index set can be minimized, thereby preventing a significant impact on image retrieval performance.
[0110] Furthermore, after the image index set is set to the suspended query state, the image index set becomes unreadable. In this case, if an image retrieval request is received and the image index set is queried, the image index set will be found to be unreadable. In this case, in one example, the image retrieval process can directly return a retrieval failure. In another example, the image retrieval process can wait until the image index set becomes readable before retrying the search based on the image index set.
[0111] The following combination Figure 3 The image index processing procedure in this embodiment is exemplified.
[0112] Figure 3 This is a schematic diagram of an image indexing process provided by an embodiment of the present application. Figure 3 As shown, assuming that it is determined at time T0 that the first image index needs to be inserted, the execution process of this embodiment is triggered. In the specific execution process, at least one second image index associated with the first image index is first determined in the image index set (i.e., process S202). It can be understood that the above process of determining the second image index involves a large number of similarity calculations, which is time-consuming. Figure 3 The time period between time T0 and time T1 in .
[0113] After the second image index is determined, the image index set is locked at time T1. Then the image index set is updated. Assume that the image index set is updated at time T2. It can be understood that the time required to update the image index set is very short, corresponding to Figure 3 The time period between time T1 and time T2.
[0114] Continue to see Figure 3 If retrieval request 1 is received between time T1 and time T2, the image index set is unlocked during this time period, so the retrieval process for retrieval request 1 can be executed normally. If retrieval request 2 is received between time T1 and time T2, the image index set is locked during this time period, so the retrieval process for retrieval request 2 cannot be executed normally. If retrieval request 3 is received after time T2, the image index set is unlocked during this time period, so the retrieval process for retrieval request 3 can be executed normally.
[0115] Depend on Figure 3 It can be seen that in this embodiment, by setting the image index set to the suspended query state only when the image index set really needs to be updated, the image index set can be locked for a very short time, thereby not having a significant impact on image retrieval performance.
[0116] The image index processing method provided in this embodiment includes: determining a first image index to be inserted into an image index set, wherein the image index set includes multiple image indexes and associations between the multiple image indexes; determining at least one second image index in the image index set that has an association with the first image index; setting the image index set to a suspended query state; updating the image index set based on the first image index and the at least one second image index; and setting the image index set to a queryable state. In the above process, by setting the image index set to a suspended query state before updating the image index set, the update process of the image index set is locked, thereby avoiding the problem of system crashes caused by the image retrieval process accessing invalid storage space and improving the stability of image retrieval performance. Furthermore, both the image index set update process and the image retrieval process can be executed online, thereby ensuring the real-time performance of image index set updates and image retrieval.
[0117] Based on the above embodiments, the present application scheme is described in more detail below in conjunction with a more specific embodiment.
[0118] Figure 4 This is a flow chart of another image index processing method provided in an embodiment of the present application. Figure 4 As shown, the method of this embodiment includes:
[0119] S401: Determine a first image index to be inserted into an image index set, where the image index set includes a plurality of image indexes and associations between the plurality of image indexes.
[0120] S402: Determine at least one second image index associated with the first image index in the image index set.
[0121] It should be understood that the specific implementation process of S401 and S402 is the same as Figure 2 S201 and S202 are similar and are not described here.
[0122] S403: Setting the at least one second image index in the image index set to a paused query state.
[0123] S404: Add the first image index to the image index set.
[0124] S405: Add an association relationship between the first image index and each second image index in the image index set.
[0125] In one possible implementation, the association relationship information corresponding to each second image index can be obtained, and the association relationship information includes the identifier of the image index that has an association relationship with the second image index; the identifier of the first image index is added to the association relationship information corresponding to the second image index; and the association relationship information corresponding to the first image index is generated based on the identifier of at least one second image index.
[0126] It should be understood that when the data structure used by the image index set is different, the representation of the association relationship information corresponding to the image index may also be different. In some examples, the association relationship information corresponding to the image index can be represented in array form. In other examples, the association relationship corresponding to the image index can be represented by edges between different image indexes.
[0127] S406: Setting the at least one second image index in the image index set to a queryable state.
[0128] This embodiment and Figure 2 One difference of the illustrated embodiment is that only some of the image indexes in the image index set can be locked. Specifically, after determining the second image indexes associated with the first image index in the image index set, subsequent updates to the image index set only require updating the association information for each second image index, without updating the associations of other image indexes. Therefore, only the second image indexes in the image index set can be locked, minimizing the impact of the image index set update process on image retrieval performance.
[0129] In the embodiment of the present application, the image retrieval technology used by the image retrieval system includes but is not limited to: hierarchical NSW (Hierarchical Navigable Small World, HNSW) vector retrieval technology, inverted file product quantization (IVFPQ) vector retrieval technology, etc. Among them, HNSW is a new graph indexing technology that approximates k-nearest neighbor vector search, which has the advantages of good effect and fast speed. IVFPQ includes two algorithms: inverted file (IVF) and product quantization (PQ). Among them, IVF is a common indexing method applied to retrieval systems. PQ is a classic algorithm for quantizing compressed vectors. For ease of understanding, the following examples are given with HNSW as an example.
[0130] Figure 5 This is a schematic diagram of another image indexing process provided by an embodiment of the present application. Figure 5 As shown, the image index set adopts a graph structure based on HNSW, in which the nodes represent image indexes and the edges represent the association relationships between image indexes.
[0131] like Figure 5 As shown, assume that the image index set includes six image indexes, namely image indexes A, B, C, D, E, and F. The image index currently to be inserted is image index G. The similarities between the first image corresponding to image index G and the images corresponding to the six image indexes can be determined, and the four image indexes with the highest similarity (assuming k = 4) can be selected as the second image index. For example, assume that the four image indexes with the highest similarity are image indexes B, C, D, and F.
[0132] Continue to see Figure 5 , set the image indexes B, C, D, and F in the image index set to the suspended query state, that is, lock the image indexes B, C, D, and F ( Figure 5(The shading indicates locking in the image index set). It can be understood that since image indexes B, C, D, and F are associated with image index G, when the image index set is subsequently updated, the association between image indexes B, C, D, and F and image index G needs to be added. Therefore, locking image indexes B, C, D, and F can prevent the image retrieval process from accessing the above four image indexes. Furthermore, image index G is not associated with image indexes A and E. When the image index set is updated, image indexes A and E will not be modified. Therefore, image indexes A and E do not need to be locked. It can be seen that in this embodiment, locking the image index set with the smallest possible granularity can minimize the impact of the image index set update process on image retrieval performance.
[0133] Furthermore, after locking image indexes B, C, D, and F, the image index set can be updated. Specifically, image index G is added to the image index set, and an association is established between image index G and image indexes B, C, D, and F. Accordingly, after the image index set is updated, image indexes B, C, D, and F are unlocked, thus completing the entire insertion process.
[0134] In practice, image index sets and images are stored separately. Specifically, the image index set is stored in the index storage space, and the images corresponding to each image index in the image index set are stored in the image storage space. To insert a new image index into the image index set, the image index must be inserted into the image index set and the corresponding image must be added to the image storage space.
[0135] The above embodiment describes the process of inserting an image index into an image index set. The following describes the process of adding an image corresponding to an image index to an image storage space in conjunction with a specific embodiment.
[0136] In the process of realizing the present application, the inventors discovered that in the prior art, the image storage space is a whole block of storage space, that is, all images corresponding to each image index are stored in the whole block of storage space. When it is necessary to add an image, it is necessary to reapply for a larger image storage space, copy all images corresponding to all image indexes to the new image storage space, and also copy the newly inserted image to the new storage space. In this way, the original image storage space will become invalid. If the image retrieval process happens to access the invalid image storage space, the image retrieval system will crash. Therefore, the embodiment of the present application also improves the image storage space. The following is combined with Figure 6 Provide a description.
[0137] Figure 6A schematic diagram of an image storage space provided in an embodiment of the present application. In this embodiment, the image storage space is no longer a whole block of storage space, but can be stored in segments. Figure 6 Each image can correspond to a segmented storage space, and different images can be stored in different segmented storage spaces. Each segmented storage space is independent of each other. Optionally, the segmented storage space can use a raw vector (RawVector) structure.
[0138] Thus, when the first image corresponding to the first image index needs to be inserted, a first storage space can be determined for the first image. For example, a new segmented storage space can be allocated for the first image. The first storage space is independent of the storage spaces for images corresponding to the image indexes in the image index set. The first image is then stored in the first storage space.
[0139] Optionally, a feature vector corresponding to the first image can be determined and stored in the first storage space. Thus, each storage space stores the feature vector of the image. During image retrieval, the image's feature vector can be directly obtained from the image storage space for matching, without having to recalculate the image's feature vector each time, thereby improving image retrieval efficiency.
[0140] In this embodiment, by adopting a segmented storage structure, when a new image corresponding to the first image index needs to be inserted, it is only necessary to apply for a new segmented storage space for the newly inserted image to store the newly inserted image without affecting the previous block storage space. Figure 7 Assume that a new segmented storage space 7 is applied for the image corresponding to the first image index. In the process of storing the image corresponding to the first image index in the segmented storage space 7, if the image retrieval process accesses the segmented storage space 2, since the segmented storage space 7 is isolated from the previous block storage space, the image retrieval process will not access the invalid storage space. Therefore, the image retrieval system will not crash, thereby improving the image retrieval performance.
[0141] Based on the above embodiments, Figure 7 The image retrieval effect of the embodiment of the present application is described.
[0142] Figure 7 A performance diagram of an image retrieval system provided in an embodiment of the present application. Figure 7 In the figure, the horizontal and vertical axes represent the construction parameters, i.e., the parameters used in the process of building the image index set. The left vertical axis represents the time taken to insert the image index, and the right vertical axis represents the time taken to retrieve the image. Figure 7The figure shows a comparison of the image index insertion time of this embodiment and the image index insertion time of the prior art. Furthermore, the figure also shows a comparison of the image retrieval time of this embodiment and the image retrieval time of the prior art. The dotted line represents the prior art, and the solid line represents the embodiment of this application.
[0143] Depend on Figure 7 It can be seen that, compared with the prior art, this embodiment has no significant difference in image index insertion performance and image retrieval performance, but provides the capability of supporting concurrent image index insertion and image retrieval, thereby being applicable to more scenarios.
[0144] Figure 8 This is a schematic diagram of the structure of an image index processing device provided in an embodiment of the present application. The device of this embodiment can be in the form of software and / or hardware. Figure 8 As shown, the image index processing device 800 provided in this embodiment includes: a first determination module 801 , a second determination module 802 and a processing module 803 .
[0145] The first determining module 801 is configured to determine a first image index to be inserted into an image index set, wherein the image index set includes a plurality of image indexes and associations between the plurality of image indexes;
[0146] A second determining module 802 is configured to determine at least one second image index associated with the first image index in the image index set;
[0147] A processing module 803 is configured to set the image index set to a paused query state, and update the image index set according to the first image index and the at least one second image index;
[0148] The processing module 803 is further configured to set the image index set to a searchable state.
[0149] In a possible implementation, the processing module 803 is specifically configured to:
[0150] Adding the first image index to the image index set;
[0151] An association relationship between the first image index and each second image index is added to the image index set.
[0152] In a possible implementation, the processing module 803 is specifically configured to:
[0153] Acquire association relationship information corresponding to each second image index, wherein the association relationship information includes an identifier of an image index associated with the second image index;
[0154] Adding an identifier of the first image index to the association relationship information corresponding to the second image index;
[0155] According to the identifier of the at least one second image index, association relationship information corresponding to the first image index is generated.
[0156] In a possible implementation, the processing module 803 is specifically configured to:
[0157] Setting the at least one second image index in the image index set to a pause query state;
[0158] The at least one second image index in the image index set is set to a queryable state.
[0159] In a possible implementation, the second determining module 802 is specifically configured to:
[0160] determining a similarity between a first image corresponding to the first image index and images corresponding to each image index in the image index set;
[0161] At least one second image index is determined in the image index set according to similarities between the first image and images corresponding to each image index in the image index set.
[0162] In a possible implementation, the second determining module 802 is specifically configured to:
[0163] Determine an image index in the image index set, whose corresponding image has a similarity with the first image greater than or equal to a first threshold, as the at least one second image index; or
[0164] The image indexes in the image index set are sorted in descending order of similarity between the first image and the images corresponding to each image index in the image index set, and the first N image indexes after sorting are determined as the at least one second image index, where N is an integer greater than or equal to 1.
[0165] In a possible implementation, the processing module 803 is further configured to:
[0166] Determining a first image corresponding to the first image index;
[0167] determining a first storage space for the first image, where the first storage space is independent of storage spaces of images corresponding to respective image indexes in the image index set;
[0168] The first image is stored in the first storage space.
[0169] In a possible implementation, the processing module 803 is specifically configured to:
[0170] determining a feature vector corresponding to the first image;
[0171] The feature vector is stored in the first storage space.
[0172] The image index processing device provided in this embodiment can be used to execute the image index processing method in any of the above method embodiments. Its implementation principles and technical effects are similar and will not be described in detail here.
[0173] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may be a server corresponding to an image retrieval system. Figure 9 As shown, the electronic device 900 provided in this embodiment includes: a processor 901 and a memory 902.
[0174] The memory 902 is configured to store computer programs, and the processor 901 is configured to execute the computer programs stored in the memory to implement one or more steps of the image indexing processing method in the above-described embodiment. For details, please refer to the relevant descriptions in the above-described method embodiments. The implementation principles and technical effects are similar and will not be further described in this embodiment.
[0175] Optionally, the memory 902 may be independent or integrated with the processor 901 .
[0176] When the memory 902 is a device independent of the processor 901 , the electronic device 900 may further include a bus 903 for connecting the memory 902 and the processor 901 .
[0177] An embodiment of the present application also provides a computer-readable storage medium, which includes a computer program. The computer program is used to implement one or more steps in the image index processing method in any of the above method embodiments. The implementation principle and technical effects are similar and will not be repeated here.
[0178] An embodiment of the present application also provides a chip, including: a memory and a processor, wherein a computer program is stored in the memory, and the processor runs the computer program to execute one or more steps of the image index processing method in any of the above method embodiments. The implementation principles and technical effects are similar and will not be repeated here.
[0179] An embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements one or more steps of the image index processing method in any of the above method embodiments. Its implementation principles and technical effects are similar and are not repeated here.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or module, which can be electrical, mechanical or other forms.
[0181] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0182] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each module may exist physically separately, or two or more modules may be integrated into a single unit. The above-mentioned modules may be implemented in the form of hardware or hardware plus software functional units.
[0183] The above-mentioned integrated module implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform some steps of the method described in various embodiments of the present application.
[0184] It should be understood that the processor described above may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), or application-specific integrated circuits (ASICs). A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0185] The memory may include a high-speed RAM memory, and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk.
[0186] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be classified into address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.
[0187] The storage medium may be implemented by any type of volatile or non-volatile memory device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0188] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and storage medium can be located in an application-specific integrated circuit (ASIC). Of course, the processor and storage medium can also exist as discrete components in an electronic device or a main control device.
[0189] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for processing an image index, characterized in that: include: Determining a first image index to be inserted into an image index set, wherein the image index set includes a plurality of image indexes and associations between the plurality of image indexes; Determining at least one second image index associated with the first image index in the image index set; Setting the image index set to a paused query state, and updating the image index set according to the first image index and the at least one second image index; The image index set is set to a searchable state.
2. The method according to claim 1, characterized in that Updating the image index set according to the first image index and the at least one second image index includes: Adding the first image index to the image index set; An association relationship between the first image index and each second image index is added to the image index set.
3. The method according to claim 2, characterized in that Adding an association relationship between the first image index and each second image index in the image index set includes: Acquire association relationship information corresponding to each second image index, wherein the association relationship information includes an identifier of an image index associated with the second image index; Adding an identifier of the first image index to the association relationship information corresponding to the second image index; According to the identifier of the at least one second image index, association relationship information corresponding to the first image index is generated.
4. The method according to claim 1, wherein Setting the image index set to a suspended query state includes: Setting the at least one second image index in the image index set to a pause query state; Setting the image index set to a queryable state includes: The at least one second image index in the image index set is set to a queryable state.
5. The method according to any one of claims 1 to 4, characterized in that Determining at least one second image index associated with the first image index in the image index set includes: determining a similarity between a first image corresponding to the first image index and images corresponding to each image index in the image index set; At least one second image index is determined in the image index set according to similarities between the first image and images corresponding to each image index in the image index set.
6. The method according to claim 5, characterized in that Determining at least one second image index in the image index set according to similarities between the first image and images corresponding to respective image indexes in the image index set includes: Determine an image index in the image index set, whose corresponding image has a similarity with the first image greater than or equal to a first threshold, as the at least one second image index; or The image indexes in the image index set are sorted in descending order of similarity between the first image and the images corresponding to each image index in the image index set, and the first N image indexes after sorting are determined as the at least one second image index, where N is an integer greater than or equal to 1.
7. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Determining a first image corresponding to the first image index; determining a first storage space for the first image, where the first storage space is independent of storage spaces of images corresponding to respective image indexes in the image index set; The first image is stored in the first storage space.
8. The method according to claim 7, characterized in that Storing the first image in the first storage space includes: determining a feature vector corresponding to the first image; The feature vector is stored in the first storage space.
9. An image index processing device, characterized in that: include: A first determining module is configured to determine a first image index to be inserted into an image index set, wherein the image index set includes a plurality of image indexes and associations between the plurality of image indexes; A second determining module, configured to determine at least one second image index associated with the first image index in the image index set; A processing module, configured to set the image index set to a paused query state, and update the image index set according to the first image index and the at least one second image index; The processing module is further configured to set the image index set to a searchable state.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that include: A computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that include: A computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image retrieval method and device, electronic device, and storage medium
CN109325141A
Target image retrieval method and device, computer equipment and storage medium
CN111177440A