Home > Enterprise >  No module named 'object_detection' import error
No module named 'object_detection' import error

Time:10-27

I know most of you who have worked with tensorflow object detection have come across this problem. I have my tensorflow project running in a different folder but now I did like to use object detection functions stored in models folder.

I have changed my working directory in my python scripts to models / object detection folder this way:

import sys
import os
changed_directory = False

if not changed_directory:
    os.chdir(os.path.join('../models/research/','object_detection/')) 
    changed_directory = True

I then append the path in my scripts this way :

import sys
sys.path.append("...models\\research\\object_detection\\")

This is how my models folder looks like

TensorFlow/
NAR_object_detection/
└─ models/
   ├─ community/
   ├─ official/
   ├─ orbit/
   ├─ research/
   └── ...

Object detection folder in inside the research models. Also important to say that my python scripts for object detection are stored in a folder called NAR_object_detection inside the Tensorflow, so I mean NAR_object_detection folder is the same folder with models folder.

When I try to import this way I get an error that no module called object detection

from object_detection.utils import label_map_util

Why is it that the import statement is not finding the object detection folder?

CodePudding user response:

try this

pip install tensorflow-object-detection-api
  • Related