Here is my thought. (Even without pasted code, I suppose we can guess the bug which was there…)
Incompatible shapes: [19,19,5,4] vs. [19,19,5,80] [Op:Mul]
From the error message, we can understand that the shape of the first parameter and that of the 2nd parameter are different. Then, “multiplication” can not be executed.
From a logical flow, the error must be at box_scores calculation in yolo_filter_boxes(). As there are 80 classes in YOLO, the 2nd parameter must be “box_class_probs”. There is no possibility that the first parameter has the same shape, there are a few cases that this multiplication works. For example, if the shape of the first parameter is [19,19,5,1], it can be “boardcasted” to [19,19,5,80] and works.
So, the problem is where [19,19,5,4] comes ? It must be the shape of “boxes”. Now I reached to the same conclusion as Tom. You passed “boxes” at the 2nd position of arguments.
can you explain why the order of parameters matters here?
I see some confusion about arguments even in the pasted code. Let"s see yolo_filter_boxes().
def yolo_filter_boxes(boxes, box_confidence, box_class_probs, threshold = .6):
It takes 4 parameters. And, threshold has a default value, which is used when a caller does not specify “threshold”.
How the computer identifies which is which ? There is a clear definition how to pass arguments in Python.
The essential augment types are;
- Positional arguments
- Keyword arguments
If you specify arguments exactly same order as a target function, then, a computer can understand what those are. That’s “Positional arguments”.
If you are difficult to set arguments exactly same as a target function, you can specify like box_confidence=a, box_class_probs=b, boxes=c,… These are “Keyword arguments”
Either is fine. But, in your case, you tried to use “Positional arguments”, but the order was wrong.
Then, next question may be "Can we use both in a single line ? The answer is Yes, but with restrictions. Position arguments can not be put after Keyword arguments.
Strictly speaking, there are other argument types like *args and **kwargs. But, I do not touch those at this time. “Default arguments” is another type of argument that has a default value. This is “threshold” in the case of yolo_filter_boxes().
Hope this clarifies.
By the way, you seem to override “threshold” value when you call yolo_filter_boxes(). You need to set a correct value which is actually passed from a caller. This may pass a particular test unexpectedly, but, if a test program changes threshold value, then, your code does not work due to this overriding.