I am stuck on the ‘yolo_non_max_suppression’ function.
I wonder if I need to slice one of the input parameters for tf.image.non_max suppression() call. I have tried both boxes and boxes_labels and get similar error.
nms_indices_label = tf.image.non_max_suppression(
boxes_label, # was boxes
scores_label, # was scores
max_boxes,
iou_threshold=iou_threshold)
upstream, I set
boxes_label = tf.boolean_mask(boxes, filtering_mask)
it fails at —> 63 nms_indices.append(tf.gather(nms_indices_label, selected_indices))
and finally reports an InvalidArgumentError: indices[0] = 1 is not in [0, 1) [Op:GatherV2]
TMosh, I got the exactly same error, I think I did the same code as colinPDX, and I switch the parameter (I guess the tf.gather()) around) but it still give the same error. I am particularly confused are the following:
selected_indices = tf.squeeze(tf.where(None), axis=1) this step asks to get Get original indices of the selected boxes, but why we need to call squeez and use tf.where()? there’s no explanation in the exercise
What is the expected shape for nms_indices_label, I always got (1,), so of course when selected_indices become 1 for the second class label which is 1, the system will complain InvalidArgumentError: indices[0] = 1 is not in [0, 1) [Op:GatherV2]
selected_indices is supposed to be a 1D tensor with just the indices of the true values from filtering_mask. Try it with and without the tf.squeeze and see what difference that makes.
For the shape of nms_indices_label, it depends on how many of the entries pass the NMS test, right? That’s the point of all this. It’s hard to use the trivially sized test cases to debug your code. You don’t really see the way things work until you get to the full test case with 54 entries.
I got the error during the unit test. When I check the unit test, the argument order in the function call looks correct. There are 4 function calls in the unit test. I passed the 1st function call. I got the error during the 2nd call where the difference is only the iou_threshold (0.9 for the 1st call and 0.1 for the 2nd call). After some debugging, I solved the problem. Thanks.
What was the debugging you did exactly? I’m getting the same issue for the 2nd call (0.1), but didn’t manage to resolve the issue with the following settings:
There are a lot of other function calls within that function other than the call to the key TF function that you show. I’ve seen 5 or 6 people make the exact same mistake when they call tf.gather to select the corresponding elements that match the nms_indices_label value that is returned from the TF call there. Please find that call and carefully consider how tf.gather works: it uses the second argument as a list of indices to select the desired elements of the first argument.