run face object and text detection parallely

This commit is contained in:
Abhinav 2022-04-11 14:02:04 +05:30
parent 9443488cd7
commit 387f13a562

View file

@ -402,7 +402,8 @@ class MachineLearningService {
} else if (fileContext.oldMlFile?.mlVersion) { } else if (fileContext.oldMlFile?.mlVersion) {
newMlFile.mlVersion = fileContext.oldMlFile.mlVersion; newMlFile.mlVersion = fileContext.oldMlFile.mlVersion;
} }
try {
const faceDetection = async () => {
await FaceService.syncFileFaceDetections(syncContext, fileContext); await FaceService.syncFileFaceDetections(syncContext, fileContext);
if (newMlFile.faces && newMlFile.faces.length > 0) { if (newMlFile.faces && newMlFile.faces.length > 0) {
@ -418,16 +419,16 @@ class MachineLearningService {
fileContext fileContext
); );
} }
};
await ObjectService.syncFileObjectDetections( try {
await Promise.all([
faceDetection(),
ObjectService.syncFileObjectDetections(
syncContext, syncContext,
fileContext fileContext
); ),
await promiseWithTimeout(
TextService.syncFileTextDetections(syncContext, fileContext), TextService.syncFileTextDetections(syncContext, fileContext),
ML_DETECTION_TIMEOUT_MS ]);
);
} catch (e) { } catch (e) {
newMlFile.mlVersion = oldMlFile.mlVersion; newMlFile.mlVersion = oldMlFile.mlVersion;
throw e; throw e;