[go: nahoru, domu]

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

feature/extend-detections-with-data-field-to-support-custom-payload #700

Conversation

SkalskiP
Copy link
Collaborator
@SkalskiP SkalskiP commented Dec 28, 2023

Description

  • Update and test Detections.__iter__
  • Update and test Detections.__eq__
  • Update and test Detections.__getitem__
  • Update and test Detections.__setitem__
  • Update and test Detections.merge

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested

  • Lots of unit tests.
  • Test in Colab.

Docs

  • Docs updated? What were the changes:

Example

Storing category name information inside sv.Detections object:

import numpy as np
import supervision as sv

from ultralytics import YOLO


# load model
model = YOLO('yolov8x-seg.pt')

# load first video frame
frames_generator = sv.get_video_frames_generator(source_path='walking.mp4')
frames_iterator = iter(frames_generator)
frame = next(frames_iterator)

# run inference
result = model.track(frame, imgsz=1920)[0]
detections = sv.Detections.from_ultralytics(result)

# map category id to category name
detections['names'] = [
    model.model.names[class_id]
    for class_id
    in detections.class_id
]

# split detections based on category
person_detections = detections[detections.class_id == 0]
nonperson_detections = detections[detections.class_id != 0]

# merge detections
merged_detections = sv.Detections.merge([person_detections, nonperson_detections])

print(merged_detections['names'])

@SkalskiP SkalskiP self-assigned this Dec 28, 2023
@SkalskiP SkalskiP added the enhancement New feature or request label Dec 28, 2023
@SkalskiP SkalskiP linked an issue Dec 28, 2023 that may be closed by this pull request
SkalskiP and others added 21 commits December 28, 2023 17:52
…ata-field-to-support-custom-payload' into feature/extend-detections-with-data-field-to-support-custom-payload
…ata-field-to-support-custom-payload' into feature/extend-detections-with-data-field-to-support-custom-payload
…ata-field-to-support-custom-payload' into feature/extend-detections-with-data-field-to-support-custom-payload

# Conflicts:
#	supervision/detection/core.py
…ata-field-to-support-custom-payload' into feature/extend-detections-with-data-field-to-support-custom-payload
@SkalskiP SkalskiP marked this pull request as ready for review January 2, 2024 15:23
@SkalskiP SkalskiP merged commit 8528a8a into develop Jan 2, 2024
8 checks passed
@SkalskiP SkalskiP deleted the feature/extend-detections-with-data-field-to-support-custom-payload branch January 2, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Current Release: Done
Development

Successfully merging this pull request may close these issues.

Extend sv.Detections with data field to support custom payload
1 participant