in research directory, Simply run:
python object_detection/builders/model_builder_test.py
as readme install suggested.
Got the error:
ImportError: No module named 'object_detection'
I know this is a low-level error, but the tutorial in readme is really misleading, follow that command just got this error message.
in object_detection many files are using from object_detection import ...
, So how to solve this problem???
go to the research directory and type:
export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
'export' is not recognized as an internal or external command,
operable program or batch file.
if you are in WINDOES you can use the following command (from the research directory):
SET PYTHONPATH=%cd%:%cd%\slim
if working with editors (like PyCharm) you can add path to PYTHONPATH variable from the software.
@jjahanip So many thanks, I'll check it again.
i am working in anaconda and i get a similar error accept it says:
File "object_detection/builders/model_builder_test.py", line 21, in
from object_detection.builders import model_builder
ModuleNotFoundError: No module named 'object_detection'
@williamsuppiger Maybe this is not supporte anymore? This is an obvious mistake.
@jinfagang @williamsuppiger this error usually occurs if you fail to set the PYTHONPATH as mentioned by @jjahanip . Have you tried setting it ?
if you use windows add in model_builder_test.py after import tensorflow as tf.
import sys
sys.path.append("{YOU_PATH}\\models-master\\research\\")
sys.path.append("{YOU_PATH}\\models-master\\research\\object_detection\\utils")
I will close this for now since things seems to work as expected. If you are still having problems please feel free to reopen this issue.
After I entered 'export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim' to get around the Import error for object detection, I got another import error
ImportError: No module named nets
to correct @jjahanip, on windows is SET PYTHONPATH=%cd%;%cd%\slim.
It's ';'
not ':'
One possible reason for this might be that you are not running the Jupyter Notebook in the same terminal where you set the $PYTHONPATH
value.
Or you can try to add $PYTHONPATH value into your ~/.bashrc
file (or ~/.zshrc
file if you are using 'oh my zsh')
on windows the line is :
SET PYTHONPATH=%cd%;%cd%\slim
NOT
SET PYTHONPATH=%cd%:%cd%\slim
You can test with :
echo %PYTHONPATH%
it should give you somethine like
Has anyone tried the same thing on floydhub?
I am getting the modulenotfound error there. Can anyone help me?
When i am running the ipython in object detection i am getting an error in line 17 saying that i do not have tensor flow how to avoid this error
I tried add these two lines and it works for me.
import sys
sys.path.append("..")
If anyone has the same issue in a Kaggle kernel, here is one fix:
import os
os.environ['PYTHONPATH'] += ':/kaggle/working/models/research/:/kaggle/working/models/research/slim/'
from imageai.Detection import ObjectDetection
error at this line while running as windows service.
please help me.
If anyone has the same issue in a Kaggle kernel, here is one fix:
import os os.environ['PYTHONPATH'] += ':/kaggle/working/models/research/:/kaggle/working/models/research/slim/'
Great working on colab too!
Thank you very much.....
for windows user......
import sys
sys.path.append("{YOU_PATH}\models-master\research\")
sys.path.append("{YOU_PATH}\models-master\research\object_detection\utils")
PATH_TO_LABELS = 'data/mscoco_label_map.pbtxt'
Thank you very much.....
for windows user......import sys
sys.path.append("{YOU_PATH}\models-master\research\")
sys.path.append("{YOU_PATH}\models-master\research\object_detection\utils")PATH_TO_LABELS = 'data/mscoco_label_map.pbtxt'
Thank you soo much...
its working now..
pip install tensorflow-object-detection-api
If anyone has the same issue in a Kaggle kernel, here is one fix:
import os os.environ['PYTHONPATH'] += ':/kaggle/working/models/research/:/kaggle/working/models/research/slim/'
Great working on colab too!
if you use windows add in model_builder_test.py after import tensorflow as tf.
import sys
sys.path.append("{YOU_PATH}\models-master\research\")
sys.path.append("{YOU_PATH}\models-master\research\object_detection\utils")
This worked for me. Thanks
I also add these above three lines of code into my train.py.
I had to move my .py file to the \research folder and it worked.
Most helpful comment
go to the research directory and type:
export PYTHONPATH=$PYTHONPATH:
pwd
:pwd
/slim