Prune
This commit is contained in:
parent
d2e7925c63
commit
ce566f522d
8 changed files with 4 additions and 68 deletions
|
@ -46,22 +46,6 @@ export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
|||
// maxDistanceInsideCluster: 0.4,
|
||||
generateDebugInfo: true,
|
||||
},
|
||||
objectDetection: {
|
||||
method: "SSDMobileNetV2",
|
||||
maxNumBoxes: 20,
|
||||
minScore: 0.2,
|
||||
},
|
||||
sceneDetection: {
|
||||
method: "ImageScene",
|
||||
minScore: 0.1,
|
||||
},
|
||||
// tsne: {
|
||||
// samples: 200,
|
||||
// dim: 2,
|
||||
// perplexity: 10.0,
|
||||
// learningRate: 10.0,
|
||||
// metric: 'euclidean',
|
||||
// },
|
||||
mlVersion: 3,
|
||||
};
|
||||
|
||||
|
@ -80,12 +64,4 @@ export const TEXT_DETECTION_TIMEOUT_MS = [10000, 30000, 60000, 120000, 240000];
|
|||
export const MOBILEFACENET_FACE_SIZE = 112;
|
||||
export const MOBILEFACENET_EMBEDDING_SIZE = 192;
|
||||
|
||||
// scene detection model takes fixed-shaped (224x224) inputs
|
||||
// https://tfhub.dev/sayannath/lite-model/image-scene/1
|
||||
export const SCENE_DETECTION_IMAGE_SIZE = 224;
|
||||
|
||||
// SSD with Mobilenet v2 initialized from Imagenet classification checkpoint. Trained on COCO 2017 dataset (images scaled to 320x320 resolution).
|
||||
// https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2
|
||||
export const OBJECT_DETECTION_IMAGE_SIZE = 320;
|
||||
|
||||
export const BATCHES_BEFORE_SYNCING_INDEX = 5;
|
||||
|
|
|
@ -127,7 +127,6 @@ export class LocalMLSyncContext implements MLSyncContext {
|
|||
public nSyncedFiles: number;
|
||||
public nSyncedFaces: number;
|
||||
public allSyncedFacesMap?: Map<number, Array<Face>>;
|
||||
public tsne?: any;
|
||||
|
||||
public error?: Error;
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ class MachineLearningService {
|
|||
.length,
|
||||
nFaceNoise:
|
||||
syncContext.mlLibraryData?.faceClusteringResults?.noise.length,
|
||||
tsne: syncContext.tsne,
|
||||
error: syncContext.error,
|
||||
};
|
||||
// log.info('[MLService] sync results: ', mlSyncResult);
|
||||
|
|
|
@ -16,7 +16,6 @@ class ReaderService {
|
|||
if (fileContext.imageBitmap) {
|
||||
return fileContext.imageBitmap;
|
||||
}
|
||||
// log.info('1 TF Memory stats: ',JSON.stringify(tf.memory()));
|
||||
if (fileContext.localFile) {
|
||||
if (
|
||||
fileContext.enteFile.metadata.fileType !== FILE_TYPE.IMAGE
|
||||
|
@ -47,7 +46,6 @@ class ReaderService {
|
|||
fileContext.newMlFile.imageSource = syncContext.config.imageSource;
|
||||
const { width, height } = fileContext.imageBitmap;
|
||||
fileContext.newMlFile.imageDimensions = { width, height };
|
||||
// log.info('2 TF Memory stats: ',JSON.stringify(tf.memory()));
|
||||
|
||||
return fileContext.imageBitmap;
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
BLAZEFACE_FACE_SIZE,
|
||||
MAX_FACE_DISTANCE_PERCENT,
|
||||
} from "constants/mlConfig";
|
||||
import { MAX_FACE_DISTANCE_PERCENT } from "constants/mlConfig";
|
||||
import { Dimensions } from "types/image";
|
||||
import {
|
||||
FaceDetection,
|
||||
|
@ -35,14 +32,12 @@ class YoloFaceDetectionService implements FaceDetectionService {
|
|||
// private onnxInferenceSession?: ort.InferenceSession;
|
||||
private onnxInferenceSession?: any;
|
||||
public method: Versioned<FaceDetectionMethod>;
|
||||
private desiredFaceSize;
|
||||
|
||||
public constructor(desiredFaceSize: number = BLAZEFACE_FACE_SIZE) {
|
||||
public constructor() {
|
||||
this.method = {
|
||||
value: "YoloFace",
|
||||
version: 1,
|
||||
};
|
||||
this.desiredFaceSize = desiredFaceSize;
|
||||
}
|
||||
|
||||
private async initOnnx() {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import * as tf from "@tensorflow/tfjs-core";
|
||||
|
||||
import { DebugInfo } from "hdbscan";
|
||||
import PQueue from "p-queue";
|
||||
import { EnteFile } from "types/file";
|
||||
|
@ -12,7 +10,6 @@ export interface MLSyncResult {
|
|||
nSyncedFaces: number;
|
||||
nFaceClusters: number;
|
||||
nFaceNoise: number;
|
||||
tsne?: any;
|
||||
error?: Error;
|
||||
}
|
||||
|
||||
|
@ -226,9 +223,6 @@ export interface MLSyncConfig {
|
|||
blurDetection: BlurDetectionConfig;
|
||||
faceEmbedding: FaceEmbeddingConfig;
|
||||
faceClustering: FaceClusteringConfig;
|
||||
objectDetection: ObjectDetectionConfig;
|
||||
sceneDetection: SceneDetectionConfig;
|
||||
tsne?: TSNEConfig;
|
||||
mlVersion: number;
|
||||
}
|
||||
|
||||
|
@ -254,7 +248,6 @@ export interface MLSyncContext {
|
|||
nSyncedFiles: number;
|
||||
nSyncedFaces: number;
|
||||
allSyncedFacesMap?: Map<number, Array<Face>>;
|
||||
tsne?: any;
|
||||
|
||||
error?: Error;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import log from "@/next/log";
|
|||
import { CACHES } from "@ente/shared/storage/cacheStorage/constants";
|
||||
import { cached } from "@ente/shared/storage/cacheStorage/helpers";
|
||||
import { FILE_TYPE } from "constants/file";
|
||||
import { BLAZEFACE_FACE_SIZE } from "constants/mlConfig";
|
||||
import { euclidean } from "hdbscan";
|
||||
import PQueue from "p-queue";
|
||||
import DownloadManager from "services/download";
|
||||
|
@ -21,10 +20,10 @@ import {
|
|||
Versioned,
|
||||
} from "types/machineLearning";
|
||||
import { getRenderableImage } from "utils/file";
|
||||
import { clamp, imageBitmapToBlob, warpAffineFloat32List } from "utils/image";
|
||||
import { clamp, warpAffineFloat32List } from "utils/image";
|
||||
import mlIDbStorage from "utils/storage/mlIDbStorage";
|
||||
import { Box, Point } from "../../../thirdparty/face-api/classes";
|
||||
import { ibExtractFaceImage, ibExtractFaceImages } from "./faceAlign";
|
||||
import { ibExtractFaceImages } from "./faceAlign";
|
||||
import { getFaceCropBlobFromStorage } from "./faceCrop";
|
||||
|
||||
export function f32Average(descriptors: Float32Array[]) {
|
||||
|
@ -105,29 +104,6 @@ export async function getLocalFile(fileId: number) {
|
|||
return localFiles.find((f) => f.id === fileId);
|
||||
}
|
||||
|
||||
export async function getFaceImage(
|
||||
face: AlignedFace,
|
||||
token: string,
|
||||
faceSize: number = BLAZEFACE_FACE_SIZE,
|
||||
file?: EnteFile,
|
||||
): Promise<FaceImageBlob> {
|
||||
if (!file) {
|
||||
file = await getLocalFile(face.fileId);
|
||||
}
|
||||
|
||||
const imageBitmap = await getOriginalImageBitmap(file);
|
||||
const faceImageBitmap = ibExtractFaceImage(
|
||||
imageBitmap,
|
||||
face.alignment,
|
||||
faceSize,
|
||||
);
|
||||
const faceImage = imageBitmapToBlob(faceImageBitmap);
|
||||
faceImageBitmap.close();
|
||||
imageBitmap.close();
|
||||
|
||||
return faceImage;
|
||||
}
|
||||
|
||||
export async function extractFaceImages(
|
||||
faces: Array<AlignedFace>,
|
||||
faceSize: number,
|
||||
|
|
Loading…
Add table
Reference in a new issue