comment out tsne generation code
This commit is contained in:
parent
34c2910ec6
commit
7888bc902b
|
@ -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,
|
||||
|
|
|
@ -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<Array<number>>, config: TSNEConfig) {
|
||||
if (!denseInput || denseInput.length < 1) {
|
||||
return null;
|
||||
}
|
||||
// export function toTSNE(denseInput: Array<Array<number>>, 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 {};
|
||||
|
|
Loading…
Reference in a new issue