2

I've been trying to set up the Object Detection environment.

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

But I'm stuck at this line;

python object_detection/builders/model_builder_test.py

It spits out this error;

Traceback (most recent call last):
  File "object_detection/builders/model_builder_test.py", line 21, in <module>
    from object_detection.builders import model_builder
ImportError: No module named object_detection.builders

My system is;

MacOS Sierra

pip freeze > requirements.txt

altgraph==0.10.2
appnope==0.1.0
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
backports.weakref==1.0rc1
bdist-mpkg==0.5.0
bleach==1.5.0
bonjour-py==0.3
certifi==2017.4.17
configparser==3.5.0
decorator==4.0.11
entrypoints==0.2.3
enum34==1.1.6
funcsigs==1.0.2
functools32==3.2.3.post2
html5lib==0.9999999
ipykernel==4.6.1
ipython==5.4.1
ipython-genutils==0.2.0
ipywidgets==6.0.0
Jinja2==2.9.6
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.0.1
jupyter-console==5.1.0
jupyter-core==4.3.0
lxml==3.8.0
macholib==1.5.1
Markdown==2.2.0
MarkupSafe==1.0
matplotlib==1.3.1
mistune==0.7.4
mock==2.0.0
modulegraph==0.10.4
nbconvert==5.2.1
nbformat==4.3.0
nose==1.3.7
notebook==5.0.0
numpy==1.13.0
olefile==0.44
pandocfilters==1.4.1
pathlib2==2.3.0
pbr==3.1.1
pexpect==4.2.1
pickleshare==0.7.4
Pillow==4.1.1
prompt-toolkit==1.0.14
protobuf==3.3.0
ptyprocess==0.5.1
py2app==0.7.3
Pygments==2.2.0
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyOpenSSL==0.13.1
pyparsing==2.0.1
python-dateutil==2.6.0
pytz==2013.7
pyzmq==16.0.2
qtconsole==4.3.0
scandir==1.5
scipy==0.13.0b1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
tensorflow==1.2.0
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
vboxapi==1.0
virtualenv==15.1.0
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.12.2
widgetsnbextension==2.0.0
xattr==0.6.4
zope.interface==4.1.1

If somebody has a clue, please.

Edit 1

I'm using virtualenv and I couldn't find the tensorflow/models/ directory;

(objectDetects) $ pip show tensorflow
Name: tensorflow
Version: 1.2.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /tensorflow/objectDetects/lib/python2.7/site-packages
Requires: bleach, werkzeug, html5lib, six, markdown, backports.weakref, wheel, numpy, mock, protobuf

So I tried to export it from the root folder, and it spits out a new error;

(objectDetects) $ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
(objectDetects) $ python object_detection/builders/model_builder_test.py
Traceback (most recent call last):
  File "object_detection/builders/model_builder_test.py", line 21, in <module>
    from object_detection.builders import model_builder
  File "/tensorflow/objectDetects/object_detection/builders/model_builder.py", line 30, in <module>
    from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
  File "/tensorflow/objectDetects/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 29, in <module>
    from nets import inception_resnet_v2
ImportError: No module named nets

2 Answers 2

2

Try adding libraries to python path.
Run the following command from tensorflow/models directory.

# From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

Now the code will run successfully.This command needs to run from every new terminal you start. If you wish to avoid running this manually, you can add it as a new line to the end of your ~/.bashrc file.

For more info check installation link : Adding Libraries to PYTHON PATH section.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm using virtualevn so I couldn't find the tensorflow/models directory. (Please see the new edit on the original post)
If you want to change the PYTHONPATH used in a virtualenv, you can add the following line to your virtualenv's bin/activate file: export PYTHONPATH="/the/path/you/want" For more details [this link] (stackoverflow.com/questions/4757178/…)
0

To avoid this error every time you can add PYTHONPATH to your ~/.bashrc file. Here is the link for the reference.

LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
var=$(printf 'export PYTHONPATH="${PYTHONPATH}:%s/slim"' "$LOCAL_DIR")
echo $var >> ~/.bashrc

run the above lines from tensorflow/models/research/ then run the line below from the same directory.

python object_detection/builders/model_builder_test.py

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.