Tensorflow Object Detection Evaluation Pycocotools Missing

Tensorflow Object Detection Evaluation Pycocotools Missing

Following the TF tutorial on pet object detection :

Ran locally :

The training seems to work well.

Trying to launch the evaluation process from the tensorflow/models/research/ directory

python object_detection/eval.py \
    --logtostderr \
    --pipeline_config_path=${PATH_TO_YOUR_PIPELINE_CONFIG} \
    --checkpoint_dir=${PATH_TO_TRAIN_DIR} \
    --eval_dir=${PATH_TO_EVAL_DIR}

I got the following error

from pycocotools import coco \
ModuleNotFoundError: No module named 'pycocotools'

Had a look on coco API but I don't see any clear way to install it on Windows.

Any advice on how to get the evaluation running the simpliest way ?


More details about the error message :

Traceback (most recent call last):   File "object_detection/eval.py", line 50, in <module>
from object_detection import evaluator
File "D:\models\research\object_detection\evaluator.py", line 27, in <module>
from object_detection.metrics import coco_evaluation
File "D:\models\research\object_detection\metrics\coco_evaluation.py", line 20, in <module>
from object_detection.metrics import coco_tools
File "D:\models\research\object_detection\metrics\coco_tools.py", line 47, in <module>
from pycocotools import coco ModuleNotFoundError: No module named 'pycocotools'
4

9 Answers

This solved the same issue for me:

pip3 install -U scikit-image
pip3 install -U cython 
pip3 install "git+"

(and use pip instead of pip3 if you are using python 2.7)

1

Following command worked for me.

pip install pycocotools
1

It works for me with this just simple method. If you are windows, try to install pycocotools in windows version. With code in following:

pip install pycocotools-windows

With this method, you don't need to install any visual build tools. Hope this can help those who finding the ways of installing pycocotools.

Could you post the full stack trace so we can see where pycocotools is being imported from? We're adding COCO support to the Tensorflow Object-Detection API (with a few other goodies), and will update the installation instructions soon.

6

I had the same problem and solved it, but unfortunately for you, I am working on Ubuntu. But hopefully this helps someone else with the same issue:

First of all, you need to follow the steps that are described in the install guide of the object detection api. In my case though, that was not enough, I had the same problem as before. During the installation process described there, you download a github repository, specifically this one.

What I did next was to navigate to the folder cocoapi/PythonAPI and running

sudo python3 setup.py install

Evaluation script seems to be working now.

1

This worked for me:

git clone 

Then in the PythonAPI directory, install library:

cd PythonAPI
python setup.py build_ext install

For Windows the sure way to do this is:

  1. Install Visual C++ 2015 Build Tools from with default selection.
  2. pip install git+^&subdirectory=PythonAPI
  1. First open a command prompt and run
git clone 
  1. Then move to this directory
cd coco/PythonAPI
  1. And then edit the setup.py file in the coco/PythonAPI directory from this
extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],

to this

extra_compile_args=['-std=c99'],

then save

  1. And then in the coco/PythonAPI directory, run
python setup.py install

Your problem should be solved

The best and the easiest way to fix this error is to just use pip to install it

!pip install -q pycocotools

You can use pip3 if you have python3 and you are in Linux or mac

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.