Inline
This commit is contained in:
parent
77bacc518c
commit
b75977186f
3 changed files with 59 additions and 70 deletions
|
@ -3,9 +3,9 @@ import { Skeleton, styled } from "@mui/material";
|
|||
import { Legend } from "components/PhotoViewer/styledComponents/Legend";
|
||||
import { t } from "i18next";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Face, Person } from "services/ml/types";
|
||||
import { Face, Person, type MlFileData } from "services/ml/types";
|
||||
import { EnteFile } from "types/file";
|
||||
import { getPeopleList, getUnidentifiedFaces } from "utils/machineLearning";
|
||||
import mlIDbStorage from "utils/storage/mlIDbStorage";
|
||||
|
||||
const FaceChipContainer = styled("div")`
|
||||
display: flex;
|
||||
|
@ -194,3 +194,45 @@ const FaceCropImageView: React.FC<FaceCropImageViewProps> = ({
|
|||
<Skeleton variant="circular" height={120} width={120} />
|
||||
);
|
||||
};
|
||||
|
||||
async function getPeopleList(file: EnteFile): Promise<Array<Person>> {
|
||||
let startTime = Date.now();
|
||||
const mlFileData: MlFileData = await mlIDbStorage.getFile(file.id);
|
||||
log.info(
|
||||
"getPeopleList:mlFilesStore:getItem",
|
||||
Date.now() - startTime,
|
||||
"ms",
|
||||
);
|
||||
if (!mlFileData?.faces || mlFileData.faces.length < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const peopleIds = mlFileData.faces
|
||||
.filter((f) => f.personId !== null && f.personId !== undefined)
|
||||
.map((f) => f.personId);
|
||||
if (!peopleIds || peopleIds.length < 1) {
|
||||
return [];
|
||||
}
|
||||
// log.info("peopleIds: ", peopleIds);
|
||||
startTime = Date.now();
|
||||
const peoplePromises = peopleIds.map(
|
||||
(p) => mlIDbStorage.getPerson(p) as Promise<Person>,
|
||||
);
|
||||
const peopleList = await Promise.all(peoplePromises);
|
||||
log.info(
|
||||
"getPeopleList:mlPeopleStore:getItems",
|
||||
Date.now() - startTime,
|
||||
"ms",
|
||||
);
|
||||
// log.info("peopleList: ", peopleList);
|
||||
|
||||
return peopleList;
|
||||
}
|
||||
|
||||
async function getUnidentifiedFaces(file: EnteFile): Promise<Array<Face>> {
|
||||
const mlFileData: MlFileData = await mlIDbStorage.getFile(file.id);
|
||||
|
||||
return mlFileData?.faces?.filter(
|
||||
(f) => f.personId === null || f.personId === undefined,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { FILE_TYPE } from "@/media/file-type";
|
|||
import log from "@/next/log";
|
||||
import * as chrono from "chrono-node";
|
||||
import { t } from "i18next";
|
||||
import { getMLSyncConfig } from "services/machineLearning/machineLearningService";
|
||||
import { Person } from "services/ml/types";
|
||||
import { Collection } from "types/collection";
|
||||
import { EntityType, LocationTag, LocationTagData } from "types/entity";
|
||||
|
@ -16,8 +17,6 @@ import {
|
|||
} from "types/search";
|
||||
import ComlinkSearchWorker from "utils/comlink/ComlinkSearchWorker";
|
||||
import { getUniqueFiles } from "utils/file";
|
||||
import { getAllPeople } from "utils/machineLearning";
|
||||
import { getMLSyncConfig } from "services/machineLearning/machineLearningService";
|
||||
import { getFormattedDate } from "utils/search";
|
||||
import mlIDbStorage from "utils/storage/mlIDbStorage";
|
||||
import { clipService, computeClipMatchScore } from "./clip-service";
|
||||
|
@ -430,3 +429,14 @@ function convertSuggestionToSearchQuery(option: Suggestion): Search {
|
|||
return { clip: option.value as ClipSearchScores };
|
||||
}
|
||||
}
|
||||
|
||||
async function getAllPeople(limit: number = undefined) {
|
||||
let people: Array<Person> = await mlIDbStorage.getAllPeople();
|
||||
// await mlPeopleStore.iterate<Person, void>((person) => {
|
||||
// people.push(person);
|
||||
// });
|
||||
people = people ?? [];
|
||||
return people
|
||||
.sort((p1, p2) => p2.files.length - p1.files.length)
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
|
|
@ -5,18 +5,10 @@ import PQueue from "p-queue";
|
|||
import DownloadManager from "services/download";
|
||||
import { getLocalFiles } from "services/fileService";
|
||||
import { Dimensions } from "services/ml/geom";
|
||||
import {
|
||||
DetectedFace,
|
||||
Face,
|
||||
FaceAlignment,
|
||||
MlFileData,
|
||||
Person,
|
||||
} from "services/ml/types";
|
||||
import { DetectedFace } from "services/ml/types";
|
||||
import { EnteFile } from "types/file";
|
||||
import { getRenderableImage } from "utils/file";
|
||||
import { clamp, warpAffineFloat32List } from "utils/image";
|
||||
import mlIDbStorage from "utils/storage/mlIDbStorage";
|
||||
|
||||
import { clamp } from "utils/image";
|
||||
|
||||
export async function getLocalFile(fileId: number) {
|
||||
const localFiles = await getLocalFiles();
|
||||
|
@ -61,7 +53,7 @@ export function getFaceId(detectedFace: DetectedFace, imageDims: Dimensions) {
|
|||
return faceID;
|
||||
}
|
||||
|
||||
export async function getImageBlobBitmap(blob: Blob): Promise<ImageBitmap> {
|
||||
async function getImageBlobBitmap(blob: Blob): Promise<ImageBitmap> {
|
||||
return await createImageBitmap(blob);
|
||||
}
|
||||
|
||||
|
@ -109,58 +101,3 @@ export async function getLocalFileImageBitmap(
|
|||
fileBlob = await getRenderableImage(enteFile.metadata.title, fileBlob);
|
||||
return getImageBlobBitmap(fileBlob);
|
||||
}
|
||||
|
||||
export async function getPeopleList(file: EnteFile): Promise<Array<Person>> {
|
||||
let startTime = Date.now();
|
||||
const mlFileData: MlFileData = await mlIDbStorage.getFile(file.id);
|
||||
log.info(
|
||||
"getPeopleList:mlFilesStore:getItem",
|
||||
Date.now() - startTime,
|
||||
"ms",
|
||||
);
|
||||
if (!mlFileData?.faces || mlFileData.faces.length < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const peopleIds = mlFileData.faces
|
||||
.filter((f) => f.personId !== null && f.personId !== undefined)
|
||||
.map((f) => f.personId);
|
||||
if (!peopleIds || peopleIds.length < 1) {
|
||||
return [];
|
||||
}
|
||||
// log.info("peopleIds: ", peopleIds);
|
||||
startTime = Date.now();
|
||||
const peoplePromises = peopleIds.map(
|
||||
(p) => mlIDbStorage.getPerson(p) as Promise<Person>,
|
||||
);
|
||||
const peopleList = await Promise.all(peoplePromises);
|
||||
log.info(
|
||||
"getPeopleList:mlPeopleStore:getItems",
|
||||
Date.now() - startTime,
|
||||
"ms",
|
||||
);
|
||||
// log.info("peopleList: ", peopleList);
|
||||
|
||||
return peopleList;
|
||||
}
|
||||
|
||||
export async function getUnidentifiedFaces(
|
||||
file: EnteFile,
|
||||
): Promise<Array<Face>> {
|
||||
const mlFileData: MlFileData = await mlIDbStorage.getFile(file.id);
|
||||
|
||||
return mlFileData?.faces?.filter(
|
||||
(f) => f.personId === null || f.personId === undefined,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getAllPeople(limit: number = undefined) {
|
||||
let people: Array<Person> = await mlIDbStorage.getAllPeople();
|
||||
// await mlPeopleStore.iterate<Person, void>((person) => {
|
||||
// people.push(person);
|
||||
// });
|
||||
people = people ?? [];
|
||||
return people
|
||||
.sort((p1, p2) => p2.files.length - p1.files.length)
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue