Skip to content

armgit / ente

Public Imported from GitHub
0

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

Show blur

Manav Rathi2d50da84c868
diff --git a/web/apps/photos/src/pages/cluster-debug.tsx b/web/apps/photos/src/pages/cluster-debug.tsx
index ad2a16fb96..9655976a21 100644
--- a/web/apps/photos/src/pages/cluster-debug.tsx
+++ b/web/apps/photos/src/pages/cluster-debug.tsx
@@ -7,6 +7,7 @@ import {
type FaceFileNeighbour,
type FaceFileNeighbours,
} from "@/new/photos/services/ml";
+import type { Face } from "@/new/photos/services/ml/face";
import {
FlexWrapper,
FluidContainer,
@@ -123,12 +124,12 @@ const ClusterPhotoList: React.FC<ClusterPhotoListProps> = ({
}, [itemList]);
const getItemSize = (i: number) =>
- typeof itemList[i] == "number" ? 36 : listItemHeight;
+ Array.isArray(itemList[i]) ? listItemHeight : 36;
const generateKey = (i: number) =>
- typeof itemList[i] == "number"
- ? `${itemList[i]}-${i}`
- : `${itemList[i][0].enteFile.id}/${itemList[i][0].face.faceID}-${itemList[i].slice(-1)[0].enteFile.id}/${itemList[i].slice(-1)[0].face.faceID}-${i}`;
+ Array.isArray(itemList[i])
+ ? `${itemList[i][0].enteFile.id}/${itemList[i][0].face.faceID}-${itemList[i].slice(-1)[0].enteFile.id}/${itemList[i].slice(-1)[0].face.faceID}-${i}`
+ : `${itemList[i].faceID}-${i}`;
return (
<VariableSizeList
@@ -151,9 +152,9 @@ const ClusterPhotoList: React.FC<ClusterPhotoListProps> = ({
columns={columns}
shrinkRatio={shrinkRatio}
>
- {typeof item == "number" ? (
+ {!Array.isArray(item) ? (
<LabelContainer span={columns}>
- {`score ${item.toFixed(2)}`}
+ {`score ${item.score.toFixed(2)} blur ${item.blur.toFixed(0)}`}
</LabelContainer>
) : (
item.map((faceFN, i) => (
@@ -171,7 +172,7 @@ const ClusterPhotoList: React.FC<ClusterPhotoListProps> = ({
);
};
-type ItemListItem = number | FaceFileNeighbour[];
+type ItemListItem = Face | FaceFileNeighbour[];
const itemListFromFaceFNs = (
faceFNs: FaceFileNeighbours[],
@@ -180,7 +181,7 @@ const itemListFromFaceFNs = (
const result: ItemListItem[] = [];
for (let index = 0; index < faceFNs.length; index++) {
const { face, neighbours } = faceFNs[index];
- result.push(face.score);
+ result.push(face);
let lastIndex = 0;
while (lastIndex < neighbours.length) {
result.push(neighbours.slice(lastIndex, lastIndex + columns));
diff --git a/web/packages/new/photos/services/ml/cluster-new.ts b/web/packages/new/photos/services/ml/cluster-new.ts
index e67688abc0..4cec15a86e 100644
--- a/web/packages/new/photos/services/ml/cluster-new.ts
+++ b/web/packages/new/photos/services/ml/cluster-new.ts
@@ -201,7 +201,7 @@ export const clusterFaces = async (faceIndexes: FaceIndex[]) => {
for (let j = 0; j < faces.length; j++) {
// ! This is an O(n^2) loop, be careful when adding more code here.
- // TODO-Cluster
+ // TODO-Cluster Commenting this here and moving it downward
// // Skip ourselves.
// if (i == j) continue;
@@ -213,6 +213,7 @@ export const clusterFaces = async (faceIndexes: FaceIndex[]) => {
// dot product as their cosine similarity.
const csim = dotProduct(embedding, n.embedding);
+ // TODO-Cluster Delete me and uncomment the check above
// Skip ourselves.
if (i == j) {
neighbours.push({ face: n, cosineSimilarity: csim });