π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove class
Manav Rathi24c33fceb74e
diff --git a/web/apps/photos/src/services/machineLearning/faceService.ts b/web/apps/photos/src/services/machineLearning/faceService.tsindex c7802a08ce..1f37ef536f 100644--- a/web/apps/photos/src/services/machineLearning/faceService.ts+++ b/web/apps/photos/src/services/machineLearning/faceService.ts@@ -10,8 +10,9 @@ import {type Versioned,} from "services/ml/types";import { imageBitmapToBlob, warpAffineFloat32List } from "utils/image";-import ReaderService, {+import {fetchImageBitmap,+ fetchImageBitmapForContext,getFaceId,getLocalFile,} from "./readerService";@@ -43,7 +44,7 @@ class FaceService {newMlFile.faceDetectionMethod = syncContext.faceDetectionService.method;fileContext.newDetection = true;- const imageBitmap = await ReaderService.getImageBitmap(fileContext);+ const imageBitmap = await fetchImageBitmapForContext(fileContext);const timerId = `faceDetection-${fileContext.enteFile.id}`;console.time(timerId);const faceDetections =@@ -89,7 +90,7 @@ class FaceService {return;}- const imageBitmap = await ReaderService.getImageBitmap(fileContext);+ const imageBitmap = await fetchImageBitmapForContext(fileContext);newMlFile.faceCropMethod = syncContext.faceCropService.method;for (const face of newMlFile.faces) {@@ -121,7 +122,7 @@ class FaceService {fileContext.newAlignment = true;const imageBitmap =fileContext.imageBitmap ||- (await ReaderService.getImageBitmap(fileContext));+ (await fetchImageBitmapForContext(fileContext));// Execute the face alignment calculationsfor (const face of newMlFile.faces) {diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.tsindex 94fae01d2a..27fa669f68 100644--- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts+++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts@@ -45,7 +45,8 @@ import hdbscanClusteringService from "./hdbscanClusteringService";import laplacianBlurDetectionService from "./laplacianBlurDetectionService";import mobileFaceNetEmbeddingService from "./mobileFaceNetEmbeddingService";import PeopleService from "./peopleService";-import ReaderService from "./readerService";++import { fetchImageBitmapForContext } from "./readerService";import yoloFaceDetectionService from "./yoloFaceDetectionService";/**@@ -581,7 +582,7 @@ class MachineLearningService {}try {- await ReaderService.getImageBitmap(fileContext);+ await fetchImageBitmapForContext(fileContext);await Promise.all([this.syncFileAnalyzeFaces(syncContext, fileContext),]);diff --git a/web/apps/photos/src/services/machineLearning/readerService.ts b/web/apps/photos/src/services/machineLearning/readerService.tsindex 9d957d70ef..3e82a9dac7 100644--- a/web/apps/photos/src/services/machineLearning/readerService.ts+++ b/web/apps/photos/src/services/machineLearning/readerService.ts@@ -9,52 +9,40 @@ import { EnteFile } from "types/file";import { getRenderableImage } from "utils/file";import { clamp } from "utils/image";-class ReaderService {- async getImageBitmap(fileContext: MLSyncFileContext) {- try {- if (fileContext.imageBitmap) {- return fileContext.imageBitmap;- }- if (fileContext.localFile) {- if (- fileContext.enteFile.metadata.fileType !== FILE_TYPE.IMAGE- ) {- throw new Error(- "Local file of only image type is supported",- );- }- fileContext.imageBitmap = await getLocalFileImageBitmap(- fileContext.enteFile,- fileContext.localFile,- );- } else if (- [FILE_TYPE.IMAGE, FILE_TYPE.LIVE_PHOTO].includes(- fileContext.enteFile.metadata.fileType,- )- ) {- fileContext.imageBitmap = await fetchImageBitmap(- fileContext.enteFile,- );- } else {- // TODO-ML(MR): We don't do it on videos, when will we ever come- // here?- fileContext.imageBitmap = await getThumbnailImageBitmap(- fileContext.enteFile,- );- }-- fileContext.newMlFile.imageSource = "Original";- const { width, height } = fileContext.imageBitmap;- fileContext.newMlFile.imageDimensions = { width, height };-- return fileContext.imageBitmap;- } catch (e) {- log.error("failed to create image bitmap", e);- throw e;+export const fetchImageBitmapForContext = async (+ fileContext: MLSyncFileContext,+) => {+ if (fileContext.imageBitmap) {+ return fileContext.imageBitmap;+ }+ if (fileContext.localFile) {+ if (fileContext.enteFile.metadata.fileType !== FILE_TYPE.IMAGE) {+ throw new Error("Local file of only image type is supported");}+ fileContext.imageBitmap = await getLocalFileImageBitmap(+ fileContext.enteFile,+ fileContext.localFile,+ );+ } else if (+ [FILE_TYPE.IMAGE, FILE_TYPE.LIVE_PHOTO].includes(+ fileContext.enteFile.metadata.fileType,+ )+ ) {+ fileContext.imageBitmap = await fetchImageBitmap(fileContext.enteFile);+ } else {+ // TODO-ML(MR): We don't do it on videos, when will we ever come+ // here?+ fileContext.imageBitmap = await getThumbnailImageBitmap(+ fileContext.enteFile,+ );}-}-export default new ReaderService();++ fileContext.newMlFile.imageSource = "Original";+ const { width, height } = fileContext.imageBitmap;+ fileContext.newMlFile.imageDimensions = { width, height };++ return fileContext.imageBitmap;+};export async function getLocalFile(fileId: number) {const localFiles = await getLocalFiles();