diff --git a/PythonAPI/Makefile b/Makefile similarity index 100% rename from PythonAPI/Makefile rename to Makefile diff --git a/PythonAPI/setup.py b/PythonAPI/setup.py deleted file mode 100644 index fb08efd9..00000000 --- a/PythonAPI/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -from distutils.core import setup -from Cython.Build import cythonize -from distutils.extension import Extension -import numpy as np - -# To install and compile to your anaconda/python site-packages, simply run: -# $ pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI -# 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'], - ) -] - -setup(name='pycocotools', - packages=['pycocotools'], - package_dir = {'pycocotools': 'pycocotools'}, - version='2.0', - ext_modules= - cythonize(ext_modules) - ) 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 99% rename from PythonAPI/pycocotools/_mask.pyx rename to pycocotools/_mask.pyx index d065837f..544bb1f0 100644 --- a/PythonAPI/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 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 98% rename from PythonAPI/pycocotools/cocoeval.py rename to pycocotools/cocoeval.py index 7a4b4adc..e5f7a43b 100644 --- a/PythonAPI/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.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) @@ -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 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 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 new file mode 100644 index 00000000..9cbedc74 --- /dev/null +++ b/setup.py @@ -0,0 +1,27 @@ +from distutils.core import setup +from Cython.Build import cythonize +from distutils.extension import Extension +import numpy as np + +# To install and compile to your anaconda/python site-packages, simply run: +# $ pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI +# Note that the original compile flags below are GCC flags unsupported by the Visual C++ 2015 build tools. +# They can safely be removed. + +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) + )