Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bounding_box.to_ragged() fails with keras 3. #2403

Closed
smitlg opened this issue Mar 22, 2024 · 3 comments
Closed

bounding_box.to_ragged() fails with keras 3. #2403

smitlg opened this issue Mar 22, 2024 · 3 comments

Comments

@smitlg
Copy link
Contributor

smitlg commented Mar 22, 2024

Steps to reproduce:

>>> bounding_boxes
{'classes': <tf.RaggedTensor [[5.0], [5.0, 5.0], [4.0, 5.0], [5.0, 5.0, 5.0, 5.0]]>,
 'boxes': <tf.RaggedTensor [[[331.08414, 0.0, 537.0, 56.885612]],
  [[283.4905, 132.49506, 349.13153, 318.0734],
   [217.2055, 164.95471, 295.0306, 338.5343]] ,
  [[305.12332, 426.07184, 640.0, 640.0],
   [307.50845, 517.3163, 334.21893, 582.8346]],
  [[244.3948, 0.0, 423.6596, 349.30737],
   [433.71707, 0.0, 479.48785, 26.02331],
   [310.58087, 0.0, 347.29642, 48.72561],
   [164.48027, 0.0, 282.78375, 236.52121]]]>}
>>> b_dense = bounding_box.to_dense(bounding_boxes)
>>> b_dense
{'classes': <tf.Tensor: shape=(4, 4), dtype=float32, numpy=
 array([[ 5., -1., -1., -1.],
        [ 5.,  5., -1., -1.],
        [ 4.,  5., -1., -1.],
        [ 5.,  5.,  5.,  5.]], dtype=float32)>,
 'boxes': <tf.Tensor: shape=(4, 4, 4), dtype=float32, numpy=
 array([[[331.08414 ,   0.      , 537.      ,  56.885612],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ]],
 
        [[283.4905  , 132.49506 , 349.13153 , 318.0734  ],
         [217.2055  , 164.95471 , 295.0306  , 338.5343  ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ]],
 
        [[305.12332 , 426.07184 , 640.      , 640.      ],
         [307.50845 , 517.3163  , 334.21893 , 582.8346  ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ],
         [ -1.      ,  -1.      ,  -1.      ,  -1.      ]],
 
        [[244.3948  ,   0.      , 423.6596  , 349.30737 ],
         [433.71707 ,   0.      , 479.48785 ,  26.02331 ],
         [310.58087 ,   0.      , 347.29642 ,  48.72561 ],
         [164.48027 ,   0.      , 282.78375 , 236.52121 ]]], dtype=float32)>}
>>> b_ragged = bounding_box.to_ragged(b_dense)
NotImplementedError                       Traceback (most recent call last)
[<ipython-input-23-a99e42282bd8>](https://localhost:8080/#) in <cell line: 1>()
----> 1 b_ragged = bounding_box.to_ragged(b_dense)
      2 b_ragged

[/usr/local/lib/python3.10/dist-packages/keras_cv/bounding_box/to_ragged.py](https://localhost:8080/#) in to_ragged(bounding_boxes, sentinel, dtype)
     55     """
     56     if backend.supports_ragged() is False:
---> 57         raise NotImplementedError(
     58             "`bounding_box.to_ragged` was called using a backend which does "
     59             "not support ragged tensors. "

NotImplementedError: `bounding_box.to_ragged` was called using a backend which does not support ragged tensors. Current backend: tensorflow.

Keras Info:

>>> keras.version(), keras.backend.backend()
('3.1.1', 'tensorflow')

Keras CV is installed using the current master branch.

@sachinprasadhs
Copy link
Collaborator

RaggedTensor is not yet implemented yet, in future Keras team is planning to support it only for TensorFlow backend, till then you can refer the suggestion here to use dynamic input keras-team/keras#18414 (comment)

Copy link

github-actions bot commented Apr 6, 2024

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Apr 6, 2024
Copy link

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants