[Solved] Tensorflow Object Detection API on Windows – ImportError: No module named “object_detection.utils”; “object_detection” is not a package

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:UsersxxxDocumentsmodelsresearchobject_detectionobject_detection.py”, line 31, in
from object_detection.utils import ops as utils_ops

File “C:UsersxxxDocumentsmodelsresearchobject_detectionobject_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
Enquirer: gta

||
Solution #1:

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
Respondent: Akshay Nair
Solution #2:

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

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

from directory C:UsersxxxDocumentsmodelsresearch

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

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.