from object_detection.utils import dataset_util ImportError: No module named object_detection.utils
when i tried to train pet detecter tutorials followed by instructions steps by steps, i 've already added PYTHONPATH, and run model_test.py successfully, and meantime, i 've added export pythonpath in bashrc manually,and successfully, however, i executed the code to transfer pet_tf_record, it occurred the error as follows like;
/usr/local/lib/python3.5/dist-packages/tensorflow/models/research$ sudo python object_detection/create_pet_tf_record.py --label_map_path=object_detection/data/pet_label_map.pbtxt --data_dir=pwd --output_dir=pwd
Traceback (most recent call last):
File "object_detection/create_pet_tf_record.py", line 39, in
how to solve it?plz tell me why?
What are the values for your python path?
hi, drpngx , i deployed the codes on the Google cloud, and the PYthonpath is ' ['', '/usr/local/lib/python3.5/dist-packages/tensorflow/models/research/slim', '/home/goldedseito_saga', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/goldedseito_saga/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
i 've already added slim directory in the pythonpath through modifing profile as follows:
export PYTHONPATH=/usr/local/lib/python3.5/dist-packages/tensorflow/models/research/slim:$PYTHONPATH
so it is weird to encounter such errors, because it can execute successfully through model_builder_test.py in installing instruction, any suggestions?
okay, i found the solution to solve it, i tried to python3 setup.py build and install in research folder, after done that, i executed the code,and worked
okay, i found the solution to solve it, i tried to python3 setup.py build and install in research folder, after done that, i executed the code,and worked
So what you did? Tried to execute python3 setup.py file in research directory?
I had found the solution (MAC OS):
- https://github.com/tensorflow/models Download.
- Go to folder "research".
- Open terminal: cd Downloads/models-master/research
(for 2.7python) python setup.py build (for 3.6python) python3.6 setup.py build 5. (for 2.7python) sudo python setup.py install (for 3.6python) sudo python3.6 setup.py install 6. You'll see : "Finished processing dependencies for object-detection==0.1"
Now, you can run your .py without object_detection error.
I am facing same error. I ran the same command in windows.... python setup.py install. But It wont be work for me... Any one can please help me to figure out the solution...??
may be due to python 2 i tried the steps by @jaskierLTD in python3 environment and it worked
@jaskierLTD You are genius . Saved my day. Thanks a ton !!
@jaskierLTD my problem is solved by training with train.py script. But i am unable to run model_main.py I am getting following error:
Tensorflow/core/framework/op_kernel.cc:1261] Invalid argument: TypeError: 'int' object is not iterable Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call ret = func(*args)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 358, in first_value_func self._metrics = self.evaluate()
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 207, in evaluate self._detection_boxes_list)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_tools.py", line 134, in LoadAnnotations results.createIndex()
File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex for cat in self.dataset['categories']:
TypeError: 'int' object is not iterable
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1292, in _do_call return fn(*args) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1277, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1367, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.OutOfRangeError: End of sequence [[{{node IteratorGetNext}} = IteratorGetNextoutput_shapes=[[1], [1,300,300,3], [1,300,300,3], [1,2], [1,3], [1,100], [1,100,4], [1,100,1], [1,100,1], [1,100], [1,100], [1,100], [1]], output_types=[DT_INT32, DT_FLOAT, DT_UINT8, DT_INT32, DT_INT32, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32, DT_BOOL, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/evaluation.py", line 212, in _evaluate_once session.run(eval_ops, feed_dict) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 671, in run run_metadata=run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 1148, in run run_metadata=run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 1239, in run raise six.reraise(*original_exc_info) File "/usr/local/lib/python3.4/dist-packages/six.py", line 693, in reraise raise value File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 1224, in run return self._sess.run(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 1296, in run run_metadata=run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py", line 1076, in run return self._sess.run(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 887, in run run_metadata_ptr) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1110, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1286, in _do_run run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1308, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.OutOfRangeError: End of sequence [[{{node IteratorGetNext}} = IteratorGetNextoutput_shapes=[[1], [1,300,300,3], [1,300,300,3], [1,2], [1,3], [1,100], [1,100,4], [1,100,1], [1,100,1], [1,100], [1,100], [1,100], [1]], output_types=[DT_INT32, DT_FLOAT, DT_UINT8, DT_INT32, DT_INT32, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32, DT_BOOL, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]
Caused by op 'IteratorGetNext', defined at:
File "legacy/model_main.py", line 109, in
OutOfRangeError (see above for traceback): End of sequence [[{{node IteratorGetNext}} = IteratorGetNextoutput_shapes=[[1], [1,300,300,3], [1,300,300,3], [1,2], [1,3], [1,100], [1,100,4], [1,100,1], [1,100,1], [1,100], [1,100], [1,100], [1]], output_types=[DT_INT32, DT_FLOAT, DT_UINT8, DT_INT32, DT_INT32, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32, DT_BOOL, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1292, in _do_call return fn(*args) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1277, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 1367, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: TypeError: 'int' object is not iterable Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call ret = func(*args)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 358, in first_value_func self._metrics = self.evaluate()
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 207, in evaluate self._detection_boxes_list)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_tools.py", line 134, in LoadAnnotations results.createIndex()
File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex for cat in self.dataset['categories']:
TypeError: 'int' object is not iterable
[[{{node PyFunc_3}} = PyFunc[Tin=[], Tout=[DT_FLOAT], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "legacy/model_main.py", line 109, in
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call ret = func(*args)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 358, in first_value_func self._metrics = self.evaluate()
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 207, in evaluate self._detection_boxes_list)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_tools.py", line 134, in LoadAnnotations results.createIndex()
File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex for cat in self.dataset['categories']:
TypeError: 'int' object is not iterable
[[{{node PyFunc_3}} = PyFunc[Tin=[], Tout=[DT_FLOAT], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Caused by op 'PyFunc_3', defined at:
File "legacy/model_main.py", line 109, in
InvalidArgumentError (see above for traceback): TypeError: 'int' object is not iterable Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call ret = func(*args)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 358, in first_value_func self._metrics = self.evaluate()
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_evaluation.py", line 207, in evaluate self._detection_boxes_list)
File "/usr/local/lib/python3.4/dist-packages/object_detection-0.1-py3.4.egg/object_detection/metrics/coco_tools.py", line 134, in LoadAnnotations results.createIndex()
File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex for cat in self.dataset['categories']:
TypeError: 'int' object is not iterable
[[{{node PyFunc_3}} = PyFunc[Tin=[], Tout=[DT_FLOAT], token="pyfunc_5", _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
how do we undo this install? setup.py & start fresh?
@jaskierLTD I by mistake did python install & now I'm doing the install again with python3(which is python 3.7.3
Setup script error:
Best match: matplotlib 3.1.1
Processing matplotlib-3.1.1.tar.gz
Writing /tmp/easy_install-bgguvpba/matplotlib-3.1.1/setup.cfg
Running matplotlib-3.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-bgguvpba/matplotlib-3.1.1/egg-dist-tmp-z3w6b8sn
error: Setup script exited with
Beginning with Matplotlib 3.1, Python 3.6 or above is required.
This may be due to an out of date pip.
Make sure you have pip >= 9.0.1.
for windows user......
import sys sys.path.append("{YOU_PATH}\models-master\research") sys.path.append("{YOU_PATH}\models-master\research\object_detection\utils")
PATH_TO_LABELS = 'data/mscoco_label_map.pbtxt'
thanks to https://github.com/temiklis
@derekjchow @jaskierLTD I followed the steps (my path was right) and I did get "Finished processing dependencies for object-detection==0.1".
But when I'm trying to run the code on Google Collab, I'm still getting the same error:
Traceback (most recent call last):
File "/content/generate_tfrecord.py", line 29, in
I had found the solution (MAC OS):
- https://github.com/tensorflow/models Download.
- Go to folder "research".
- Open terminal: cd Downloads/models-master/research
(for 2.7python) python setup.py build (for 3.6python) python3.6 setup.py build 5. (for 2.7python) sudo python setup.py install (for 3.6python) sudo python3.6 setup.py install 6. You'll see : "Finished processing dependencies for object-detection==0.1"
Now, you can run your .py without object_detection error.
Where is the setup.py? setup.py file does not exist in the folder ........./models-master/research. Thanks!
I had found the solution (MAC OS):
- https://github.com/tensorflow/models Download.
- Go to folder "research".
- Open terminal: cd Downloads/models-master/research
(for 2.7python) python setup.py build (for 3.6python) python3.6 setup.py build 5. (for 2.7python) sudo python setup.py install (for 3.6python) sudo python3.6 setup.py install 6. You'll see : "Finished processing dependencies for object-detection==0.1" Now, you can run your .py without object_detection error.
Where is the setup.py? setup.py file does not exist in the folder ........./models-master/research. Thanks!
it's in ./research/object_detection/packages/tf2/ read more about it here
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'}
when I run this command than this error showing me
Traceback (most recent call last):
File "F:\Tensorflow Object Detection\Dhainik mask detection\tensorflow\scripts\generate_tfrecord.py", line 29, in
I also try to run python setup.py build in research folder but it's not working
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'} when I run this command than this error showing me Traceback (most recent call last): File "F:\Tensorflow Object Detection\Dhainik mask detection\tensorflow\scripts\generate_tfrecord.py", line 29, in from object_detection.utils import dataset_util, label_map_util ModuleNotFoundError: No module named 'object_detection'
I also try to run python setup.py build in research folder but it's not working
Hi, is your problem solved? Because I'm having the same problem and tried many ways but still couldn't solve it.
https://www.codeproject.com/Articles/5130220/Make-Your-Own-Image-Classifier-On-Android-Using-Te Try to look through this or any similar articles.
If you're sure that you have installed the object_detection module, which python(2.7 or 3.0) uses it? The most of problems are related to paths because we install all libraries for python 3 but the default python 2.7 could be used by system defaults. Check your current version with command line/terminal and try to play with directories)
On Thu, Jul 22, 2021 at 8:10 PM anisyaamimi @.***> wrote:
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'} when I run this command than this error showing me Traceback (most recent call last): File "F:\Tensorflow Object Detection\Dhainik mask detection\tensorflow\scripts\generate_tfrecord.py", line 29, in from object_detection.utils import dataset_util, label_map_util ModuleNotFoundError: No module named 'object_detection'
I also try to run python setup.py build in research folder but it's not working
Hi, is your problem solved? Because I'm having the same problem and tried many ways but still couldn't solve it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/2543#issuecomment-885074637, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISNJAIFB4E3CSUP2ZIRAQ3TZBGG3ANCNFSM4D7PIMLA .
This is probably a silly mistake on my part but I happened to have a file named object_detection.py in the same directory as the script I was running and import object_detection was trying to import that Python file. Since that file didn't have a subsequent utils module, this error showed up...