Essence
This commit is contained in:
parent
512766ebed
commit
295f4a0c2a
|
@ -3,14 +3,6 @@ import { Dimensions } from "services/face/geom";
|
||||||
import { EnteFile } from "types/file";
|
import { EnteFile } from "types/file";
|
||||||
import { Box, Point } from "./geom";
|
import { Box, Point } from "./geom";
|
||||||
|
|
||||||
export interface MLSyncResult {
|
|
||||||
nOutOfSyncFiles: number;
|
|
||||||
nSyncedFiles: number;
|
|
||||||
nSyncedFaces: number;
|
|
||||||
nFaceClusters: number;
|
|
||||||
error?: Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
export declare type FaceDescriptor = Float32Array;
|
export declare type FaceDescriptor = Float32Array;
|
||||||
|
|
||||||
export declare type Cluster = Array<number>;
|
export declare type Cluster = Array<number>;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {
|
||||||
MLLibraryData,
|
MLLibraryData,
|
||||||
MLSearchConfig,
|
MLSearchConfig,
|
||||||
MLSyncFileContext,
|
MLSyncFileContext,
|
||||||
MLSyncResult,
|
|
||||||
MlFileData,
|
MlFileData,
|
||||||
} from "services/face/types";
|
} from "services/face/types";
|
||||||
import { getLocalFiles } from "services/fileService";
|
import { getLocalFiles } from "services/fileService";
|
||||||
|
@ -151,7 +150,7 @@ class MachineLearningService {
|
||||||
private localSyncContext: Promise<MLSyncContext>;
|
private localSyncContext: Promise<MLSyncContext>;
|
||||||
private syncContext: Promise<MLSyncContext>;
|
private syncContext: Promise<MLSyncContext>;
|
||||||
|
|
||||||
public async sync(token: string, userID: number): Promise<MLSyncResult> {
|
public async sync(token: string, userID: number): Promise<boolean> {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw Error("Token needed by ml service to sync file");
|
throw Error("Token needed by ml service to sync file");
|
||||||
}
|
}
|
||||||
|
@ -180,18 +179,9 @@ class MachineLearningService {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mlSyncResult: MLSyncResult = {
|
const error = syncContext.error;
|
||||||
nOutOfSyncFiles: syncContext.outOfSyncFiles.length,
|
const nOutOfSyncFiles = syncContext.outOfSyncFiles.length;
|
||||||
nSyncedFiles: syncContext.nSyncedFiles,
|
return !error && nOutOfSyncFiles > 0;
|
||||||
nSyncedFaces: syncContext.nSyncedFaces,
|
|
||||||
nFaceClusters:
|
|
||||||
syncContext.mlLibraryData?.faceClusteringResults?.clusters
|
|
||||||
.length,
|
|
||||||
error: syncContext.error,
|
|
||||||
};
|
|
||||||
// log.info('[MLService] sync results: ', mlSyncResult);
|
|
||||||
|
|
||||||
return mlSyncResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async regenerateFaceCrop(faceID: string) {
|
public async regenerateFaceCrop(faceID: string) {
|
||||||
|
|
|
@ -269,11 +269,8 @@ class MLWorkManager {
|
||||||
const userID = getUserID();
|
const userID = getUserID();
|
||||||
const jobWorkerProxy = await this.getSyncJobWorker();
|
const jobWorkerProxy = await this.getSyncJobWorker();
|
||||||
|
|
||||||
const mlSyncResult = await jobWorkerProxy.sync(token, userID);
|
return await jobWorkerProxy.sync(token, userID);
|
||||||
|
|
||||||
// this.terminateSyncJobWorker();
|
// this.terminateSyncJobWorker();
|
||||||
return !mlSyncResult.error && mlSyncResult.nOutOfSyncFiles > 0;
|
|
||||||
|
|
||||||
// TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job
|
// TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error("Failed to run MLSync Job", e);
|
log.error("Failed to run MLSync Job", e);
|
||||||
|
|
Loading…
Reference in a new issue