Image clustering method and device, storage medium and electronic device
By labeling and removing low-value and non-high-value sets, and comparing only in specific sets, combined with a two-level mapping strategy, the problem of low efficiency in image clustering is solved, achieving efficient image clustering and resource optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-31
AI Technical Summary
Traditional image clustering systems require feature comparison with all sets in the image collection when processing newly captured images, resulting in low efficiency.
Low-value and non-high-value sets are identified and removed by labeling rules. Feature comparison is performed only on the sets that have not been removed from the image set. A two-level mapping strategy is used to evenly distribute data to the computing nodes.
It improves the efficiency of image clustering, optimizes the utilization of storage resources, and ensures the integrity and reliability of critical data.
Smart Images

Figure CN121767690A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and more specifically, to an image clustering method and apparatus, a storage medium, and an electronic device. Background Technology
[0002] Traditional image clustering systems typically employ a full comparison strategy when processing newly captured images. This means that each new captured image needs to be compared with all existing sets in the image set to determine whether it is associated with an existing set of entities or whether a new set needs to be created. As the size of the image set continues to increase, the complexity and time consumption of feature comparison also increase dramatically, resulting in low efficiency for image clustering.
[0003] There is no effective solution to the problem that image clustering is inefficient because it requires comparison with all sets in the image set. Summary of the Invention
[0004] This application provides an image clustering method and apparatus, storage medium and electronic device to at least solve the problem in the related art that image clustering requires comparison with all sets in the image set, resulting in low efficiency of image clustering.
[0005] According to one embodiment of this application, an image clustering method is provided, comprising: marking a first set to be deleted in an image set according to a first labeling rule, wherein the first set to be deleted is a low-value set; when the number of unlabeled first sets in the image set is greater than a preset capacity threshold, marking a second set to be deleted in the first set according to a second labeling rule, wherein the second set to be deleted is a non-high-value set; determining an actual set to be deleted based on the first set to be deleted and the second set to be deleted, and removing the actual set to be deleted from the image set; comparing a captured first image with a second image contained in the second set that has not been removed from the image set, and when it is determined that the similarity between the first image and a third image in the second image reaches a preset threshold, adding the first image to a third set corresponding to the third image, wherein the second set includes the third set.
[0006] In an exemplary embodiment, marking a first set to be deleted in an image set according to a first marking rule includes: for any fourth set in the image set, determining whether the fourth set satisfies a first condition or a second condition, wherein the first marking rule includes the first condition and the second condition, the first condition including: the identifier of the target object indicated by the fourth set is not authenticated, and the second number of fourth images contained in the fourth set is less than a first preset value, and no fifth image is added to the fourth set during a first time period, the first time point at which the fifth image is added to the fourth set is later than the second time point at which the fourth image is added to the fourth set, the second condition including: the identifier of the target object indicated by the fourth set is not authenticated, and no fifth image is added to the fourth set during a second time period, the second time period being longer than the first time period; if it is determined that the fourth set satisfies the first condition or the second condition, the fourth set is marked as the first set to be deleted.
[0007] In an exemplary embodiment, after marking a first set to be deleted in an image set according to a first marking rule, the method further includes: determining the maximum capacity of a first computing node corresponding to the first set for a fifth set of a first type, and determining the actual number of the fifth set in the first computing node, wherein the first computing node is used to store the first set; determining a first proportion of the fifth set in the first computing node based on the actual number and the maximum capacity; and determining that the first number is greater than the preset capacity threshold if the first proportion is determined to be greater than a second preset value.
[0008] In an exemplary embodiment, before marking the second set to be deleted in the first set according to the second marking rule, the method further includes: determining whether there is a sixth set in the first set that satisfies the second marking rule, wherein the second marking rule is that the identifier of the target object indicated by the sixth set is not authenticated; and if it is determined that there is a sixth set in the first set that satisfies the second marking rule, determining that the sixth set is the non-high-value set.
[0009] In an exemplary embodiment, marking a second set to be deleted in the first set according to a second marking rule includes: determining a third number Di' of sets expected to be removed in the first computing node according to the following formula: Di' = (Ri - T) * Ci, where Ri is the first proportion, T is the second preset value, and Ci is the maximum capacity; if the fourth number of the sixth set is less than or equal to the third number, marking the sixth set as the second set to be deleted; if the fourth number is greater than the third number, determining a third time point in which the sixth image was added to the sixth set, where the sixth image is the last image added to the sixth set; determining a plurality of fourth time points that are furthest from the current time among the plurality of third time points, where the plurality of third time points correspond one-to-one with the plurality of sixth sets; marking the seventh set containing the seventh image corresponding to the plurality of fourth time points as the second set to be deleted, where the sixth set includes the seventh set.
[0010] In an exemplary embodiment, determining the actual set to be deleted based on the first set to be deleted and the second set to be deleted includes: determining whether the image set includes a predetermined third set to be deleted; if it is determined that the image set includes the third set to be deleted, determining the first set to be deleted, the second set to be deleted, and the third set to be deleted as the actual set to be deleted.
[0011] In one exemplary embodiment, after adding the first image to the third set corresponding to the third image, the method further includes: determining the bucket number A of the logical bucket according to the following formula. id A id =hash(B id )%A num Among them, B id Let A be the name of the second set. num The number of logical buckets is defined as follows: the logical buckets are used to evenly distribute the second set across the second computing nodes, and the second computing nodes are used to store the second set. The node number N of the second computing node is determined according to the following formula. id :N id =A id %N num , where N num The number of nodes in the second computing node; the second set is allocated to the second computing node according to the bucket number and the node number.
[0012] According to another embodiment of this application, an image clustering apparatus is also provided, comprising: a first labeling module, configured to label a first set to be deleted in an image set according to a first labeling rule, wherein the first set to be deleted is a low-value set; a second labeling module, configured to label a second set to be deleted in the first set according to a second labeling rule when the number of unlabeled first sets in the image set is greater than a preset capacity threshold, wherein the second set to be deleted is a non-high-value set; a determining module, configured to determine an actual set to be deleted based on the first set to be deleted and the second set to be deleted, and remove the actual set to be deleted from the image set; and an adding module, configured to compare a captured first image with a second image contained in the second set that has not been removed from the image set, and add the first image to a third set corresponding to the third image when the similarity between the first image and a third image in the second image reaches a preset threshold, wherein the second set includes the third set.
[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program is configured to execute the above-described image clustering method at runtime.
[0014] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described image clustering method through the computer program.
[0015] In this embodiment, a first set to be deleted is marked in the image set according to a first marking rule, wherein the first set to be deleted is a low-value set; if the number of unmarked first sets in the image set exceeds a preset capacity threshold, a second set to be deleted is marked in the first set according to a second marking rule, wherein the second set to be deleted is a non-high-value set; the actual set to be deleted is determined based on the first and second sets to be deleted, and the actual set to be deleted is removed from the image set; the captured first image is compared with the second image contained in the unremoved second set in the image set, and if the similarity between the first image and the third image in the second image reaches a preset threshold, the first image is added to the third set corresponding to the third image, wherein the second set includes the third set. By adopting the above technical solution, the problem of low efficiency in image clustering due to the need to compare with all sets in the image set in related technologies is solved, thus achieving efficient image clustering. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0017] Figure 1 This is a hardware structure block diagram of a camera device for an image clustering method according to an embodiment of this application;
[0018] Figure 2 This is a flowchart of an image clustering method according to an embodiment of this application;
[0019] Figure 3 This is a first schematic diagram of an image clustering method according to an embodiment of this application;
[0020] Figure 4 This is a second schematic diagram of an image clustering method according to an embodiment of this application;
[0021] Figure 5 This is a third schematic diagram of an image clustering method according to an embodiment of this application;
[0022] Figure 6 This is a structural block diagram of an image clustering device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] The methods and embodiments provided in this application can be executed in a camera device or a similar computing system. Taking operation on a camera device as an example, Figure 1 This is a hardware structure block diagram of a camera device for an image clustering method according to an embodiment of this application. For example... Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the image. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. In one exemplary embodiment, the camera device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned computer terminal. For example, the camera device may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1 The functions shown have more different configurations.
[0026] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the image clustering method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thus implementing the methods described above. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage systems, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a secure text network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0027] The transmission system 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the camera equipment. In one example, the transmission system 106 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet.
[0028] This embodiment provides an image clustering method, applied to the aforementioned camera device. Figure 2 This is a flowchart of an image clustering method according to an embodiment of this application, the process including the following steps:
[0029] Step S202: Mark the first set to be deleted in the image set according to the first marking rule, wherein the first set to be deleted is a low-value set;
[0030] Step S204: If the number of unmarked first sets in the image set is greater than a preset capacity threshold, mark a second set to be deleted in the first set according to the second marking rule, wherein the second set to be deleted is a non-high-value set;
[0031] Step S206: Determine the actual set to be deleted based on the first set to be deleted and the second set to be deleted, and remove the actual set to be deleted from the image set;
[0032] Step S208: Compare the captured first image with the second image contained in the second set that has not been removed from the image set. If the similarity between the first image and the third image in the second image reaches a preset threshold, add the first image to the third set corresponding to the third image, wherein the second set includes the third set.
[0033] In this embodiment, a first set to be deleted is marked in the image set according to a first marking rule, wherein the first set to be deleted is a low-value set; if the number of unmarked first sets in the image set exceeds a preset capacity threshold, a second set to be deleted is marked in the first set according to a second marking rule, wherein the second set to be deleted is a non-high-value set; the actual set to be deleted is determined based on the first and second sets to be deleted, and the actual set to be deleted is removed from the image set; the captured first image is compared with the second image contained in the unremoved second set in the image set, and if the similarity between the first image and the third image in the second image reaches a preset threshold, the first image is added to the third set corresponding to the third image, wherein the second set includes the third set. Therefore, this solves the problem in related technologies where image clustering requires comparison with all sets in the image set, resulting in low efficiency, and achieves efficient image clustering.
[0034] In an exemplary embodiment, marking a first set to be deleted in an image set according to a first marking rule includes: for any fourth set in the image set, determining whether the fourth set satisfies a first condition or a second condition, wherein the first marking rule includes the first condition and the second condition, the first condition including: the identifier of the target object indicated by the fourth set is not authenticated, and the second number of fourth images contained in the fourth set is less than a first preset value, and no fifth image is added to the fourth set during a first time period, the first time point at which the fifth image is added to the fourth set is later than the second time point at which the fourth image is added to the fourth set, the second condition including: the identifier of the target object indicated by the fourth set is not authenticated, and no fifth image is added to the fourth set during a second time period, the second time period being longer than the first time period; if it is determined that the fourth set satisfies the first condition or the second condition, the fourth set is marked as the first set to be deleted.
[0035] Optionally, the first marking rule is used to determine low-value sets. Specifically, the first marking rule satisfies any one of the following conditions: (a) Uncertified identifier, for example, when image data of an entity (e.g., a vehicle) is captured and some feature information (such as license plate number, object shape, etc.) is extracted, but this information is insufficient to completely match the known, certified entity features in the database, thus making it impossible to authenticate the entity (equivalent to the uncertified identifier of the target object indicated by the fourth set) & number of trajectories < 2 (equivalent to the second number of fourth images contained in the fourth set being less than the first preset value) & no new trajectories added for 30 days (equivalent to the fourth set not adding the fifth image in the first time period); (b) Uncertified identifier & no new trajectories added for 180 days (equivalent to the fourth set not adding the fifth image in the second time period). Following the first marking rule, all sets in the image set are traversed, and each set is checked one by one to see if it meets any of the above conditions. If a set meets the first condition or the second condition, then it will be marked as the first set to be deleted.
[0036] In an exemplary embodiment, after marking a first set to be deleted in an image set according to a first marking rule, the method further includes: determining the maximum capacity of a first computing node corresponding to the first set for a fifth set of a first type, and determining the actual number of the fifth set in the first computing node, wherein the first computing node is used to store the first set; determining a first proportion of the fifth set in the first computing node based on the actual number and the maximum capacity; and determining that the first number is greater than the preset capacity threshold if the first proportion is determined to be greater than a second preset value.
[0037] In an exemplary embodiment, before marking the second set to be deleted in the first set according to the second marking rule, the method further includes: determining whether there is a sixth set in the first set that satisfies the second marking rule, wherein the second marking rule is that the identifier of the target object indicated by the sixth set is not authenticated; and if it is determined that there is a sixth set in the first set that satisfies the second marking rule, determining that the sixth set is the non-high-value set.
[0038] For the first computing node corresponding to the first set, the maximum capacity of each type of set in the first computing node is determined and denoted as Ci (i represents the computing node number, i is a positive integer). The actual number of different types of sets under the first computing node is denoted as Di. The first proportion Ri of any type of set in the first computing node is determined according to the following formula: Ri = Di / Ci. When Ri exceeds the second preset value T, it indicates that the storage resources of the first computing node have exceeded the limit of its reasonable utilization and the storage pressure is relatively large.
[0039] At this point, it is necessary to determine the non-high-value sets and high-value sets from the first set (the set not marked as low-value sets). Specifically, the non-high-value sets in the first set are determined according to the second marking rule. That is, if there is an unauthenticated identifier for the target object indicated by the sixth set in the first set, the sixth set is considered to meet the second marking rule and is determined as a non-high-value set. All sets in the first set other than the sixth set are determined as high-value sets. Non-high-value sets are deleted, and high-value sets are expanded. The expansion is divided into smart card expansion and node expansion. Each standard machine has 4 smart cards by default. If the number of smart cards in a standard machine is less than 4, expansion can be achieved by adding smart cards. Node expansion refers to using existing solutions to manage new computing nodes to form a computing cluster to cope with larger data specifications.
[0040] In an exemplary embodiment, marking a second set to be deleted in the first set according to a second marking rule includes: determining a third number Di' of sets expected to be removed in the first computing node according to the following formula: Di' = (Ri - T) * Ci, where Ri is the first proportion, T is the second preset value, and Ci is the maximum capacity; if the fourth number of the sixth set is less than or equal to the third number, marking the sixth set as the second set to be deleted; if the fourth number is greater than the third number, determining a third time point in which the sixth image was added to the sixth set, where the sixth image is the last image added to the sixth set; determining a plurality of fourth time points that are furthest from the current time among the plurality of third time points, where the plurality of third time points correspond one-to-one with the plurality of sixth sets; marking the seventh set containing the seventh image corresponding to the plurality of fourth time points as the second set to be deleted, where the sixth set includes the seventh set.
[0041] If the sixth set is determined to be a non-high-value set and needs to be removed from the first computing node, the third number Di' of sets to be removed from the first computing node is determined according to the following formula: Di' = (Ri - T) * Ci, where Ri is the first proportion of any type of set in the first computing node, T is the second preset value, and Ci is the maximum capacity of the first computing node to store any type of set. Optionally, assuming the third number Di' is 50, if the number of sixth sets is 30 (30 < 50), these 30 sixth sets are marked as the second set to be deleted. If the number of sixth sets is 90 (90 > 50), then the last update time (equivalent to the third time point) of these 90 sixth sets needs to be determined. By comparing the third time with the current time, 90 time intervals can be obtained. For example, if a third time point is 2024 / 10 / 14 / 12:00 and the current time is 2025 / 10 / 14 / 12:00, then the time interval is 12 months. By analogy, the lengths of these 90 time intervals are compared to determine the 50 (third number) seventh sets with longer time intervals, i.e. sets that have not been updated for a long time. These 50 seventh sets are marked as the second set to be deleted.
[0042] In an exemplary embodiment, determining the actual set to be deleted based on the first set to be deleted and the second set to be deleted includes: determining whether the image set includes a predetermined third set to be deleted; if it is determined that the image set includes the third set to be deleted, determining the first set to be deleted, the second set to be deleted, and the third set to be deleted as the actual set to be deleted.
[0043] First, the system checks if the image collection contains a third set to be deleted, which is a set pre-marked by the user. If the image collection contains a third set, the first, second, and third sets to be deleted are identified as the actual sets to be deleted and integrated into a temporary Hive table. Then, the collection management module on the computer terminal intervenes, reading the full data table used to store the entire image collection. It compares the full data table with the previously prepared temporary data table of sets to be deleted, removing the actual sets to be deleted from the temporary data table. Finally, the filtered and optimized collection data is rewritten to the Hive table of the image collection in one go, completing the update and optimization of the image collection.
[0044] In one exemplary embodiment, after adding the first image to the third set corresponding to the third image, the method further includes: determining the bucket number A of the logical bucket according to the following formula. id A id =hash(B id )%A num Among them, B id Let A be the name of the second set. num The number of logical buckets is defined as follows: the logical buckets are used to evenly distribute the second set across the second computing nodes, and the second computing nodes are used to store the second set. The node number N of the second computing node is determined according to the following formula. id :N id =A id %N num , where N num The number of nodes in the second computing node; the second set is allocated to the second computing node according to the bucket number and the node number.
[0045] In the set allocation mechanism of the image clustering system, each computing node is responsible for processing set data from a specific part of the image set to ensure the efficient operation of feature comparison and clustering processes. To achieve uniform data distribution and balanced processing, a two-level mapping strategy of "set identifier → logical bucket → physical node" is adopted. Through this strategy, the binding relationship between the set and the computing node is decoupled, thereby optimizing the distribution of data processing.
[0046] First, a hash function is used to calculate a value based on the unique identifier (i.e., the set name) of each set. To ensure uniform distribution, this hash value is further matched with a fixed total number of logical buckets (e.g., 300) using a modulo operation (%) to obtain the logical bucket number to which the set belongs. This calculation formula can be expressed as A id =hash(B id )%A numAmong them, B id Let A be the name of the second set. num The set name is a 48-character string (containing numbers and letters) generated according to a specific rule, representing the number of logical buckets (a fixed value of 300). After obtaining the logical bucket numbers of the set, these logical buckets are further mapped to actual computing nodes. By applying the modulo operation again, the logical bucket number A is determined. id Compared to the current total number of computing nodes N num Perform matching to obtain the computation node number N that the set should store. id The formula for calculating this mapping relationship is N. id =A id %N num The number of nodes is N, and the node numbers are from 0 to N-1.
[0047] The two-level mapping mechanism described above ensures that the ensemble data is evenly distributed across the GPU memory of each computing node. Each computing node loads the associated ensemble from the image set into the GPU memory of the smart card based on the mapping results, preparing the data for feature comparison and clustering processes. Once all computing nodes have completed loading the ensembles, the clustering process proceeds as designed, achieving efficient execution of data processing and classification.
[0048] To better understand the image clustering process described above, the image clustering method will be further explained below with reference to optional embodiments, but this is not intended to limit the technical solutions of the embodiments of this application.
[0049] Figure 3 This is a first schematic diagram of an image clustering method according to an embodiment of this application, as shown below. Figure 3 As shown, it specifically includes the following:
[0050] First, in the feature comparison module, the full set of data containing feature information extracted from the Hive table is periodically loaded into the GPU memory of each computing node for real-time processing and comparison with captured images. This process is limited by the GPU memory size of the computing nodes, ensuring that the system can perform efficient feature comparison under limited resources. Subsequently, the offline clustering module receives and processes all incoming captured data. By extracting feature information from the captured images, it performs a rapid 1V1 collision comparison with the full set pre-loaded into the GPU memory of the computing nodes. If the captured data matches an existing set, the new captured data is merged into that set, and the feature information of the set is updated accordingly; conversely, captured data that does not match an existing set is created as a new set and updated in the GPU memory, achieving more comprehensive image clustering coverage.
[0051] Finally, the collection management module, as the core of the entire process, is responsible for integrating the results of updated, merged, and deleted collections generated in the offline clustering module and maintaining this change information in the image collection. More importantly, this module also undertakes the lifecycle management of the image collection. It filters out low-value collections using a first marking rule, especially when storage capacity approaches a preset threshold. Then, it identifies non-high-value collections using a second marking rule and determines the second set to be deleted from these. Furthermore, it removes the first, second, and user-marked third sets to be deleted from the image collection. This ensures efficient matching of computing and storage resources, enabling the image clustering system to maintain good operational status and processing capacity even when facing massive amounts of data.
[0052] Figure 4 This is a second schematic diagram of an image clustering method according to an embodiment of this application, as shown below. Figure 4 As shown, it specifically includes the following:
[0053] First, the preset configuration of the image clustering system is read to obtain preset rule one (equivalent to the first labeling rule) and preset rule two (equivalent to the second labeling rule). Preset rule one is used to identify low-value sets, and preset rule two is used to identify non-high-value sets. Specifically, preset rule one satisfies any of the following conditions: (a) uncertified, for example, when image data of an entity (e.g., a vehicle) is captured and some feature information (such as license plate number, object shape, etc.) is extracted from it, but this information is not enough to completely match the known, certified entity features in the database, so the entity cannot be certified & number of trajectories < 2 & no new trajectories in 30 days (b) uncertified & no new trajectories in 180 days; preset rule two satisfies (a) uncertified.
[0054] Furthermore, according to preset rule one, a first set to be deleted is marked in the image set, and it is determined whether the first number of unmarked first sets in the image set is greater than a preset capacity threshold. If the first number is greater than the preset capacity threshold, a second set to be deleted is marked in the first set according to preset rule two, and the first set to be deleted, the second set to be deleted, and the pre-determined third set to be deleted are determined as the actual sets to be deleted. Conversely, if the first number is less than or equal to the preset capacity threshold, the first set to be deleted and the pre-determined third set to be deleted are determined as the actual sets to be deleted.
[0055] The actual sets to be deleted are removed from the image set. If, after cleanup, the sets in a certain computing node still exceed the capacity threshold of that computing node, then the sets in that computing node are expanded. Expansion is divided into smart card expansion and node expansion. Each standard machine has 4 smart cards by default. If the number of smart cards in a standard machine is less than 4, expansion can be achieved by adding smart cards. Node expansion refers to using existing solutions to manage new computing nodes to form a computing cluster to handle larger data sizes.
[0056] Figure 5 This is a third schematic diagram of an image clustering method according to an embodiment of this application, as shown below. Figure 5 As shown, it specifically includes the following:
[0057] This invention filters low-quality sets based on preset rule one and retains high-quality sets based on preset rule two when computing nodes exceed capacity thresholds. The preset rules are calculated from historical set data from multiple implementation sites. Specifically, preset rule one focuses on filtering low-quality sets, which are often characterized by a small number of trajectories, long periods without updates, or a lack of identification and authentication. Low-value sets are identified by evaluating key attributes such as the richness of trajectories, the most recent update time, and whether identification and authentication have been completed. Secondly, preset rule two focuses on prioritizing the retention of high-quality sets when computing nodes exceed a preset storage capacity threshold. Specifically, if the identifier of the target object indicated by the set is not authenticated, the set is determined to be a non-high-value set; excluding non-high-value sets yields high-value sets. High-quality sets typically possess rich trajectories, frequent update records, and clear identification and authentication status. These sets are crucial for reconstructing entity activity trajectories and providing detailed entity information. This rule ensures that important data is fully preserved even under storage pressure, preventing the loss of critical sets due to storage resource constraints and maintaining data integrity and reliability.
[0058] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0059] Figure 6 This is a structural block diagram of an image clustering device according to an embodiment of this application; as shown below. Figure 6 As shown, it includes:
[0060] The first marking module 62 is used to mark a first set to be deleted in the image set according to a first marking rule, wherein the first set to be deleted is a low-value set;
[0061] The second marking module 64 is used to mark a second set to be deleted in the first set according to a second marking rule when the number of unmarked sets in the image set is greater than a preset capacity threshold, wherein the second set to be deleted is a non-high value set;
[0062] The determining module 66 is configured to determine the actual set to be deleted based on the first set to be deleted and the second set to be deleted, and remove the actual set to be deleted from the image set;
[0063] The addition module 68 is used to compare the captured first image with the second image contained in the second set that has not been removed from the image set. If it is determined that the similarity between the first image and the third image in the second image reaches a preset threshold, the first image is added to the third set corresponding to the third image, wherein the second set includes the third set.
[0064] The system described above marks a first set to be deleted in the image set according to a first marking rule. This first set is a low-value set. If the number of unmarked sets in the image set exceeds a preset capacity threshold, a second set to be deleted is marked in the first set according to a second marking rule. This second set is a non-high-value set. The actual set to be deleted is determined based on the first and second sets and removed from the image set. The captured first image is compared with a second image contained in the unremoved second set in the image set. If the similarity between the first image and a third image in the second set reaches a preset threshold, the first image is added to the third set corresponding to the third image. The second set includes the third set. This technical solution solves the problem of low efficiency in image clustering due to the need to compare with all sets in the image set, achieving efficient image clustering.
[0065] In an exemplary embodiment, the first marking module 62 is further configured to determine, for any fourth set in the image set, whether the fourth set satisfies a first condition or a second condition, wherein the first marking rule includes the first condition and the second condition, the first condition including: the identifier of the target object indicated by the fourth set is not authenticated, and the second number of fourth images contained in the fourth set is less than a first preset value, and no fifth image is added to the fourth set during a first time period, the first time point at which the fifth image is added to the fourth set is later than the second time point at which the fourth image is added to the fourth set, the second condition including: the identifier of the target object indicated by the fourth set is not authenticated, and no fifth image is added to the fourth set during a second time period, the second time period being longer than the first time period; if it is determined that the fourth set satisfies the first condition or the second condition, the fourth set is marked as the first set to be deleted.
[0066] In an exemplary embodiment, the first marking module 62 is further configured to determine the maximum capacity of the first computing node corresponding to the first set for the fifth set of the first type, and to determine the actual number of the fifth set in the first computing node, wherein the first computing node is used to store the first set; determine a first proportion of the fifth set in the first computing node based on the actual number and the maximum capacity; and determine that the first number is greater than the preset capacity threshold if the first proportion is determined to be greater than a second preset value.
[0067] In an exemplary embodiment, the second marking module 64 is further configured to determine whether there exists a sixth set in the first set that satisfies the second marking rule, wherein the second marking rule is that the identifier of the target object indicated by the sixth set is not authenticated; if it is determined that there exists a sixth set in the first set that satisfies the second marking rule, the sixth set is determined to be the non-high-value set.
[0068] In an exemplary embodiment, the second marking module 64 is further configured to determine the third number Di' of the expected set to be removed in the first computing node according to the following formula: Di' = (Ri - T) * Ci, where Ri is the first proportion, T is the second preset value, and Ci is the maximum capacity; if the fourth number of the sixth set is less than or equal to the third number, mark the sixth set as the second set to be deleted; if the fourth number is greater than the third number, determine the third time point at which the sixth image is added to the sixth set, where the sixth image is the last image added to the sixth set; determine a plurality of fourth time points of the third number that are farthest from the current time among the plurality of third time points, where the plurality of third time points correspond one-to-one with the plurality of sixth sets; mark the seventh set where the seventh image corresponding to the plurality of fourth time points is located as the second set to be deleted, where the sixth set includes the seventh set.
[0069] In an exemplary embodiment, the determining module 66 is further configured to determine whether the image set includes a predetermined third set to be deleted; if it is determined that the image set includes the third set to be deleted, the first set to be deleted, the second set to be deleted, and the third set to be deleted are determined as the actual set to be deleted.
[0070] In one exemplary embodiment, module 68 is further configured to determine the bucket number A of the logical bucket according to the following formula. id A id =hash(B id )%A num Among them, B id Let A be the name of the second set. num The number of logical buckets is defined as follows: the logical buckets are used to evenly distribute the second set across the second computing nodes, and the second computing nodes are used to store the second set. The node number N of the second computing node is determined according to the following formula. id :N id =A id %N num , where N num The number of nodes in the second computing node; the second set is allocated to the second computing node according to the bucket number and the node number.
[0071] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.
[0072] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0073] S1, mark the first set to be deleted in the image set according to the first marking rule, wherein the first set to be deleted is a low-value set;
[0074] S2, if the number of unmarked first sets in the image set is greater than a preset capacity threshold, mark a second set to be deleted in the first set according to the second marking rule, wherein the second set to be deleted is a non-high-value set;
[0075] S3, determine the actual set to be deleted based on the first set to be deleted and the second set to be deleted, and remove the actual set to be deleted from the image set;
[0076] S4, compare the captured first image with the second image contained in the second set that has not been removed from the image set. If it is determined that the similarity between the first image and the third image in the second image reaches a preset threshold, add the first image to the third set corresponding to the third image, wherein the second set includes the third set.
[0077] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0078] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0079] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0080] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0081] S1, mark the first set to be deleted in the image set according to the first marking rule, wherein the first set to be deleted is a low-value set;
[0082] S2, if the number of unmarked first sets in the image set is greater than a preset capacity threshold, mark a second set to be deleted in the first set according to the second marking rule, wherein the second set to be deleted is a non-high-value set;
[0083] S3, determine the actual set to be deleted based on the first set to be deleted and the second set to be deleted, and remove the actual set to be deleted from the image set;
[0084] S4, compare the captured first image with the second image contained in the second set that has not been removed from the image set. If it is determined that the similarity between the first image and the third image in the second image reaches a preset threshold, add the first image to the third set corresponding to the third image, wherein the second set includes the third set.
[0085] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0086] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0087] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing systems. They can be centralized on a single computing system or distributed across a network of multiple computing systems. Optionally, they can be implemented using program code executable by a computing system, thereby storing them in a storage system for execution by the computing system. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0088] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A method of clustering images, characterized in that, The method comprises: marking a first to-be-deleted set in the image set according to a first marking rule, wherein the first to-be-deleted set is a low-value set; in a case where a first quantity of a first set that is not marked in the image set is greater than a preset capacity threshold, marking a second to-be-deleted set in the first set according to a second marking rule, wherein the second to-be-deleted set is a non-high-value set; determining an actual to-be-deleted set according to the first to-be-deleted set and the second to-be-deleted set, and removing the actual to-be-deleted set from the image set; comparing a first image that is captured with a second image included in a second set that is not removed from the image set, and in a case where it is determined that a similarity between the first image and a third image of the second image reaches a preset threshold, adding the first image to a third set corresponding to the third image, wherein the second set includes the third set.
2. The clustering method of images according to claim 1, characterized in that, The method comprises: For any fourth set in the image set, determining whether the fourth set satisfies a first condition or a second condition, wherein the first marking rule comprises the first condition and the second condition, the first condition comprises that an identity of a target object indicated by the fourth set is not authenticated, a second quantity of fourth images included in the fourth set is less than a first preset value, and the fourth set does not add a fifth image within a first time period, a first time point at which the fifth image is added to the fourth set is later than a second time point at which the fourth image is added to the fourth set, and the second condition comprises that the identity of the target object indicated by the fourth set is not authenticated, and the fourth set does not add the fifth image within a second time period, the second time period being greater than the first time period; in a case where it is determined that the fourth set satisfies the first condition or the second condition, marking the fourth set as the first to-be-deleted set.
3. The clustering method of images according to claim 1, characterized in that, After the first to-be-deleted set is marked in the image set according to the first marking rule, the method further comprises: determining a maximum capacity of a first computing node corresponding to the first set for a fifth set of a first type, and determining an actual quantity of the fifth set in the first computing node, wherein the first computing node is used to store the first set; determining a first proportion of the fifth set in the first computing node according to the actual quantity and the maximum capacity; in a case where it is determined that the first proportion is greater than a second preset value, determining that the first quantity is greater than the preset capacity threshold.
4. The method of clustering images according to claim 3, wherein, Before the second to-be-deleted set is marked in the first set according to the second marking rule, the method further comprises: determining whether a sixth set in the first set satisfies the second marking rule, wherein the second marking rule is that an identity of a target object indicated by the sixth set is not authenticated; in a case where it is determined that the sixth set in the first set satisfies the second marking rule, determining that the sixth set is the non-high-value set.
5. The method of clustering images according to claim 4, wherein, According to a second marking rule, a second to-be-deleted set is marked from the first set, comprising: According to the following formula, a third number Di' of the predicted removal set in the first computing node is determined: Di'=(Ri-T)*Ci, wherein Ri is the first proportion, T is the second preset value, and Ci is the maximum capacity; In a case where a fourth number of the sixth set is less than or equal to the third number, the sixth set is marked as the second to-be-deleted set; In a case where the fourth number is greater than the third number, a third time point of adding a sixth image in the sixth set is determined, wherein the sixth image is the last added image in the sixth set; A third number of fourth time points farthest from a current time among a plurality of third time points is determined, wherein the plurality of third time points correspond to a plurality of sixth sets one by one; A seventh set in which a seventh image corresponding to the plurality of fourth time points is located is marked as the second to-be-deleted set, wherein the sixth set includes the seventh set.
6. The method of clustering images of claim 1, wherein, According to the first to-be-deleted set and the second to-be-deleted set, an actual to-be-deleted set is determined, comprising: Determining whether a third to-be-deleted set is included in the image set; In a case where it is determined that the third to-be-deleted set is included in the image set, the first to-be-deleted set, the second to-be-deleted set, and the third to-be-deleted set are determined as the actual to-be-deleted set.
7. The method of clustering images of claim 1, wherein, After the first image is added to the third set corresponding to the third image, the method further comprises: A bucket number A of a logical bucket is determined according to the following formula id : A id = hash(B id ) % A num , wherein B id is a set name of the second set, and A num is a bucket number of the logical bucket, the logical bucket being used to evenly distribute the second set to second computing nodes, the second computing nodes being used to store the second set; The node number N of the second computing node is determined according to the following formula id : N id = A id % N num , wherein N num is the node number of the second computing node. According to the bucket number and the node number, the second set is allocated to the second computing node.
8. An apparatus for clustering images, characterized by Comprising: A first marking module is configured to mark a first to-be-deleted set from an image set according to a first marking rule, wherein the first to-be-deleted set is a low-value set; A second marking module is configured to mark a second to-be-deleted set from a first set in the image set according to a second marking rule in a case where a first number of the first set that is not marked is greater than a preset capacity threshold, wherein the second to-be-deleted set is a non-high-value set; A determination module is configured to determine an actual to-be-deleted set according to the first to-be-deleted set and the second to-be-deleted set, and remove the actual to-be-deleted set from the image set; An adding module is configured to compare a first image captured with a second image included in a second set in the image set that is not removed, and add the first image to a third set corresponding to a third image in the second image in a case where a similarity between the first image and the third image reaches a preset threshold, wherein the second set includes the third set.
9. A computer readable storage medium, characterized in that, The computer-readable storage medium comprises a stored program, wherein the program executes the method described in any one of claims 1 to 7 when running. 10.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 by using the computer program.