Python - "from Utils Import Label_map_util" ImportError: Cannot Import Name 'label_map_util'
Solution 1:
CD to object_detection directory
import( os )
os.chdir( 'D:\\projects\\data core\\helmet detection\\models\\research\\object_detection' )
and change these lines
from utils import label_map_util
from utils import visualization_utils as vis_util
to the following lines
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
It will work.
Solution 2:
This works for me. However, in order to make it work I had to do the following:
Create a virtual environment with the following: i) OpenCV 4.0.1 ii) Python 3.6 iii) tensorflow v1.12
Install and/or update the various dependencies individually: conda install scipy pip install --upgrade sklearn pip install --upgrade pandas pip install --upgrade pandas-datareader pip install --upgrade matplotlib pip install --upgrade pillow pip install --upgrade requests pip install --upgrade h5py pip install --upgrade pyyaml pip install --upgrade psutil pip install --upgrade tensorflow==1.12.0 pip install -- upgrade lxml pip install opencv-contrib-python
Compile all the protocol buffer definition files: i)cd to the models/research folder ii)protoc object_detection/protos/*.proto --python_out=.
4.Export the correct PYTHONPATH variable path:
i)export PYTHONPATH=$PYTHONPATH:pwd
:pwd
/slim
ii)echo $PYTHONPATH
- Go to the folder where the file resides (object_dectection) and run it in python i) cd object_detection/ ii) python test_pyprog.py
Solution 3:
pip install tensorflow-object-detection-api
Post a Comment for "Python - "from Utils Import Label_map_util" ImportError: Cannot Import Name 'label_map_util'"