Image clustering method, device, apparatus and storage medium
By constructing an image clustering topology graph and selecting a set of edges with high similarity, the problem of excessive memory consumption during image clustering is solved, thus improving the stability and efficiency of the device.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI SENSETIME INTELLIGENT TECH CO LTD
- Filing Date
- 2022-08-12
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, the large memory usage of adjacency lists during image clustering can cause device lag or even crashes.
By determining the similarity of images in the set of images to be clustered, a clustering topology graph is constructed. In this topology graph, a set of edges representing similarity greater than the target safety threshold is selected to limit the number of high-similarity edges, reduce the memory required for storage, and then perform clustering.
Without affecting the clustering results, memory consumption is reduced, the probability of device lag or crash due to excessive memory usage is lowered, and the stability of the image clustering process is improved.
Smart Images

Figure CN115147633B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and includes, but is not limited to, an image clustering method, apparatus, device, and storage medium. Background Technology
[0002] Image clustering is the process of grouping similar images together, such as those in a photo album, and representing these similar images using a clustering topology graph. In related technologies, adjacency lists can be used to record this clustering topology graph; however, storing these adjacency lists consumes a large amount of memory, which can cause device lag or even crashes during image clustering. Summary of the Invention
[0003] This application provides an image clustering technology solution.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] In a first aspect, embodiments of this application provide an image clustering method, the method comprising:
[0006] The similarity between images in the image set to be clustered is determined; based on the similarity, a clustering topology graph of the image set to be clustered is determined; in the clustering topology graph, a first target edge set representing similarity greater than a target safety threshold is determined; if the number of edges in the first target edge set is greater than a preset number threshold, edges of the preset number threshold are selected from the first target edge set as a second target edge set; based on the second target edge set, the image set to be clustered is clustered to obtain a first clustering result.
[0007] Secondly, embodiments of this application provide an image clustering apparatus, the apparatus comprising:
[0008] The first determining module is used to determine the similarity between images to be clustered in the image set to be clustered; the second determining module is used to determine the clustering topology of the image set to be clustered based on the similarity.
[0009] The third determining module is used to determine a first set of target edges in the clustered topology graph, characterized by a similarity greater than a target security threshold; the selection module is used to select edges of the preset number threshold as a second set of target edges in the first set of target edges when the number of edges in the first set of target edges is greater than a preset number threshold; the first clustering module is used to cluster the set of images to be clustered based on the second set of target edges to obtain a first clustering result; the first determining module is used to determine the similarity between the images to be clustered in the set of images to be clustered.
[0010] This application provides a computer storage medium storing computer-executable instructions, which, when executed, can implement the image clustering method described above.
[0011] This application provides a terminal device, which includes a memory and a processor. The memory stores computer-executable instructions, and the processor can implement the above-mentioned image clustering method when it executes the computer-executable instructions in the memory.
[0012] This application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above method.
[0013] In this embodiment, firstly, the similarity between images to be clustered in the image set to be clustered is determined, and a clustering topology graph of the image set to be clustered is determined based on this similarity. Thus, the similarity between images to be clustered in the image set to be clustered can be visually observed through the nodes and edges in the clustering topology graph. Then, in the clustering topology graph, a first target edge set representing similarity greater than a target safety threshold is determined. Thus, the first target set can more accurately obtain images to be clustered with high similarity in the clustering topology graph. When the number of edges in the first target edge set exceeds a preset threshold, the first target edge... The set selects edges with a preset number threshold as the second target edge set; thus, by setting a number threshold, the number of edges with high similarity is limited, thereby reducing the memory required to store the adjacency list of the clustering topology graph; based on the second target edge set, the set of images to be clustered is clustered to obtain the first clustering result; thus, by using the second target edge set to cluster the set of images to be clustered to obtain the first clustering result, the memory consumption used to store the clustering topology graph during the clustering process is reduced without affecting the clustering result, thereby reducing the probability of machine lag or even crash due to excessive memory consumption during the clustering process. Attached Figure Description
[0014] Figure 1A A schematic diagram of the architecture of an execution system for an image clustering method provided in an embodiment of this application;
[0015] Figure 1B A schematic diagram illustrating the implementation process of the image clustering method provided in this application embodiment;
[0016] Figure 2 This is a schematic diagram illustrating another implementation process of the image clustering method provided in the embodiments of this application;
[0017] Figure 3This is a schematic diagram illustrating another implementation of the image clustering method provided in the embodiments of this application;
[0018] Figure 4 This is a schematic diagram of a clustering topology graph provided in an embodiment of this application;
[0019] Figure 5 A schematic diagram of another clustering topology provided in an embodiment of this application;
[0020] Figure 6 This is a schematic diagram of the structural composition of the image clustering device provided in the embodiments of this application;
[0021] Figure 7 This is a schematic diagram of the composition structure of the terminal device provided in the embodiments of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the invention will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.
[0023] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0024] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0026] Before providing a more detailed description of the embodiments of this application, the nouns and terms used in the embodiments of this application will be explained.
[0027] 1) Adjacency list is a storage structure that combines sequential allocation and linked allocation. If a vertex corresponding to a head node has adjacent vertices, then the adjacent vertices are stored sequentially in the singly linked list pointed to by the head node.
[0028] 2) An adjacency matrix is a matrix that represents the adjacency relationship between vertices. It is usually stored in a one-dimensional array to store all vertex data and in a two-dimensional array to store the data of the relationship (edges or arcs) between vertices. This two-dimensional array is called the adjacency matrix.
[0029] 3) False Acceptance Rate (FAR) refers to the proportion of images that are misidentified as the same object out of the total number of image recognition attempts.
[0030] 4) True Accept Rate (TAR) refers to the proportion of images that identify the same object as the same object out of the total number of image recognition attempts.
[0031] This application provides an image clustering method applied to a terminal device. The terminal device includes, but is not limited to, mobile phones, laptops, tablets, mobile internet devices, desktop computers, or other types of terminal devices. The functionality implemented by this method can be achieved by a processor in the terminal device calling program code. The program code can be stored in a computer storage medium; therefore, the terminal device includes at least a processor and a storage medium. The processor can be used to execute the image clustering method, and the memory can be used to store the data required and generated during the execution of the image clustering method.
[0032] Figure 1A This is a schematic diagram of an optional architecture for an execution system 10 of an image clustering method provided in an embodiment of this application, as shown below. Figure 1AAs shown, terminal device 300 is connected to image acquisition device 100 or server 400 via network 200. Network 200 can be a wide area network (WAN), a local area network (LAN), or a combination of both. Terminal device 300 and image acquisition device 100 can be physically separate or integrated. Image acquisition device 100 can send or store the acquired images to be clustered to terminal device 300 via network 200. Terminal device 300 determines the similarity between images to be clustered in the image set to be clustered; based on the similarity, it determines a clustering topology graph of the image set to be clustered; in the clustering topology graph, it determines a first target edge set representing similarity greater than a target security threshold; if the number of edges in the first target edge set is greater than a preset number threshold, it selects edges of the preset number threshold from the first target edge set as a second target edge set; based on the second target edge set, it clusters the image set to be clustered to obtain a first clustering result. In this way, by filtering the first target edge set with high similarity, edges with a preset number threshold are selected to reduce the number of edges in the first target edge set and filter out edges that have little impact on the clustering results. Thus, image clustering is performed according to the smaller number of second target edge sets. This is equivalent to saving computing resources when clustering images of the same size due to the reduction of edges. In this way, without affecting the clustering results, the memory consumption used to store the clustering topology graph during the clustering process is reduced, and the probability of machine lag or even crash due to excessive memory consumption during the clustering process is reduced.
[0033] In some embodiments, Figure 1A The system shown can also exist without network 200 and image acquisition device 100, consisting only of terminal device 300. In this case, the terminal device acquires images to be clustered from the local image set and performs image clustering. In other embodiments, image acquisition device 100 and terminal device 300 can be integrated, such as a terminal device with a camera, like a mobile phone. In this case, image acquisition device 100 and terminal device 300 can be connected via wired transmission instead of a network.
[0034] In some embodiments, server 400 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminals and servers can be connected directly or indirectly via wired or wireless communication, which is not limited in this embodiment.
[0035] Figure 1B This is a schematic diagram illustrating the implementation process of an image clustering method provided in an embodiment of this application, as shown below. Figure 1B As shown, the method includes the following steps:
[0036] Step S101: Determine the similarity between images to be clustered in the image set to be clustered;
[0037] Here, the image set to be clustered refers to a collection that includes at least two images to be clustered, such as an image folder, image file package, electronic photo album, image library, etc. Within the image set to be clustered, the images can be images of the same object captured in different scenes, images of different objects captured in different scenes, or images of the same object or different objects captured in the same scene. The object typically refers to the main element or foreground content in the image, and can include people, animals, plants, etc., which are not limited in this embodiment. In some embodiments, the form of the images to be clustered in the image set can include one or more dimensions such as two-dimensional (2D) images and three-dimensional (3D) images. Images can include images in various color modes, such as red-green-blue (RGB) images, cyan-magenta-yellow (CMY) images, etc. For example, the set of images to be clustered includes an electronic photo album containing images of target person A in scenes such as subway stations, airports, train stations, and farms, as well as images of target person B in scenes such as parks, amusement parks, zoos, botanical gardens, and flower and bird markets.
[0038] In some embodiments, the images to be clustered acquired by the image acquisition device may include images of high quality and images of low quality. Images of high quality may have high image clarity and high completeness of the objects to be clustered; for example, in the case of a face image, the image may include complete and clear facial features. Images of low quality may have low image clarity and low completeness of the objects to be clustered; for example, in the case of a face image, the image may be blurry, missing any area of facial features, or any area of facial features may be unrecognizable. In practice, images of low quality may be discarded; alternatively, such images may be identified and stored in a set of identified images.
[0039] Here, since the set of images to be clustered includes at least two images to be clustered, and these images are images of the same object or different objects, there are images with high similarity and images with low similarity among the at least two images to be clustered.
[0040] In some embodiments, the similarity between the images to be clustered is between 0 and 1. When at least two images to be clustered contain images of different objects, the similarity between the images to be clustered is very low, even 0; when at least two images to be clustered contain images of the same object, the similarity between the images to be clustered is high.
[0041] In some possible implementations, image similarity algorithms can be used to analyze the similarity between images to be clustered. These algorithms include pixel variance comparison algorithms, perceptual hashing (PHA), template matching algorithms, etc., and are not limited to any particular algorithm in this application. For example, when using pixel variance comparison algorithms for similarity calculation, the variance of each frame of the images to be clustered is calculated sequentially, and then the difference in variance between different images is compared. The smaller the difference in variance, the higher the similarity between the images. Similarly, when using perceptual hashing algorithms for similarity calculation, a 64-bit hash value is generated for each frame of the images to be clustered, and then the hash values of different images are compared. The closer the hash values are, the higher the similarity between the images.
[0042] In some embodiments, at least two images to be clustered have a certain degree of similarity. During implementation, a similarity threshold is set according to the requirements or based on the experience of those skilled in the art. If the similarity between at least two images to be clustered is greater than or equal to the similarity threshold, the images to be clustered are considered to be images of the same object; if the similarity between at least two images to be clustered is less than the similarity threshold, the images to be clustered are considered to be images of different objects. For example, if the similarity threshold is 0.6, then if the similarity between at least two images to be clustered is greater than 0.6, such as 0.8, the images to be clustered are determined to be images of the same object; if the similarity between at least two images to be clustered is less than 0.6, such as 0.2, the images to be clustered are determined to be images of different objects.
[0043] Step S102: Based on the similarity, determine the clustering topology of the image set to be clustered;
[0044] Here, the clustering topology graph represents the topological graph of images of the same object in the image set to be clustered. In the clustering topology graph, each image to be clustered is represented as a node, and nodes corresponding to any two frames of images to be clustered are connected by a line segment, which serves as an edge of the clustering topology graph. The similarity between any two frames of images to be clustered is the weight of this edge. A complete clustering topology graph is a connected component, meaning that all nodes in the clustering topology graph are mutually connected and reachable. For example, if the image set to be clustered includes 10 frames of images of one object, then there are 10 corresponding nodes in the clustering topology graph. Every two nodes are connected by an edge, and the weight of the edge is the similarity value between the two frames of images represented by the two nodes corresponding to the edge.
[0045] In some embodiments, there are multiple frames of images of one or more objects in the set of images to be clustered. Therefore, one or more clustering topology maps can be obtained based on the similarity between the images; wherein, a clustering topology map corresponds to multiple frames of images of one object. For example, if the similarity between images is greater than a preset similarity threshold, the images in this class are considered to be images of the same object. Therefore, a clustering topology map is obtained based on the images of the same object in this class.
[0046] In some embodiments, the clustering topology graph can be stored using an adjacency matrix or an adjacency list. When storing an adjacency matrix, the memory consumption is the square of the number of nodes in the clustering topology graph; when storing an adjacency list, the memory consumption is proportional to the number of edges in the clustering topology graph. In practice, memory consumption is significant when both the number of nodes and edges in the clustering topology graph are large.
[0047] Step S103: In the clustering topology graph, determine the first set of target edges whose representation similarity is greater than the target security threshold;
[0048] Here, the target safety threshold is an indicator of the similarity between images. When the similarity between images is greater than the target safety threshold, it indicates that the content of the two images being compared includes the same object. In the clustering topology graph, this is represented as follows: if the weight of an edge in the clustering topology graph is greater than the target safety threshold, the images corresponding to the two nodes at both ends of that edge belong to the same object, and the similarity between the images corresponding to those two nodes is greater than the target safety threshold. For example, if the target safety threshold is 0.8, and the similarity between two images in the set to be clustered is 0.9, since the similarity between these two images is greater than the target safety threshold, in the clustering topology graph representing the object image, because the similarity between these two images is 0.9, that is, the weight of the edge connecting these two images is 0.9, which is greater than the target safety threshold of 0.8, therefore, the two images corresponding to the two nodes at both ends of this edge belong to the same object.
[0049] Here, the first target edge set refers to the set of edges in the clustered topology graph whose weights, i.e., image similarity, are greater than the target safety threshold. For example, if the target safety threshold is 0.8, and in the clustered topology graph, edge A has a weight of 0.85, edge B has a weight of 0.87, and edge C has a weight of 0.9, then the first target edge set is the set of edges including edges A, B, and C.
[0050] Step S104: If the number of edges in the first target edge set is greater than a preset number threshold, select the edges of the preset number threshold from the first target edge set as the second target edge set;
[0051] In some embodiments, since the edges in the first target edge set satisfy the condition that the edge weight, i.e. the image similarity, is greater than the target safety threshold, the size of the adjacency list is reduced by setting a quantity threshold to limit the number of edges with high similarity, thereby reducing memory consumption without affecting the clustering results.
[0052] Here, the second target edge set refers to the set of edges that include a preset number threshold selected from the first target edge set. It can be seen that the number of edges in the second target set is less than the number of edges in the first target set.
[0053] In some embodiments, the number threshold is set based on the acquired needs or empirical values. For example, if the number of edges in the first target edge set is 100, since the images corresponding to the two nodes at both ends of the edge belong to the same object, the number threshold is set to 50 without affecting the clustering results. This limits the number of highly similar edges, simplifies the size of the adjacency list, and reduces memory consumption.
[0054] Step S105: Based on the second target edge set, cluster the set of images to be clustered to obtain the first clustering result.
[0055] Here, the first clustering result refers to the classification result of each image in the image set to be clustered. For example, if the images to be clustered are people, and the image set includes images of the first person A, the second person B, and the third person C, and the images to be clustered include images 001 to 009, then the first clustering result means that in the image set, the images of the first person A include images 001 and 008; the images of the second person B include images 002, 003, 005, and 006; and the images of the third person C include images 004, 007, and 009. As another example, if the image set to be clustered includes images of people, monkeys, and horses, and the images to be clustered include images 001 to 008, then the first clustering result means that in the image set, the images of people include images 001 and 002; the images of monkeys include images 003, 004, 005, and 006; and the images of horses include images 007 and 008.
[0056] Among some possible implementations, clustering methods include at least one of the following:
[0057] (1) The k-means clustering algorithm (K-means) is implemented by first dividing the images to be clustered into K groups, and randomly selecting K images from the images to be clustered as initial cluster centers. Then, the distance between each image and each initial cluster center is calculated, and each image is assigned to the cluster center closest to it. The cluster center and the image assigned to the cluster center represent a cluster. After each image in the set of images to be clustered has been assigned, the cluster center of each cluster is re-determined based on the current images in the cluster. This process is repeated until a certain termination condition is met. The termination condition includes at least one of the following: no or a minimum number of images are reassigned to different clusters; no or a minimum number of cluster centers change; the sum of squared errors between images in the image set corresponding to a cluster is locally minimized, wherein the minimum number of images is set according to the obtained requirements or empirical values.
[0058] (2) Spectral clustering treats all images in the set of images to be clustered as points in space. These points can be connected by edges. The weight of the edge between two points that are far apart is lower, and the weight of the edge between two points that are close together is higher. Then, the graph composed of all points is sliced so that the sum of the weights of the edges between different subgraphs after slicing is as low as possible, and the sum of the weights of the edges within the subgraphs is as high as possible. That is, the distance between subgraphs is as far apart as possible, and the distance within the subgraphs is as close as possible. The process of iteratively deleting edges that represent far distances is carried out.
[0059] In this embodiment, firstly, the similarity between images to be clustered in the image set to be clustered is determined, and a clustering topology graph of the image set to be clustered is determined based on this similarity. Thus, the similarity between images to be clustered in the image set to be clustered can be visually observed through the nodes and edges in the clustering topology graph. Then, in the clustering topology graph, a first target edge set representing similarities greater than a target safety threshold is determined. Thus, the first target edge set can more accurately identify the images to be clustered with high similarity in the clustering topology graph. When the number of edges in the first target edge set exceeds a preset threshold, [further details about the first target edge set are needed]. The edges with a preset number threshold are selected as the second target edge set. By setting a number threshold, the number of edges with high similarity is limited, reducing the size of the adjacency list used to store the clustering topology graph and thus reducing memory usage. Based on this second target edge set, the image set to be clustered is clustered to obtain the first clustering result. This method reduces memory consumption for storing the clustering topology graph during clustering without affecting the clustering result, lowering the probability of machine lag or even crashes due to excessive memory consumption during clustering.
[0060] In some embodiments, a first security threshold is determined by the false recognition rate and a first image pair; a first recognition rate is determined by the first security threshold and a second image pair; and a target security threshold is determined if the first recognition rate is greater than a preset recognition rate. That is, before step S103, the method further includes:
[0061] Step S111: Obtain the similarity between every two different images to be clustered in the image set to be clustered, and obtain a first image pair with a similarity less than a first similarity threshold and a second image pair with a similarity greater than a second similarity threshold;
[0062] Here, the second similarity threshold is greater than or equal to the first similarity threshold. The first image pair refers to an image pair consisting of images of different objects with very low similarity, i.e., a negative image pair. For example, if the first image pair includes image A and image B, where image A is an image of object A and image B is an image of object B, then the similarity between image A and image B is very low, and they are called a negative image pair.
[0063] Here, the second image pair refers to an image pair consisting of images with high similarity or the same object, that is, an image pair. For example, the second image pair includes image A and image B. Image A is an image of object A, and image B is also an image of object A. Then, image A and image B have high similarity and are called an image pair.
[0064] Step S112: Determine a first security threshold based on the first image pair and the first preset false recognition rate;
[0065] In some embodiments, the method for determining the first security threshold based on the first image pair and the first preset false recognition rate is as shown in formula (1), where FAR is the first preset false recognition rate, and given the first preset false recognition rate FAR and N, the first security threshold is determined. n For the first image pair and N n Similarity of the first image pair In this case, a range or a specific value of the first safety threshold t can be determined.
[0066]
[0067] Where, N n For the nth first image pair, t is the first security threshold. It is the similarity of the i-th first image pair, and l(x) is an indicator function. When x is true, the value of l(x) is 1; when x is false, the value of l(x) is 0.
[0068] In some possible implementations, the first image pair is provided by the user according to requirements, and the first preset false recognition rate is provided by the user according to requirements, or set by those skilled in the art based on experience.
[0069] Step S113: Determine the first recognition rate based on the first security threshold and the second image pair;
[0070] In some embodiments, the method for determining the first recognition rate based on a first security threshold and a second image pair is as shown in formula (2), where TAR is the first recognition rate, and the second image pair N is known. p The first image for N n Similarity of the second image pair Given the first security threshold t, the value of the first recognition rate can be determined.
[0071]
[0072] in, Let be the similarity of the j-th second image pair, and let 1(x) be the indicator function. When the expression in parentheses is true, the value of the whole expression is 1; when the expression in parentheses is false, the value of the whole expression is 0.
[0073] Step S114: If the first recognition rate is greater than or equal to the preset recognition rate, determine the first security threshold as the target security threshold.
[0074] In some possible implementations, the preset recognition rate is provided according to requirements or set by those skilled in the art based on experience.
[0075] In some embodiments, when the first recognition rate is greater than or equal to the preset recognition rate, it indicates that when clustering the given set of images to be clustered, the recognition rate of the images to be clustered can meet the user's requirements. Therefore, the first security threshold at this time is the target security threshold.
[0076] In steps S111 to S114, a first security threshold is determined by the first image pair and the first preset false recognition rate, and a first recognition rate is determined by the first security threshold and the second image pair. After the first recognition rate is greater than or equal to the preset recognition rate, the first security threshold is determined as the target security threshold. In this way, when the first security threshold is the target security threshold, the recognition rate of the images to be clustered in the image set to be clustered reaches the preset recognition rate, thereby improving the accuracy of image clustering.
[0077] In some embodiments, after determining a first recognition rate based on a first security threshold and the second image pair, the method further includes:
[0078] If the first recognition rate is less than the preset recognition rate, the first preset false recognition rate is updated to obtain the updated false recognition rate.
[0079] In some embodiments, the updated false recognition rate is less than the first preset false recognition rate. When the first recognition rate is less than the preset recognition rate, it indicates that the first recognition rate has not met the user's required recognition rate. Therefore, the false recognition rate needs to be updated (reset), and the first recognition rate is recalculated using the above formulas (1) and (2) so that the first recognition rate is ultimately greater than or equal to the preset recognition rate. The steps of the above method include:
[0080] Step 1: Determine the updated false recognition rate;
[0081] In some embodiments, the updated false recognition rate is less than the first preset false recognition rate. In this case, the lower the probability of the image to be clustered being misidentified, the higher the recognition rate can be.
[0082] The second step is to determine a second security threshold based on the first image pair and the updated false recognition rate.
[0083] In some embodiments, the method for determining the second security threshold based on the first image pair and the updated false recognition rate is as shown in the above formula (1), and can be understood with reference to step S112.
[0084] In some embodiments, the second security threshold is greater than the first security threshold so that the second recognition rate is higher than the first recognition rate.
[0085] The third step is to determine the second recognition rate based on the second security threshold and the second image pair.
[0086] In some embodiments, the method for determining the second recognition rate based on the second security threshold and the second image pair is as shown in the above formula (2), and can be understood with reference to step S113.
[0087] Fourth step: If the second recognition rate is greater than or equal to the preset recognition rate, determine the second security threshold as the target security threshold.
[0088] In some embodiments, the fourth step can be understood with reference to step S114.
[0089] In this embodiment of the application, when the first recognition rate is less than the preset recognition rate, the first preset false recognition rate is updated to obtain the updated false recognition rate. This facilitates the subsequent determination of the second security threshold based on the first image pair and the updated false recognition rate, and the determination of the second recognition rate based on the second security threshold and the second image pair, thereby making the second recognition rate greater than or equal to the preset recognition rate, and thus improving the accuracy of image clustering.
[0090] In some embodiments, a clustering threshold is determined based on the set of images to be clustered and a second preset false recognition rate, and an intermediate clustered image group and the corresponding clustering topology map are determined based on the clustering threshold, i.e., as shown below. Figure 2 As shown, the implementation of step S102 includes the following steps:
[0091] Step S201: Determine the clustering threshold based on the set of images to be clustered and the second preset false recognition rate;
[0092] Here, the clustering threshold refers to the image similarity threshold that must be met for images to be clustered into one class. For example, if the clustering threshold is set to 0.6, then if the similarity between images to be clustered is greater than 0.6, the images to be clustered will be grouped into one class, or the images to be clustered will be considered as images of the same object.
[0093] In some embodiments, the clustering threshold is less than the target security threshold; the second preset false recognition rate is greater than the first preset false recognition rate;
[0094] In some embodiments, a third cluster image pair is determined in the set of images to be clustered; wherein the two images in the third target image pair are images of different objects and the number of the third cluster image pair is greater than the number of the first cluster image pair; a clustering threshold is determined based on the third cluster image pair and a preset third false recognition rate, wherein the clustering threshold can be calculated according to formula (1), and when calculating the clustering threshold according to formula (1), the value of FAR is the preset third false recognition rate, N n The value represents the third cluster image pair.
[0095] Step S202: Determine at least one intermediate clustered image group whose similarity is greater than the clustering threshold;
[0096] Here, the intermediate clustering image group refers to a set of images to be clustered that belong to the same object or that have a similarity greater than the clustering threshold.
[0097] In some embodiments, the image set to be clustered includes images of several objects. In this case, the images in the image set to be clustered can be divided into several intermediate clustering image groups.
[0098] Step S203: For each intermediate cluster image group in the at least one intermediate cluster image group, take any image in the intermediate cluster image group as a node and the line connecting any two frames in the intermediate cluster image group as an edge to obtain the clustering topology graph corresponding to the intermediate cluster image group.
[0099] In some embodiments, each intermediate clustered image group in the set of images to be clustered corresponds to a clustering topology graph. In this clustering topology graph, a node is any image in the intermediate clustered image group, and an edge is the line connecting any two frames in the intermediate clustered image group.
[0100] In some embodiments, determining a first set of target edges with a similarity greater than the target security threshold in the clustering topology graph includes: determining a first set of target edges with a similarity greater than the target security threshold in the clustering topology graph corresponding to each intermediate clustering image group.
[0101] In steps S201 to S203, a clustering threshold is first determined based on the set of images to be clustered and a second preset false recognition rate; and at least one intermediate clustered image group with a similarity greater than the clustering threshold is determined. In this way, the intermediate clustered image group can be quickly determined from the set of images to be clustered by using the clustering threshold. Then, taking any image in the intermediate clustered image group as a node and the line connecting any two frames of images as an edge, the clustering topology map corresponding to the intermediate clustered image group is obtained. In this way, by establishing the clustering topology map corresponding to the intermediate clustered image group, images of the same object in the set of images to be clustered or images with a similarity greater than the clustering threshold can be seen intuitively, thereby improving the efficiency of image clustering.
[0102] In some embodiments, the step of determining a first set of target edges in a clustered topology graph whose representation similarity is greater than a target security threshold includes:
[0103] Step S21: In the clustering topology graph, determine the third target edge set whose representation similarity is greater than the clustering threshold;
[0104] In some embodiments, the weight of an edge in a clustered topology graph represents image similarity. Therefore, the set of edges in the clustered topology graph where the image similarity is greater than the clustering threshold is taken as the third target edge set. In other words, in the third target edge set, the weight of the edge, i.e., the image similarity, is greater than the clustering threshold.
[0105] Step S22: In the third target edge set, determine the first target edge set whose representation similarity is greater than the target security threshold.
[0106] In some embodiments, in the third target edge set, the weight of the edges is further filtered, that is, the edges with image similarity greater than the target safety threshold are used as edges in the first target edge set.
[0107] In steps S21 and S22, a third set of target edges with a similarity greater than the clustering threshold is first determined in the clustering topology graph; then, a first set of target edges with a similarity greater than the target security threshold is determined from the third set of target edges. In this way, by filtering the first set of target edges from the third set of target edges according to the target security threshold, the first set of target edges can be obtained more accurately.
[0108] In some embodiments, when the weight of an edge in the third target edge set, i.e., the image similarity, is less than a target safety threshold, the method further includes:
[0109] Step S211: In the third set of target edges, determine a fourth set of target edges that are less than the target security threshold;
[0110] Here, the weights of the edges included in the fourth target edge set, i.e., the image similarity, are greater than the clustering threshold but less than the target safety threshold.
[0111] Step S212: Based on the fourth target edge set, cluster the image set to be clustered to obtain the second clustering result.
[0112] In some embodiments, since the image similarity is greater than the clustering threshold but less than the target security threshold, the images corresponding to the nodes at both ends of an edge in the clustering topology graph may not be images of the same object. Therefore, image clustering is performed sequentially based on the images corresponding to the two ends of all edges in the clustering topology graph, and all edges in the clustering topology graph are stored to obtain the second clustering result.
[0113] Here, the second clustering result can be understood by referring to the first clustering result.
[0114] In some embodiments, after determining the clustering threshold based on the set of images to be clustered and the second preset false recognition rate, the method further includes:
[0115] Step S221: If the similarity between the images to be clustered is less than the clustering threshold, determine the edges in the clustering topology graph that represent similarity less than the clustering threshold to obtain the fifth target edge set.
[0116] Here, in the fifth target edge set, the edge weight, i.e. the image similarity, is less than the clustering threshold.
[0117] Step S222: Delete the fifth target edge set in the clustered topology graph.
[0118] Here, if the image similarity is less than the clustering threshold, it indicates that the similarity between the images is low, or that at least two images are images of different objects. Therefore, the fifth target edge set is deleted in the clustering topology graph representing images of the same object.
[0119] In steps S221 and S222, when the similarity between the images to be clustered is less than the clustering threshold, edges representing similarity less than the clustering threshold are determined in the clustering topology graph to obtain the fifth target edge set; and the fifth target edge set is deleted in the clustering topology graph. In this way, deleting the fifth target edge set in the clustering topology graph representing an image of an object can reduce the number of edges in the first target edge set, thereby reducing memory consumption and reducing the probability of machine lag or even crash due to excessive memory consumption during the clustering process.
[0120] In some embodiments, when the number of edges in the first target edge set is greater than a preset threshold, selecting the edges of the preset threshold from the first target edge set as the second target edge set includes at least one of the following:
[0121] (1) Randomly select the preset number threshold of edges from the first target edge set as the second target edge set;
[0122] In some embodiments, for example, if the preset quantity threshold is n, then n edges are randomly selected from the first target edge set as the second target edge set.
[0123] (2) In the first target edge set, the edges with the preset number threshold are selected as the second target edge set according to the preset order of similarity.
[0124] Here, the preset order includes similarity from high to low, similarity from low to high, or other orders.
[0125] In some embodiments, for example, if the preset quantity threshold is n, then the first n edges in the first target edge set are selected as the second target edge set in order of similarity from high to low.
[0126] In this embodiment of the application, in the first target edge set, if the similarity is greater than the target security threshold and the number of edges is greater than the preset number threshold, edges of the preset number threshold are randomly selected or selected according to the preset order of similarity as the second target edge set. This can reduce the memory consumption used to store the clustering topology graph during the clustering process without affecting the clustering results, and reduce the probability of machine lag or even crash due to excessive memory consumption during the clustering process.
[0127] In some embodiments, within the first target edge set, if the similarity is greater than a target security threshold and the number of edges is less than a preset threshold, a sixth target edge set is determined, and clustering is performed based on the sixth target edge set to obtain a third clustering result, i.e., as shown below. Figure 3 As shown, after step S103, the method further includes:
[0128] Step S301: In the first target edge set, determine a sixth target edge set whose representation similarity is greater than the target security threshold and whose number is less than the preset number threshold;
[0129] Here, in the sixth target edge set, the edge weight, i.e., the image similarity, is greater than the target safety threshold, and the number of edges is less than the preset number threshold. For example, if the target safety threshold is 0.8 and the preset number threshold is 100, then in the sixth target edge set, the edge weight is greater than 0.8, and the number of edges is less than 100, for example, 50 edges.
[0130] Step S302: Cluster the images to be clustered corresponding to the sixth target edge set to obtain the third clustering result.
[0131] Here, the results of the third clustering can be understood by referring to the results of the first clustering.
[0132] In some embodiments, although the image similarity is greater than the target security threshold, since the number of edges in the sixth target edge set is less than the preset number threshold, in order to connect all nodes in the clustering topology graph, in practice, all edges in the sixth target edge set should be stored, and clustering should be performed according to the image to be clustered corresponding to the sixth target edge set to obtain the third clustering result.
[0133] In steps S301 and S302, when the similarity is greater than the target security threshold and the number of edges in the topology graph is less than the preset number threshold, the images to be clustered corresponding to the sixth target edge set are clustered to obtain the third clustering result. In this way, all nodes in the clustering topology graph can be connected, thus not affecting the clustering result.
[0134] In some embodiments, when the set of images to be clustered includes a set of photos stored in an album, images with high similarity and a large number of similar images in the photo set are selected to reduce the number of highly similar photos, thereby reducing the storage space occupied by the photos. That is, the above steps S103 and S104 can be implemented by the following process:
[0135] The first step is to determine the first set of candidate photos whose images contain the same object in the clustering topology graph of the photo set.
[0136] Here, the candidate photos in the first candidate photo set correspond to the edges in the first target edge set; each node on each edge of the clustering topology graph of the photo set represents a photo. Thus, by analyzing the similarity on each edge, the similarity between the photos represented by the nodes at both ends of the edge can be obtained, thereby obtaining photos with high similarity, and thus obtaining a candidate photo set whose content is the same object. For example, a set of photos of people whose content is the same person; or a set of photos of the same building, etc.
[0137] The second step is to select, in the first candidate photo set, a number of candidate photos corresponding to the preset number threshold as the second candidate photo set if the number of candidate photos in the first candidate photo set is greater than the preset number threshold.
[0138] Here, the candidate photos in the second candidate photo set correspond to the edges in the second target edge set. The nodes at both ends of the edges in the second target edge set represent photos in the second candidate photo set. If the number of candidate photos in the first candidate photo set is greater than the preset number threshold, it indicates that there are many photos with the same content in the album, occupying a lot of content. Thus, the first candidate photo set with a large number of photos is filtered according to the preset number threshold to obtain the second candidate photo set with the preset number threshold. Since the number of images in the second candidate photo set is less than the number of images in the first candidate photo set, reducing the number of photos with the same content reduces the consumption of album memory, thereby maintaining the accuracy of clustering the photo set with lower computational resource consumption.
[0139] In some embodiments, when the image set to be clustered includes a set of photos stored in an album, in order to further reduce the storage space occupied by the photos in the album, if the photo set meets preset conditions, the photo set is clustered based on the second candidate photo set to obtain the first clustering result; wherein, the preset conditions include at least one of the following:
[0140] The difference between the storage space occupied by the photo collection and the storage space of the album is less than a preset difference.
[0141] The photo set consists of photos stored in the album whose resolution meets the resolution threshold;
[0142] The photo set consists of photos stored in the album whose size meets the size threshold.
[0143] Here, the preset difference can be set according to the storage space of the album, for example, the preset difference is one-tenth of the album's storage space. Photos with resolutions that meet the resolution threshold and photos with sizes that meet the size threshold indicate that these photos have a large amount of data and occupy a large amount of storage space in the album. In order to reduce the amount of memory occupied by photos on the electronic device that owns the album, these photos with the same object in their image content are filtered to obtain a smaller set of second candidate photos that can contain rich information. Thus, in the process of image clustering based on the second set of candidate photos, both computational resources can be reduced and the accuracy of clustering can be maintained.
[0144] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario, using a clustering method for face images in a photo album as an example.
[0145] The goal of album clustering is to group faces found in an album together, that is, to group faces of the same person in the album into one category. Album clustering includes the following steps:
[0146] (1) Perform face detection on the images in the album; (2) After the detected faces are segmented and aligned, they are sent to the face feature extractor to obtain the feature vector corresponding to each face; (3) Cluster the feature vector corresponding to each face to obtain the face clustering result.
[0147] In the process of photo album clustering, the essence is to decompose the images in the album into multiple connected components. In a connected component, each node corresponds to a frame of face image, and the weight of the edge between two nodes corresponds to the similarity between the two frames. The topology graph containing a connected component can be recorded using an adjacency matrix or an adjacency list. Since the memory consumption of an adjacency matrix is the square of the number of nodes, it is relatively large. Therefore, an adjacency list is used to record edges in the topology graph that are greater than the clustering threshold, and the memory consumption is proportional to the number of edges. However, even so, the number of edges is usually very large, and it still occupies a lot of memory.
[0148] Based on this, this application provides an image clustering method, which can be implemented through the following steps:
[0149] The first step is to perform face detection on the face images in the album to be clustered and input the detected faces into the feature extractor to obtain the feature vector corresponding to the face in each face image;
[0150] Here, the album to be clustered is the set of images to be clustered in the aforementioned embodiments. The face images are the images to be clustered in the aforementioned embodiments.
[0151] The second step is to obtain the similarity between any two faces based on the feature vector of each face.
[0152] The third step is to establish a clustering topology graph based on each face image and the similarity between each pair of faces; wherein, in the clustering topology graph, each face image is a node, and the weight of the edge between two nodes is the similarity between each pair of faces.
[0153] Step 4: Determine the feature similarity distribution pattern based on the similarity between each pair of faces;
[0154] Here, the feature similarity distribution pattern means that, under the condition that the face comparison model conforms to the expected pattern, the similarity between face images of the same person is high, the similarity between face images of different people is low, and the similarity between different face images of the same person is different, but the similarity will be greater than a certain threshold.
[0155] Step 4: Determine the clustering threshold and the target safety threshold based on the feature similarity distribution pattern; wherein the target safety threshold is greater than the clustering threshold;
[0156] Step 5: If the similarity between any two faces is less than the target security threshold and greater than or equal to the clustering threshold, store the edge between the nodes corresponding to each pair of faces.
[0157] Step 6: If the similarity is greater than the target security threshold, store the edges between the nodes corresponding to each pair of faces according to a preset number threshold.
[0158] Step 7: If the similarity between any two faces is less than the clustering threshold, do not store the edges between the nodes corresponding to any two faces.
[0159] For example, if the album to be clustered contains only face photos of one object, the clustering topology graph corresponding to the face images to be clustered is a complete graph (there is an edge between any two nodes), such as... Figure 4 As shown, five nodes correspond to 10 edges. After setting a target security threshold, the number of edges in the clustered topology graph is limited; that is, if the number of edges exceeds a preset threshold, only edges exceeding the preset threshold are stored, as shown below. Figure 5As shown, five nodes correspond to seven edges. Since each pair of the five nodes is still connected, they will eventually cluster into one class. However, reducing the number of edges can greatly reduce memory consumption without affecting the clustering results. In actual testing, the memory consumption of clustering was reduced by 30% during this clustering process.
[0160] In practical applications, the clustering algorithm reduces memory usage by 30% and can silently obtain clustering results while running in the background. This solves the problem that clustering algorithms can cause device lag or even crash due to insufficient memory when memory usage is high during the clustering process, thus improving the user experience of clustering.
[0161] This application provides an image clustering device. Figure 6 This is a schematic diagram of the structural composition of the image clustering device according to an embodiment of this application, as shown below. Figure 6 As shown, the image clustering device 600 includes:
[0162] The first determining module 601 is used to determine the similarity between images to be clustered in the image set to be clustered;
[0163] The second determining module 602 is used to determine the clustering topology of the set of images to be clustered based on the similarity.
[0164] The third determining module 603 is used to determine a first set of target edges in the clustered topology graph, characterized by a similarity greater than the target security threshold.
[0165] Selection module 604 is used to select the edges of the preset number threshold as the second target edge set when the number of edges in the first target edge set is greater than a preset number threshold.
[0166] The first clustering module 605 is used to cluster the set of images to be clustered based on the second target edge set to obtain a first clustering result.
[0167] In some embodiments, the apparatus further includes: a matching module, configured to obtain the similarity between every two different images to be clustered in the image set to be clustered, and obtain a first image pair with a similarity less than a first similarity threshold and a second image pair with a similarity greater than a second similarity threshold; wherein the second similarity threshold is greater than or equal to the first similarity threshold; a fourth determining module, configured to determine a first security threshold based on the first image pair and a first preset false recognition rate; a fifth determining module, configured to determine a first recognition rate based on the first security threshold and the second image pair; and a sixth determining module, configured to determine the first security threshold as the target security threshold if the first recognition rate is greater than or equal to the preset recognition rate.
[0168] In some embodiments, the apparatus further includes: an update module, configured to update a first preset false recognition rate to obtain an updated false recognition rate when the first recognition rate is less than a preset recognition rate; wherein the updated false recognition rate is less than the first preset false recognition rate.
[0169] In some embodiments, the second determining module 602 includes: a first determining submodule, configured to determine a clustering threshold based on the set of images to be clustered and a second preset false recognition rate; wherein the clustering threshold is less than the target security threshold; and the second preset false recognition rate is greater than the first preset false recognition rate; a second determining submodule, configured to determine at least one intermediate clustering image group whose similarity is greater than the clustering threshold; a third determining submodule, configured to, for each intermediate clustering image group in the at least one intermediate clustering image group, take any image in the intermediate clustering image group as a node and the line connecting any two frames in the intermediate clustering image group as an edge, to obtain a clustering topology graph corresponding to the intermediate clustering image group; and a third determining module 603, further configured to determine a first target edge set representing a similarity greater than the target security threshold in the clustering topology graph corresponding to each intermediate clustering image group.
[0170] In some embodiments, the third determining module 603 includes: a fourth determining submodule, configured to determine a third set of target edges in the clustering topology graph whose representation similarity is greater than the clustering threshold; and a fifth determining submodule, configured to determine a first set of target edges in the third set of target edges whose representation similarity is greater than the target security threshold.
[0171] In some embodiments, the apparatus further includes: a seventh determining module, configured to determine a fourth set of target edges less than the target security threshold in the third set of target edges; and a second clustering module, configured to cluster the set of images to be clustered based on the fourth set of target edges to obtain a second clustering result.
[0172] In some embodiments, the apparatus further includes: an eighth determining module, configured to determine, in the clustering topology graph, edges representing similarity less than the clustering threshold when the similarity between the images to be clustered is less than the clustering threshold, to obtain a fifth target edge set; and a deleting module, configured to delete the fifth target edge set in the clustering topology graph.
[0173] In some embodiments, the selection module 604 includes at least one of the following: a first selection submodule, configured to randomly select edges of the preset number threshold from the first target edge set as a second target edge set; and a second selection submodule, configured to select edges of the preset number threshold from the first target edge set according to a preset order of similarity as a second target edge set.
[0174] In some embodiments, the apparatus further includes: a ninth determining module, configured to determine, in the first target edge set, a sixth target edge set whose representation similarity is greater than the target security threshold and whose quantity is less than the preset quantity threshold; and a third clustering module, configured to cluster the images to be clustered corresponding to the sixth target edge set to obtain a third clustering result.
[0175] In some embodiments, the set of images to be clustered includes a set of photos stored in an album, and the third determining module 603 is further configured to: determine a first set of candidate photos whose image content is the same object in the clustering topology graph of the photo set; wherein, the candidate photos in the first set of candidate photos correspond to the edges in the first set of target edges;
[0176] The selection module 604 is further configured to: when the number of candidate photos in the first candidate photo set is greater than the preset number threshold, select the number of candidate photos corresponding to the preset number threshold in the first candidate photo set as the second candidate photo set; wherein, the candidate photos in the second candidate photo set correspond to the edges in the second target edge set.
[0177] It should be noted that the description of the above device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0178] It should be noted that, in the embodiments of this application, if the above-described image clustering method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, 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 and includes several instructions to cause a terminal device (which may be a terminal, server, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0179] This application embodiment further provides a computer program product, which includes computer-executable instructions. When executed, the computer-executable instructions can implement the image clustering method provided in this application embodiment.
[0180] This application embodiment further provides a computer storage medium storing computer-executable instructions, which, when executed by a processor, implement the image clustering method provided in the above embodiment.
[0181] This application provides a terminal device. Figure 7 This is a schematic diagram of the composition structure of the terminal device according to an embodiment of this application, such as... Figure 7 As shown, the terminal device 700 includes: a processor 701, a communication interface 702, a memory 703, and a communication bus for data transmission between the various components. The communication interface 702 can assist in internal data transmission within the terminal device 700 and can also enable data transmission with external devices. For example, the communication interface 702, as an external communication interface, can enable data transmission between the terminal device 700 and output devices such as a display screen. The external communication interface can include standard wired and wireless interfaces. The processor 701 is configured to execute an image processing program in the memory to implement the image clustering method provided in the above embodiments. It should be noted that the terminal device 700 may include, but is not limited to, the components listed above. The number of each component can be configured or adjusted according to actual needs and the specific characteristics of the terminal device 700, and is not limited here.
[0182] The descriptions of the above-described image clustering apparatus, terminal device, and storage medium embodiments are similar to those of the above-described method embodiments, and have similar technical descriptions and beneficial effects. Due to space limitations, the descriptions of the above-described method embodiments are sufficient, and therefore will not be repeated here. For technical details not disclosed in the embodiments of the image clustering apparatus, terminal device, and storage medium of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0183] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence number of the above-described processes does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0184] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0185] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0186] Furthermore, in the various embodiments of this application, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0187] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a terminal device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks. The above descriptions are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image clustering method, characterized in that, The method includes: Determine the similarity between images in the set of images to be clustered; Based on the similarity, a clustering topology graph of the set of images to be clustered is determined; In the clustered topology graph, a first set of target edges with a similarity greater than the target security threshold is determined; If the number of edges in the first target edge set is greater than a preset threshold, then the edges of the preset threshold are selected from the first target edge set as the second target edge set. Based on the second target edge set, the set of images to be clustered is clustered to obtain the first clustering result; Determining the clustering topology graph of the image set to be clustered based on the similarity includes: Based on the set of images to be clustered and the second preset false recognition rate, a clustering threshold is determined; wherein the clustering threshold is less than the target security threshold; and the second preset false recognition rate is greater than the first preset false recognition rate. Determine at least one intermediate clustered image group whose similarity is greater than the clustering threshold; For each intermediate cluster image group in the at least one intermediate cluster image group, with any image in the intermediate cluster image group as a node and the line connecting any two frames in the intermediate cluster image group as an edge, the clustering topology graph corresponding to the intermediate cluster image group is obtained. The step of determining the first set of target edges with a similarity greater than the target security threshold in the clustering topology graph includes: determining the first set of target edges with a similarity greater than the target security threshold in the clustering topology graph corresponding to each intermediate clustering image group; The step of determining the first set of target edges in the clustered topology graph, characterized by a similarity greater than the target security threshold, includes: In the clustering topology graph, a third set of target edges representing similarities greater than the clustering threshold is determined; In the third target edge set, a first target edge set whose representation similarity is greater than the target security threshold is determined.
2. The method according to claim 1, characterized in that, Before determining the first set of target edges with a similarity greater than the target security threshold in the clustered topology graph, the method further includes: The similarity between any two different images to be clustered in the image set to be clustered is obtained, resulting in a first image pair with a similarity less than a first similarity threshold and a second image pair with a similarity greater than a second similarity threshold; wherein the second similarity threshold is greater than or equal to the first similarity threshold. Based on the first image pair and the first preset false recognition rate, a first security threshold is determined; Based on the first security threshold and the second image pair, a first recognition rate is determined; If the first recognition rate is greater than or equal to the preset recognition rate, the first security threshold is determined as the target security threshold.
3. The method according to claim 2, characterized in that, After determining the first recognition rate based on the first security threshold and the second image pair, the method further includes: If the first recognition rate is less than the preset recognition rate, the first preset false recognition rate is updated to obtain the updated false recognition rate; wherein the updated false recognition rate is less than the first preset false recognition rate.
4. The method according to claim 1, characterized in that, After determining the third set of target edges in the clustered topology graph whose representation similarity is greater than the clustering threshold, the method further includes: Within the third set of target edges, a fourth set of target edges that is less than the target security threshold is determined; Based on the fourth target edge set, the set of images to be clustered is clustered to obtain the second clustering result.
5. The method according to claim 1, characterized in that, After determining the clustering threshold based on the set of images to be clustered and the second preset false recognition rate, the method further includes: If the similarity between the images to be clustered is less than the clustering threshold, the edges representing the similarity less than the clustering threshold are determined in the clustering topology graph to obtain the fifth target edge set; In the clustered topology graph, delete the fifth target edge set.
6. The method according to any one of claims 1 to 5, characterized in that, When the number of edges in the first target edge set is greater than a preset threshold, selecting the edges of the preset threshold from the first target edge set as the second target edge set includes: In the first target edge set, edges of the preset number threshold are randomly selected as the second target edge set, or in the first target edge set, edges of the preset number threshold are selected as the second target edge set according to a preset order of similarity.
7. The method according to any one of claims 1, 2, 3 and 4, characterized in that, After determining the first set of target edges in the clustered topology graph, representing images with similarity greater than the target safety threshold, the method further includes: In the first set of target edges, a sixth set of target edges is determined, wherein the similarity of the representation is greater than the target security threshold and the number is less than the preset number threshold; The images to be clustered corresponding to the sixth target edge set are clustered to obtain the third clustering result.
8. The method according to any one of claims 1, 2, 3 and 4, characterized in that, The set of images to be clustered includes a set of photos stored in an album. Determining the first set of target edges in the clustering topology graph, representing similarities greater than a target safety threshold, includes: In the clustering topology graph of the photo set, a first candidate photo set is determined whose image content is the same object; wherein, the candidate photos in the first candidate photo set correspond to the edges in the first target edge set; When the number of edges in the first target edge set is greater than a preset threshold, selecting the edges of the preset threshold from the first target edge set as the second target edge set includes: If the number of candidate photos in the first candidate photo set is greater than the preset number threshold, then the number of candidate photos corresponding to the preset number threshold in the first candidate photo set is selected as the second candidate photo set; wherein, the candidate photos in the second candidate photo set correspond to the edges in the second target edge set.
9. An image clustering device, characterized in that, The device includes: The first determining module is used to determine the similarity between images to be clustered in the image set to be clustered; The second determining module is used to determine the clustering topology of the set of images to be clustered based on the similarity. The third determining module is used to determine, in the clustered topology graph, a first set of target edges whose representation similarity is greater than the target security threshold; The selection module is used to select the edges of the preset number threshold as the second target edge set when the number of edges in the first target edge set is greater than the preset number threshold. The first clustering module is used to cluster the set of images to be clustered based on the second target edge set to obtain a first clustering result; Determining the clustering topology graph of the image set to be clustered based on the similarity includes: Based on the set of images to be clustered and the second preset false recognition rate, a clustering threshold is determined; wherein the clustering threshold is less than the target security threshold; and the second preset false recognition rate is greater than the first preset false recognition rate. Determine at least one intermediate clustered image group whose similarity is greater than the clustering threshold; For each intermediate cluster image group in the at least one intermediate cluster image group, with any image in the intermediate cluster image group as a node and the line connecting any two frames in the intermediate cluster image group as an edge, the clustering topology graph corresponding to the intermediate cluster image group is obtained. The step of determining the first set of target edges with a similarity greater than the target security threshold in the clustering topology graph includes: determining the first set of target edges with a similarity greater than the target security threshold in the clustering topology graph corresponding to each intermediate clustering image group; The step of determining the first set of target edges in the clustered topology graph, characterized by a similarity greater than the target security threshold, includes: In the clustering topology graph, a third set of target edges representing similarities greater than the clustering threshold is determined; In the third target edge set, a first target edge set whose representation similarity is greater than the target security threshold is determined.
10. A computer storage medium, characterized in that, The computer storage medium stores computer-executable instructions, which, when executed, enable the image clustering method according to any one of claims 1 to 8.
11. A terminal device, characterized in that, The terminal device includes a memory and a processor. The memory stores computer-executable instructions, and when the processor executes the computer-executable instructions in the memory, it can implement the image clustering method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image clustering method, device, computer equipment and readable storage medium
CN113963221A