Open Inshu32 opened 11 months ago
I am having a similar (maybe equal) problem with keras_cv.metrics.BoxCOCOMetrics().
The problem happens in the call self.metrics.result(force=True) and it would run properly in the keras_cv==0.5.1
reproducing the tutorial in keras yolov8 detection
+1 to this issue. @luisliborio you seem to be right. The issue happens on the call to self.metrics.results
. I am currently using keras_cv==0.6.4. It seems that BoxCOCOMetrics.result requires the bounding_box
tensor to be dense
. I have changed the dict_to_tuple
function to
def dict_to_tuple(inputs):
return inputs["images"], bounding_box.to_dense(
inputs["bounding_boxes"], max_boxes=32
)
However it is not clear to me how changing the bounding_box
tensor from ragged
to dense
affects training if at all.
EDIT: I tried running my code with keras-cv==0.5.1
using the original dict_to_tuple
function as well as the one I posted above. When using the original dict_to_tuple
with keras-cv==0.5.1
it works. If I use the version I posted above, I get the same error.
@LukeWood's tutorial on Object Detection with KerasCV highlights the use of dense
tensors but only necessary when using TPU's. As a matter of fact, he uses the BoxCOCOMetrics as an argument during the model compilation when on GPU. However the YoloV8Detector does not support adding a metric as an argument.
@LukeWood does converting a ragged
tensor to a dense
affect training and/or inference? Also can you take a look at the issue that is being described above? Thank you!
I still donot understand that what should I do to make to resolve the callback metric issue. Surprisingly, it is only arising when there are multiple bounding boxes in the labelled dataset. When I changed my data and used only single bounding box per image, its not giving the concat error.
I still donot understand that what should I do to make to resolve the callback metric issue. Surprisingly, it is only arising when there are multiple bounding boxes in the labelled dataset. When I changed my data and used only single bounding box per image, its not giving the concat error.
So you have two options:
dict_to_tupl
function will work.dict_to_tuple
function that I posted above, ie, convert the ragged tensor to dense.I was having a similar error, using keras-cv 0.8.2.
My understanding is that the issue is not multiple boxes in an image, but the concatenation of boxes for multiple images in a batch.
In the code for box_coco_metrics.py
the _box_concat()
function has the following line:
for key in ["boxes", "classes"]:
result[key] = tf.concat([b[key] for b in boxes], axis=0)
I think that should be axis=1
because that's the dimension for the number of boxes.
Discussed in https://github.com/keras-team/keras-cv/discussions/2126