diff --git a/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts b/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts index 2075d6acf..049fa5258 100644 --- a/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts +++ b/web/apps/photos/src/services/machineLearning/arcfaceCropService.ts @@ -2,7 +2,6 @@ import { Box, enlargeBox } from "services/ml/geom"; import { FaceAlignment, FaceCrop, - FaceCropConfig, FaceCropMethod, FaceCropService, FaceDetection, @@ -24,10 +23,9 @@ class ArcFaceCropService implements FaceCropService { public async getFaceCrop( imageBitmap: ImageBitmap, faceDetection: FaceDetection, - config: FaceCropConfig, ): Promise { const alignedFace = getArcfaceAlignment(faceDetection); - const faceCrop = getFaceCrop(imageBitmap, alignedFace, config); + const faceCrop = getFaceCrop(imageBitmap, alignedFace); return faceCrop; } @@ -38,19 +36,21 @@ export default new ArcFaceCropService(); export function getFaceCrop( imageBitmap: ImageBitmap, alignment: FaceAlignment, - config: FaceCropConfig, ): FaceCrop { + const padding = 0.25; + const maxSize = 256; + const alignmentBox = new Box({ x: alignment.center.x - alignment.size / 2, y: alignment.center.y - alignment.size / 2, width: alignment.size, height: alignment.size, }).round(); - const scaleForPadding = 1 + config.padding * 2; + const scaleForPadding = 1 + padding * 2; const paddedBox = enlargeBox(alignmentBox, scaleForPadding).round(); const faceImageBitmap = cropWithRotation(imageBitmap, paddedBox, 0, { - width: config.maxSize, - height: config.maxSize, + width: maxSize, + height: maxSize, }); return { diff --git a/web/apps/photos/src/services/machineLearning/faceService.ts b/web/apps/photos/src/services/machineLearning/faceService.ts index 93e2c0a0a..b6a7da097 100644 --- a/web/apps/photos/src/services/machineLearning/faceService.ts +++ b/web/apps/photos/src/services/machineLearning/faceService.ts @@ -218,7 +218,6 @@ class FaceService { const faceCrop = await syncContext.faceCropService.getFaceCrop( imageBitmap, face.detection, - DEFAULT_ML_SYNC_CONFIG.faceCrop, ); const blobOptions = DEFAULT_ML_SYNC_CONFIG.faceCrop.blobOptions; diff --git a/web/apps/photos/src/services/ml/types.ts b/web/apps/photos/src/services/ml/types.ts index f7382d3da..a5e97098c 100644 --- a/web/apps/photos/src/services/ml/types.ts +++ b/web/apps/photos/src/services/ml/types.ts @@ -271,7 +271,6 @@ export interface FaceCropService { getFaceCrop( imageBitmap: ImageBitmap, face: FaceDetection, - config: FaceCropConfig, ): Promise; }