Skip to content

Clustering threshold

matiasdelellis edited this page Jan 13, 2022 · 1 revision

Clustering threshold

Clusters are determined as groups of similar faces, and to obtain them, all the faces found must be compared. The similarity of two faces is established by the Euclidean Distance between their descriptors and the Clustering threshold (aka Sensitivity) determines how different can be the descriptors of two faces, to determine that they belong to the same person.

A small value groups only very similar faces, resulting in many clusters of the same person that you will have to rename each one, but of great quality. A higher value will be more flexible when differentiating the descriptors to group them, resulting in less clusters but with largest number of faces of the same person, but can make mistakes grouping faces of others similar persons.

Examples

For the development of the application I have a small collection of images of the The Big Bag Theory sitcom. There are 2155 photos, with 6122 faces.

[matias@nube nextcloud]$ sudo -u apache php occ face:stats -u user
+------+--------+-------+---------+---------+
| User | Images | Faces | Cluster | Persons |
+------+--------+-------+---------+---------+
| user | 2155   | 6122  | 0       | 0       |
+------+--------+-------+---------+---------+

Let's see how the Clustering threshold parameter intervenes for the result of facial recognition.

Clustering threshold: 0.4 (default)

[matias@nube nextcloud]$ sudo -u apache php occ face:background_job -t 83600 -u user
1/10 - Executing task CheckRequirementsTask (Check all requirements)
2/10 - Executing task CheckCronTask (Check that service is started from either cron or from command)
3/10 - Executing task LockTask (Acquire lock so that only one background task can run)
4/10 - Executing task DisabledUserRemovalTask (Purge all the information of a user when disable the analysis.)
5/10 - Executing task StaleImagesRemovalTask (Crawl for stale images (either missing in filesystem or under .nomedia) and remove them from DB)
6/10 - Executing task CreateClustersTask (Create new persons or update existing persons)
	Face clustering will be created for the first time.
	6122 faces found for clustering
	3317 persons found after clustering
7/10 - Executing task AddMissingImagesTask (Crawl for missing images for each user and insert them in DB)
8/10 - Executing task EnumerateImagesMissingFacesTask (Find all images which don't have faces generated for them)
9/10 - Executing task ImageProcessingTask (Process all images to extract faces)
	NOTE: Starting face recognition. If you experience random crashes after this point, please look FAQ at https://github.com/matiasdelellis/facerecognition/wiki/FAQ
10/10 - Executing task UnlockTask (Release obtained lock)
[matias@nube nextcloud]$ sudo -u apache php occ face:stats -u user
+------+--------+-------+---------+---------+
| User | Images | Faces | Cluster | Persons |
+------+--------+-------+---------+---------+
| user | 2155   | 6122  | 3317    | 0       |
+------+--------+-------+---------+---------+

After assing names

[matias@nube nextcloud]$ sudo -u apache php occ face:stats -u user
[sudo] password for matias: 
+------+--------+-------+---------+---------+
| User | Images | Faces | Cluster | Persons |
+------+--------+-------+---------+---------+
| user | 2155   | 6122  | 3317    | 8       |
+------+--------+-------+---------+---------+

Clustering threshold: 0.5

[matias@nube nextcloud]$ sudo -u apache php occ face:background_job -t 83600 -u user
1/10 - Executing task CheckRequirementsTask (Check all requirements)
2/10 - Executing task CheckCronTask (Check that service is started from either cron or from command)
3/10 - Executing task LockTask (Acquire lock so that only one background task can run)
4/10 - Executing task DisabledUserRemovalTask (Purge all the information of a user when disable the analysis.)
5/10 - Executing task StaleImagesRemovalTask (Crawl for stale images (either missing in filesystem or under .nomedia) and remove them from DB)
6/10 - Executing task CreateClustersTask (Create new persons or update existing persons)
	Face clustering will be created for the first time.
	6122 faces found for clustering
	2717 persons found after clustering
7/10 - Executing task AddMissingImagesTask (Crawl for missing images for each user and insert them in DB)
8/10 - Executing task EnumerateImagesMissingFacesTask (Find all images which don't have faces generated for them)
9/10 - Executing task ImageProcessingTask (Process all images to extract faces)
	NOTE: Starting face recognition. If you experience random crashes after this point, please look FAQ at https://github.com/matiasdelellis/facerecognition/wiki/FAQ
10/10 - Executing task UnlockTask (Release obtained lock)
[matias@nube nextcloud]$ sudo -u apache php occ face:stats -u user