Update copy based on feedback from James & Piotr

This commit is contained in:
Brad Dwyer committed 2023-12-28 11:50:06 -06:00
1 parent 1d4d7dd4ea
commit 5d1e76fbd0
5 files changed
+21 -35

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ git push -u origin main
### Pre-commit tool
This project utilizes the [pre-commit](https://pre-commit.com/) tool to maintain code quality and consistency. Before submitting a pull request or making any commits, it is important to run the pre-commit tool to ensure that your changes meet the project's guidelines.
This project uses the [pre-commit](https://pre-commit.com/) tool to maintain code quality and consistency. Before submitting a pull request or making any commits, it is important to run the pre-commit tool to ensure that your changes meet the project's guidelines.
Furthermore, we have integrated a pre-commit GitHub Action into our workflow. This means that with every pull request opened, the pre-commit checks will be automatically enforced, streamlining the code review process and ensuring that all contributions adhere to our quality standards.
+1 -1
View File
@@ -1,4 +1,4 @@
Utilize Supervision to elevate your video analysis capabilities by effortlessly
Use Supervision to elevate your video analysis capabilities by effortlessly
[tracking](https://supervision.roboflow.com/trackers/) objects identified by various
object detection and segmentation models. This guide will walk you through the process
of running inference using the [Ultralytics](https://github.com/ultralytics/ultralytics)
+4 -4
View File
@@ -97,7 +97,7 @@ class MaskAnnotator(BaseAnnotator):
!!! warning
This annotator utilizes the `sv.Detections.mask`.
This annotator uses `sv.Detections.mask`.
"""
def __init__(
@@ -180,7 +180,7 @@ class PolygonAnnotator(BaseAnnotator):
!!! warning
This annotator utilizes the `sv.Detections.mask`.
This annotator uses `sv.Detections.mask`.
"""
def __init__(
@@ -348,7 +348,7 @@ class HaloAnnotator(BaseAnnotator):
!!! warning
This annotator utilizes the `sv.Detections.mask`.
This annotator uses `sv.Detections.mask`.
"""
def __init__(
@@ -1004,7 +1004,7 @@ class TraceAnnotator:
!!! warning
This annotator utilizes the `sv.Detections.tracker_id`. Read
This annotator uses the `sv.Detections.tracker_id`. Read
[here](https://supervision.roboflow.com/trackers/) to learn how to plug
tracking into your inference pipeline.
"""
+1 -1
View File
@@ -15,7 +15,7 @@ class LineZone:
!!! warning
LineZone utilizes the `tracker_id`. Read
LineZone uses the `tracker_id`. Read
[here](https://supervision.roboflow.com/trackers/) to learn how to plug
tracking into your inference pipeline.
+14 -28
View File
@@ -7,9 +7,9 @@ from supervision.detection.core import Detections
class Smoother:
"""
A class for smoothing out noise in predictions over time by using a Tracker
to track objects over time and averaging out the predictions over the
`length` most recent frames.
Smooth out noise in predictions over time with the `Smoother` class.
This classes uses an existing `Tracker` to track objects over time.
Detections are averaged out over the `length` most recent frames.
<video controls>
<source src="https://media.roboflow.com/supervision/video-examples/smoothed-grocery-example-720.mp4" type="video/mp4">
@@ -17,6 +17,14 @@ class Smoother:
> _On the left are the model's raw predictions,
> on the right is the output of Smoother._
!!! warning
Smoother uses the `tracker_id`. Read
[here](https://supervision.roboflow.com/trackers/) to learn how to plug
tracking into your inference pipeline.
Note: Smoother is intended for use on Detections without a `mask` field.
## Example Usage:
```python
@@ -63,12 +71,6 @@ class Smoother:
pipeline.start()
pipeline.join()
```
!!! warning
Smoother utilizes the `tracker_id`. Read
[here](https://supervision.roboflow.com/trackers/) to learn how to plug
tracking into your inference pipeline.
"""
def __init__(self, length: int = 5) -> None:
@@ -80,9 +82,9 @@ class Smoother:
self.length = length
self.current_frame = 0
self.tracks = NoneDict()
self.track_starts = NoneDict()
self.track_ends = NoneDict()
self.tracks = defaultdict(lambda: deque(maxlen=length))
self.track_starts = defaultdict(lambda: deque(maxlen=length))
self.track_ends = defaultdict(lambda: deque(maxlen=length))
def tracker_length(self, tracker_id):
return self.current_frame - self.track_starts[tracker_id]
@@ -154,19 +156,3 @@ class Smoother:
tracked_detections.append(track)
return Detections.merge(tracked_detections)
class NoneDict(defaultdict):
"""
Helper class that returns None instead of raising a KeyError
when a key is not found.
"""
def __init__(self, *args, **kwargs):
super(NoneDict, self).__init__(None, *args, **kwargs)
def __getitem__(self, key):
try:
return super(NoneDict, self).__getitem__(key)
except KeyError:
return None