tensorflow / tensorflow/models
ValueError: Tensor's shape (1, 1, 128, 36) is not compatible with supplied shape (1, 1, 128, 42)
@srjoglekar246 is already working on this.
Since Apr 12, 2021.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- I am using the latest TensorFlow Model Garden release and TensorFlow 2.
- I am reporting the issue to the correct repository. (Model Garden official or research directory)
- I checked to make sure that this issue has not already been filed.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/tree/master/research/object_detection
2. Describe the bug
Running the program exprt_tflite_graph_tf2.py I got the following message:
ValueError: Tensor's shape (1, 1, 128, 36) is not compatible with supplied shape (1, 1, 128, 42)
3. Steps to reproduce
I tried to generate a tflite version of an ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu_8 trained for my applcation.
1 - I started running model_main_tf2.py for training.
2 - I generated the saved_model using exporter_main_v2.py and tested. It worked.
3 _ Then I ran export_tflite_graph_tf2.py and got the error.
4. Expected behavior
Obtain a saved_model to be converted to tflite format.
5. Additional context
python ~/tf2/models/research/object_detection/export_tflite_graph_tf2.py --pipeline_config_path pipeline.config --trained_checkpoint_dir models/train-21-04-06 --output_directory models\train-21-04-06\tflite
2021-04-07 10:45:57.607822: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-04-07 10:45:59.237727: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-04-07 10:45:59.238360: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-04-07 10:45:59.266212: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.266453: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GT 730 computeCapability: 3.5
coreClock: 0.9015GHz coreCount: 2 deviceMemorySize: 1.95GiB deviceMemoryBandwidth: 13.41GiB/s
2021-04-07 10:45:59.266475: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-04-07 10:45:59.268437: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-04-07 10:45:59.268480: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-04-07 10:45:59.269653: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-04-07 10:45:59.269849: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-04-07 10:45:59.271179: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-04-07 10:45:59.271681: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2021-04-07 10:45:59.271785: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-04-07 10:45:59.271883: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.272189: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.272491: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-04-07 10:45:59.272791: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-04-07 10:45:59.273039: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-04-07 10:45:59.273123: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.273336: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GT 730 computeCapability: 3.5
coreClock: 0.9015GHz coreCount: 2 deviceMemorySize: 1.95GiB deviceMemoryBandwidth: 13.41GiB/s
2021-04-07 10:45:59.273353: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-04-07 10:45:59.273374: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-04-07 10:45:59.273390: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-04-07 10:45:59.273406: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-04-07 10:45:59.273422: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-04-07 10:45:59.273437: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-04-07 10:45:59.273453: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2021-04-07 10:45:59.273469: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-04-07 10:45:59.273523: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.273758: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.273952: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-04-07 10:45:59.273977: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-04-07 10:45:59.649971: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-04-07 10:45:59.650001: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0
2021-04-07 10:45:59.650010: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N
2021-04-07 10:45:59.650182: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.650439: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.650648: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-07 10:45:59.650834: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1418 MB memory) -> physical GPU (device: 0, name: GeForce GT 730, pci bus id: 0000:01:00.0, compute capability: 3.5)
Traceback (most recent call last):
File "/home/dantas/tf2/models/research/object_detection/export_tflite_graph_tf2.py", line 161, in
app.run(main)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/home/dantas/tf2/models/research/object_detection/export_tflite_graph_tf2.py", line 154, in main
export_tflite_graph_lib_tf2.export_tflite_model(
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/export_tflite_graph_lib_tf2.py", line 366, in export_tflite_model
concrete_function = detection_module.inference_fn.get_concrete_function(
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 1299, in get_concrete_function
concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 1205, in _get_concrete_function_garbage_collected
self._initialize(args, kwargs, add_initializers_to=initializers)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 725, in _initialize
self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2969, in _get_concrete_function_internal_garbage_collected
graph_function, _ = self._maybe_define_function(args, kwargs)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3361, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3196, in _create_graph_function
func_graph_module.func_graph_from_py_func(
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 990, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 634, in wrapped_fn
out = weak_wrapped_fn().wrapped(*args, **kwds)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3887, in bound_method_wrapper
return wrapped_fn(*args, **kwargs)
File "/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 977, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/export_tflite_graph_lib_tf2.py:170 inference_fn *
predicted_tensors = self._model.predict(image, true_image_shapes=None)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/meta_architectures/ssd_meta_arch.py:591 predict *
predictor_results_dict = self._box_predictor(feature_maps)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/core/box_predictor.py:202 call *
return self._predict(image_features, **kwargs)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/predictors/convolutional_keras_box_predictor.py:484 _predict *
prediction = head_obj(head_tower_feature)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/predictors/heads/head.py:69 call *
return self._predict(features)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/object_detection/predictors/heads/keras_class_head.py:342 _predict *
class_predictions_with_background = layer(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1008 __call__ **
self._maybe_build(inputs)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:2710 _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/layers/convolutional.py:1820 build
self.pointwise_kernel = self.add_weight(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:623 add_weight
variable = self._add_variable_with_custom_getter(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py:805 _add_variable_with_custom_getter
new_variable = getter(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py:130 make_variable
return tf_variables.VariableV1(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:260 __call__
return cls._variable_v1_call(*args, **kwargs)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:206 _variable_v1_call
return previous_getter(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:67 getter
return captured_getter(captured_previous, **kwargs)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py:712 variable_capturing_scope
v = UnliftedInitializerVariable(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:264 __call__
return super(VariableMetaclass, cls).__call__(*args, **kwargs)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py:227 __init__
initial_value = initial_value()
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py:81 __call__
return CheckpointInitialValue(
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py:117 __init__
self.wrapped_value.set_shape(shape)
/home/dantas/anaconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/framework/ops.py:1215 set_shape
raise ValueError(
ValueError: Tensor's shape (1, 1, 128, 36) is not compatible with supplied shape (1, 1, 128, 42)
6. System information
- OS Platform and Distribution: Linux Ubuntu 20.04
- TensorFlow installed from binary using pip
- TensorFlow version: 2.4.1
- Python version: 3.8.5
- CUDA/cuDNN version: cuda-11.0
- GPU model and memory: GeForce GT 730 1.95 Gb
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.