To sum up, I think this is a limitation right now, because as it does work for colors, so it should work for texts across bounding boxes. I could not spot a limitation that would force only one text display per image.
If you also agree, I would volunteer to help with a fix attempt @yongtang @terrytangyuan
DrawBoundingBoxesV3Op
can essentially only draw one text output per imageI think this issue got first mentioned in https://github.com/tensorflow/io/issues/1088.
However, it got labelled as an enhancement, though it looks more like an imposed limitation in the implementation as it currently is.
A simple example that works is having a single box inside a single image, with a single color code and a single text output:
We already know from
tensorflow/io/tensorflow_io/core/kernels/image_font_kernels.cc
that there is no point in trying without a batch dimension, as there is a check for the image rank to be 4:This is also what the https://github.com/tensorflow/io/pull/254 PR by @yongtang that added this feature demonstrates as well
It's also spiritually the same as the one test available in the code at
tensorflow/io/tests/test_image.py
Now, still within a batch size of 1 (one image), we could have more boxes, each with their own text labels and colors, but this does not work:
batch sizes should be the same
refers to the batch size of images and texts, which required intensorflow/io/tensorflow_io/core/kernels/image_font_kernels.cc
:Yet, interestingly, not required for colors....
Okay, then let's try to make the shape batch size fit the image batch size, as the OP requires:
But then we hit this error:
The rank of the texts tensor should be 1
is required by another op:tensorflow/io/tensorflow_io/core/kernels/image_font_kernels.cc
:But does it work for colors only, no text? Yes
To sum up, I think this is a limitation right now, because as it does work for colors, so it should work for texts across bounding boxes. I could not spot a limitation that would force only one text display per image.
If you also agree, I would volunteer to help with a fix attempt @yongtang @terrytangyuan
Here is a link to the demo notebook with the above cells: https://colab.research.google.com/drive/1rSder84urmOGF21rtWGb7TDEu-7zq1MP?usp=sharing