Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Move

Manav Rathib97988e04a60
diff --git a/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts b/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts
index 65d33bb215..77ec03b6b2 100644
--- a/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts
+++ b/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts
@@ -10,7 +10,7 @@ import {
} from "services/ml/types";
import { cropWithRotation } from "utils/image";
import { getArcfaceAlignment } from "utils/machineLearning/faceAlign";
-import { enlargeBox } from "utils/machineLearning/index";
+import { enlargeBox } from "services/ml/geom";
class ArcFaceCropService implements FaceCropService {
public method: Versioned<FaceCropMethod>;
diff --git a/web/apps/photos/src/services/ml/geom.ts b/web/apps/photos/src/services/ml/geom.ts
index 1cf51963cf..556e2b309d 100644
--- a/web/apps/photos/src/services/ml/geom.ts
+++ b/web/apps/photos/src/services/ml/geom.ts
@@ -76,3 +76,17 @@ export class Box implements IRect {
return new Box({ x, y, width, height });
}
}
+
+export function enlargeBox(box: Box, factor: number = 1.5) {
+ const center = new Point(box.x + box.width / 2, box.y + box.height / 2);
+
+ const size = new Point(box.width, box.height);
+ const newHalfSize = new Point((factor * size.x) / 2, (factor * size.y) / 2);
+
+ return boxFromBoundingBox({
+ left: center.x - newHalfSize.x,
+ top: center.y - newHalfSize.y,
+ right: center.x + newHalfSize.x,
+ bottom: center.y + newHalfSize.y,
+ });
+}
diff --git a/web/apps/photos/src/utils/image/index.ts b/web/apps/photos/src/utils/image/index.ts
index 39263ab308..bdaf64d735 100644
--- a/web/apps/photos/src/utils/image/index.ts
+++ b/web/apps/photos/src/utils/image/index.ts
@@ -1,9 +1,8 @@
// these utils only work in env where OffscreenCanvas is available
import { Matrix, inverse } from "ml-matrix";
-import { Box, Dimensions } from "services/ml/geom";
+import { Box, Dimensions, enlargeBox } from "services/ml/geom";
import { FaceAlignment } from "services/ml/types";
-import { enlargeBox } from "utils/machineLearning";
export function normalizePixelBetween0And1(pixelValue: number) {
return pixelValue / 255.0;
diff --git a/web/apps/photos/src/utils/machineLearning/index.ts b/web/apps/photos/src/utils/machineLearning/index.ts
index 987eabc00e..1891a18719 100644
--- a/web/apps/photos/src/utils/machineLearning/index.ts
+++ b/web/apps/photos/src/utils/machineLearning/index.ts
@@ -4,7 +4,7 @@ import log from "@/next/log";
import PQueue from "p-queue";
import DownloadManager from "services/download";
import { getLocalFiles } from "services/fileService";
-import { Box, Dimensions, Point, boxFromBoundingBox } from "services/ml/geom";
+import { Dimensions } from "services/ml/geom";
import {
DetectedFace,
Face,
@@ -18,20 +18,6 @@ import { getRenderableImage } from "utils/file";
import { clamp, warpAffineFloat32List } from "utils/image";
import mlIDbStorage from "utils/storage/mlIDbStorage";
-export function enlargeBox(box: Box, factor: number = 1.5) {
- const center = new Point(box.x + box.width / 2, box.y + box.height / 2);
-
- const size = new Point(box.width, box.height);
- const newHalfSize = new Point((factor * size.x) / 2, (factor * size.y) / 2);
-
- return boxFromBoundingBox({
- left: center.x - newHalfSize.x,
- top: center.y - newHalfSize.y,
- right: center.x + newHalfSize.x,
- bottom: center.y + newHalfSize.y,
- });
-}
-
export function getAllFacesFromMap(allFacesMap: Map<number, Array<Face>>) {
const allFaces = [...allFacesMap.values()].flat();