tensorflow / models

Models and examples built with TensorFlow
Other
77k stars 45.79k forks source link

[DeepLab]: Error: 'dict_items' object does not support indexing #3793

Closed esksw4 closed 6 years ago

esksw4 commented 6 years ago

Python: python3.6 TensorFlow: GPU Version

When I type: $ python deeplab/model_test.py from models/research, I get following error:

E...

ERROR: testBuildDeepLabv2 (main.DeeplabModelTest)

Traceback (most recent call last): File "deeplab/model_test.py", line 71, in testBuildDeepLabv2 inputs, model_options, image_pyramid=image_pyramid) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 289, in multi_scale_logits fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 454, in _get_logits fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 357, in _extract_features fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 227, in extract_features final_endpoint=final_endpoint) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 262, in network_fn return func(preprocess_function(inputs), *args, *kwargs) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 65, in _mobilenet_v2 scope=scope) File "/home/computer/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args return func(args, **current_args) File "/home/computer/Documents/SBIR/TensorFlow/models/research/slim/nets/mobilenet/mobilenet.py", line 198, in mobilenet_base _set_arg_scope_defaults(conv_defs_defaults), \ File "/home/computer/anaconda3/envs/tensorflow/lib/python3.6/contextlib.py", line 81, in enter return next(self.gen) File "/home/computer/Documents/SBIR/TensorFlow/models/research/slim/nets/mobilenet/mobilenet.py", line 90, in _set_arg_scope_defaults func, default_arg = items[0] TypeError: 'dict_items' object does not support indexing

====================================================================== ERROR: testForwardpassDeepLabv3plus (main.DeeplabModelTest)

Traceback (most recent call last): File "deeplab/model_test.py", line 105, in testForwardpassDeepLabv3plus image_pyramid=[1.0]) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 289, in multi_scale_logits fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 454, in _get_logits fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/model.py", line 357, in _extract_features fine_tune_batch_norm=fine_tune_batch_norm) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 227, in extract_features final_endpoint=final_endpoint) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 262, in network_fn return func(preprocess_function(inputs), *args, *kwargs) File "/home/computer/Documents/SBIR/TensorFlow/models/research/deeplab/core/feature_extractor.py", line 65, in _mobilenet_v2 scope=scope) File "/home/computer/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args return func(args, **current_args) File "/home/computer/Documents/SBIR/TensorFlow/models/research/slim/nets/mobilenet/mobilenet.py", line 198, in mobilenet_base _set_arg_scope_defaults(conv_defs_defaults), \ File "/home/computer/anaconda3/envs/tensorflow/lib/python3.6/contextlib.py", line 81, in enter return next(self.gen) File "/home/computer/Documents/SBIR/TensorFlow/models/research/slim/nets/mobilenet/mobilenet.py", line 90, in _set_arg_scope_defaults func, default_arg = items[0] TypeError: 'dict_items' object does not support indexing


Ran 5 tests in 7.630s

FAILED (errors=2)

Can anybody identify the solution for this?

esksw4 commented 6 years ago

nevermind, I fixed it.

sunzhcas commented 6 years ago

@esksw4 I meet the same problem, can you tell me how to solve this problem? Than you very much!

Johnson-yue commented 6 years ago

@sunzhcas hi, I also meet the same problem, and I fixed it. Because of difference between python2 and python3, so in python3 if you using following code it will be error a = {key1:value1, key2:value2} key = a.keys() print(key[0]) You can using this to fix it: a = {key1:value1, key2:value2} key = list(a.keys()) print(key[0])

cannguyen275 commented 6 years ago

Hi @esksw4 , How can u fix this? I have the same problem.

cannguyen275 commented 6 years ago

For anyone in the future facing with this error, In nets/mobilenet/mobilenet.py line 90, before func, default_arg = items[0], add items = list(items)