This commit is contained in:
Manav Rathi 2024-04-11 11:46:41 +05:30
parent 006ea085fe
commit d2e7925c63
No known key found for this signature in database
2 changed files with 3 additions and 39 deletions

View file

@ -121,7 +121,6 @@ export class LocalMLSyncContext implements MLSyncContext {
public blurDetectionService: BlurDetectionService;
public faceEmbeddingService: FaceEmbeddingService;
public faceClusteringService: ClusteringService;
public sceneDetectionService: SceneDetectionService;
public localFilesMap: Map<number, EnteFile>;
public outOfSyncFiles: EnteFile[];
@ -175,10 +174,6 @@ export class LocalMLSyncContext implements MLSyncContext {
this.config.faceClustering.method,
);
this.sceneDetectionService = MLFactory.getSceneDetectionService(
this.config.sceneDetection.method,
);
this.outOfSyncFiles = [];
this.nSyncedFiles = 0;
this.nSyncedFaces = 0;

View file

@ -22,8 +22,6 @@ import PeopleService from "./peopleService";
import ReaderService from "./readerService";
class MachineLearningService {
private initialized = false;
private localSyncContext: Promise<MLSyncContext>;
private syncContext: Promise<MLSyncContext>;
@ -300,7 +298,7 @@ class MachineLearningService {
throw error;
}
await this.persistMLFileSyncError(syncContext, enteFile, error);
await this.persistMLFileSyncError(enteFile, error);
syncContext.nSyncedFiles += 1;
}
}
@ -337,7 +335,7 @@ class MachineLearningService {
newMlFile.errorCount = 0;
newMlFile.lastErrorMessage = undefined;
await this.persistOnServer(newMlFile, enteFile);
await this.persistMLFileData(syncContext, newMlFile);
await mlIDbStorage.putFile(newMlFile);
} catch (e) {
log.error("ml detection failed", e);
newMlFile.mlVersion = oldMlFile.mlVersion;
@ -368,38 +366,11 @@ class MachineLearningService {
log.info("putEmbedding response: ", res);
}
public async init() {
if (this.initialized) {
return;
}
await tf.ready();
log.info("01 TF Memory stats: ", JSON.stringify(tf.memory()));
this.initialized = true;
}
public async dispose() {
this.initialized = false;
}
private async getMLFileData(fileId: number) {
return mlIDbStorage.getFile(fileId);
}
private async persistMLFileData(
syncContext: MLSyncContext,
mlFileData: MlFileData,
) {
mlIDbStorage.putFile(mlFileData);
}
private async persistMLFileSyncError(
syncContext: MLSyncContext,
enteFile: EnteFile,
e: Error,
) {
private async persistMLFileSyncError(enteFile: EnteFile, e: Error) {
try {
await mlIDbStorage.upsertFileInTx(enteFile.id, (mlFileData) => {
if (!mlFileData) {
@ -432,8 +403,6 @@ class MachineLearningService {
await PeopleService.syncPeopleIndex(syncContext);
await ObjectService.syncThingsIndex(syncContext);
await this.persistMLLibraryData(syncContext);
}