11

I'm trying to run the object_detection API in Tensorflow using my webcam as an input.

The error says: "from utils import label_map_util ModuleNotFoundError: No module named 'utils'"

Which relates to the lines:

from utils import label_map_util
from utils import visualization_utils as vis_util

I've tried "pip install util" appears to work but doesn't solve the problem. I have also reinstalled multiple versions of protobuf as other questions online appear to have this as the solution. I don't get any errors when I install protoc so I don't think this is the issue.

I'm using python 3.6 on windows 10 with tensorflow-gpu.

  • 3
    Possible duplicate of [from utils import label\_map\_util Import Error: No module named utils](https://stackoverflow.com/questions/46494160/from-utils-import-label-map-util-import-error-no-module-named-utils) – Tim Woocker Mar 28 '18 at 22:25

5 Answers5

7

add object_detection to the front of utils:

# from utils import label_map_util
# from utils import visualization_utils as vis_util

from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
sailfish009
  • 2,228
  • 1
  • 20
  • 30
6

What folder are you running your python script from?

To be able to access the 'utils' module directly, you need to be running the script inside the <models-master>\research\object_detection folder.

drec4s
  • 7,718
  • 8
  • 29
  • 49
4
  • Instead of running script inside object detection folder append the path of tensorflow object detection in your script by writing

    import sys
    
    sys.path.append('PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER')
    
  • e.g 'PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER' in my ubuntu system is

    /home/dc-335/Documents/Softwares/tensorflow/models/research/object_detection

  • Cheers, You done it !!

Kamble Tanaji
  • 421
  • 4
  • 11
2

I used a quicker method to fix it.

I copied the utils folder from models\research\object_detection and pasted it within the same directory as the python file which required utils

Lovesh Dongre
  • 1,210
  • 7
  • 21
0

the installation didn't go through, you will notice no module called model_utils in your project folder. uninstall it pip uninstall django-model-utils then install it again pip install django-model-utils a new app called model_utils in your project folder.

lvingstone
  • 103
  • 8