From c6054cf0b6649196dedf9fde3e742ee77bdc3ae0 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 13 Feb 2020 14:15:58 +0200 Subject: [PATCH 1/8] fixes according to the numpy update 1.18.1 --- PythonAPI/pycocotools/cocoeval.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PythonAPI/pycocotools/cocoeval.py b/PythonAPI/pycocotools/cocoeval.py index 7a4b4adc..b3a8806a 100644 --- a/PythonAPI/pycocotools/cocoeval.py +++ b/PythonAPI/pycocotools/cocoeval.py @@ -504,8 +504,8 @@ def setDetParams(self): self.imgIds = [] self.catIds = [] # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) + self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05) + 1), endpoint=True) + self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01) + 1), endpoint=True) self.maxDets = [1, 10, 100] self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'small', 'medium', 'large'] @@ -515,8 +515,8 @@ def setKpParams(self): self.imgIds = [] self.catIds = [] # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) + self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05) + 1), endpoint=True) + self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01) + 1), endpoint=True) self.maxDets = [20] self.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'medium', 'large'] @@ -531,4 +531,4 @@ def __init__(self, iouType='segm'): raise Exception('iouType not supported') self.iouType = iouType # useSegm is deprecated - self.useSegm = None \ No newline at end of file + self.useSegm = None From aeb8ca544a9e0ad610cbb76cf6d447724e496638 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 13 Feb 2020 21:12:05 +0200 Subject: [PATCH 2/8] moved setup.py to root to make easeier to install pycococtools --- PythonAPI/setup.py => setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename PythonAPI/setup.py => setup.py (86%) diff --git a/PythonAPI/setup.py b/setup.py similarity index 86% rename from PythonAPI/setup.py rename to setup.py index fb08efd9..2684641e 100644 --- a/PythonAPI/setup.py +++ b/setup.py @@ -11,8 +11,8 @@ ext_modules = [ Extension( 'pycocotools._mask', - sources=['../common/maskApi.c', 'pycocotools/_mask.pyx'], - include_dirs = [np.get_include(), '../common'], + sources=['common/maskApi.c', 'PythonAPI/pycocotools/_mask.pyx'], + include_dirs = [np.get_include(), 'common'], extra_compile_args=[] # originally was ['-Wno-cpp', '-Wno-unused-function', '-std=c99'], ) ] From 11a87dcde11fe556866f0882a4069810cc23d507 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 13 Feb 2020 21:20:13 +0200 Subject: [PATCH 3/8] Moved all to root directory --- PythonAPI/Makefile => Makefile | 0 {PythonAPI/demos => demos}/pycocoDemo.ipynb | 0 {PythonAPI/demos => demos}/pycocoEvalDemo.ipynb | 0 {PythonAPI/pycocotools => pycocotools}/__init__.py | 0 {PythonAPI/pycocotools => pycocotools}/_mask.pyx | 0 {PythonAPI/pycocotools => pycocotools}/coco.py | 0 {PythonAPI/pycocotools => pycocotools}/cocoeval.py | 0 {PythonAPI/pycocotools => pycocotools}/mask.py | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename PythonAPI/Makefile => Makefile (100%) rename {PythonAPI/demos => demos}/pycocoDemo.ipynb (100%) rename {PythonAPI/demos => demos}/pycocoEvalDemo.ipynb (100%) rename {PythonAPI/pycocotools => pycocotools}/__init__.py (100%) rename {PythonAPI/pycocotools => pycocotools}/_mask.pyx (100%) rename {PythonAPI/pycocotools => pycocotools}/coco.py (100%) rename {PythonAPI/pycocotools => pycocotools}/cocoeval.py (100%) rename {PythonAPI/pycocotools => pycocotools}/mask.py (100%) diff --git a/PythonAPI/Makefile b/Makefile similarity index 100% rename from PythonAPI/Makefile rename to Makefile diff --git a/PythonAPI/demos/pycocoDemo.ipynb b/demos/pycocoDemo.ipynb similarity index 100% rename from PythonAPI/demos/pycocoDemo.ipynb rename to demos/pycocoDemo.ipynb diff --git a/PythonAPI/demos/pycocoEvalDemo.ipynb b/demos/pycocoEvalDemo.ipynb similarity index 100% rename from PythonAPI/demos/pycocoEvalDemo.ipynb rename to demos/pycocoEvalDemo.ipynb diff --git a/PythonAPI/pycocotools/__init__.py b/pycocotools/__init__.py similarity index 100% rename from PythonAPI/pycocotools/__init__.py rename to pycocotools/__init__.py diff --git a/PythonAPI/pycocotools/_mask.pyx b/pycocotools/_mask.pyx similarity index 100% rename from PythonAPI/pycocotools/_mask.pyx rename to pycocotools/_mask.pyx diff --git a/PythonAPI/pycocotools/coco.py b/pycocotools/coco.py similarity index 100% rename from PythonAPI/pycocotools/coco.py rename to pycocotools/coco.py diff --git a/PythonAPI/pycocotools/cocoeval.py b/pycocotools/cocoeval.py similarity index 100% rename from PythonAPI/pycocotools/cocoeval.py rename to pycocotools/cocoeval.py diff --git a/PythonAPI/pycocotools/mask.py b/pycocotools/mask.py similarity index 100% rename from PythonAPI/pycocotools/mask.py rename to pycocotools/mask.py From 034853ee252969abb0c8cce8c5d9e3c2e8d015d8 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 13 Feb 2020 21:22:22 +0200 Subject: [PATCH 4/8] Fixed paths --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2684641e..bd2780b9 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ ext_modules = [ Extension( 'pycocotools._mask', - sources=['common/maskApi.c', 'PythonAPI/pycocotools/_mask.pyx'], + sources=['common/maskApi.c', 'pycocotools/_mask.pyx'], include_dirs = [np.get_include(), 'common'], extra_compile_args=[] # originally was ['-Wno-cpp', '-Wno-unused-function', '-std=c99'], ) From b6219d4752475df018242439c594088c9636b10d Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 13 Feb 2020 21:29:12 +0200 Subject: [PATCH 5/8] fixed paths --- pycocotools/_mask.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycocotools/_mask.pyx b/pycocotools/_mask.pyx index d065837f..544bb1f0 100644 --- a/pycocotools/_mask.pyx +++ b/pycocotools/_mask.pyx @@ -1,5 +1,5 @@ # distutils: language = c -# distutils: sources = ../common/maskApi.c +# distutils: sources = common/maskApi.c #************************************************************************** # Microsoft COCO Toolbox. version 2.0 From 4c4de66772a4b1b1c4af572c827f03a5a73b58d3 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Wed, 14 Jul 2021 10:13:50 +0300 Subject: [PATCH 6/8] added pyproject.toml --- pyproject.toml | 3 +++ setup.py | 31 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..a6cb48b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "numpy >= 1.21.0", "Cython >= 0.29.23"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index bd2780b9..9cbedc74 100644 --- a/setup.py +++ b/setup.py @@ -8,19 +8,20 @@ # Note that the original compile flags below are GCC flags unsupported by the Visual C++ 2015 build tools. # They can safely be removed. -ext_modules = [ - Extension( - 'pycocotools._mask', - sources=['common/maskApi.c', 'pycocotools/_mask.pyx'], - include_dirs = [np.get_include(), 'common'], - extra_compile_args=[] # originally was ['-Wno-cpp', '-Wno-unused-function', '-std=c99'], - ) -] +if __name__ == '__main__': + ext_modules = [ + Extension( + 'pycocotools._mask', + sources=['common/maskApi.c', 'pycocotools/_mask.pyx'], + include_dirs = [np.get_include(), 'common'], + extra_compile_args=[] # originally was ['-Wno-cpp', '-Wno-unused-function', '-std=c99'], + ) + ] -setup(name='pycocotools', - packages=['pycocotools'], - package_dir = {'pycocotools': 'pycocotools'}, - version='2.0', - ext_modules= - cythonize(ext_modules) - ) + setup(name='pycocotools', + packages=['pycocotools'], + package_dir = {'pycocotools': 'pycocotools'}, + version='2.0', + ext_modules= + cythonize(ext_modules) + ) From 3a46d99b738628a7658ce9b09a62a758810e9df9 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Fri, 30 Dec 2022 00:26:47 +0200 Subject: [PATCH 7/8] replaced np.float -> np.float32 --- pycocotools/cocoeval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycocotools/cocoeval.py b/pycocotools/cocoeval.py index b3a8806a..e2a62dfe 100644 --- a/pycocotools/cocoeval.py +++ b/pycocotools/cocoeval.py @@ -376,8 +376,8 @@ def accumulate(self, p = None): tps = np.logical_and( dtm, np.logical_not(dtIg) ) fps = np.logical_and(np.logical_not(dtm), np.logical_not(dtIg) ) - tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float) - fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float) + tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float.32) + fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float.32) for t, (tp, fp) in enumerate(zip(tp_sum, fp_sum)): tp = np.array(tp) fp = np.array(fp) From 4f13e60c5791125d64db4851e367e7f9e5ecf135 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Fri, 30 Dec 2022 00:45:34 +0200 Subject: [PATCH 8/8] fixed typo --- pycocotools/cocoeval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycocotools/cocoeval.py b/pycocotools/cocoeval.py index e2a62dfe..e5f7a43b 100644 --- a/pycocotools/cocoeval.py +++ b/pycocotools/cocoeval.py @@ -376,8 +376,8 @@ def accumulate(self, p = None): tps = np.logical_and( dtm, np.logical_not(dtIg) ) fps = np.logical_and(np.logical_not(dtm), np.logical_not(dtIg) ) - tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float.32) - fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float.32) + tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float32) + fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float32) for t, (tp, fp) in enumerate(zip(tp_sum, fp_sum)): tp = np.array(tp) fp = np.array(fp)