From 657f27822c210c7d03a55426a2af791c1491e9db Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 30 Aug 2024 15:21:28 +0530 Subject: [PATCH] form 1 --- web/apps/photos/src/pages/cluster-debug.tsx | 39 ++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/web/apps/photos/src/pages/cluster-debug.tsx b/web/apps/photos/src/pages/cluster-debug.tsx index d1ab0342b0..6f6e9d4c23 100644 --- a/web/apps/photos/src/pages/cluster-debug.tsx +++ b/web/apps/photos/src/pages/cluster-debug.tsx @@ -6,6 +6,7 @@ import { type ClusterPreviewFaceWF, } from "@/new/photos/services/ml"; import { faceDirection } from "@/new/photos/services/ml/face"; +import { wait } from "@/utils/promise"; import { FlexWrapper, FluidContainer, @@ -14,6 +15,7 @@ import { import EnteSpinner from "@ente/shared/components/EnteSpinner"; import BackButton from "@mui/icons-material/ArrowBackOutlined"; import { Box, IconButton, Stack, styled, Typography } from "@mui/material"; +import { useFormik } from "formik"; import { useRouter } from "next/router"; import { AppContext } from "pages/_app"; import React, { useContext, useEffect, useMemo, useRef, useState } from "react"; @@ -76,6 +78,12 @@ interface ClusterListProps { width: number; } +interface ClusteringOpts { + method: "hdbscan"; + batchSize: number; + joinThreshold: number; +} + const ClusterList: React.FC = ({ height, width }) => { const { startLoading, finishLoading } = useContext(AppContext); @@ -86,9 +94,11 @@ const ClusterList: React.FC = ({ height, width }) => { const listRef = useRef(null); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const cluster = async () => { + const cluster = async (opts: ClusteringOpts) => { startLoading(); // setClusterRes(await wipClusterDebugPageContents()); + console.log(opts); + await wait(5000); setClusterRes({ clusteredCount: 1, unclusteredCount: 2, @@ -139,7 +149,10 @@ const ClusterList: React.FC = ({ height, width }) => { if (index === 0) return (
-
+
void cluster(opts)} + />
); @@ -230,12 +243,26 @@ const ListItem = styled("div")` interface HeaderProps { clusterRes: ClusterDebugPageContents | undefined; + onCluster: (opts: ClusteringOpts) => void; } -const Header: React.FC = ({ clusterRes }) => { - if (!clusterRes) return ; - return ( +const Header: React.FC = ({ clusterRes, onCluster }) => { + const formik = useFormik({ + initialValues: { + method: "hdbscan", + batchSize: 2500, + joinThreshold: 0.7, + }, + onSubmit: onCluster, + }); + + const clusterInfo = !clusterRes ? ( + + ) : ( +
+ +
{`${clusterRes.clusters.length} clusters from ${clusterRes.clusteredCount} faces. ${clusterRes.unclusteredCount} unclustered faces.`} @@ -252,6 +279,8 @@ const Header: React.FC = ({ clusterRes }) => {
); + + return
{clusterInfo}
; }; const Loader = () => (