From 1ce2b4c81ef5b5b311747a93bab7472de514175b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pinard?= Date: Thu, 16 Mar 2023 23:20:11 +0100 Subject: [PATCH 1/2] Add _ImageEvaluationResult * Add additional typeddict for self.eval which is NOT the same as self.evalImgs elements * Correct Params.areaRng which is in fact a list of pairs --- stubs/pycocotools/pycocotools/cocoeval.pyi | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index d9845c6cb712..bbfef431e927 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -10,7 +10,7 @@ from .coco import COCO _NDArray: TypeAlias = Incomplete _TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"] -class _EvaluationResult(TypedDict): +class _ImageEvaluationResult(TypedDict): image_id: int category_id: int aRng: list[int] @@ -27,10 +27,21 @@ class _EvaluationResult(TypedDict): dtIgnore: _NDArray # dtIgnore: npt.NDArray[np.float64] +class _EvaluationResult(TypedDict): + params: Params + counts: list[int] + date: str + # precision: npt.NDArray[np.float64] + precision: _NDArray + # recall: npt.NDArray[np.float64] + recall: _NDArray + # scores: npt.NDArray[np.float64] + scores: _NDArray + class COCOeval: cocoGt: COCO cocoDt: COCO - evalImgs: list[_EvaluationResult] + evalImgs: list[_ImageEvaluationResult] eval: _EvaluationResult params: Params stats: _NDArray @@ -53,7 +64,7 @@ class Params: recThrs: _NDArray # recThrs: npt.NDArray[np.float64] maxDets: list[int] - areaRng: list[int] + areaRng: list[list[int | float]] areaRngLbl: list[str] useCats: int kpt_oks_sigmas: _NDArray From 02c4b69ffbe2c692a02a08f017ce076fd99bc457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pinard?= Date: Fri, 17 Mar 2023 13:52:15 +0100 Subject: [PATCH 2/2] Use proper return type + use only float --- stubs/pycocotools/pycocotools/cocoeval.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index bbfef431e927..1fd74e517f4c 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -52,7 +52,7 @@ class COCOeval: def computeIoU(self, imgId: int, catId: int) -> list[float]: ... def computeOks(self, imgId: int, catId: int) -> _NDArray: ... # def computeOks(self, imgId: int, catId: int) -> npt.NDArray[np.float64]: ... - def evaluateImg(self, imgId: int, catId: int, aRng: list[int], maxDet: int) -> _EvaluationResult: ... + def evaluateImg(self, imgId: int, catId: int, aRng: list[int], maxDet: int) -> _ImageEvaluationResult: ... def accumulate(self, p: Params | None = ...) -> None: ... def summarize(self) -> None: ... @@ -64,7 +64,7 @@ class Params: recThrs: _NDArray # recThrs: npt.NDArray[np.float64] maxDets: list[int] - areaRng: list[list[int | float]] + areaRng: list[list[float]] areaRngLbl: list[str] useCats: int kpt_oks_sigmas: _NDArray