Yolo car detection -> yolo_eval

Hello everyone.

I passed all the previous steps, except for the yolo_eval part.

I have no clue what is wrong with my code.

And here is the error I got.

There is probably an error in your code for box_class_scores.

Note that it is “throwing” about the shapes on the >= comparison. The RHS of that comparison is a scalar, right? The value (threshold) is passed to you as an argument (parameter) and you shouldn’t need to mess with it. But it appears you have turned it into a 5D tensor with dimensions (1,19,19,5,4). So how could that happen?

FWIW I put in some print statements in my code to show the shapes of things here and this is what I see:

box_scores.shape (19, 19, 5, 80)
box_scores.dtype <dtype: 'float32'>
box_classes.shape (19, 19, 5)
box_classes.dtype <dtype: 'int64'>
box_class_scores.shape (19, 19, 5)
box_class_scores.dtype <dtype: 'float32'>
scores[2] = 9.270486
boxes[2] = [ 4.6399336  3.2303846  4.431282  -2.202031 ]
classes[2] = 8
scores.shape = (1789,)
boxes.shape = (1789, 4)
classes.shape = (1789,)
 All tests passed!

I ran into a similar error while implementing yolo_eval:

But my error is in the multiplication of box_confidence and box_class_probs.

Please help.

1 Like

Turns out that the pre-defined function named yolo_boxes_to_corners(box_xy, box_wh) changes the shape to (19,19,5,4), which cannot be multiplied with a tensor of shape (19,19,5,80).

How do I stop this from happening?

The problem is caused by the fact that you are invoking yolo_filter_boxes incorrectly. Compare your invocation of that function with the function definition.

It looks like you might be working with an old solution from the previous version of the course. They changed the definition of several of the APIs in the April 2021 reissue of the courses. You can’t just blindly copy old solutions: you have to look carefully at the definitions. And if got this problem because you’re copying other people’s solutions, then you got what you deserve. :nerd_face:

Yikes!

I tend to learn by working backwards and analysing code line by line and comparing results. I apologise if this is an incorrect or illegal approach.

I will recheck my work and make sure to correct the required function definitions.

Thanks,
Shreyas

That’s a perfectly legal approach as long as the code you are looking at and analyzing was written by you, not something you got from someone else. The reason for asking the question is that the mistake you made is something that was the way it was in the old version of the course (before April 2021, aka more than a year ago), so I was just wondering how that happened. :nerd_face:

Thank you, sir. I will learn from this experience and won’t repeat it in the future assignments. :grin:

I am grateful for you and this community.