Reduce distance to server type
This commit is contained in:
parent
6b5788539b
commit
ee894a668c
|
@ -2,12 +2,10 @@ import { Box, Dimensions, Point } from "services/face/geom";
|
||||||
|
|
||||||
export declare type Cluster = Array<number>;
|
export declare type Cluster = Array<number>;
|
||||||
|
|
||||||
export declare type Landmark = Point;
|
|
||||||
|
|
||||||
export interface FaceDetection {
|
export interface FaceDetection {
|
||||||
// box and landmarks is relative to image dimentions stored at mlFileData
|
// box and landmarks is relative to image dimentions stored at mlFileData
|
||||||
box: Box;
|
box: Box;
|
||||||
landmarks?: Array<Landmark>;
|
landmarks?: Point[];
|
||||||
probability?: number;
|
probability?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ import PQueue from "p-queue";
|
||||||
import { putEmbedding } from "services/embeddingService";
|
import { putEmbedding } from "services/embeddingService";
|
||||||
import mlIDbStorage, { ML_SEARCH_CONFIG_NAME } from "services/face/db";
|
import mlIDbStorage, { ML_SEARCH_CONFIG_NAME } from "services/face/db";
|
||||||
import { fetchImageBitmap, getLocalFile } from "services/face/file";
|
import { fetchImageBitmap, getLocalFile } from "services/face/file";
|
||||||
import { Face, FaceDetection, Landmark, MlFileData } from "services/face/types";
|
import type { Point } from "services/face/geom";
|
||||||
|
import { Face, FaceDetection, MlFileData } from "services/face/types";
|
||||||
import { getLocalFiles } from "services/fileService";
|
import { getLocalFiles } from "services/fileService";
|
||||||
import { EnteFile } from "types/file";
|
import { EnteFile } from "types/file";
|
||||||
import { isInternalUserForML } from "utils/user";
|
import { isInternalUserForML } from "utils/user";
|
||||||
|
@ -483,9 +484,9 @@ class ServerFace {
|
||||||
|
|
||||||
class ServerDetection {
|
class ServerDetection {
|
||||||
public box: ServerFaceBox;
|
public box: ServerFaceBox;
|
||||||
public landmarks: Landmark[];
|
public landmarks: Point[];
|
||||||
|
|
||||||
public constructor(box: ServerFaceBox, landmarks: Landmark[]) {
|
public constructor(box: ServerFaceBox, landmarks: Point[]) {
|
||||||
this.box = box;
|
this.box = box;
|
||||||
this.landmarks = landmarks;
|
this.landmarks = landmarks;
|
||||||
}
|
}
|
||||||
|
@ -529,19 +530,12 @@ function LocalFileMlDataToServerFileMl(
|
||||||
const box = detection.box;
|
const box = detection.box;
|
||||||
const landmarks = detection.landmarks;
|
const landmarks = detection.landmarks;
|
||||||
const newBox = new ServerFaceBox(box.x, box.y, box.width, box.height);
|
const newBox = new ServerFaceBox(box.x, box.y, box.width, box.height);
|
||||||
const newLandmarks: Landmark[] = [];
|
|
||||||
for (let j = 0; j < landmarks.length; j++) {
|
|
||||||
newLandmarks.push({
|
|
||||||
x: landmarks[j].x,
|
|
||||||
y: landmarks[j].y,
|
|
||||||
} as Landmark);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO-ML: Add client UA and version
|
// TODO-ML: Add client UA and version
|
||||||
const newFaceObject = new ServerFace(
|
const newFaceObject = new ServerFace(
|
||||||
faceID,
|
faceID,
|
||||||
Array.from(embedding),
|
Array.from(embedding),
|
||||||
new ServerDetection(newBox, newLandmarks),
|
new ServerDetection(newBox, landmarks),
|
||||||
score,
|
score,
|
||||||
blur,
|
blur,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue