Extra logging from FileFaceWidget

This commit is contained in:
laurenspriem
2025-07-15 21:59:38 +02:00
parent 6ef9e0fdb0
commit 6e7ee1fa16
3 changed files with 38 additions and 20 deletions

View File

@@ -37,24 +37,29 @@ class FaceThumbnailGenerator extends SuperIsolate {
String imagePath,
List<FaceBox> faceBoxes,
) async {
_logger.info(
"Generating face thumbnails for ${faceBoxes.length} face boxes in $imagePath",
);
final List<Map<String, dynamic>> faceBoxesJson =
faceBoxes.map((box) => box.toJson()).toList();
final List<Uint8List> faces = await runInIsolate(
IsolateOperation.generateFaceThumbnails,
{
'imagePath': imagePath,
'faceBoxesList': faceBoxesJson,
},
).then((value) => value.cast<Uint8List>());
_logger.info("Generated face thumbnails");
final compressedFaces =
await compressFaceThumbnails({'listPngBytes': faces});
_logger.info(
"Compressed face thumbnails from sizes ${faces.map((e) => e.length / 1024).toList()} to ${compressedFaces.map((e) => e.length / 1024).toList()} kilobytes",
);
return compressedFaces;
try {
_logger.info(
"Generating face thumbnails for ${faceBoxes.length} face boxes in $imagePath",
);
final List<Map<String, dynamic>> faceBoxesJson =
faceBoxes.map((box) => box.toJson()).toList();
final List<Uint8List> faces = await runInIsolate(
IsolateOperation.generateFaceThumbnails,
{
'imagePath': imagePath,
'faceBoxesList': faceBoxesJson,
},
).then((value) => value.cast<Uint8List>());
_logger.info("Generated face thumbnails");
final compressedFaces =
await compressFaceThumbnails({'listPngBytes': faces});
_logger.info(
"Compressed face thumbnails from sizes ${faces.map((e) => e.length / 1024).toList()} to ${compressedFaces.map((e) => e.length / 1024).toList()} kilobytes",
);
return compressedFaces;
} catch (e, s) {
_logger.severe("Failed to generate face thumbnails", e, s);
rethrow;
}
}
}

View File

@@ -323,6 +323,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
final mlDataDB = MLDataDB.instance;
final faces =
await mlDataDB.getFacesForGivenFileID(widget.file.uploadedFileID!);
_logger.info('Fetched ${faces?.length} faces');
if (faces == null) {
return _FaceDataResult(
@@ -336,8 +337,15 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
final faceIdsToClusterIds = await mlDataDB.getFaceIdsToClusterIds(
faces.map((face) => face.faceID).toList(),
);
_logger
.info('Fetched ${faceIdsToClusterIds.length} face IDs to cluster IDs');
_logger.info('Face IDs to Cluster IDs: $faceIdsToClusterIds');
final persons = await PersonService.instance.getPersonsMap();
_logger.info('Fetched ${persons.length} persons');
final clusterIDToPerson = await mlDataDB.getClusterIDToPersonID();
_logger.info('Fetched ${clusterIDToPerson.length} cluster IDs to person IDs');
_logger.info("Now getting cached face crops");
final faceCrops =
await getCachedFaceCrops(widget.file, faces, useTempCache: true);
final defaultFaces = <Face>[];

View File

@@ -111,6 +111,7 @@ Future<Map<String, Uint8List>?> getCachedFaceCrops(
try {
final faceIdToCrop = <String, Uint8List>{};
final facesWithoutCrops = <String, FaceBox>{};
_logger.info("Now getting cached face crops for ${faces.length} faces");
for (final face in faces) {
final Uint8List? cachedFace =
_checkInMemoryCachedCropForFaceID(face.faceID);
@@ -149,6 +150,7 @@ Future<Map<String, Uint8List>?> getCachedFaceCrops(
}
}
if (facesWithoutCrops.isEmpty) {
_logger.info("All face crops gotten from cache");
return faceIdToCrop;
}
@@ -231,7 +233,7 @@ Future<Map<String, Uint8List>?> getCachedFaceCrops(
s,
);
} else {
_logger.info(
_logger.severe(
"Stopped getting face crops for faceIDs: ${faces.map((face) => face.faceID).toList()} due to $e",
);
}
@@ -330,6 +332,9 @@ Future<Map<String, Uint8List>?> _getFaceCrops(
Map<String, FaceBox> faceBoxeMap, {
bool useFullFile = true,
}) async {
_logger.info(
"`_getFaceCrops` started for ${file.uploadedFileID} and ${faceBoxeMap.length} faces",
);
late String? imagePath;
if (useFullFile && file.fileType != FileType.video) {
final File? ioFile = await getFile(file);