From 7888bc902b41e320a7209eadb6c461bcc754c51e Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 10 Feb 2023 22:25:37 +0530 Subject: [PATCH] comment out tsne generation code --- .../machineLearning/machineLearningService.ts | 28 ++++---- src/utils/machineLearning/visualization.ts | 64 ++++++++++--------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/services/machineLearning/machineLearningService.ts b/src/services/machineLearning/machineLearningService.ts index 64a5340c9..497c498bd 100644 --- a/src/services/machineLearning/machineLearningService.ts +++ b/src/services/machineLearning/machineLearningService.ts @@ -15,12 +15,12 @@ import { MLSyncResult, } from 'types/machineLearning'; -import { toTSNE } from 'utils/machineLearning/visualization'; +// import { toTSNE } from 'utils/machineLearning/visualization'; // import { // incrementIndexVersion, // mlFilesStore // } from 'utils/storage/mlStorage'; -import { getAllFacesFromMap } from 'utils/machineLearning'; +// import { getAllFacesFromMap } from 'utils/machineLearning'; import { MLFactory } from './machineLearningFactory'; import mlIDbStorage from 'utils/storage/mlIDbStorage'; import { getMLSyncConfig } from 'utils/machineLearning/config'; @@ -88,9 +88,9 @@ class MachineLearningService { // tf.engine().endScope(); - if (syncContext.config.tsne) { - await this.runTSNE(syncContext); - } + // if (syncContext.config.tsne) { + // await this.runTSNE(syncContext); + // } const mlSyncResult: MLSyncResult = { nOutOfSyncFiles: syncContext.outOfSyncFiles.length, @@ -560,16 +560,16 @@ class MachineLearningService { await this.persistMLLibraryData(syncContext); } - private async runTSNE(syncContext: MLSyncContext) { - const allFacesMap = await FaceService.getAllSyncedFacesMap(syncContext); - const allFaces = getAllFacesFromMap(allFacesMap); + // private async runTSNE(syncContext: MLSyncContext) { + // const allFacesMap = await FaceService.getAllSyncedFacesMap(syncContext); + // const allFaces = getAllFacesFromMap(allFacesMap); - const input = allFaces - .slice(0, syncContext.config.tsne.samples) - .map((f) => Array.from(f.embedding)); - syncContext.tsne = toTSNE(input, syncContext.config.tsne); - addLogLine('tsne: ', syncContext.tsne); - } + // const input = allFaces + // .slice(0, syncContext.config.tsne.samples) + // .map((f) => Array.from(f.embedding)); + // syncContext.tsne = toTSNE(input, syncContext.config.tsne); + // addLogLine('tsne: ', syncContext.tsne); + // } private async syncFaceDetections( syncContext: MLSyncContext, diff --git a/src/utils/machineLearning/visualization.ts b/src/utils/machineLearning/visualization.ts index 7275a50ac..949dde6f2 100644 --- a/src/utils/machineLearning/visualization.ts +++ b/src/utils/machineLearning/visualization.ts @@ -1,38 +1,40 @@ -import TSNE from 'tsne-js'; -import { TSNEConfig, TSNEData } from 'types/machineLearning'; +// // import TSNE from 'tsne-js'; +// import { TSNEConfig, TSNEData } from 'types/machineLearning'; -export function toD3Tsne(tsne) { - const data: TSNEData = { - width: 800, - height: 800, - dataset: [], - }; - data.dataset = tsne.map((t) => { - return { - x: (data.width * (t[0] + 1.0)) / 2, - y: (data.height * (t[1] + 1.0)) / 2, - }; - }); +// export function toD3Tsne(tsne) { +// const data: TSNEData = { +// width: 800, +// height: 800, +// dataset: [], +// }; +// data.dataset = tsne.map((t) => { +// return { +// x: (data.width * (t[0] + 1.0)) / 2, +// y: (data.height * (t[1] + 1.0)) / 2, +// }; +// }); - return data; -} +// return data; +// } -export function toTSNE(denseInput: Array>, config: TSNEConfig) { - if (!denseInput || denseInput.length < 1) { - return null; - } +// export function toTSNE(denseInput: Array>, config: TSNEConfig) { +// if (!denseInput || denseInput.length < 1) { +// return null; +// } - const model = new TSNE(config); +// const model = new TSNE(config); - model.init({ - data: denseInput, - type: 'dense', - }); +// model.init({ +// data: denseInput, +// type: 'dense', +// }); - // `error`, `iter`: final error and iteration number - // note: computation-heavy action happens here - model.run(); +// // `error`, `iter`: final error and iteration number +// // note: computation-heavy action happens here +// model.run(); - // `outputScaled` is `output` scaled to a range of [-1, 1] - return model.getOutputScaled(); -} +// // `outputScaled` is `output` scaled to a range of [-1, 1] +// return model.getOutputScaled(); +// } + +export {};