models icon indicating copy to clipboard operation
models copied to clipboard

model_main.py - invalid syntax

Open lukaszs-appdate opened this issue 8 years ago • 6 comments

System information

  • What is the top-level directory of the model you are using: tensorflow/models/research
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): NO
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Ubuntu 16.04.3 LTS
  • TensorFlow installed from (source or binary):pip install tensorflow-gpu
  • TensorFlow version (use command below):v1.9.0-0-g25c197e023 1.9.0
  • Bazel version (if compiling from source):none
  • CUDA/cuDNN version: cuda 9.0 cudnn 7.1
  • GPU model and memory: tesla v100
  • Exact command to reproduce: see bug report

Describe the problem

Not able to run object detection training locally. Did all steps in https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md (tests are passing), followed https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pets.md (I copied data to ~/gcs/data instead of gs bucket), got stuck on trying to run training and eval locally.

Source code / logs

$ python object_detection/model_main.py --pipeline_config_path=~/gcs/data/faster_rcnn_resnet101_pets.config --model_dir=~/gcs/data/ --num_train_steps=50000 --num_eval_steps=2000 --alsologtostderr /home/paperspace/anaconda3/lib/python3.6/site-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "object_detection/model_main.py", line 26, in from object_detection import model_lib File "/home/paperspace/tensorflow/models/research/object_detection/model_lib.py", line 26, in from object_detection import eval_util File "/home/paperspace/tensorflow/models/research/object_detection/eval_util.py", line 28, in from object_detection.metrics import coco_evaluation File "/home/paperspace/tensorflow/models/research/object_detection/metrics/coco_evaluation.py", line 21, in from object_detection.utils import object_detection_evaluation File "/home/paperspace/tensorflow/models/research/object_detection/utils/object_detection_evaluation.py", line 842 print 'Scores and tpfp per class label: {}'.format(class_index) ^ SyntaxError: invalid syntax


lukaszs-appdate avatar Jul 16 '18 15:07 lukaszs-appdate

Are you using python 2 or python 3. This line /home/paperspace/anaconda3/lib/python3.6/site-packages/h5py/init.py:34 seems to suggest its python 3 and when you print in python 3 you have to use parenthesis. The error happens in a print statement that does not follow this syntax. You will either have to update the code or run it with python 2.

MonkeyWithAComputer avatar Jul 16 '18 16:07 MonkeyWithAComputer

The current code was written in Python 2. If you run it through Python 3.X, several py files need to be revised. I documented necessary revisions based on my experience click here and hopefully they can help you.

cosmojiang avatar Jul 17 '18 15:07 cosmojiang

I'm seeing the exact same error when running the script on Windows 10, Python 3.6. On Windows tensorflow-gpu is not available for Python 2.7.

ghost avatar Jul 20 '18 02:07 ghost

@calebh try my revisions on the code and see if they help you. See it here

cosmojiang avatar Jul 20 '18 02:07 cosmojiang

@cosmojiang yes your fixes worked 🙂. Hopefully they will be incorporated into the repo soon.

ghost avatar Jul 20 '18 13:07 ghost

This should be gone now.

pkulzc avatar Sep 14 '18 01:09 pkulzc