Models: consider not using pycocotools since it doesn't work on windows

Created on 17 Sep 2018  路  6Comments  路  Source: tensorflow/models

Please go to Stack Overflow for help and support:

http://stackoverflow.com/questions/tagged/tensorflow

Also, please understand that many of the models included in this repository are experimental and research-style code. If you open a GitHub issue, here is our policy:

  1. It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
  2. The form below must be filled out.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information

  • What is the top-level directory of the model you are using:
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • TensorFlow installed from (source or binary):
  • TensorFlow version (use command below):
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:
  • Exact command to reproduce:

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

_== cat /etc/issue ===============================================
MINGW64_NT-10.0 Beast 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys

== are we in docker =============================================
No

== compiler =====================================================
bash: c++: command not found

== uname -a =====================================================
MINGW64_NT-10.0 Beast 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys

== check pips ===================================================
numpy 1.14.2
protobuf 3.6.1
tensorflow 1.7.0
tensorflow-gpu 1.10.0
tensorflow-hub 0.1.1

== check for virtualenv =========================================
False

== tensorflow import ============================================
tf.VERSION = 1.10.0
tf.GIT_VERSION = b'v1.10.0-rc1-19-g656e7a2b34'
tf.COMPILER_VERSION = b'v1.10.0-rc1-19-g656e7a2b34'
Sanity check: array([1])_

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

the current model_main.py script for object detection uses pycoco and pycocotools. There is a known bug in pycocotools and the maintainers of that project have no plans to support windows. This means anyone using windows has to use the legacy.trainer.py instead. On MacOS model_main.py works fine. Until pycocotools maintainers decide to support windows, I suggest not using pycocotools or at least let users know it only works on Mac and Linux.

Source code / logs

The exact issue with pycocotools can be found at this link. https://github.com/cocodataset/cocoapi/issues/169
The error when you try to run pip install pycocotools on windows.

Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools ... error
Complete output from command d:\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\P
ETERL~1\AppData\Local\Temp\pip-install-qwoxf3_t\pycocotools\setup.py';f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\PETERL~1\
AppData\Local\Temp\pip-record-nkxviuzj\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools
copying pycocotools__init__.py -> build\lib.win-amd64-3.6\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\pycocotools
creating build\temp.win-amd64-3.6\Release\common
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe /c /n
ologo /Ox /W3 /GL /DNDEBUG /MD -Id:\python\python36\lib\site-packages\numpy\core\include -Icommon -Id:\python\python36\i
nclude -Id:\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14
.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\includ
e" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\1
0.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windo
ws Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcpycocotools/_mask.c /Fobuild\temp.win-amd64-3.6\Release\py
cocotools/_mask.obj -Wno-cpp -Wno-unused-function -std=c99
cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin
\HostX86\x64\cl.exe' failed with exit status 2

----------------------------------------

Most helpful comment

From conda command prompt do this two commands. Just copy and paste and enter to run..
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

All 6 comments

As a work around can try using this
https://github.com/philferriere/cocoapi

I would think it does not work well on MacOS neither. See this issue

I did test model_main.py MacOS Mojave 10.14 and it worked fine with pycoco and pycocotools. I've only had issues on windows. I haven't tried the workaround cocoapi on windows.

@woolfel I had the problem when I was using gcloud suggested by an article, which needs to copy a repackaged pycocotools:

gcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` \
--job-dir=gs://${YOUR_GCS_BUCKET}/train \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
--module-name object_detection.model_tpu_main \
--runtime-version 1.8 \
--scale-tier BASIC_TPU \
--region us-central1 \
-- \
--model_dir=gs://${YOUR_GCS_BUCKET}/train \
--tpu_zone us-central1 \
--pipeline_config_path=gs://${YOUR_GCS_BUCKET}/data/pipeline.config

On mac, repackaging pycocotools using sed does not work. The detail can be seen in the issue

From conda command prompt do this two commands. Just copy and paste and enter to run..
first:
conda install git
then:
pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

Hi There,
We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing.
If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

Was this page helpful?
0 / 5 - 0 ratings