Better use of constants
This commit is contained in:
parent
39f16ff517
commit
a443ac1680
4 changed files with 15 additions and 8 deletions
|
@ -154,7 +154,7 @@ class FaceMLDataDB {
|
|||
final Map<int, int> result = {};
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
'SELECT $fileIDColumn, COUNT(*) as count FROM $facesTable where $faceScore > 0.8 GROUP BY $fileIDColumn',
|
||||
'SELECT $fileIDColumn, COUNT(*) as count FROM $facesTable where $faceScore > $kMinFaceDetectionScore GROUP BY $fileIDColumn',
|
||||
);
|
||||
|
||||
for (final map in maps) {
|
||||
|
@ -197,7 +197,7 @@ class FaceMLDataDB {
|
|||
final clusterIDs =
|
||||
cluterRows.map((e) => e[cluserIDColumn] as int).toList();
|
||||
final List<Map<String, dynamic>> faceMaps = await db.rawQuery(
|
||||
'SELECT * FROM $facesTable where $faceClusterId IN (${clusterIDs.join(",")}) AND $fileIDColumn in (${fileId.join(",")}) AND $faceScore > 0.8 ORDER BY $faceScore DESC',
|
||||
'SELECT * FROM $facesTable where $faceClusterId IN (${clusterIDs.join(",")}) AND $fileIDColumn in (${fileId.join(",")}) AND $faceScore > $kMinHighQualityFaceScore ORDER BY $faceScore DESC',
|
||||
);
|
||||
if (faceMaps.isNotEmpty) {
|
||||
if (avatarFileId != null) {
|
||||
|
@ -341,7 +341,7 @@ class FaceMLDataDB {
|
|||
///
|
||||
/// Only selects faces with score greater than [minScore] and blur score greater than [minClarity]
|
||||
Future<Map<String, (int?, Uint8List)>> getFaceEmbeddingMap({
|
||||
double minScore = kMinFaceScore,
|
||||
double minScore = kMinHighQualityFaceScore,
|
||||
int minClarity = kLaplacianThreshold,
|
||||
int maxRows = 20000,
|
||||
}) async {
|
||||
|
@ -398,7 +398,7 @@ class FaceMLDataDB {
|
|||
facesTable,
|
||||
columns: [faceIDColumn, faceEmbeddingBlob],
|
||||
where:
|
||||
'$faceScore > 0.8 AND $faceBlur > $kLaplacianThreshold AND $fileIDColumn IN (${fileIDs.join(",")})',
|
||||
'$faceScore > $kMinHighQualityFaceScore AND $faceBlur > $kLaplacianThreshold AND $fileIDColumn IN (${fileIDs.join(",")})',
|
||||
limit: batchSize,
|
||||
offset: offset,
|
||||
orderBy: '$faceIDColumn DESC',
|
||||
|
|
|
@ -11,7 +11,7 @@ class Face {
|
|||
|
||||
bool get isBlurry => blur < kLaplacianThreshold;
|
||||
|
||||
bool get hasHighScore => score > kMinFaceScore;
|
||||
bool get hasHighScore => score > kMinHighQualityFaceScore;
|
||||
|
||||
bool get isHighQuality => (!isBlurry) && hasHighScore;
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
import "package:photos/services/face_ml/face_detection/yolov5face/onnx_face_detection.dart";
|
||||
|
||||
/// Blur detection threshold
|
||||
const kLaplacianThreshold = 15;
|
||||
|
||||
/// Default blur value
|
||||
const kLapacianDefault = 10000.0;
|
||||
|
||||
/// The minimum score for a face to be considered a face
|
||||
const kMinFaceScore = 0.78;
|
||||
/// The minimum score for a face to be considered a high quality face for clustering and person detection
|
||||
const kMinHighQualityFaceScore = 0.78;
|
||||
|
||||
/// The minimum score for a face to be detected, regardless of quality. Use [kMinHighQualityFaceScore] for high quality faces.
|
||||
const kMinFaceDetectionScore = YoloOnnxFaceDetection.kMinScoreSigmoidThreshold;
|
||||
|
|
|
@ -362,7 +362,9 @@ class FaceMlService {
|
|||
await clusterAllImages();
|
||||
}
|
||||
|
||||
Future<void> clusterAllImages({double minFaceScore = kMinFaceScore}) async {
|
||||
Future<void> clusterAllImages({
|
||||
double minFaceScore = kMinHighQualityFaceScore,
|
||||
}) async {
|
||||
_logger.info("`clusterAllImages()` called");
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue