Show direction

This commit is contained in:
Manav Rathi
2024-08-29 19:47:16 +05:30
parent 29b5830e19
commit c9acda1b6d
2 changed files with 13 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import {
type ClusterPreviewFaceWF,
type ClusterPreviewWF,
} from "@/new/photos/services/ml";
import { faceDirection } from "@/new/photos/services/ml/face";
import {
FlexWrapper,
FluidContainer,
@@ -236,6 +237,8 @@ const FaceItem: React.FC<FaceItemProps> = ({ faceWF, clusterIDForFaceID }) => {
};
}, [faceID, enteFile]);
const fd = faceDirection(face.detection);
const d = fd == "straight" ? "•" : fd == "left" ? "←" : "→";
return (
<FaceChip
style={{
@@ -255,13 +258,19 @@ const FaceItem: React.FC<FaceItemProps> = ({ faceWF, clusterIDForFaceID }) => {
)}
<Stack direction="row" justifyContent="space-between">
<Typography variant="small" color="text.muted">
{`b ${face.blur.toFixed(0)} b`}
{`b${face.blur.toFixed(0)} `}
</Typography>
<Typography variant="small" color="text.muted">
{`s ${face.score.toFixed(2)}`}
{`s${face.score.toFixed(1)}`}
</Typography>
<Typography variant="small" color="text.muted">
{`c ${cosineSimilarity.toFixed(2)}`}
{`c${cosineSimilarity.toFixed(1)}`}
</Typography>
<Typography variant="small" color="text.muted">
{`c${cosineSimilarity.toFixed(1)}`}
</Typography>
<Typography variant="small" color="text.muted">
{`d${d}`}
</Typography>
</Stack>
</FaceChip>

View File

@@ -714,7 +714,7 @@ const detectBlur = (
type FaceDirection = "left" | "right" | "straight";
const faceDirection = ({ landmarks }: FaceDetection): FaceDirection => {
export const faceDirection = ({ landmarks }: FaceDetection): FaceDirection => {
const leftEye = landmarks[0]!;
const rightEye = landmarks[1]!;
const nose = landmarks[2]!;