3
votes

I am using the tensorflow object detection api from https://github.com/tensorflow/models and I am trying to make an object detection program using open cv with tensorflow. When the code reaches at line 30 (see code below), the program will get an error and will print:

Traceback (most recent call last):

File "C:\Users\xxx\Documents\models\research\object_detection\object_detection.py", line 31, in from object_detection.utils import ops as utils_ops

File "C:\Users\xxx\Documents\models\research\object_detection\object_detection.py", line 31, in from object_detection.utils import ops as utils_ops

ImportError: No module named 'object_detection.utils'; 'object_detection' is not a package

I tried the solutions that are in this link (Tensorflow Object Detection API on Windows - error "ModuleNotFoundError: No module named 'utils'") step by step, but it still didn't work. I don't know what should be targeted in order to solve this problem. Also, I am not that familiar with machine learning, tensorflow, and opencv, I just start learning it now. Can anyone please help me with this? Thanks in advance.

Btw, this is the part of the code where I got a problem with.

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
2

2 Answers

3
votes

I tried the 'export path' method on python and the 'Develop' method for Conda but nothing worked. Finally tried installing this API and the tutorial worked. Maybe I missed this step during the installation. You try this too

pip install tensorflow-object-detection-api
1
votes

I have followed below steps: For every new terminal, append PYTHONPATH as follows:

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

from directory C:\Users\xxx\Documents\models\research

Else, add that particular line to ~/.bashrc file in order to avoid running for every new terminal.