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

allow mask to be propagated within the box during tracking #780

Conversation

AntonioConsiglio
Copy link
Contributor

@AntonioConsiglio AntonioConsiglio commented Jan 25, 2024

Description:

This pull request addresses the following changes:

  1. ByteTrack Enhancement:

  2. Base Code Modification:

    • Made adjustments to the base code to resolve the issue.

Changes Made:

  • byte_tracker.update_with_detections method update the tracker id of detections based on ByteTrack tracker.

Minor Changes Made:

  • box_annotator.annotate method added a flag (only_tracked) to show only bbox with tracker id assigned

Testing:

colab: LinkToNotebook
Successfully tested the code with both object-detection and segmentation-models using the provided testing code:

import supervision as sv
from tqdm import tqdm
from ultralytics import YOLO

VIDEO_ROOT = "./walking_people.mp4"

class CustomDetections(sv.Detections):
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.class_name:list = []


if __name__ == "__main__":

    model = YOLO("yolov8x-seg.pt").cuda()  
    #model = YOLO("yolov8x.pt").cuda() 

    mask_annotator = sv.MaskAnnotator()
    box_annotator = sv.BoxAnnotator(thickness=1,
                                text_scale=0.2,
                                text_padding=4)
    track_annotator = sv.TraceAnnotator()

    video_info = sv.VideoInfo.from_video_path(video_path=VIDEO_ROOT)
    frame_generator = sv.get_video_frames_generator(source_path=VIDEO_ROOT)
    byte_tracker = sv.ByteTrack()

    with sv.VideoSink(f'test_box_and_mask_tracking.mp4', video_info=video_info) as sink:
  
        for frame in tqdm(frame_generator, total=video_info.total_frames):
            
            result = model.track(frame, imgsz = 640,verbose=False)[0]
            detections = CustomDetections.from_ultralytics(result)
            detections = byte_tracker.update_with_detections(detections)

            annotated_frame = box_annotator.annotate(
                scene=frame.copy(),
                detections=detections)
            annotated_frame = track_annotator.annotate(
                scene=annotated_frame.copy(),
                detections=detections)
            annotated_frame = mask_annotator.annotate(
                scene=annotated_frame.copy(),
                detections=detections)
           
            sink.write_frame(frame=annotated_frame)

@AntonioConsiglio
Copy link
Contributor Author

Box-Tracking only result

test_box_tracking-ezgif com-video-to-gif-converter

Box-Tracking and Segmentation result

test_box_and_mask_tracking-ezgif com-video-to-gif-converter

@SkalskiP
Copy link
Collaborator

Hi @AntonioConsiglio I just updated the description in #754. I hope that will help you understand my reasoning.

onuralpszr and others added 26 commits January 28, 2024 01:25
docs: 📝 missing import of numpy and correct variable name in tracker section
…ctions-in-detaset-loaders

fix looping over detections in dataset loaders
---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
…aterial-9.5.6

⬆️ bump mkdocs-material from 9.5.5 to 9.5.6
….0.0

⬆️ bump pytest from 7.4.4 to 8.0.0
feat: ✨ mkdocs multi versioning package and old doc deployment CI disabled
updates:
- [github.com/PyCQA/bandit: 1.7.6 → 1.7.7](PyCQA/bandit@1.7.6...1.7.7)
…_count method and add center method to vector
…nfig

chore(pre_commit): ⬆ pre_commit autoupdate
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.14 to 0.1.15.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.1.14...v0.1.15)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Adding else statement
adding else statement to return an empty array when there is no detections
Refactor class DetectionsManager to handle empty detections_all array
onuralpszr and others added 27 commits February 2, 2024 15:15
docs(fix): 🐞📝 relative path fix for mike
…tections_csv

New function [CSVSink] - allowing to serialise Detections to a CSV file
…ut-values

[LineZone] - flip in/out line crossing directions roboflow#838
@CLAassistant
Copy link

CLAassistant commented Feb 5, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
5 out of 6 committers have signed the CLA.

✅ onuralpszr
✅ AdonaiVera
✅ SkalskiP
✅ Kadermiyanyedi
✅ AntonioConsiglio
❌ dependabot[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@AntonioConsiglio
Copy link
Contributor Author

Hello @SkalskiP, the PR is ready to be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants