comment out erroring used code

This commit is contained in:
Abhinav 2023-01-20 21:16:39 +05:30
parent 3b183bbb00
commit 9073760799

View file

@ -1,27 +1,24 @@
import { euclidean, TreeNode } from 'hdbscan'; import { euclidean, TreeNode } from 'hdbscan';
import { RawNodeDatum } from 'react-d3-tree/lib/types/common'; import { RawNodeDatum } from 'react-d3-tree/lib/types/common';
import { f32Average, getAllFacesFromMap } from '.'; // import { f32Average, getAllFacesFromMap } from '.';
import { import {
FacesCluster, FacesCluster,
Cluster, // Cluster,
FaceDescriptor, // FaceDescriptor,
FaceWithEmbedding, FaceWithEmbedding,
MLSyncContext, MLSyncContext,
NearestCluster, NearestCluster,
} from 'types/machineLearning'; } from 'types/machineLearning';
import { getAllFacesMap } from 'utils/storage/mlStorage'; // import { getAllFacesMap } from 'utils/storage/mlStorage';
export function getClusterSummary(cluster: Cluster): FaceDescriptor { // export function getClusterSummary(cluster: Cluster): FaceDescriptor {
// const faceScore = (f) => f.detection.score; // f.alignedRect.box.width * // const faceScore = (f) => f.detection.score; // f.alignedRect.box.width *
// return cluster
// return cluster // .map((f) => this.allFaces[f].face)
// .map((f) => this.allFaces[f].face) // .sort((f1, f2) => faceScore(f2) - faceScore(f1))[0].descriptor;
// .sort((f1, f2) => faceScore(f2) - faceScore(f1))[0].descriptor; // const descriptors = cluster.map((f) => this.allFaces[f].embedding);
// return f32Average(descriptors);
const descriptors = cluster.map((f) => this.allFaces[f].embedding); // }
return f32Average(descriptors);
}
export function updateClusterSummaries(syncContext: MLSyncContext) { export function updateClusterSummaries(syncContext: MLSyncContext) {
if ( if (
@ -63,36 +60,36 @@ export function getNearestCluster(
return { cluster: nearest, distance: nearestDist }; return { cluster: nearest, distance: nearestDist };
} }
export async function assignNoiseWithinLimit(syncContext: MLSyncContext) { // export async function assignNoiseWithinLimit(syncContext: MLSyncContext) {
if ( // if (
!syncContext.mlLibraryData?.faceClusteringResults?.noise || // !syncContext.mlLibraryData?.faceClusteringResults?.noise ||
syncContext.mlLibraryData?.faceClusteringResults.noise.length < 1 // syncContext.mlLibraryData?.faceClusteringResults.noise.length < 1
) { // ) {
return; // return;
} // }
const noise = syncContext.mlLibraryData.faceClusteringResults.noise; // const noise = syncContext.mlLibraryData.faceClusteringResults.noise;
const allFacesMap = await getAllFacesMap(); // const allFacesMap = await getAllFacesMap();
const allFaces = getAllFacesFromMap(allFacesMap); // const allFaces = getAllFacesFromMap(allFacesMap);
noise.forEach((n) => { // noise.forEach((n) => {
const noiseFace = allFaces[n]; // const noiseFace = allFaces[n];
const nearest = this.getNearestCluster(syncContext, noiseFace); // const nearest = this.getNearestCluster(syncContext, noiseFace);
if (nearest.cluster && nearest.distance < this.maxFaceDistance) { // if (nearest.cluster && nearest.distance < this.maxFaceDistance) {
console.log('Adding noise to cluser: ', n, nearest.distance); // console.log('Adding noise to cluser: ', n, nearest.distance);
nearest.cluster.faces.push(n); // nearest.cluster.faces.push(n);
} else { // } else {
console.log( // console.log(
'No cluster for noise: ', // 'No cluster for noise: ',
n, // n,
'within distance: ', // 'within distance: ',
this.maxFaceDistance // this.maxFaceDistance
); // );
this.clustersWithNoise.noise.push(n); // this.clustersWithNoise.noise.push(n);
} // }
}); // });
} // }
// TODO: remove recursion to avoid stack size limits // TODO: remove recursion to avoid stack size limits
export function toD3Tree( export function toD3Tree(