-
Notifications
You must be signed in to change notification settings - Fork 45.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[object detection] TypeError: can't pickle dict_values objects #4780
Comments
Were you using python2 or 3? |
I am seeing the same issue, with python 3.6 |
I'm not 100% sure but could you try with python2 ? |
If you're using python3 , add |
Thank you very much for your help, my problem is solved, I did use Python 3.5 |
I had the same problem with Python 3.6.5. I then created a Python 2.7.15 virtualenv and ran through the tf obj det installation requirements. It ran perfectly on a reasonably sized dataset (nearly 10,000 images). So clearly, this and about a half dozen other issues that I found (and others have already submitted) are all related to incompatibilities with Python 3. |
Same problem and solved with MaeThird fix. Thanks! |
got a same issue and solved with @MaeThird 's fix. Thanks! |
Solved with @MaeThird 's fix. |
@MaeThird Thanks. |
Got the same error and tried @MaeThird 's fix, but I still get the same error "TypeError: can't pickle dict_values objects". Any idea how to solve this? |
Hi Everyone,
|
I tried the fix as well. For me it is still producing the same error. I am using Python 3.6
|
I can confirm what @RocketRider said. Fix does not work... I got exactly the same error as he received. |
Closing this since there is a clear answer already. We will also fix py3 compatibility issue in future releases. Thanks! |
@RocketRider looks like you're loading |
Fixed python3 compatibility issue tensorflow#4780
|
InvalidArgumentError (see above for traceback): TypeError: can't pickle dict_values objects File "/home/dptandroid/.local/lib/python3.5/site-packages/tensorflow/python/ops/script_ops.py", line 158, in call File "/home/dptandroid/zhanjie/20181018/models/research/object_detection/metrics/coco_evaluation.py", line 346, in first_value_func File "/home/dptandroid/zhanjie/20181018/models/research/object_detection/metrics/coco_evaluation.py", line 207, in evaluate File "/home/dptandroid/zhanjie/20181018/models/research/object_detection/metrics/coco_tools.py", line 118, in LoadAnnotations File "/usr/lib/python3.5/copy.py", line 174, in deepcopy TypeError: can't pickle dict_values objects |
This doesnt seem to fix the problem |
I found it at at line 411 |
@Glomels |
thank you! it help! i used with python3.6 @MaeThird |
my problem is solved by training with train.py script. But i am unable to run model_main.py tensorflow/core/framework/op_kernel.cc:1261] Invalid argument: TypeError: 'int' object is not iterable File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call 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 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 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 File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex TypeError: 'int' object is not iterable Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Caused by op 'IteratorGetNext', defined at: OutOfRangeError (see above for traceback): End of sequence During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call 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 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 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 File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex TypeError: 'int' object is not iterable
During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call 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 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 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 File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex TypeError: 'int' object is not iterable
Caused by op 'PyFunc_3', defined at: InvalidArgumentError (see above for traceback): TypeError: 'int' object is not iterable File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in call 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 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 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 File "/usr/local/lib/python3.4/dist-packages/pycocotools/coco.py", line 106, in createIndex TypeError: 'int' object is not iterable
|
In my situation. I also had the same problem and I have changed |
@JerryZhuzq ,Thank you ,It worked me also. The reason could be as I already completed the object detection API setup i.e |
changing to list as per @MaeThird worked for me. Didn't need to do @JerryZhuzq . Using TF 1.10.1 |
Does somebody how can I fizx this on Python 3.7.6? I can't find the ´model_lib.py´ that @MaeThird pointed for Python 3.6. Thanks! My error is: Traceback (most recent call last): File "", line 1, in File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\site-packages\dill_dill.py", line 351, in dump_session File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\site-packages\dill_dill.py", line 445, in dump File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 437, in dump File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 504, in save File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\site-packages\dill_dill.py", line 1295, in save_module File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 662, in save_reduce File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 504, in save File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\site-packages\dill_dill.py", line 912, in save_module_dict File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 859, in save_dict File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 885, in _batch_setitems File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 504, in save File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\site-packages\dill_dill.py", line 912, in save_module_dict File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 859, in save_dict File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 885, in _batch_setitems File "D:\Downloads\Instaladores\WPy64-3760\python-3.7.6.amd64\lib\pickle.py", line 524, in save TypeError: can't pickle dict_items objects` |
Hello, Even i get the same issue with Python 3. TypeError Traceback (most recent call last) /databricks/spark/python/pyspark/cloudpickle.py in dumps(obj, protocol) /databricks/spark/python/pyspark/cloudpickle.py in dump(self, obj) /usr/lib/python3.7/pickle.py in dump(self, obj) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_tuple(self, obj) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /databricks/spark/python/pyspark/cloudpickle.py in save_function(self, obj, name) /databricks/spark/python/pyspark/cloudpickle.py in save_function_tuple(self, func) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_dict(self, obj) /usr/lib/python3.7/pickle.py in _batch_setitems(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_list(self, obj) /usr/lib/python3.7/pickle.py in _batch_appends(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /databricks/spark/python/pyspark/cloudpickle.py in save_function(self, obj, name) /databricks/spark/python/pyspark/cloudpickle.py in save_function_tuple(self, func) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_dict(self, obj) /usr/lib/python3.7/pickle.py in _batch_setitems(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_dict(self, obj) /usr/lib/python3.7/pickle.py in _batch_setitems(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /databricks/spark/python/pyspark/cloudpickle.py in save_function(self, obj, name) /databricks/spark/python/pyspark/cloudpickle.py in save_function_tuple(self, func) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_dict(self, obj) /usr/lib/python3.7/pickle.py in _batch_setitems(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_dict(self, obj) /usr/lib/python3.7/pickle.py in _batch_setitems(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) /usr/lib/python3.7/pickle.py in save_list(self, obj) /usr/lib/python3.7/pickle.py in _batch_appends(self, items) /usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id) TypeError: can't pickle dict_values objects During handling of the above exception, another exception occurred: PicklingError Traceback (most recent call last) /local_disk0/pythonVirtualEnvDirs/virtualEnv-e6ccc149-901a-412c-b6f3-19fe27ba5f0d/lib/python3.7/site-packages/databricks/koalas/usage_logging/init.py in wrapper(*args, **kwargs) /local_disk0/pythonVirtualEnvDirs/virtualEnv-e6ccc149-901a-412c-b6f3-19fe27ba5f0d/lib/python3.7/site-packages/databricks/koalas/series.py in apply(self, func, args, **kwds) /local_disk0/pythonVirtualEnvDirs/virtualEnv-e6ccc149-901a-412c-b6f3-19fe27ba5f0d/lib/python3.7/site-packages/databricks/koalas/typedef.py in wrapper(*args, **kwargs) /local_disk0/pythonVirtualEnvDirs/virtualEnv-e6ccc149-901a-412c-b6f3-19fe27ba5f0d/lib/python3.7/site-packages/databricks/koalas/typedef.py in _make_fun(f, return_type, *args, **kwargs) /databricks/spark/python/pyspark/sql/udf.py in wrapper(*args) /databricks/spark/python/pyspark/sql/udf.py in call(self, *cols) /databricks/spark/python/pyspark/sql/udf.py in _judf(self) /databricks/spark/python/pyspark/sql/udf.py in _create_judf(self) /databricks/spark/python/pyspark/sql/udf.py in _wrap_function(sc, func, returnType) /databricks/spark/python/pyspark/rdd.py in _prepare_for_python_RDD(sc, command) /databricks/spark/python/pyspark/serializers.py in dumps(self, obj) PicklingError: Could not serialize object: TypeError: can't pickle dict_values objects |
creating index...
index created!
2018-07-16 22:12:38.626883: W T:\src\github\tensorflow\tensorflow\core\framework
\op_kernel.cc:1306] Invalid argument: TypeError: can't pickle dict_values objects
Traceback (most recent call last):
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 158, in call
ret = func(*args)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 339, in first_value_func
self._metrics = self.evaluate()
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 193, in evaluate
self._detection_boxes_list)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_tools.py", line 118, in LoadAnnotations
results.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
File "d:\Program Files\Anaconda3\lib\copy.py", line 174, in deepcopy
rv = reductor(4)
TypeError: can't pickle dict_values objects
Traceback (most recent call last):
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1322, in _do_call
return fn(*args)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1307, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1409, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: TypeError: can't p
ickle dict_values objects
Traceback (most recent call last):
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 158, in call
ret = func(*args)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 339, in first_value_func
self._metrics = self.evaluate()
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 193, in evaluate
self._detection_boxes_list)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_tools.py", line 118, in LoadAnnotations
results.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
File "d:\Program Files\Anaconda3\lib\copy.py", line 174, in deepcopy
rv = reductor(4)
TypeError: can't pickle dict_values objects
evice="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "object_detection\model_main.py", line 101, in
tf.app.run()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\platform
app.py", line 125, in run
_sys.exit(main(argv))
File "object_detection\model_main.py", line 97, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 447, in train_and_evaluate
return executor.run()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 531, in run
return self.run_local()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 681, in run_local
eval_result, export_results = evaluator.evaluate_and_export()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 886, in evaluate_and_export
hooks=self._eval_spec.hooks)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\estimator.py", line 460, in evaluate
output_dir=self.eval_dir(name))
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\estimator.py", line 1386, in _evaluate_run
config=self._session_config)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training
evaluation.py", line 212, in _evaluate_once
session.run(eval_ops, feed_dict)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training
monitored_session.py", line 689, in exit
self._close_internal(exception_type)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training
monitored_session.py", line 721, in _close_internal
h.end(self._coordinated_creator.tf_sess)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\training
basic_session_run_hooks.py", line 824, in end
self._final_ops, feed_dict=self._final_ops_feed_dict)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 900, in run
run_metadata_ptr)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1135, in _run
feed_dict_tensor, options, run_metadata)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1316, in _do_run
run_metadata)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\se
ssion.py", line 1335, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: TypeError: can't p
ickle dict_values objects
Traceback (most recent call last):
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 158, in call
ret = func(*args)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 339, in first_value_func
self._metrics = self.evaluate()
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 193, in evaluate
self._detection_boxes_list)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_tools.py", line 118, in LoadAnnotations
results.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
File "d:\Program Files\Anaconda3\lib\copy.py", line 174, in deepcopy
rv = reductor(4)
TypeError: can't pickle dict_values objects
evice="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Caused by op 'PyFunc_1', defined at:
File "object_detection\model_main.py", line 101, in
tf.app.run()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\platform
app.py", line 125, in run
_sys.exit(main(argv))
File "object_detection\model_main.py", line 97, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 447, in train_and_evaluate
return executor.run()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 531, in run
return self.run_local()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 681, in run_local
eval_result, export_results = evaluator.evaluate_and_export()
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\training.py", line 886, in evaluate_and_export
hooks=self._eval_spec.hooks)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\estimator.py", line 453, in evaluate
input_fn, hooks, checkpoint_path)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\estimator.py", line 1348, in _evaluate_build_graph
features, labels, model_fn_lib.ModeKeys.EVAL, self.config)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\estimator
\estimator.py", line 1107, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\model_lib.py", line 383, in model_fn
include_metrics_per_category=eval_config.include_metrics_per_category)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\eval_util.py", line 629, in get_eval_metric_ops_for_evaluators
input_data_fields.groundtruth_is_crowd)))
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 349, in get_estimator_eval_me
tric_ops
first_value_op = tf.py_func(first_value_func, [], tf.float32)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 384, in py_func
func=func, inp=inp, Tout=Tout, stateful=stateful, eager=False, name=name)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 227, in _internal_py_func
input=inp, token=token, Tout=Tout, name=name)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_s
cript_ops.py", line 130, in py_func
"PyFunc", input=input, token=token, Tout=Tout, name=name)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework
\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework
\ops.py", line 3414, in create_op
op_def=op_def)
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework
\ops.py", line 1740, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-
access
InvalidArgumentError (see above for traceback): TypeError: can't pickle dict_val
ues objects
Traceback (most recent call last):
File "d:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\ops\scrip
t_ops.py", line 158, in call
ret = func(*args)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 339, in first_value_func
self._metrics = self.evaluate()
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_evaluation.py", line 193, in evaluate
self._detection_boxes_list)
File "D:\Program Files\Anaconda3\Lib\site-packages\tensorflow\models\research
object_detection\metrics\coco_tools.py", line 118, in LoadAnnotations
results.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
File "d:\Program Files\Anaconda3\lib\copy.py", line 174, in deepcopy
rv = reductor(4)
TypeError: can't pickle dict_values objects
evice="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
The text was updated successfully, but these errors were encountered: