Hi, I’m having a problem with yolo_eval. The problem is with the shape of the boxes. I get an error
InvalidArgumentError: boxes must be 2-D[19,19,5,1] [Op:NonMaxSuppressionV3]
This happens when I call
yolo_non_max_suppression(boxes, box_confidence, box_class_probs, iou_threshold = score_threshold)
The error is when I call
tf.image.non_max_suppresion(boxes, scores, max_boxes, iou_threshold).
I print the shape and get (19,19,5,1) but then the error says that it has to be 2-D[19,19,5,1]. I don’t really know what the problem is. The shape seems to be correct. I think I am using the correct functions with the correct arguments. All the previous tests passed and everything seems to be fine with the functions that I’m calling. Anybody got an idea what the problem is?
Any chance your object is a list instead of a matrix ? Maybe examine its type
1 Like
Hi there,
I have another student asking me about a similar error in that function. I copy here my reply:
Be careful with the line:
boxes = scale_boxes(…
Go to the original file when scale_boxes is defined in utils.py (at the notebook if you go to open and then yad2k.utils.utils, you will see where that method is defined. If you pay attention you will discover that the method is expecting an array or tuple with two elements (height, width) however image_shape is a Tensor of shape (2,0) so you need to do some manipulation of image_shape elements to pass them to scale_boxes .
Happy learning!
Rosa
1 Like
Thanks for the replies, guys! But I can’t seem to find the error. It doesn’t seem to matter whether or not I pass image_scale as the tuple that is given or as a array. Also it doesn’t seem to matter if I use .numpy() to get the tensors as arrays. I think I must be inputting the wrong values for either yolo_non_max_suppression() or for tf.image.non_max_suppression(). I’m calling with the arguments:
yolo_non_max_suppression(boxes, scores, classes, max_boxes, iou_threshold)
and then
tf.image.non_max_suppression(boxes, scores, max_boxes_tensor, iou_threshold)
I actually had accidentally been calling yolo_non_max_suppression() twice (once instead of yolo_filter_boxes()). But the same kind of problem remains for the “correct” yolo_non_max_suppression() call. Like if I print out the shapes they are correct in terms of the numbers and it doesn’t seem to matter if I use cast to arrays or keep the tensors. Don’t know . So the error I’m getting now is
InvalidArgumentError: boxes must be 2-D[1786] [Op:NonMaxSuppressionV3]
so maybe the it is (1786) but should be [1786,none] or something like that but then it doesn’t seem to matter if I change the boxes to an array before I use it as an argument in tf.image.non_max_suppression(). Anybody have any idea?
Your error is in the line before yolo_non_max_suppresion, actually the line that is producing the boxes. If you just put:
boxes = scale_boxes(boxes, image_shape)
I am afraid this is not right because image_shape is a Tensor and not a tuple. Please read my comment below to find how to fix it.
Good luck,
Rosa
Where is your comment? I can’t see it. Did you take it off? Please repost. I’m struggling with the same issue. Thanks.
Hi Tmurayi,
I have 2 comments in this thread. The comment below I mean is the first comment I did, it is all here in this page.
Hope that helps.
Good luck,
Rosa
Thank you Rosa. I tried tuple, numpy array, float for Image_shape and nothing works. So I have to be more creative I guess. Thanks anyway.
Hi Tmurayi,
Will try to give you a bit of help without telling you the solution…
image_shape has only two elements right? image_shape[0] and image_shape[1]. Now try to think in Python how to build a tuple, my_tuple= (…) with these two elements.
You are close to the solution!
Best,
Rosa
I had other issues in my code but your hint helped. Thanks.
1 Like