models icon indicating copy to clipboard operation
models copied to clipboard

ImportError: No module named utils

Open adithya-p opened this issue 7 years ago • 8 comments

System information

  • What is the top-level directory of the model you are using: 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): Linux Ubuntu 18.04.2
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 1.13.1
  • pip version (if installed with pip): 9.0.1 -python version: 2.7.15 -pip command used: pip install tensorflow
  • CUDA/cuDNN version: No CUDA, installed CPU version
  • GPU model and memory: No GPU, installed CPU version
  • Exact command to reproduce: python object_detection/object_detection.py

Describe the problem

I am running the following script, say object_detection.py which is in the /models/research/object_detection directory from /models/research directory, with the command, python object_detection/object_detection.py, It produces the following error:


Traceback (most recent call last):
  File "object_detection/object_detection.py", line 18, in <module>
    from object_detection.utils import ops as utils_ops
  File "/home/adithya/models/research/object_detection/object_detection.py", line 18, in <module>
    from object_detection.utils import ops as utils_ops
ImportError: No module named utils

Source code / logs

Link to the source file: object_detection.py

Please note because this issue appears to be quite common, I tried the following fixes based on the responses provided in different forums online:

  • Followed every instruction in installation guide and ran the command ./bin/protoc object_detection/protos/*.proto --python_out=. multiple times.
  • python object_detection/builders/model_builder_test.py ran successfully and the log is as follows:
WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

............s...
----------------------------------------------------------------------
Ran 16 tests in 0.055s

OK (skipped=1)
  • Did python setup.py build and python setup.py install which showed Finished processing dependencies for object-detection==0.1 but running python object_detection/object_detection.py did not work
  • Tried running it from the object_detection directory and changed import statements accordingly but that didn't work

How do I fix this issue?

adithya-p avatar Apr 22 '19 10:04 adithya-p

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. Bazel version

tensorflowbutler avatar Apr 23 '19 00:04 tensorflowbutler

I'm sorry. I accidentally opened it.Please leave them as N/A.Thanks

------------------ 原始邮件 ------------------ 发件人: "Alfred Sorten Wolf"[email protected]; 发送时间: 2019年4月23日(星期二) 上午8:25 收件人: "tensorflow/models"[email protected]; 抄送: "Subscribed"[email protected]; 主题: Re: [tensorflow/models] ImportError: No module named utils (#6629)

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. Bazel version

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Anyueanne avatar Apr 23 '19 01:04 Anyueanne

@tensorflowbutler I've updated them. No Bazel because I did the installation using pip.

adithya-p avatar Apr 23 '19 04:04 adithya-p

Python path seems to be missing. Please set PYTHONPATH to models/research directory.

kmadhugit avatar Apr 23 '19 15:04 kmadhugit

@kmadhugit I did export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim, but it didn't work. And pwd is models/research dir. Do you mean anything different from this?

adithya-p avatar Apr 23 '19 16:04 adithya-p

@adithya-p Were able to figure out a work around for this?

rohithrpai avatar Oct 30 '19 14:10 rohithrpai

for windows user......

import sys sys.path.append("{YOUR_PATH}\models-master\research") sys.path.append("{YOUR_PATH}\models-master\research\object_detection\utils")

PATH_TO_LABELS = 'data/mscoco_label_map.pbtxt'

thanks to https://github.com/temiklis

Sakifneoworld avatar Nov 19 '19 05:11 Sakifneoworld

@adithya-p There is no object_detection/object_detection.py file. Could you please reopen with correct instructions if this is still being a problem ?

tombstone avatar Jun 30 '20 21:06 tombstone