AI: Add face.CollisionDist variable for face comparison #5167

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2025-10-26 09:50:20 +01:00
parent 100883ea9a
commit c53ac3353b
4 changed files with 6 additions and 4 deletions

View file

@ -28,6 +28,8 @@ var (
ClusterDist = 0.64
// MatchDist is the distance offset threshold used to match new faces with existing clusters.
MatchDist = 0.46
// CollisionDist is the minimum distance under which embeddings cannot be distinguished.
CollisionDist = 0.1
// ClusterCore is the minimum number of faces required to seed a cluster core.
ClusterCore = 4
// SampleThreshold is the number of faces required before automatic clustering begins.

View file

@ -217,7 +217,7 @@ func (c *Config) FaceClusterCore() int {
// FaceClusterDist returns the radius of faces forming a cluster core.
func (c *Config) FaceClusterDist() float64 {
if c.options.FaceClusterDist < 0.1 || c.options.FaceClusterDist > 1.5 {
if c.options.FaceClusterDist < face.CollisionDist || c.options.FaceClusterDist > 1.5 {
return face.ClusterDist
}
@ -226,7 +226,7 @@ func (c *Config) FaceClusterDist() float64 {
// FaceMatchDist returns the offset distance when matching faces with clusters.
func (c *Config) FaceMatchDist() float64 {
if c.options.FaceMatchDist < 0.1 || c.options.FaceMatchDist > 1.5 {
if c.options.FaceMatchDist < face.CollisionDist || c.options.FaceMatchDist > 1.5 {
return face.MatchDist
}

View file

@ -164,7 +164,7 @@ func (m *Face) Match(embeddings face.Embeddings) (match bool, dist float64) {
case dist > (m.SampleRadius + face.MatchDist):
// Too far.
return false, dist
case m.CollisionRadius > 0.1 && dist > m.CollisionRadius:
case m.CollisionRadius > face.CollisionDist && dist > m.CollisionRadius:
// Within radius of reported collisions.
return false, dist
}

View file

@ -107,7 +107,7 @@ func (c faceCandidate) match(embeddings face.Embeddings) (bool, float64) {
return false, dist
}
if c.collisionRadius > 0.1 && dist > c.collisionRadius {
if c.collisionRadius > face.CollisionDist && dist > c.collisionRadius {
return false, dist
}