Clear tf memory usage after each sync run
This commit is contained in:
parent
7bfddfedce
commit
498603eb34
|
@ -59,6 +59,8 @@ class MachineLearningService {
|
||||||
throw Error('Token needed by ml service to sync file');
|
throw Error('Token needed by ml service to sync file');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tf.engine().startScope();
|
||||||
|
|
||||||
const syncContext = new MLSyncContext(token, config);
|
const syncContext = new MLSyncContext(token, config);
|
||||||
|
|
||||||
await this.getOutOfSyncFiles(syncContext);
|
await this.getOutOfSyncFiles(syncContext);
|
||||||
|
@ -69,6 +71,7 @@ class MachineLearningService {
|
||||||
await this.syncIndex(syncContext);
|
await this.syncIndex(syncContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tf.engine().endScope();
|
||||||
console.log('Final TF Memory stats: ', tf.memory());
|
console.log('Final TF Memory stats: ', tf.memory());
|
||||||
|
|
||||||
if (syncContext.config.tsne) {
|
if (syncContext.config.tsne) {
|
||||||
|
@ -166,6 +169,7 @@ class MachineLearningService {
|
||||||
const detectedFaces = await this.faceDetectionService.detectFaces(
|
const detectedFaces = await this.faceDetectionService.detectFaces(
|
||||||
tfImage
|
tfImage
|
||||||
);
|
);
|
||||||
|
// console.log('3 TF Memory stats: ', tf.memory());
|
||||||
|
|
||||||
const filtertedFaces = detectedFaces.filter(
|
const filtertedFaces = detectedFaces.filter(
|
||||||
(f) => f.box.width > syncContext.config.faceDetection.minFaceSize
|
(f) => f.box.width > syncContext.config.faceDetection.minFaceSize
|
||||||
|
@ -179,7 +183,7 @@ class MachineLearningService {
|
||||||
const alignedFaces =
|
const alignedFaces =
|
||||||
this.faceAlignmentService.getAlignedFaces(filtertedFaces);
|
this.faceAlignmentService.getAlignedFaces(filtertedFaces);
|
||||||
console.log('[MLService] alignedFaces: ', alignedFaces);
|
console.log('[MLService] alignedFaces: ', alignedFaces);
|
||||||
// console.log('3 TF Memory stats: ', tf.memory());
|
// console.log('4 TF Memory stats: ', tf.memory());
|
||||||
|
|
||||||
const facesWithEmbeddings =
|
const facesWithEmbeddings =
|
||||||
await this.faceEmbeddingService.getFaceEmbeddings(
|
await this.faceEmbeddingService.getFaceEmbeddings(
|
||||||
|
@ -187,7 +191,7 @@ class MachineLearningService {
|
||||||
alignedFaces
|
alignedFaces
|
||||||
);
|
);
|
||||||
console.log('[MLService] facesWithEmbeddings: ', facesWithEmbeddings);
|
console.log('[MLService] facesWithEmbeddings: ', facesWithEmbeddings);
|
||||||
// console.log('4 TF Memory stats: ', tf.memory());
|
// console.log('5 TF Memory stats: ', tf.memory());
|
||||||
|
|
||||||
tf.dispose(tfImage);
|
tf.dispose(tfImage);
|
||||||
// console.log('8 TF Memory stats: ', tf.memory());
|
// console.log('8 TF Memory stats: ', tf.memory());
|
||||||
|
|
Loading…
Reference in a new issue