Skip to content

Commit 35142fc

Browse files
authored
Merge pull request roboflow#456 from roboflow/revert-436-develop
Revert "roboflow#418 Make sv.ByteTrack work with segmentation model "
2 parents 9cefff8 + f041f0d commit 35142fc

2 files changed

Lines changed: 16 additions & 34 deletions

File tree

examples/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Supervision Examples
22

3-
This repository is packed with real-world use-cases, provided through Python scripts or
4-
interactive notebooks. Browse through to understand how the Supervision library
3+
This repository is packed with real-world use-cases, provided through Python scripts or
4+
interactive notebooks. Browse through to understand how the Supervision library
55
interfaces with diverse applications.
66

77
| **Title** | **Contributor** |
@@ -12,20 +12,20 @@ interfaces with diverse applications.
1212

1313
## Guidelines for Contributing
1414

15-
We welcome contributions from the community in the form of examples, applications, and
15+
We welcome contributions from the community in the form of examples, applications, and
1616
guides. To contribute, please follow these steps:
1717

18-
1. Create a pull request (PR) with the `[Example]` prefix in the title, adding your
18+
1. Create a pull request (PR) with the `[Example]` prefix in the title, adding your
1919
project folder to the `examples/` directory in the repository.
2020
2. Confirm your project aligns with the following standards:
2121
- Incorporates the `supervision` package.
2222
- Provides a `README.md` file, detailing the instructions to execute the project.
2323
- Showcases visual results, demonstrating the app's functionality.
2424
- Avoids adding large assets or dependencies unless absolutely necessary.
25-
- The contributor is expected to provide support for issues related to their
25+
- The contributor is expected to provide support for issues related to their
2626
examples.
27-
- In case the presented model has licensing complications, kindly specify them to
27+
- In case the presented model has licensing complications, kindly specify them to
2828
circumvent potential misunderstandings.
2929

30-
For inquiries or concerns about these prerequisites, feel free to raise a PR. We are
30+
For inquiries or concerns about these prerequisites, feel free to raise a PR. We are
3131
committed to assist and guide you.

supervision/tracker/byte_tracker/core.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional, Tuple
1+
from typing import List, Tuple
22

33
import numpy as np
44

@@ -11,7 +11,7 @@
1111
class STrack(BaseTrack):
1212
shared_kalman = KalmanFilter()
1313

14-
def __init__(self, tlwh, score, class_ids, mask: Optional[np.array] = None):
14+
def __init__(self, tlwh, score, class_ids):
1515
# wait activate
1616
self._tlwh = np.asarray(tlwh, dtype=np.float32)
1717
self.kalman_filter = None
@@ -21,7 +21,6 @@ def __init__(self, tlwh, score, class_ids, mask: Optional[np.array] = None):
2121
self.score = score
2222
self.class_ids = class_ids
2323
self.tracklet_len = 0
24-
self.mask = mask
2524

2625
def predict(self):
2726
mean_state = self.mean.copy()
@@ -75,7 +74,6 @@ def re_activate(self, new_track, frame_id, new_id=False):
7574
if new_id:
7675
self.track_id = self.next_id()
7776
self.score = new_track.score
78-
self.mask = new_track.mask
7977

8078
def update(self, new_track, frame_id):
8179
"""
@@ -97,8 +95,6 @@ def update(self, new_track, frame_id):
9795

9896
self.score = new_track.score
9997

100-
self.mask = new_track.mask
101-
10298
@property
10399
def tlwh(self):
104100
"""Get current position in bounding box format `(top left x, top left y,
@@ -235,8 +231,9 @@ def update_with_detections(self, detections: Detections) -> Detections:
235231
... )
236232
```
237233
"""
234+
238235
tracks = self.update_with_tensors(
239-
tensors=detections2boxes(detections=detections), masks=detections.mask
236+
tensors=detections2boxes(detections=detections)
240237
)
241238
detections = Detections.empty()
242239
if len(tracks) > 0:
@@ -252,22 +249,17 @@ def update_with_detections(self, detections: Detections) -> Detections:
252249
detections.confidence = np.array(
253250
[t.score for t in tracks], dtype=np.float32
254251
)
255-
detections.mask = np.array([t.mask for t in tracks], dtype=bool)
256-
257252
else:
258253
detections.tracker_id = np.array([], dtype=int)
259254

260255
return detections
261256

262-
def update_with_tensors(
263-
self, tensors: np.ndarray, masks: Optional[np.array] = None
264-
) -> List[STrack]:
257+
def update_with_tensors(self, tensors: np.ndarray) -> List[STrack]:
265258
"""
266259
Updates the tracker with the provided tensors and returns the updated tracks.
267260
268261
Parameters:
269262
tensors: The new tensors to update with.
270-
masks: The new masks associated to new tensors
271263
272264
Returns:
273265
List[STrack]: Updated tracks.
@@ -289,12 +281,6 @@ def update_with_tensors(
289281
inds_second = np.logical_and(inds_low, inds_high)
290282
dets_second = bboxes[inds_second]
291283
dets = bboxes[remain_inds]
292-
if masks is not None:
293-
masks_keep = masks[remain_inds]
294-
masks_second = masks[inds_second]
295-
else:
296-
masks_keep = np.array([None] * len(remain_inds))
297-
masks_second = np.array([None] * len(inds_second))
298284
scores_keep = scores[remain_inds]
299285
scores_second = scores[inds_second]
300286

@@ -304,10 +290,8 @@ def update_with_tensors(
304290
if len(dets) > 0:
305291
"""Detections"""
306292
detections = [
307-
STrack(STrack.tlbr_to_tlwh(tlbr), s, c, m)
308-
for (tlbr, s, c, m) in zip(
309-
dets, scores_keep, class_ids_keep, masks_keep
310-
)
293+
STrack(STrack.tlbr_to_tlwh(tlbr), s, c)
294+
for (tlbr, s, c) in zip(dets, scores_keep, class_ids_keep)
311295
]
312296
else:
313297
detections = []
@@ -347,10 +331,8 @@ def update_with_tensors(
347331
if len(dets_second) > 0:
348332
"""Detections"""
349333
detections_second = [
350-
STrack(STrack.tlbr_to_tlwh(tlbr), s, c, m)
351-
for (tlbr, s, c, m) in zip(
352-
dets_second, scores_second, class_ids_second, masks_second
353-
)
334+
STrack(STrack.tlbr_to_tlwh(tlbr), s, c)
335+
for (tlbr, s, c) in zip(dets_second, scores_second, class_ids_second)
354336
]
355337
else:
356338
detections_second = []

0 commit comments

Comments
 (0)