2021-09-21 09:51:48 +02:00
|
|
|
package face
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/crop"
|
|
|
|
)
|
|
|
|
|
2021-10-05 18:42:39 +02:00
|
|
|
var CropSize = crop.Sizes[crop.Tile160] // Face image crop size for FaceNet.
|
|
|
|
var OverlapThreshold = 42 // Face area overlap threshold in percent.
|
|
|
|
var OverlapThresholdFloor = OverlapThreshold - 1 // Reduced overlap area to avoid rounding inconsistencies.
|
|
|
|
var ScoreThreshold = 9.0 // Min face score.
|
|
|
|
var ClusterScoreThreshold = 15 // Min score for faces forming a cluster.
|
2021-10-07 09:32:17 +02:00
|
|
|
var SizeThreshold = 50 // Min face size in pixels.
|
2021-10-05 18:42:39 +02:00
|
|
|
var ClusterSizeThreshold = 80 // Min size for faces forming a cluster in pixels.
|
|
|
|
var ClusterDist = 0.64 // Similarity distance threshold of faces forming a cluster core.
|
2022-04-03 17:25:37 +02:00
|
|
|
var MatchDist = 0.46 // Dist offset threshold for matching new faces with clusters.
|
2021-10-05 18:42:39 +02:00
|
|
|
var ClusterCore = 4 // Min number of faces forming a cluster core.
|
|
|
|
var SampleThreshold = 2 * ClusterCore // Threshold for automatic clustering to start.
|
2021-09-23 13:16:05 +02:00
|
|
|
|
|
|
|
// QualityThreshold returns the scale adjusted quality score threshold.
|
|
|
|
func QualityThreshold(scale int) (score float32) {
|
|
|
|
score = float32(ScoreThreshold)
|
2021-09-21 09:51:48 +02:00
|
|
|
|
|
|
|
// Smaller faces require higher quality.
|
|
|
|
switch {
|
2021-09-21 11:03:07 +02:00
|
|
|
case scale < 26:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 26.0
|
2021-09-21 11:03:07 +02:00
|
|
|
case scale < 32:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 16.0
|
2021-09-21 11:03:07 +02:00
|
|
|
case scale < 40:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 11.0
|
2021-09-21 09:51:48 +02:00
|
|
|
case scale < 50:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 9.0
|
2021-09-21 09:51:48 +02:00
|
|
|
case scale < 80:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 6.0
|
2021-09-21 09:51:48 +02:00
|
|
|
case scale < 110:
|
2021-09-23 13:16:05 +02:00
|
|
|
score += 2.0
|
2021-09-21 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-23 13:16:05 +02:00
|
|
|
return score
|
2021-09-21 09:51:48 +02:00
|
|
|
}
|