diff --git a/web/src/pages/FaceLibrary.tsx b/web/src/pages/FaceLibrary.tsx index c062066a4..cf3929de9 100644 --- a/web/src/pages/FaceLibrary.tsx +++ b/web/src/pages/FaceLibrary.tsx @@ -876,6 +876,7 @@ function FaceAttempt({ onRefresh, }: FaceAttemptProps) { const { t } = useTranslation(["views/faceLibrary"]); + const [imageLoaded, setImageLoaded] = useState(false); const scoreStatus = useMemo(() => { if (data.score >= recognitionConfig.recognition_threshold) { @@ -896,14 +897,12 @@ function FaceAttempt({ }); const imageArea = useMemo(() => { - if (!imgRef.current) { + if (imgRef.current == null || !imageLoaded) { return undefined; } return imgRef.current.naturalWidth * imgRef.current.naturalHeight; - // only refresh when severity changes - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [imgRef.current]); + }, [imageLoaded]); // api calls @@ -966,9 +965,10 @@ function FaceAttempt({ : "outline-transparent duration-500", )} > -
+
setImageLoaded(true)} className={cn("size-44", isMobile && "w-full")} src={`${baseUrl}clips/faces/train/${data.filename}`} onClick={(e) => {