keras-team/keras-cv

AnchorGenerator ValueError

Closed this issue · 0 comments

Current Behavior:

Calling AnchorGenerator with an image fails with a ValueError:

Traceback (most recent call last):
  File "/work/kerascv-bug/test.py", line 23, in <module>
    main()
  File "/work/kerascv-bug/test.py", line 16, in main
    anchors = ag(image=img)
  File "/work/kerascv-bug/venv/lib/python3.10/site-packages/keras_cv/src/layers/object_detection/anchor_generator.py", lin
e 179, in __call__
    results[key] = bounding_box.convert_format(
  File "/work/kerascv-bug/venv/lib/python3.10/site-packages/keras_cv/src/backend/scope.py", line 37, in wrapper
    return function(*args, **kwargs)
  File "/work/kerascv-bug/venv/lib/python3.10/site-packages/keras_cv/src/bounding_box/converters.py", line 395, in convert
_format
    _validate_image_shape(image_shape)
  File "/work/kerascv-bug/venv/lib/python3.10/site-packages/keras_cv/src/bounding_box/converters.py", line 501, in _valida
te_image_shape
    raise ValueError(
ValueError: Expected image_shape to be either a tuple, list, Tensor. Received image_shape=(416, 416, 3)

Expected Behavior:

No error.

Steps To Reproduce:

gist

Version:

  • 0.8.1

Possible fix

Changing this line to use tf.shape seem to fix the issue locally.