CN111813988B - HNSW node deletion method, system, device and medium for image feature library - Google Patents
HNSW node deletion method, system, device and medium for image feature library Download PDFInfo
- Publication number
- CN111813988B CN111813988B CN202010925664.4A CN202010925664A CN111813988B CN 111813988 B CN111813988 B CN 111813988B CN 202010925664 A CN202010925664 A CN 202010925664A CN 111813988 B CN111813988 B CN 111813988B
- Authority
- CN
- China
- Prior art keywords
- node
- nodes
- deleted
- hnsw
- graph
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 37
- 238000012217 deletion Methods 0.000 title claims abstract description 33
- 230000037430 deletion Effects 0.000 title claims abstract description 33
- 230000002457 bidirectional effect Effects 0.000 claims 2
- 238000012545 processing Methods 0.000 description 12
- 238000004891 communication Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 8
- 238000004364 calculation method Methods 0.000 description 7
- 230000000694 effects Effects 0.000 description 4
- 238000010845 search algorithm Methods 0.000 description 4
- 230000008859 change Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 230000001815 facial effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/50—Information retrieval; Database structures therefor; File system structures therefor of still image data
- G06F16/58—Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
- G06F16/583—Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V40/00—Recognition of biometric, human-related or animal-related patterns in image or video data
- G06V40/10—Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
- G06V40/16—Human faces, e.g. facial parts, sketches or expressions
- G06V40/168—Feature extraction; Face representation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Oral & Maxillofacial Surgery (AREA)
- Health & Medical Sciences (AREA)
- Library & Information Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Health & Medical Sciences (AREA)
- Human Computer Interaction (AREA)
- Multimedia (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
Abstract
The invention provides a method, a system, equipment and a medium for deleting HNSW nodes in an image feature library, which comprise the following steps: acquiring nodes to be deleted and the levels thereof in an HNSW graph from an image feature library; finding out nodes associated with the nodes to be deleted according to the hierarchical relation corresponding to each node in the HNSW graph; establishing a connection relationship between the associated nodes; deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library; the invention does not influence the overall structure of the graph, does not reduce the searching speed and accuracy of the graph after multiple times of deletion, has simple and flexible node deletion interface, can update in real time and improves the user experience.
Description
Technical Field
The present invention relates to the field of image processing, and in particular, to a method, system, device, and medium for HNSW node deletion for an image feature library.
Background
In the field of face recognition, the nearest neighbor search algorithm is widely applied, and along with the continuous development of the technology and the continuous change of the market environment, the requirements of the product on the speed and the accuracy of the search algorithm are higher and higher.
At present, the best effect among the nearest neighbor search algorithms recognized by the industry is the search algorithm based on the graph. In the field of vector comparison, which has high requirement on accuracy and tens of millions of data volumes, of face feature comparison, the best performance is the graph-based neighbor search method, HNSW (Hierarchical navigatable Small World).
The HNSW algorithm has the advantage of being unique in vector search at the ten-million level, the accuracy is at the top level, and the time complexity is only logarithmic complexity. Therefore, the method is widely applied to the field of human face feature comparison.
As is known, in the actual application of face recognition, the identified base library needs to be updated frequently, but since the HNSW thesis does not provide a method for deleting nodes, information can only be updated by reconstructing the base each time, which results in great waste of time and labor and failure to implement real-time update of nodes. In the prior art, there are two general ways to delete HNSW nodes, one of which is to establish a blacklist and to record the deleted node information into the blacklist, and this way does not actually delete nodes, and when the number of the blacklist exceeds a certain threshold, the searching efficiency is seriously affected, and only a new graph can be reconstructed; second, the node to be deleted is copied and replaced by the node most similar to it. This method does not affect the integrity of the graph, but it is complicated if the node that has just been copied needs to be deleted in the future, because it is not known how many parts of this node are distributed in which places of the graph, and the repeated deletion may be problematic, and if the node is shifted a little while being copied, a new problem may occur, which may cause the node that has been shifted to be possibly output by the future graph, and this node information is not in our base library, which may cause the user of the interface to be overwhelmed.
Disclosure of Invention
In view of the above problems in the prior art, the present invention provides a method for deleting HNSW nodes, which mainly solves the problems that the conventional HNSW node deleting operation is complex and is difficult to update in real time.
In order to achieve the above and other objects, the present invention adopts the following technical solutions.
The HNSW node deleting method for the image feature library comprises the following steps:
acquiring nodes to be deleted and the levels thereof in an HNSW graph from an image feature library;
finding out nodes associated with the nodes to be deleted according to the hierarchical relation corresponding to each node in the HNSW graph;
establishing a connection relationship between the associated nodes;
and deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library.
Optionally, the associated node comprises: a node most similar to the node to be deleted, a node connected to the node to be deleted in the HNSW graph.
Optionally, the method further comprises: and if the sum of the number of the nodes connected with the node to be deleted and the most similar node is greater than the preset number, deleting redundant nodes, and keeping the number of the remaining nodes the same as the preset number.
Optionally, the establishing a connection relationship between the associated nodes includes: a bi-directional connection relationship between the most similar node and the remaining nodes.
Optionally, the remaining nodes are selected according to a rule of distance to the most similar node.
Optionally, a time threshold is set, and when the time interval during which the node is not accessed exceeds the time threshold, the corresponding node is taken as the node to be deleted; and/or setting a frequency threshold, and when the visited frequency of the node is lower than the frequency threshold, taking the corresponding node as the node to be deleted.
An HNSW node deletion system for an image feature library, comprising:
the node acquisition module is used for acquiring nodes to be deleted in the HNSW graph from the image feature library and the levels of the nodes;
the node deleting module is used for finding out nodes associated with the nodes to be deleted according to the hierarchical relationship corresponding to the nodes in the HNSW graph; establishing a connection relationship between the associated nodes; and deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library.
Optionally, the associated node comprises: a node most similar to the node to be deleted, a node connected to the node to be deleted in the HNSW graph.
Optionally, the node deletion module is connected to the node number detection module, and configured to delete redundant nodes if a sum of the number of nodes connected to the node to be deleted and the most similar node is greater than a preset number, so that the number of the remaining nodes is the same as the preset number.
Optionally, the establishing a connection relationship between the associated nodes includes: a bi-directional connection relationship between the most similar node and the remaining nodes.
Optionally, the node number detecting module includes a rule setting unit, configured to select the remaining nodes according to a rule that the distance to the most similar node is far or near.
Optionally, the node obtaining module includes a node selecting unit, configured to set a time threshold, and when a time interval during which a node is not accessed exceeds the time threshold, take the corresponding node as the node to be deleted; and/or setting a frequency threshold, and when the visited frequency of the node is lower than the frequency threshold, taking the corresponding node as the node to be deleted.
An apparatus, comprising:
one or more processors; and
one or more machine readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the node deletion method for an image feature library.
One or more machine readable media having instructions stored thereon that, when executed by one or more processors, cause an apparatus to perform the HNSW node deletion method for an image feature library.
As described above, the HNSW node deletion method, system, device, and medium for an image feature library of the present invention have the following advantageous effects.
The connection relation of the nodes to be deleted is replaced by the nearest nodes of the nodes to be deleted, the overall structure of the HNSW graph is not damaged, the searching efficiency and precision are not influenced, and the number of the deleted nodes is not limited.
Drawings
Fig. 1 is a flowchart of an HNSW node deletion method for an image feature library according to an embodiment of the present invention.
Fig. 2 is a block diagram of an HNSW node deletion system for an image feature library according to an embodiment of the present invention.
Fig. 3 is a schematic structural diagram of a terminal device in an embodiment of the present invention.
Fig. 4 is a schematic structural diagram of a terminal device in another embodiment of the present invention.
Fig. 5 is a schematic diagram of HNSW before node deletion according to an embodiment of the present invention.
Fig. 6 is a schematic diagram of HNSW after node deletion according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
Referring to FIG. 1, the present invention provides a HNSW node deleting method for an image feature library, which includes steps S01-S02.
In step S01, the node to be deleted in the HNSW graph from the image feature library and the level thereof are obtained:
in an embodiment, a time threshold may be set, and when the time interval during which the node in HNSW is not accessed exceeds the time threshold, the corresponding node is taken as the node to be deleted. If the node N contains the facial features of the target object A and the node is not visited again for more than one month, the node can be judged to be an unusually used node, and the node can be classified into a list of nodes to be deleted. The time threshold may be adjusted according to the actual application scenario.
In an embodiment, a frequency threshold may also be set, and when the visited frequency of a node in HNSW is lower than the frequency threshold, the corresponding node may be regarded as a node to be deleted. If the frequency threshold can be set to 5 times a month and the node N is only accessed 1 time in a month, the node N can be classified into the list of nodes to be deleted. By the method, the occupation of part of the unused nodes on the memory can be reduced.
In an embodiment, before each node in HNSW is put into a database, a random function is used to obtain its own level, which determines the importance of the node, and the higher the level is, the greater the navigation function in the search is, and once the level is determined, the level cannot be modified. Wherein the random function can be expressed as:
When the node deleting operation is carried out, the corresponding hierarchy can be directly obtained according to the layer where the node to be deleted is located.
In step S02, finding out a node associated with the node to be deleted according to the hierarchical relationship corresponding to each node in the HNSW graph;
establishing a connection relationship between the associated nodes;
and deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library.
The node hierarchy of the HNSW through the random function means that the node is highest projected to the second layer of the HNSW, the nodes exist from the highest layer to the bottom layer of the HNSW, and the searching process of the HNSW is from top to bottom. Node deletion can also be performed layer by layer in an up-down manner. The method comprises the steps of firstly, obtaining the levels of nodes to be deleted when the nodes to be deleted are put in a warehouse, and obtaining all nodes connected with the nodes to be deleted in each level and the corresponding connection relation by taking the highest level of the nodes to be deleted as a starting point and the bottom level as an end point.
Further, a node most similar to the node to be deleted is acquired as a nearest node. The similarity between the node to be deleted and other nodes in the current hierarchy can be calculated, and the node with the highest similarity is selected as the nearest neighbor node. Specifically, the feature similarity stored in the nodes can be calculated, and the similarity between the nodes can be further judged. The similarity calculation method may adopt one of the commonly used feature similarity calculation methods, such as a preselected similarity calculation method, an euclidean distance calculation method, a paradigm distance calculation method, and the like. After the nearest neighbor node is obtained, all nodes connected with the nearest neighbor node and the corresponding connection relation can be further obtained.
In an embodiment, the union of all the connection relationships of the nodes to be deleted in the highest hierarchy and all the connection relationships of the corresponding nearest nodes may be stored in an array, and the connection relationships in the array may be screened according to a rule of distance from the nearest nodes.
Specifically, the number of nodes (i.e., the preset number) to which a single node can be connected at most is specified in each level in the HNSW graph;
if the sum of the number of the nodes connected with the node to be deleted and the most similar node is larger than the preset number, deleting redundant nodes, and keeping the number of the remaining nodes the same as the preset number;
and if the sum of the number of the nodes connected with the node to be deleted and the most similar node is less than the preset number, keeping all the remaining connection relations.
In general, for graph search based on HNSW, in order to improve the search accuracy, the lowest layer is often set to be 2 times of the preset number of nodes, and if the preset number of nodes is specified to be 6, the maximum connection relation limit of the nodes at the bottom layer may be set to be 12. The maximum connection relation quantity of the nodes can be adjusted according to the actual application scene.
In one embodiment, before selecting the connection relations exceeding the preset number for deletion, the distance between the remaining nodes and the nearest neighbor node can be calculated, and the connection relations meeting the preset number are selected according to the distance in a descending order.
In an embodiment, the distance between the nodes may be calculated according to the similarity between the nodes, and when the connection relationship between the nearest neighboring node of the current hierarchy and other nodes is established (without considering the node to be deleted), the similarity between the nearest neighboring node and other nodes may be respectively calculated, and the nodes with the highest corresponding number of similarities are selected according to the similarity ranking to establish the connection relationship. If the preset number is 8 and the number of nodes connected with the node to be deleted is 6, all the nodes and the connection relation need to be reserved. And 6 nearest nodes of the nearest neighbor node X are calculated to establish a connection relation.
Referring to fig. 5, the node to be deleted is node 7, the predetermined number of nodes in the HNSW graph is 6, and the level of the node 7 to be deleted is the second last level.
Firstly, the nearest neighbor node of the node 7 is found as the node 4 through the node similarity calculation in the graph of the penultimate layer;
further, all nodes connected to the node 7 and the node 4 are found. In this embodiment, nodes 1, 2, 3, 5, 6, 8, and 9.
Since the preset number is 6, and the union of all the connection nodes of the node 7 and the node 4 is 7, which is larger than the preset number of nodes specified by the HNSW graph, 6 of the 7 nodes need to be selected for constructing the hierarchical network after the node 7 is deleted.
Specifically, the distances from the 7 nodes to the point 4 may be sequentially calculated, and the distance calculation may be performed by using cosine distances, euclidean distances, and the like. 6 points with the nearest distance are selected: 1. 2, 3, 6, 8 and 9. And establishing the connection relationship between the node 4 and the selected 6 points, and deleting the node 7 and all the connection relationships with the node 7.
And after finishing deleting the nodes of the penultimate hierarchy, entering the bottom layer, and repeating the steps to delete the nodes to be deleted at the bottom layer.
Referring to fig. 6, fig. 6 is a HNSW diagram after deleting node 7.
Referring to fig. 2, the present embodiment provides an HNSW node deletion system for executing the HNSW node deletion method in the foregoing method embodiment. Since the technical principle of the system embodiment is similar to that of the method embodiment, repeated description of the same technical details is omitted.
In an embodiment, the HNSW node deletion system for an image feature library includes a node obtaining module 10 and a node deleting module 11, where the node obtaining module 10 is configured to assist in executing step S01 described in the foregoing method embodiment, and the node deleting module 11 is configured to execute step S02 described in the foregoing method embodiment.
In one embodiment, the associated node comprises: a node most similar to the node to be deleted, a node connected to the node to be deleted in the HNSW graph.
In an embodiment, the node deletion module 11 is further configured to, in response to the node number detection module, further include: and if the sum of the number of the nodes connected with the node to be deleted and the most similar node is greater than the preset number, deleting redundant nodes, and keeping the number of the remaining nodes the same as the preset number.
In one embodiment, establishing the connection relationship between the associated nodes comprises: a bi-directional connection relationship between the most similar node and the remaining nodes.
In an embodiment, the node number detection module includes a rule setting unit, configured to select the remaining nodes according to a rule of distance to the most similar node.
In an embodiment, the node obtaining module 10 includes a node selecting unit, configured to set a time threshold, and when a time interval during which a node is not accessed exceeds the time threshold, take the corresponding node as the node to be deleted; and/or setting a frequency threshold, and when the visited frequency of the node is lower than the frequency threshold, taking the corresponding node as the node to be deleted.
An embodiment of the present application further provides an apparatus, which may include: one or more processors; and one or more machine readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of fig. 1. In practical applications, the device may be used as a terminal device, and may also be used as a server, where examples of the terminal device may include: the mobile terminal includes a smart phone, a tablet computer, an electronic book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop, a vehicle-mounted computer, a desktop computer, a set-top box, an intelligent television, a wearable device, and the like.
The embodiment of the present application further provides a non-volatile readable storage medium, where one or more modules (programs) are stored in the storage medium, and when the one or more modules are applied to a device, the device may be enabled to execute instructions (instructions) of steps included in the HNSW node deletion method for an image feature library in fig. 1 according to the embodiment of the present application.
Fig. 3 is a schematic diagram of a hardware structure of a terminal device according to an embodiment of the present application. As shown, the terminal device may include: an input device 1100, a first processor 1101, an output device 1102, a first memory 1103, and at least one communication bus 1104. The communication bus 1104 is used to implement communication connections between the elements. The first memory 1103 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and the first memory 1103 may store various programs for performing various processing functions and implementing the method steps of the present embodiment.
Alternatively, the first processor 1101 may be, for example, a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a controller, a microcontroller, a microprocessor, or other electronic components, and the processor 1101 is coupled to the input device 1100 and the output device 1102 through a wired or wireless connection.
Optionally, the input device 1100 may include a variety of input devices, such as at least one of a user-oriented user interface, a device-oriented device interface, a software programmable interface, a camera, and a sensor. Optionally, the device interface facing the device may be a wired interface for data transmission between devices, or may be a hardware plug-in interface (e.g., a USB interface, a serial port, etc.) for data transmission between devices; optionally, the user-facing user interface may be, for example, a user-facing control key, a voice input device for receiving voice input, and a touch sensing device (e.g., a touch screen with a touch sensing function, a touch pad, etc.) for receiving user touch input; optionally, the programmable interface of the software may be, for example, an entry for a user to edit or modify a program, such as an input pin interface or an input interface of a chip; the output devices 1102 may include output devices such as a display, audio, and the like.
In this embodiment, the processor of the terminal device includes a function for executing each module of the speech recognition apparatus in each device, and specific functions and technical effects may refer to the above embodiments, which are not described herein again.
Fig. 4 is a schematic hardware structure diagram of a terminal device according to another embodiment of the present application. Fig. 4 is a specific embodiment of fig. 3 in an implementation process. As shown, the terminal device of the present embodiment may include a second processor 1201 and a second memory 1202.
The second processor 1201 executes the computer program code stored in the second memory 1202 to implement the method described in fig. 1 in the above embodiment.
The second memory 1202 is configured to store various types of data to support operations at the terminal device. Examples of such data include instructions for any application or method operating on the terminal device, such as messages, pictures, videos, and so forth. The second memory 1202 may include a Random Access Memory (RAM) and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
Optionally, a second processor 1201 is provided in the processing assembly 1200. The terminal device may further include: communication components 1203, power components 1204, multimedia components 1205, audio components 1206, input/output interfaces 1207, and/or sensor components 1208. The specific components included in the terminal device are set according to actual requirements, which is not limited in this embodiment.
The processing component 1200 generally controls the overall operation of the terminal device. The processing assembly 1200 may include one or more second processors 1201 to execute instructions to perform all or part of the steps of the method illustrated in fig. 1 described above. Further, the processing component 1200 can include one or more modules that facilitate interaction between the processing component 1200 and other components. For example, the processing component 1200 can include a multimedia module to facilitate interaction between the multimedia component 1205 and the processing component 1200.
The power supply component 1204 provides power to the various components of the terminal device. The power components 1204 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the terminal device.
The multimedia components 1205 include a display screen that provides an output interface between the terminal device and the user. In some embodiments, the display screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the display screen includes a touch panel, the display screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
The audio component 1206 is configured to output and/or input speech signals. For example, the audio component 1206 includes a Microphone (MIC) configured to receive external voice signals when the terminal device is in an operational mode, such as a voice recognition mode. The received speech signal may further be stored in the second memory 1202 or transmitted via the communication component 1203. In some embodiments, audio component 1206 also includes a speaker for outputting voice signals.
The input/output interface 1207 provides an interface between the processing component 1200 and peripheral interface modules, which may be click wheels, buttons, etc. These buttons may include, but are not limited to: a volume button, a start button, and a lock button.
The sensor component 1208 includes one or more sensors for providing various aspects of status assessment for the terminal device. For example, the sensor component 1208 may detect an open/closed state of the terminal device, relative positioning of the components, presence or absence of user contact with the terminal device. The sensor assembly 1208 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact, including detecting the distance between the user and the terminal device. In some embodiments, the sensor assembly 1208 may also include a camera or the like.
The communication component 1203 is configured to facilitate communications between the terminal device and other devices in a wired or wireless manner. The terminal device may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In one embodiment, the terminal device may include a SIM card slot therein for inserting a SIM card therein, so that the terminal device may log onto a GPRS network to establish communication with the server via the internet.
As can be seen from the above, the communication component 1203, the audio component 1206, the input/output interface 1207 and the sensor component 1208 in the embodiment of fig. 4 may be implemented as the input device in the embodiment of fig. 3.
In summary, the HNSW node deletion method, system, device and medium for the image feature library of the present invention do not change the integrity of the graph and actually delete the node information, so the deletion operation has no limitation on the number of times, and does not need to be used in combination with a black list, thereby enhancing the portability of the algorithm; because the connection relation of a part of nodes to be deleted is transferred to the nodes most similar to the nodes, and the deletion principle is consistent with the graph establishment principle of the HNSW, the deletion operation does not influence the overall searching efficiency and progress of the HNSW and does not cause the reduction of the searching speed and accuracy; the time consumption is short. Theoretically, the deletion work of one node can be finished only by searching the current graph once and adding the time of one node in the current graph; the integrity of the graph can be guaranteed. The node deleting operation adopts the same principle as the graph building, so that the integrity of the graph can be ensured to the maximum extent; the real-time updating is realized, the node interface deletion is simple and flexible, the real-time updating can be realized, and the user experience is improved; the overall structure of the graph is not influenced, and the searching speed and accuracy of the graph cannot be reduced by deleting the graph for multiple times. Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.
Claims (7)
1. The HNSW node deleting method for the image feature library is characterized by comprising the following steps:
acquiring nodes to be deleted and the levels thereof in an HNSW graph from an image feature library;
finding out nodes associated with the nodes to be deleted according to the hierarchical relation corresponding to each node in the HNSW graph; wherein the associated node comprises: a node most similar to the node to be deleted, a node connected to the node to be deleted in the HNSW graph; if the sum of the number of the nodes connected with the node to be deleted and the most similar node is larger than the preset number, deleting redundant nodes to keep the number of the residual nodes the same as the preset number;
establishing a connection relationship between the associated nodes, comprising: a bidirectional connection relationship between the most similar node and the remaining nodes;
and deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library.
2. The HNSW node deletion method for image feature library of claim 1, wherein the remaining nodes are selected according to a rule of distance to the most similar node.
3. The HNSW node deletion method for the image feature library according to claim 1 or 2, wherein a time threshold is set, and when a time interval during which nodes are not accessed exceeds the time threshold, the corresponding node is taken as the node to be deleted; and/or setting a frequency threshold, and when the visited frequency of the node is lower than the frequency threshold, taking the corresponding node as the node to be deleted.
4. An HNSW node deletion system for an image feature library, comprising:
the node acquisition module is used for acquiring nodes to be deleted in the HNSW graph from the image feature library and the levels of the nodes;
the node deleting module is used for finding out nodes associated with the nodes to be deleted according to the hierarchical relationship corresponding to the nodes in the HNSW graph; wherein the associated node comprises: a node most similar to the node to be deleted, a node connected to the node to be deleted in the HNSW graph; if the sum of the number of the nodes connected with the node to be deleted and the most similar node is larger than the preset number, deleting redundant nodes to keep the number of the residual nodes the same as the preset number; establishing a connection relationship between the associated nodes, comprising: a bidirectional connection relationship between the most similar node and the remaining nodes; and deleting the nodes to be deleted and the connection relation related to the nodes to be deleted, and generating a new HNSW graph so as to update the image feature library.
5. The HNSW node deletion system for the image feature library according to claim 4, wherein the node acquisition module comprises a node selection unit for setting a time threshold, and when a time interval during which a node is not accessed exceeds the time threshold, the corresponding node is taken as the node to be deleted; and/or setting a frequency threshold, and when the visited frequency of the node is lower than the frequency threshold, taking the corresponding node as the node to be deleted.
6. An HNSW node deletion apparatus for an image feature library, comprising:
one or more processors; and
one or more machine-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-3.
7. One or more machine readable media having instructions stored thereon that, when executed by one or more processors, cause an apparatus to perform the method of any of claims 1-3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010925664.4A CN111813988B (en) | 2020-09-07 | 2020-09-07 | HNSW node deletion method, system, device and medium for image feature library |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010925664.4A CN111813988B (en) | 2020-09-07 | 2020-09-07 | HNSW node deletion method, system, device and medium for image feature library |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111813988A CN111813988A (en) | 2020-10-23 |
CN111813988B true CN111813988B (en) | 2021-03-12 |
Family
ID=72860027
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010925664.4A Active CN111813988B (en) | 2020-09-07 | 2020-09-07 | HNSW node deletion method, system, device and medium for image feature library |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111813988B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116595325B (en) * | 2023-04-18 | 2023-11-21 | 南京小唐安朴科技有限公司 | Method for calculating virtual coupling of vehicle portrait and detection code equipment |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108710626A (en) * | 2018-03-20 | 2018-10-26 | 浙江大学 | A kind of the approximate KNN search method and searching system of the high dimensional data based on satellite system figure |
CN110008256A (en) * | 2019-04-09 | 2019-07-12 | 杭州电子科技大学 | It is a kind of to be navigated the approximate KNN searching method of worldlet figure based on layering |
-
2020
- 2020-09-07 CN CN202010925664.4A patent/CN111813988B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN111813988A (en) | 2020-10-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112906574B (en) | Dynamic threshold management method and system | |
CN112163642A (en) | Wind control rule obtaining method, device, medium and equipment | |
CN112163428A (en) | Semantic tag acquisition method and device, node equipment and storage medium | |
CN112698793A (en) | Data storage method and device, machine readable medium and equipment | |
CN112241789A (en) | Structured pruning method, device, medium and equipment for lightweight neural network | |
CN108646962B (en) | Editing method and device for terminal desktop layout, storage medium and mobile terminal | |
CN112949172A (en) | Data processing method and device, machine readable medium and equipment | |
CN109407914A (en) | User characteristics recognition methods, device, equipment, medium and operating system | |
CN110942046B (en) | Image retrieval method, device, equipment and storage medium | |
CN104516643A (en) | Method and device for start application, and computing terminal | |
CN111813988B (en) | HNSW node deletion method, system, device and medium for image feature library | |
CN103677519A (en) | Method for collecting multimedia resource, terminal and server | |
CN111178455B (en) | Image clustering method, system, device and medium | |
CN106775445B (en) | Data migration method and device | |
CN111091152A (en) | Image clustering method, system, device and machine readable medium | |
CN112069184A (en) | Vector retrieval method, system, device and medium | |
CN112417197B (en) | Sorting method, sorting device, machine readable medium and equipment | |
CN111428652B (en) | Biological characteristic management method, system, equipment and medium | |
CN111626233B (en) | Key point marking method, system, machine readable medium and equipment | |
CN107256151A (en) | Processing method, device and the terminal of page rendering | |
CN112051270B (en) | Power transmission line defect detection method, system, equipment and medium | |
CN111612682B (en) | Watermark processing method and device | |
CN110262864B (en) | Application processing method and device, storage medium and terminal | |
CN114070892A (en) | Data transmission method and device | |
CN112990783A (en) | Material allocation method, system, equipment and medium |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |