vision icon indicating copy to clipboard operation
vision copied to clipboard

Add BoundingBoxes class information

Open MaKaNu opened this issue 1 year ago • 6 comments

🚀 The feature

Another meta field which includes the index of the corresponding class of the BoudingBox.

Motivation, pitch

At the moment, I need to carry the class indices of the BoundingBoxes separate. This leads to the issue, that I need to carry it around everywhere I need to access the bbox.

Additional when creating a BBox the class creation method (init/new?) can guard against wrong shapes, if this optional feature is used.

Alternatives

No response

Additional context

No response

MaKaNu avatar Jan 09 '25 11:01 MaKaNu

@NicolasHug I don't actually know who to ask, but what is the right approach to a bot implementation like the above?

MaKaNu avatar Jan 09 '25 13:01 MaKaNu

Can you just pass tuples like (BoundingBox, class_index)? Or even a dict or anything. The index is an int and would be passed-through by the transforms (see also: https://pytorch.org/vision/stable/auto_examples/transforms/plot_transforms_getting_started.html#what-do-i-pass-as-input)

NicolasHug avatar Feb 20 '25 09:02 NicolasHug

While this works and might be feasible for most projects, it makes it harder for other circumstances:

  • Type Annotation and Checking
  • Loose Bound of context between BBox and Index

I see why it might not be feasible to extend context for BBox, because of the different other possible context extensions, but what bothers me the process as a user, when I want to extend any Tensor based class.

MaKaNu avatar Feb 20 '25 10:02 MaKaNu

Hmmm have you tried to create your own subclass of BoundingBoxes? You should be able to handle the label attribute the same way we handle the other attributes/metadata of BoundingBoxes

NicolasHug avatar Feb 20 '25 12:02 NicolasHug

I've tried an approach with standard python inheritance.

I've looked inside BoundingBoxes and was wandering do I need to apply the hole wrapper configuration or is there a simpler way to extend the class?

MaKaNu avatar Feb 20 '25 14:02 MaKaNu

I honestly don't know the answer to that from the top of my head, sorry. What I would try if I were you is to create a subclass of BoundingBoxes and copy/paste most of the overridden methods of BoundingBoxes in your subclass. And then take it from there, see what can be removed and what needs to stay.

NicolasHug avatar Feb 20 '25 15:02 NicolasHug