Skip to content

Make bounding box operators consistent #9142

Closed

Description

@Panaetius

Right now, the bounding box operators (tf.image.draw_bounding_boxes, tf.image.non_max_suppression and tf.image.sample_distorted_bounding_box) expect bounding boxes in the form of [ymin, xmin, ymax, xmax], with the origin (0,0) being the lower left corner of the image. But images themselves are tensors, and the pixel with index [0,0] in the tensor is in the top left, so bounding box coordinates are the opposite in the y direction to tensor indices.

Additionally, the operations tf.image.pad_to_bounding_box and tf.image.crop_to_bounding_box take coordinates in the form of [ymin, xmin, height, width], with the origin being the top-left corner, so the coordinates are inconsistent even within the image ops themselves (plus the parametrization of the bounding boxes is different, too).

And the tf.image.crop_and_resize op doesn't specify what origin it uses (though I think it's bottom left too)

I feel like this sort of inconsistency is unnecessarily confusing and a high risk for introducing errors.

It's especially bad since, if you supply bounding boxes the wrong way around to draw_bounding_boxes, it'll still draw them correctly (

All bounding box operators should use the same coordinate system and preferably the same parametrization, and preferably the coordinates should be consistent with image tensor indexing.

Activity

  1. added
    stat:awaiting tensorflower
    on Apr 11, 2017
  2. asimshankar commented on Apr 11, 2017

    @asimshankar
    Contributor

    @shlens : Do you have any thoughts about this?

  3. shlens commented on Apr 11, 2017

    @shlens
    Contributor

    I think this is a great proposal. It would be great to aim for a consistent API with regard to bounding box coordinates. I suspect that the default origin of top-left corner would make sense but I am open to suggestions.

    If we do agree upon this then, we would need to update the API for tf.image.draw_bounding_boxes, tf.image.non_max_suppression and tf.image.sample_distorted_bounding_box in a manner that avoids (silently) breaking all users.

  4. tensorflowbutler commented on Dec 22, 2017

    @tensorflowbutler
    Member

    It has been 14 days with no activity and the awaiting tensorflower label was assigned. Please update the label and/or status accordingly.

  5. added
    API review
    and removed
    stat:awaiting tensorflower
    on Dec 22, 2017
  6. tensorflowbutler commented on Jan 6, 2018

    @tensorflowbutler
    Member

    Nagging Assigneee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

  7. asimshankar commented on Jan 8, 2018

    @asimshankar
    Contributor

    Marking this as "Contributions Welcome" in case someone wants to pick this up (and any API changes can be reviewed in the pull request). Thanks.

  8. added
    stat:contribution welcome
    type:feature
    and removed
    API review
    type:feature
    on Jan 8, 2018
  9. github-actions commented on Mar 28, 2023

    @github-actions

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

  10. added
    stale
    on Mar 28, 2023
  11. github-actions commented on Mar 29, 2024

    @github-actions

    This issue was closed because it has been inactive for 1 year.

  12. google-ml-butler commented on Mar 29, 2024

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stalestat:contribution welcometype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions