From fc1957be49f17b5f8807b16be9909cab654b8bd3 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 14 May 2024 11:09:12 +0530 Subject: [PATCH] Inline --- .../machineLearning/yoloFaceDetectionService.ts | 10 +++++++--- web/apps/photos/src/services/ml/geom.ts | 8 ++++++-- web/apps/photos/src/utils/machineLearning/index.ts | 10 +--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/web/apps/photos/src/services/machineLearning/yoloFaceDetectionService.ts b/web/apps/photos/src/services/machineLearning/yoloFaceDetectionService.ts index 14a5fb9f3..ba3ed1113 100644 --- a/web/apps/photos/src/services/machineLearning/yoloFaceDetectionService.ts +++ b/web/apps/photos/src/services/machineLearning/yoloFaceDetectionService.ts @@ -1,6 +1,12 @@ import { workerBridge } from "@/next/worker/worker-bridge"; import { euclidean } from "hdbscan"; -import { Box, Point, boxFromBoundingBox } from "services/ml/geom"; +import { + Box, + Dimensions, + Point, + boxFromBoundingBox, + newBox, +} from "services/ml/geom"; import { FaceDetection, FaceDetectionMethod, @@ -14,13 +20,11 @@ import { scale, translate, } from "transformation-matrix"; -import { Dimensions } from "services/ml/geom"; import { clamp, getPixelBilinear, normalizePixelBetween0And1, } from "utils/image"; -import { newBox } from "utils/machineLearning"; class YoloFaceDetectionService implements FaceDetectionService { public method: Versioned; diff --git a/web/apps/photos/src/services/ml/geom.ts b/web/apps/photos/src/services/ml/geom.ts index 37e452578..424c7ed7a 100644 --- a/web/apps/photos/src/services/ml/geom.ts +++ b/web/apps/photos/src/services/ml/geom.ts @@ -21,8 +21,8 @@ export class Point { } export interface Dimensions { - width: number; - height: number; + width: number; + height: number; } export interface IBoundingBox { @@ -39,6 +39,10 @@ export interface IRect { height: number; } +export function newBox(x: number, y: number, width: number, height: number) { + return new Box({ x, y, width, height }); +} + export const boxFromBoundingBox = ({ left, top, diff --git a/web/apps/photos/src/utils/machineLearning/index.ts b/web/apps/photos/src/utils/machineLearning/index.ts index 54060802f..352b79e13 100644 --- a/web/apps/photos/src/utils/machineLearning/index.ts +++ b/web/apps/photos/src/utils/machineLearning/index.ts @@ -18,20 +18,12 @@ import { getRenderableImage } from "utils/file"; import { clamp, warpAffineFloat32List } from "utils/image"; import mlIDbStorage from "utils/storage/mlIDbStorage"; -export function newBox(x: number, y: number, width: number, height: number) { - return new Box({ x, y, width, height }); -} - function getBoxCenterPt(topLeft: Point, bottomRight: Point): Point { return topLeft.add(bottomRight.sub(topLeft).div(new Point(2, 2))); } -function getBoxCenter(box: Box): Point { - return getBoxCenterPt(box.topLeft, box.bottomRight); -} - export function enlargeBox(box: Box, factor: number = 1.5) { - const center = getBoxCenter(box); + const center = getBoxCenterPt(box.topLeft, box.bottomRight); const size = new Point(box.width, box.height); const newHalfSize = new Point((factor * size.x) / 2, (factor * size.y) / 2);