automl
automl copied to clipboard
Unable to export model with batch size > 1
Bug:
I was unable to export a model with batch size of 2. Batch sizes of 0 and 1 can be exported, but it seems like there is a bug when trying to export a model with a batch size > 1.
Repro steps:
- Open tutorial notebook in colab.
- Run the 0.1 cells.
- Create a new cell and run the readme commands to export the model, but with batch size set to 2
!rm -rf savedmodeldir
!python model_inspect.py --runmode=saved_model --model_name=efficientdet-d0 \
--ckpt_path=efficientdet-d0 --saved_model_dir=savedmodeldir \
--batch_size=2
Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1654, in _create_c_op
c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 2 and 100 for '{{node mul_9}} = Mul[T=DT_FLOAT](range_2, ones_like)' with input shapes: [2], [2,100].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "model_inspect.py", line 490, in <module>
app.run(main)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "model_inspect.py", line 483, in main
trace_filename=FLAGS.trace_filename)
File "model_inspect.py", line 436, in run_model
self.export_saved_model(**config_dict)
File "model_inspect.py", line 146, in export_saved_model
driver.build()
File "/content/automl/efficientdet/inference.py", line 501, in build
detections = det_post_process(params, class_outputs, box_outputs, scales)
File "/content/automl/efficientdet/inference.py", line 270, in det_post_process
img_ids * tf.ones_like(nms_scores),
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py", line 984, in binary_op_wrapper
return func(x, y, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py", line 1283, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 6092, in mul
"Mul", x=x, y=y, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 744, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3327, in _create_op_internal
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1817, in __init__
control_input_ops, op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1657, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 2 and 100 for '{{node mul_9}} = Mul[T=DT_FLOAT](range_2, ones_like)' with input shapes: [2], [2,100].