People: Improve face clustering #22

This commit is contained in:
Michael Mayer 2021-08-15 12:17:14 +02:00
parent b7d9557f67
commit 6291b406b6
2 changed files with 7 additions and 5 deletions

View file

@ -17,6 +17,8 @@ import (
)
const FaceSampleThreshold = 25
const FaceClusterDistance = 0.66
const FaceClusterSamples = 3
// Faces represents a worker for face clustering and matching.
type Faces struct {
@ -133,10 +135,10 @@ func (w *Faces) Analyze() (err error) {
}
}
if len(dist) == 0 {
if l := len(dist); l == 0 {
log.Infof("faces: analyzed %d clusters, no matches", samples)
} else {
log.Infof("faces: %d faces match to the same person", samples)
log.Infof("faces: %d faces match to the same person", l)
}
for personUID, d := range dist {
@ -206,7 +208,7 @@ func (w *Faces) Start() (err error) {
var c clusters.HardClusterer
// See https://dl.photoprism.org/research/ for research on face clustering algorithms.
if c, err = clusters.DBSCAN(1, 1.0, w.conf.Workers(), clusters.EuclideanDistance); err != nil {
if c, err = clusters.DBSCAN(FaceClusterSamples, FaceClusterDistance, w.conf.Workers(), clusters.EuclideanDistance); err != nil {
return err
} else if err = c.Learn(embeddings); err != nil {
return err
@ -302,7 +304,7 @@ func (w *Faces) Start() (err error) {
}
}
if faceId == "" {
if faceId == "" || faceDist > FaceClusterDistance {
continue
}

View file

@ -43,7 +43,7 @@ func (ind *Index) detectFaces(jpeg *MediaFile) face.Faces {
}
if len(faces) > 0 {
log.Infof("index: detected %d faces in %s [%s]", len(faces), txt.Quote(jpeg.BaseName()), time.Since(start))
log.Infof("index: %d faces in %s [%s]", len(faces), txt.Quote(jpeg.BaseName()), time.Since(start))
}
return faces