Hello for all, I'm getting this error while trying to run the Object Detection test on Tensorflow in Debian and Ubuntu. I have other Tensorflow applications that are working properly. I followed the help of the link below with Ubuntu 17.04 clean and also had the error, please help me guys.
https://github.com/tensorflow/models/blob/master/object_detection/g3doc/installation.md
Linux Ubuntu 17.04 /64 bits
Python 2.7
sudo pip install pillow
sudo pip install lxml
sudo pip install jupyter
sudo pip install matplotlib
sudo pip install tensorflow *(TensorFlow 1.2 and requisites installed correct, I have others aplication tests)
cd /user/workspace/models/
git clone https://github.com/tensorflow/models.git
Im my ~/.bashrc file, I add:
export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
And execute in /workspace/models/:
python object_detection/builders/model_builder_test.py
Error:
ImportError Traceback (most recent call last)
2
3 from google.protobuf import text_format
----> 4 from object_detection.builders import model_builder
5 from object_detection.meta_architectures import faster_rcnn_meta_arch
6 from object_detection.meta_architectures import rfcn_meta_arch
ImportError: No module named object_detection.builders
You need to build and run setup.py using following steps:
$ sudo apt-get install protobuf-compiler python-pil python-lxml
$ sudo -H pip install jupyter
$ sudo -H pip install matplotlib
$ mkdir protoc_3.3
$ cd protoc_3.3/
$ wget wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
$ chmod 775 protoc-3.3.0-linux-x86_64.zip
$ unzip protoc-3.3.0-linux-x86_64.zip
$ /home/humayun/tensorflow/protoc_3.3/bin/protoc object_detection/protos/*.proto --python_out=.
tensorflow/models$ export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
$ sudo python setup.py build
$ sudo python setup.py install
then you can run this command:
$ python object_detection/builders/model_builder_test.py
I followed these steps and it works on my ubuntu 14.0.4 machine with GPU and CUDA CUDNN installation.
-Humayun
Thanks Humanyum, I did exactly those steps, and everything worked fine in the terminal but I got the error on execute command: $ python object_detection/builders/model_builder_test.py
Traceback (most recent call last):
File "object_detection/builders/model_builder_test.py", line 21, in
from object_detection.builders import model_builder
File "/home/user/workspace/models/object_detection/builders/model_builder.py", line 30, in
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "/home/user/workspace/models/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 29, in
from nets import inception_resnet_v2
ImportError: No module named nets
@DarkNavrel
I'm also getting this error, how did you fix it?
edit: The following fixed my error ImportError: No module named nets
pwd
(env var $PWD
) means print working directory so just replace pwd
with the location of your models folder.
So I fixed this by updating the env var defined in my ~/.bashrc
file by replacing:
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
with
export PYTHONPATH=$PYTHONPATH:$HOME/j/Lib/models:$HOME/j/Lib/models/slim
After editing the .bashrc, open new console window and type echo $PYTHONPATH
to make sure it looks ok. Then cd
into your models folder and run the python test file.
answer taken from https://github.com/tensorflow/models/issues/729
test file output:
j@j-pc ~/Lib/models $ python3 object_detection/builders/model_builder_test.py
.......
----------------------------------------------------------------------
Ran 7 tests in 0.028s
OK
I am getting the same error, it seems that the 'nets' folder is missing during the import, and indeed this folder does not exist in the models directory, does anyone know why the example does import this folder and where is it?
Traceback (most recent call last):
File "object_detection/builders/model_builder_test.py", line 21, in
from object_detection.builders import model_builder
File "/home/user/workspace/models/object_detection/builders/model_builder.py", line 30, in
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "/home/user/workspace/models/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 29, in
from nets import inception_resnet_v2
ImportError: No module named nets
@DarkNavrel the "nets" folder exists in the /models/slim directory. Check if you have it there. If not, then clone it from the git repo.
I also get this error.
And I do have a /models/slim/nets folder
Reconfirm if your PYTHONPATH is set correctly to "slim" folder.
Run:
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
Verify:
echo PYTHONPATH
@hardik1973 I'm using windows
(py35cv3) C:\Users\DanMo\Anaconda3\envs\py35cv3\Lib\site-packages\tensorflow\models>echo %PYTHONPATH%
"C:\Users\DanMo\Anaconda3\envs\py35cv3\Lib\site-packages\tensorflow\models\slim";"C:\Users\DanMo\Anaconda3\envs\py35cv3\Lib\site-packages\tensorflow\models"
@DanMossa can you post a screenshot of the error message?
@hardik1973 Look at the newest post #2031
I am building a tensorflow object detection training model but I am facing this issue can you guide me how to over come this.( from nets.nasnet import pnasnet ImportError: cannot import name 'pnasnet')
I had to ensure that
os.environ['PYTHONPATH'] = '/env/python:/content/models/research/slim/:/content/models/research/'
le m锚me probl猫me pour moi voila capture lors d'exuction :
et voila rep茅rtoir "C:\ProgramData\Anaconda3\envs\tensorflow1\Lib\site-packages\object_detection-0.1-py3.7.egg\object_detectionbuilders "
Hi!
I tried to install Tensorflow Object Detection on my Ubuntu vmware machine.
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
TensorFlow vers. that I used:
python -c 'import tensorflow as tf; print(tf.__version__)'
1.13.1
I used this tutorial to install it : https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
When I want to testing if had correctly installed the Tensorflow Object Detection, using command line:
python object_detection/builders/model_builder_test.py , I received next error:
python object_detection/builders/model_builder_test.py
Traceback (most recent call last):
File "object_detection/builders/model_builder_test.py", line 22, in
from research.google.protobuf import text_format
ImportError: No module named research.google.protobuf
OBS!
I used:
Python 2.7.12
Python 3.5.2
I notice that if I want to install again TensorFlow for CPU using pip ( pip install tensorflow ), I received next error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in
from pip._internal import main
ImportError: No module named _internal
Do you have any suggestions? There is some connection between pip error and my initial problem?
Most helpful comment
You need to build and run setup.py using following steps:
$ sudo apt-get install protobuf-compiler python-pil python-lxml
$ sudo -H pip install jupyter
$ sudo -H pip install matplotlib
$ mkdir protoc_3.3
$ cd protoc_3.3/
$ wget wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
$ chmod 775 protoc-3.3.0-linux-x86_64.zip
$ unzip protoc-3.3.0-linux-x86_64.zip
$ /home/humayun/tensorflow/protoc_3.3/bin/protoc object_detection/protos/*.proto --python_out=.
tensorflow/models$ export PYTHONPATH=$PYTHONPATH:
pwd
:pwd
/slim$ sudo python setup.py build
$ sudo python setup.py install
then you can run this command:
$ python object_detection/builders/model_builder_test.py
I followed these steps and it works on my ubuntu 14.0.4 machine with GPU and CUDA CUDNN installation.
-Humayun