google-coral / tutorials

Colab/Jupyter tutorials about training TensorFlow models for Edge TPU, and other tutorials
Apache License 2.0
181 stars 39 forks source link

Retrain SSDLite MobileDet detector for the Edge TPU (TF1) error with NotImplementedError #20

Closed taro-ishihara closed 2 years ago

taro-ishihara commented 2 years ago

Description

I tried tutorial "Retrain SSDLite MobileDet detector for the Edge TPU (TF1)" and exec python3 object_detection/model_main.py and then an error has occurred with message "NotImplementedError: Cannot convert a symbolic Tensor (cond_2/strided_slice:0) to a numpy array.".

I have not changed anything from the sample, and I use just GoogleColab. Any ideas?

Click to expand! ### Issue Type Build/Install ### Operating System Mac OS ### Coral Device _No response_ ### Other Devices _No response_ ### Programming Language Python 3.7 ### Relevant Log Output ```shell Traceback (most recent call last): File "object_detection/model_main.py", line 108, in tf.app.run() File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 312, in run _run_main(main, args) File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 258, in _run_main sys.exit(main(argv)) File "object_detection/model_main.py", line 104, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate return executor.run() File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/training.py", line 613, in run return self.run_local() File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/training.py", line 714, in run_local saving_listeners=saving_listeners) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/estimator.py", line 370, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/estimator.py", line 1161, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/estimator.py", line 1188, in _train_model_default input_fn, ModeKeys.TRAIN)) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/estimator.py", line 1025, in _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) File "/tensorflow-1.15.2/python3.7/tensorflow_estimator/python/estimator/estimator.py", line 1116, in _call_input_fn return input_fn(**kwargs) File "/content/models/research/object_detection/inputs.py", line 764, in _train_input_fn params=params) File "/content/models/research/object_detection/inputs.py", line 907, in train_input reduce_to_frame_fn=reduce_to_frame_fn) File "/content/models/research/object_detection/builders/dataset_builder.py", line 252, in build input_reader_config) File "/content/models/research/object_detection/builders/dataset_builder.py", line 237, in dataset_map_fn fn_to_map, num_parallel_calls=num_parallel_calls) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/util/deprecation.py", line 324, in new_func return func(*args, **kwargs) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/data/ops/dataset_ops.py", line 1950, in map_with_legacy_function use_legacy_function=True)) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/data/ops/dataset_ops.py", line 3472, in __init__ use_legacy_function=use_legacy_function) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/data/ops/dataset_ops.py", line 2689, in __init__ self._function.add_to_graph(ops.get_default_graph()) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/function.py", line 545, in add_to_graph self._create_definition_if_needed() File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/function.py", line 377, in _create_definition_if_needed self._create_definition_if_needed_impl() File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/function.py", line 408, in _create_definition_if_needed_impl capture_resource_var_by_value=self._capture_resource_var_by_value) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/function.py", line 944, in func_graph_from_py_func outputs = func(*func_graph.inputs) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/data/ops/dataset_ops.py", line 2681, in wrapper_fn ret = _wrapper_helper(*args) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/data/ops/dataset_ops.py", line 2652, in _wrapper_helper ret = autograph.tf_convert(func, ag_ctx)(*nested_args) File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/autograph/impl/api.py", line 237, in wrapper raise e.ag_error_metadata.to_exception(e) NotImplementedError: in converted code: /content/models/research/object_detection/data_decoders/tf_example_decoder.py:580 decode default_groundtruth_weights) /tensorflow-1.15.2/python3.7/tensorflow_core/python/util/deprecation.py:507 new_func return func(*args, **kwargs) /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/control_flow_ops.py:1235 cond orig_res_f, res_f = context_f.BuildCondBranch(false_fn) /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/control_flow_ops.py:1061 BuildCondBranch original_result = fn() /content/models/research/object_detection/data_decoders/tf_example_decoder.py:573 default_groundtruth_weights dtype=tf.float32) /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py:2560 ones output = _constant_if_small(one, shape, dtype, name) /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py:2295 _constant_if_small if np.prod(shape) < 1000: <__array_function__ internals>:6 prod /usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py:3052 prod keepdims=keepdims, initial=initial, where=where) /usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py:86 _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) /tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py:736 __array__ " array.".format(self.name)) NotImplementedError: Cannot convert a symbolic Tensor (cond_2/strided_slice:0) to a numpy array. ```
hjonnala commented 2 years ago

Hello @taro-ishihara can you please try the colab with pycocotools installation (! pip install pycocotools==2.0.0). Thanks!

taro-ishihara commented 2 years ago

hi @jjonnala I have tried to implement your advice now, but the situation did not change anything. Because this line (! apt-get install protobuf-compiler) automatically install pycocotools 2.0.0. Thanks.

Then I tried downgrading and upgrading numpy.

taro-ishihara commented 2 years ago

OK, finally I solved this issue. Numpy downgrading AND pycocotools installation is needed.

! pip install -U numpy==1.19.5
! pip install -U pycocotools==2.0.0

Thanks, @hjonnala

google-coral-bot[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No