Setting up the pycocotools-2.0.tar.gz package using cocoapi

November 8, 2018

 

Git clone: git clone is a Git command line utility.

It is used to target an existing repository and create a clone, or copy of the target repository which is nothing but the storehouse.

Cloning a local or remote or a bare storehouse. Using empty options to partially clone storehouse.

Let us see the use of pycocotools

Install Git clone cocoapi project on your machine by running the given url:

https://github.com/cocodataset/cocoapi.git

Copy the path using the below command:

Copy /PATH/TO/cocoapi/common folder in/PATH/TO/cocoapi/PythonAPI/.

Finally, let us now do the editing

Edit /PATH/TO/cocoapi/PythonAPI/setup.py to contain the code below.

from setuptools import setup, Extension

import numpy as np

# To compile and install locally run "python setup.py build_ext --inplace"

# To install library to Python site-packages run "python setup.py build_ext install"

ext_modules = [

  Extension(

      'pycocotools._mask',

      sources=['common/maskApi.c', 'pycocotools/_mask.pyx'],

      include_dirs = [np.get_include(), 'common'],

      extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],

  )

]

setup(

  name='pycocotools',

  packages=['pycocotools'],

  package_dir = {'pycocotools': 'pycocotools'},

  install_requires=[

      'setuptools>=18.0',

      'cython>=0.27.3',

      'matplotlib>=2.1.0'

  ],

  version='2.0',

  ext_modules= ext_modules

)

Installation process includes the following steps:

pip3 install numpy

pip3 install cython

sudo apt install python3-pip

sudo apt-get install python3-setuptools

sudo apt-get install gcc

sudo apt-get install python3-dev libxml2-dev libxslt-dev

Go to Makefile and change python to python3

Compile PythonAPI

cd /PATH/TO/cocoapi/PythonAPI

sudo make

Create a tar.gz compressed file of /PATH/TO/cocoapi/PythonAPI and name it pycocotools-2.0.tar.gz For macOS or Windows, because you need to run

tar -zcvf pycocotools-2.0.tar.gz /PATH/TO/cocoapi/PythonAPI

Generate folder /PATH/TO/tensorflow/models/research/cocoapi/ so that you can put the newly compressedpycocotools-2.0.tar.gz inside.

Leave a Reply:

Your email address will not be published. Required fields are marked *