-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Detections Metadata #1585
Comments
Contribution guidelinesIf you would like to make a contribution, please check that no one else is assigned already. Then leave a comment such as "Hi, I would like to work on this issue". We're happy to answer any questions about the task even if you choose not to contribute. TestingPlease share a Google Colab with minimal code to test the new feature. We know it's additional work, but it will speed up the review process. You may use the Starter Template. The reviewer must test each change. Setting up a local environment to do this is time-consuming. Please ensure that Google Colab can be accessed without any issues (make it public). Thank you! 🙏 |
Note: For historical reasons, |
Hey, I'd like to give this issue a try. |
Hey @LinasKo, I would like to work on this issue. |
Hi @souhhmm 👋, Let's see how it goes. Assigning it to you! |
Hey @LinasKo, I have a query. Is a detection empty if the metadata is not empty? If so, is there a need to change empty_detection = sv.Detections(
xyxy=np.empty((0, 4)),
data={},
metadata={"camera_id": 1}
) Is this empty? |
Good question! For our purposes, this is empty. It could be that |
Thank you for the clarification. I'll create a PR with a linked colab soon. |
Detections Metadata
Tip
Hacktoberfest is calling! Whether it's your first PR or your 50th, you’re helping shape the future of open source. Help us build the most reliable and user-friendly computer vision library out there! 🌱
This is a summarized version of #1226.
See the original discussion for more context.
In brief:
Detections
object stores arrays of values and a dict of arrays, each of lengthN
. We'd like to add a global dict of values to store data on a collection-level.I expect this to be a hard issue, as it involves many elements within the library.
Detections
is a class for encoding the results of any model - detection, segmentation, etc. Here's how it looks:All of these, as well as
data
contents are either:None
: Model will never detect anything of that fieldempty array
: Model detected no elements this time.What if we want to store 1 value per-list? E.g. a video name for what every detection was extracted from? Or camera parameters?
Let's introduce a new field:
metadata
. Detections will now look as follows:The users can set it directly by doing
detections.metadata["key"] = "val"
.The primary complexity is caused by functions that merge, slice, split and index into detections.
Relevant methods to be updated:
__eq__
should use metadata for comparisonis_empty
should borrow the data for comparison, just like it does withdata
.__iter__
, should NOT return metadata.from_...
methods should be affectedmerge
should:merge_metadata
function.merge_data
is rather aggressive. It merges if the keys are identical. Let's mimick that here as well - merge if the keys are the same, and the values are identical, while assuming thatmerge
took care of empty detetions.validate_detection_fields
should not - there's nothing to check so far.__getitem__
can return either adata
element or a sliced detections object. Let's update so it sets the metadata as well.merge_inner_detection_object_pair
should merge metadata similarly to howmerge
does it.I believe I've covered everything, but we'll check later on. When testing, make sure to test these changes, as well as
ByteTrack.update_with_detections
andsv.DetectionsSmoother.update_with_detection
.Helpful links:
The text was updated successfully, but these errors were encountered: