Reputation:
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.
Upvotes: 18
Views: 226901
Reputation: 1
faced similar issue download utils.py file and copy it in your project folder
Upvotes: 0
Reputation: 239
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.
Upvotes: 2
Reputation: 1344
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
Upvotes: 3
Reputation: 2927
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
Upvotes: 9
Reputation: 497
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 !!
Upvotes: 9
Reputation: 8077
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.
Upvotes: 8