diff --git a/examples/README.md b/examples/README.md index 5be3b19d..d004688c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,7 +1,7 @@ ## Supervision Examples -This repository is packed with real-world use-cases, provided through Python scripts or -interactive notebooks. Browse through to understand how the Supervision library +This repository is packed with real-world use-cases, provided through Python scripts or +interactive notebooks. Browse through to understand how the Supervision library interfaces with diverse applications. | **Title** | **Contributor** | @@ -12,20 +12,20 @@ interfaces with diverse applications. ## Guidelines for Contributing -We welcome contributions from the community in the form of examples, applications, and +We welcome contributions from the community in the form of examples, applications, and guides. To contribute, please follow these steps: -1. Create a pull request (PR) with the `[Example]` prefix in the title, adding your +1. Create a pull request (PR) with the `[Example]` prefix in the title, adding your project folder to the `examples/` directory in the repository. 2. Confirm your project aligns with the following standards: - Incorporates the `supervision` package. - Provides a `README.md` file, detailing the instructions to execute the project. - Showcases visual results, demonstrating the app's functionality. - Avoids adding large assets or dependencies unless absolutely necessary. - - The contributor is expected to provide support for issues related to their + - The contributor is expected to provide support for issues related to their examples. - - In case the presented model has licensing complications, kindly specify them to + - In case the presented model has licensing complications, kindly specify them to circumvent potential misunderstandings. -For inquiries or concerns about these prerequisites, feel free to raise a PR. We are +For inquiries or concerns about these prerequisites, feel free to raise a PR. We are committed to assist and guide you. diff --git a/supervision/tracker/byte_tracker/core.py b/supervision/tracker/byte_tracker/core.py index 03589c3d..34a90138 100644 --- a/supervision/tracker/byte_tracker/core.py +++ b/supervision/tracker/byte_tracker/core.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple +from typing import List, Tuple import numpy as np @@ -11,7 +11,7 @@ from supervision.tracker.byte_tracker.kalman_filter import KalmanFilter class STrack(BaseTrack): shared_kalman = KalmanFilter() - def __init__(self, tlwh, score, class_ids, mask: Optional[np.array] = None): + def __init__(self, tlwh, score, class_ids): # wait activate self._tlwh = np.asarray(tlwh, dtype=np.float32) self.kalman_filter = None @@ -21,7 +21,6 @@ class STrack(BaseTrack): self.score = score self.class_ids = class_ids self.tracklet_len = 0 - self.mask = mask def predict(self): mean_state = self.mean.copy() @@ -75,7 +74,6 @@ class STrack(BaseTrack): if new_id: self.track_id = self.next_id() self.score = new_track.score - self.mask = new_track.mask def update(self, new_track, frame_id): """ @@ -97,8 +95,6 @@ class STrack(BaseTrack): self.score = new_track.score - self.mask = new_track.mask - @property def tlwh(self): """Get current position in bounding box format `(top left x, top left y, @@ -235,8 +231,9 @@ class ByteTrack: ... ) ``` """ + tracks = self.update_with_tensors( - tensors=detections2boxes(detections=detections), masks=detections.mask + tensors=detections2boxes(detections=detections) ) detections = Detections.empty() if len(tracks) > 0: @@ -252,22 +249,17 @@ class ByteTrack: detections.confidence = np.array( [t.score for t in tracks], dtype=np.float32 ) - detections.mask = np.array([t.mask for t in tracks], dtype=bool) - else: detections.tracker_id = np.array([], dtype=int) return detections - def update_with_tensors( - self, tensors: np.ndarray, masks: Optional[np.array] = None - ) -> List[STrack]: + def update_with_tensors(self, tensors: np.ndarray) -> List[STrack]: """ Updates the tracker with the provided tensors and returns the updated tracks. Parameters: tensors: The new tensors to update with. - masks: The new masks associated to new tensors Returns: List[STrack]: Updated tracks. @@ -289,12 +281,6 @@ class ByteTrack: inds_second = np.logical_and(inds_low, inds_high) dets_second = bboxes[inds_second] dets = bboxes[remain_inds] - if masks is not None: - masks_keep = masks[remain_inds] - masks_second = masks[inds_second] - else: - masks_keep = np.array([None] * len(remain_inds)) - masks_second = np.array([None] * len(inds_second)) scores_keep = scores[remain_inds] scores_second = scores[inds_second] @@ -304,10 +290,8 @@ class ByteTrack: if len(dets) > 0: """Detections""" detections = [ - STrack(STrack.tlbr_to_tlwh(tlbr), s, c, m) - for (tlbr, s, c, m) in zip( - dets, scores_keep, class_ids_keep, masks_keep - ) + STrack(STrack.tlbr_to_tlwh(tlbr), s, c) + for (tlbr, s, c) in zip(dets, scores_keep, class_ids_keep) ] else: detections = [] @@ -347,10 +331,8 @@ class ByteTrack: if len(dets_second) > 0: """Detections""" detections_second = [ - STrack(STrack.tlbr_to_tlwh(tlbr), s, c, m) - for (tlbr, s, c, m) in zip( - dets_second, scores_second, class_ids_second, masks_second - ) + STrack(STrack.tlbr_to_tlwh(tlbr), s, c) + for (tlbr, s, c) in zip(dets_second, scores_second, class_ids_second) ] else: detections_second = []