Skip to content

armgit / ente

Public Imported from GitHub
0

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

SearchPerson => Person

Manav Rathi816d74a5e6e8
diff --git a/web/packages/new/photos/components/PeopleList.tsx b/web/packages/new/photos/components/PeopleList.tsx
index 7c42d157dd..6de6dadd1b 100644
--- a/web/packages/new/photos/components/PeopleList.tsx
+++ b/web/packages/new/photos/components/PeopleList.tsx
@@ -1,14 +1,14 @@
+import type { Person } from "@/new/photos/services/ml";
import { faceCrop, unidentifiedFaceIDs } from "@/new/photos/services/ml";
import type { EnteFile } from "@/new/photos/types/file";
import { Skeleton, Typography, styled } from "@mui/material";
import { t } from "i18next";
import React, { useEffect, useState } from "react";
-import type { SearchPerson } from "../services/search/types";
export interface PeopleListProps {
- people: SearchPerson[];
+ people: Person[];
maxRows: number;
- onSelect?: (person: SearchPerson, index: number) => void;
+ onSelect?: (person: Person, index: number) => void;
}
export const PeopleList: React.FC<PeopleListProps> = ({
@@ -60,7 +60,7 @@ const FaceChip = styled("div")<{ clickable?: boolean }>`
export interface PhotoPeopleListProps {
file: EnteFile;
- onSelect?: (person: SearchPerson, index: number) => void;
+ onSelect?: (person: Person, index: number) => void;
}
export function PhotoPeopleList() {
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 80ed1fb432..cfbd6e15d4 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -396,7 +396,7 @@ const EmptyState: React.FC<EmptyStateProps> = () => {
// const peopleSuggestions = options.filter(
// (o) => o.type === SuggestionType.PERSON,
// );
- // const people = peopleSuggestions.map((o) => o.value as SearchPerson);
+ // const people = peopleSuggestions.map((o) => o.value as Person);
// return (
// <SelectComponents.Menu {...props}>
// <Box my={1}>
@@ -457,7 +457,7 @@ export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
}
async function getAllPeople(limit: number = undefined) {
- return (await wipSearchPersons()).slice(0, limit);
+ return (await wipPersons()).slice(0, limit);
// TODO-Clustetr
// if (done) return [];
@@ -468,7 +468,7 @@ async function getAllPeople(limit: number = undefined) {
// log.debug(() => ["people", { people }]);
// }
- // let people: Array<SearchPerson> = []; // await mlIDbStorage.getAllPeople();
+ // let people: Array<Person> = []; // await mlIDbStorage.getAllPeople();
// people = await wipCluster();
// // await mlPeopleStore.iterate<Person, void>((person) => {
// // people.push(person);
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index c5c326120c..673803a6dd 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -17,7 +17,7 @@ import { throttled } from "@/utils/promise";
import { proxy, transfer } from "comlink";
import { isInternalUser } from "../feature-flags";
import { getRemoteFlag, updateRemoteFlag } from "../remote-store";
-import type { SearchPerson } from "../search/types";
+import type { Person } from "../search/types";
import type { UploadItem } from "../upload/types";
import {
type ClusterFace,
@@ -329,7 +329,7 @@ export const wipClusterEnable = async (): Promise<boolean> =>
// // TODO-Cluster temporary state here
let _wip_isClustering = false;
-let _wip_searchPersons: SearchPerson[] | undefined;
+let _wip_Persons: Person[] | undefined;
let _wip_hasSwitchedOnce = false;
export const wipHasSwitchedOnceCmpAndSet = () => {
@@ -338,9 +338,9 @@ export const wipHasSwitchedOnceCmpAndSet = () => {
return false;
};
-export const wipSearchPersons = async () => {
+export const wipPersons = async () => {
if (!(await wipClusterEnable())) return [];
- return _wip_searchPersons ?? [];
+ return _wip_Persons ?? [];
};
export interface ClusterPreviewWithFile {
@@ -374,7 +374,7 @@ export const wipClusterDebugPageContents = async (
log.info("clustering", opts);
_wip_isClustering = true;
- _wip_searchPersons = undefined;
+ _wip_Persons = undefined;
triggerStatusUpdate();
const {
@@ -407,7 +407,7 @@ export const wipClusterDebugPageContents = async (
const clusterByID = new Map(clusters.map((c) => [c.id, c]));
- const searchPersons = cgroups
+ const Persons = cgroups
.map((cgroup) => {
const faceID = ensure(cgroup.displayFaceID);
const fileID = ensure(fileIDFromFaceID(faceID));
@@ -432,7 +432,7 @@ export const wipClusterDebugPageContents = async (
.sort((a, b) => b.faceIDs.length - a.faceIDs.length);
_wip_isClustering = false;
- _wip_searchPersons = searchPersons;
+ _wip_Persons = Persons;
triggerStatusUpdate();
return {
@@ -581,6 +581,39 @@ const setInterimScheduledStatus = () => {
const workerDidProcessFileOrIdle = throttled(updateMLStatusSnapshot, 2000);
+/**
+ * A massaged version of {@link CGroup} suitable for being shown in the UI.
+ *
+ * While cgroups are synced with remote, they do not directly correspond to
+ * "people" (this is ignoring the other issue that the cluster groups may be for
+ * non-human faces too). CGroups represent both positive and negative feedback,
+ * and the negations are specifically meant so that they're not shown in the UI.
+ *
+ * So while each Person has an underlying cgroups, not all cgroups have a
+ * corresponding Person.
+ *
+ * Beyond this, a {@link Person} object has data converted into a format that
+ * the UI can use directly and efficiently (as compared to a {@link CGroup},
+ * which is tailored for transmission and storage).
+ */
+export interface Person {
+ /** Unique ID (nanoid) of the underlying {@link CGroup}. */
+ id: string;
+ /** If this is a named person, then their name. */
+ name?: string;
+ /** The files in which this face occurs. */
+ files: number[];
+ /**
+ * The face that should be used as the "cover" face to represent this {@link
+ * Person} in the UI.
+ */
+ displayFaceID: string;
+ /**
+ * The {@link EnteFile} which contains the display face.
+ */
+ displayFaceFile: EnteFile;
+}
+
/**
* Use CLIP to perform a natural language search over image embeddings.
*
diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.ts
index c386684d85..c22e462282 100644
--- a/web/packages/new/photos/services/search/types.ts
+++ b/web/packages/new/photos/services/search/types.ts
@@ -6,6 +6,7 @@
import type { Location } from "@/base/types";
import type { Collection } from "@/media/collection";
import { FileType } from "@/media/file-type";
+import type { Person } from "@/new/photos/services/ml";
import type { EnteFile } from "@/new/photos/types/file";
import type { LocationTag } from "../user-entity";
@@ -24,7 +25,7 @@ export type SearchSuggestion = { label: string } & (
| { type: "location"; locationTag: LocationTag }
| { type: "city"; city: City }
| { type: "clip"; clipScoreForFileID: Map<number, number> }
- | { type: "cgroup"; cgroup: SearchPerson }
+ | { type: "person"; person: Person }
);
/**
@@ -117,18 +118,6 @@ export interface SearchDateComponents {
hour?: number;
}
-/**
- * A massaged version of {@link CGroup} suitable for being shown in search
- * results.
- */
-export interface SearchPerson {
- id: string;
- name?: string;
- files: number[];
- displayFaceID: string;
- displayFaceFile: EnteFile;
-}
-
/**
* A city as identified by a static dataset.
*