Autonomous_driving_application_Car_detection problems

Having problems with this lab

InvalidArgumentError Traceback (most recent call last)
in
14 assert np.array_equal(classes2.numpy(), [0, 1]), f"Wrong value on classes {classes2.numpy()}"
15
β€”> 16 scores2, boxes2, classes2 = yolo_non_max_suppression(scores, boxes, classes, iou_threshold = 0.1)
17
18 assert np.allclose(scores2.numpy(), [0.855, 0.828]), f"Wrong value on scores {scores2.numpy()}"

in yolo_non_max_suppression(scores, boxes, classes, max_boxes, iou_threshold)
55 # Append the resulting boxes into the partial result
56 # Use tf.gather() with β€˜selected_indices’ and nms_indices_label
β€”> 57 nms_indices.append(tf.gather(nms_indices_label, selected_indices))
58
59 # Flatten the list of indices and concatenate

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.β€β€œβ€
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in gather_v2(params, indices, validate_indices, axis, batch_dims, name)
4693 name=name,
4694 axis=axis,
β†’ 4695 batch_dims=batch_dims)
4696
4697

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.β€β€œβ€
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in gather(failed resolving arguments)
4676 return params.sparse_read(indices, name=name)
4677 except AttributeError:
β†’ 4678 return gen_array_ops.gather_v2(params, indices, axis, name=name)
4679
4680

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py in gather_v2(params, indices, axis, batch_dims, name)
3843 return _result
3844 except _core._NotOkStatusException as e:
β†’ 3845 _ops.raise_from_not_ok_status(e, name)
3846 except _core._FallbackException:
3847 pass

/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
6841 message = e.message + (" name: " + name if name is not None else β€œβ€)
6842 # pylint: disable=protected-access
β†’ 6843 six.raise_from(core._status_to_exception(e.code, message), None)
6844 # pylint: enable=protected-access
6845

/opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value)

InvalidArgumentError: indices[0] = 1 is not in [0, 1) [Op:GatherV2]

It appears there is an error in the code you added to yolo_non_max_suppression().

As numbered in your error log, at line 57 the order of the arguments is backwards.

1 Like

I tried it the other way and it gives me the same error.


InvalidArgumentError Traceback (most recent call last)
in
8 print(f"iou: \t{iou(boxes[0], boxes[1])}β€œ)
9
β€”> 10 scores2, boxes2, classes2 = yolo_non_max_suppression(scores, boxes, classes, iou_threshold = 0.9)
11
12 assert np.allclose(scores2.numpy(), [0.855, 0.828]), f"Wrong value on scores {scores2.numpy()}”

in yolo_non_max_suppression(scores, boxes, classes, max_boxes, iou_threshold)
55 # Append the resulting boxes into the partial result
56 # Use tf.gather() with β€˜selected_indices’ and nms_indices_label
β€”> 57 nms_indices.append(tf.gather( selected_indices, nms_indices_label))
58
59 # Flatten the list of indices and concatenate

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.β€β€œβ€
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in gather_v2(params, indices, validate_indices, axis, batch_dims, name)
4693 name=name,
4694 axis=axis,
β†’ 4695 batch_dims=batch_dims)
4696
4697

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.β€β€œβ€
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in gather(failed resolving arguments)
4676 return params.sparse_read(indices, name=name)
4677 except AttributeError:
β†’ 4678 return gen_array_ops.gather_v2(params, indices, axis, name=name)
4679
4680

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py in gather_v2(params, indices, axis, batch_dims, name)
3843 return _result
3844 except _core._NotOkStatusException as e:
β†’ 3845 _ops.raise_from_not_ok_status(e, name)
3846 except _core._FallbackException:
3847 pass

/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
6841 message = e.message + (" name: " + name if name is not None else β€œβ€)
6842 # pylint: disable=protected-access
β†’ 6843 six.raise_from(core._status_to_exception(e.code, message), None)
6844 # pylint: enable=protected-access
6845

/opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value)

InvalidArgumentError: indices[1] = 1 is not in [0, 1) [Op:GatherV2]

I figured it out. Thanks for the help

Nice work!