supervision
supervision copied to clipboard
add data payload dict #461
Description
Addressing the following - #461 data payload enhancement feature in Detections
.
Adding data payload to Detections
, in order to allow more flexibility.
List any dependencies that are required for this change.
Type of change
- [x] New feature (non-breaking change which adds functionality)
in __iter__
method - code snippet is something like -
Here i am assuming that metadata stored in self.data
has (N,)
dimensional shape. So iter
magic method, will iterate over and for a corresponding detection it'll find the meta data np array throughout the keys in the dict of data payload
for i in range(len(self.xyxy)):
data_for_i = {
key: value[i] if value is not None else None
for key, value in self.data.items()
}
yield (
self.xyxy[i],
self.mask[i] if self.mask is not None else None,
self.confidence[i] if self.confidence is not None else None,
self.class_id[i] if self.class_id is not None else None,
self.tracker_id[i] if self.tracker_id is not None else None,
data_for_i,
)
Rest of my implementation follow the same assumptions
How has this change been tested, please provide a testcase or example of how you tested the change?
YOUR_ANSWER
Docs
- [ ] Docs updated? What were the changes:
@SkalskiP - hi, let me know what do you think about the PR. I did some changes which could be helpful.
Plus, in your example #461 . I was looking at the guideline, you mentioned -
Notice that the shape of every `np.ndarray` is dictated by `N` - detections count.
When designing `data: Dict[str, np.ndarray]`,
we must ensure that every value in that
dictionary has `(N, ...)` shape.
But it contradicts your example of OCR in the comment
"storing extracted_text
into data payload".
the extracted text is going to be standalone string for example "Hi, How are you", right?
Maybe (N, ...)
shape doesnt fit well in OCR example?
Please correct me if you feel so.
Hi @hiteshhedwig 👋🏻! Sorry for lagging with the review. I'll taka a look on Monday.
Hi @hiteshhedwig! I made the review and left a few comments. Overall, we are moving in the right direction! 🔥
@SkalskiP Hi, can you let me know if some changes are still recommended ?
Hi @hiteshhedwig 👋🏻 ! I'm closing this PR as this change was already implemented in the 0.18.0
release. Thanks a lot for the help and time you spend crafting this code.