Skip to content

Commit

Permalink
Introduce version 0.2.0
Browse files Browse the repository at this point in the history
- Change `boxes_confs` to `boxes_conf` for `VSenseAssets`
- Update requirements
- Update and improve documentation
  • Loading branch information
rathaROG committed May 22, 2024
1 parent b85611a commit 5f3158b
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/vsensebox/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The table below shows all the current supported modules which are integrated in
| | | | | * Run on: CPU or GPU (Tensorflow) |
| +--------------+------------------+-------------------------------------------------+
| | BasicIoU | BasicIoU | | * Built-in / Native |
| | | | | * Run on: CPU or GUP |
| | | | | * Run on: CPU or GUP (PyTorch) |
+------------+--------------+------------------+-------------------------------------------------+

.. _v2, v3: https://pjreddie.com/darknet/yolo/
Expand Down
2 changes: 1 addition & 1 deletion examples/example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
input_image,
ids=results.ids,
boxes_xyxy=results.boxes_xyxy,
boxes_confs=results.boxes_confs,
boxes_conf=results.boxes_conf,
img_is_mat=False
)

Expand Down
2 changes: 1 addition & 1 deletion examples/example_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
frame = draw_boxes(
frame, ids=vs.assets.ids,
boxes_xyxy=vs.assets.boxes_xyxy,
boxes_confs=vs.assets.boxes_confs
boxes_conf=vs.assets.boxes_conf
)

# Display
Expand Down
2 changes: 1 addition & 1 deletion examples/example_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def detect_and_track(vsense, input_video, det_yaml, trk_yaml, name="Detect & Tra
frame = draw_boxes(
frame, ids=vsense.assets.ids,
boxes_xyxy=vsense.assets.boxes_xyxy,
boxes_confs=vsense.assets.boxes_confs
boxes_conf=vsense.assets.boxes_conf
)

# Display
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ torchvision
torchaudio
### Tracker: SORT
filterpy
lapx>=0.5.8
lapx>=0.5.9
### GUI
PyQt6
### Customized vsensebox-ultralytics
Expand Down
2 changes: 1 addition & 1 deletion tests/test_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
frame = draw_boxes(
frame, ids=vs.assets.ids,
boxes_xyxy=vs.assets.boxes_xyxy,
boxes_confs=vs.assets.boxes_confs
boxes_conf=vs.assets.boxes_conf
)

# Save frame as jpg
Expand Down
2 changes: 1 addition & 1 deletion vsensebox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from vsensebox.gui import config, reset
from vsensebox.utils.about import docs, github

__version__ = "0.1.1"
__version__ = "0.2.0"
__author__ = "Ratha SIV"
__description__ = "VSenseBox - Python toolbox for visual sensing."
__homepage__ = "https://numediart.github.io/vsensebox"
Expand Down
14 changes: 13 additions & 1 deletion vsensebox/modules/detectors/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@


def checkDet(detector, config_yaml, relative_to_vsensebox_root):

"""Automatically check, select, and config the supported detector according to the
input :obj:`config_yaml`.
Parameters
----------
detector : detector object
A detector object; for example, :class:`YOLO_Ultralytics` or :class:`YOLO_Classic`.
config_yaml : str or dict
A YAML/JSON file path, or a raw/ready dictionary.
relative_to_vsensebox_root : bool
This parameter is passed to the corresponding configurator; for example,
:class:`DCFG_YOLOULT` or :class:`DCFG_YOLOCLS`.
"""
cfg = getCFGDict(config_yaml)
det_name = USTR.getUnifiedFormat(cfg['detector'])

Expand Down
4 changes: 2 additions & 2 deletions vsensebox/modules/trackers/basiciou.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def _findPID(self, box_xyxy, box_class):
if max_iou < self.min_iou: pindex = -1
return pindex

def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
def update(self, boxes_xyxy, boxes_conf, boxes_cls=None, img=None):
"""Update the tracker and return a track list.
Parameters
----------
boxes_xyxy : list[[X1, Y1, X2, Y2], ...]
A list of boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_confs : list[float, ...]
boxes_conf : list[float, ...]
Being consistent with other trackers, will be ignored.
boxes_cls : list[int, ...], default=None
A list of detection class corresponding to boxes_xyxy.
Expand Down
4 changes: 2 additions & 2 deletions vsensebox/modules/trackers/centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def _findPID(self, point):
if min_d > self.max_spread: pindex = -1
return pindex

def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
def update(self, boxes_xyxy, boxes_conf, boxes_cls=None, img=None):
"""Update the tracker and return a track list.
Parameters
----------
boxes_xyxy : list[[X1, Y1, X2, Y2], ...]
A list of boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_confs : list[float, ...]
boxes_conf : list[float, ...]
Being consistent with other trackers, will be ignored.
boxes_cls : list[int, ...], default=None
Being consistent with other trackers, will be ignored.
Expand Down
6 changes: 3 additions & 3 deletions vsensebox/modules/trackers/deepsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def __init__(self, cfg):
self.tracker = DSTracker(self.metric)


def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
def update(self, boxes_xyxy, boxes_conf, boxes_cls=None, img=None):
"""Update the tracker and return a track list.
Parameters
----------
boxes_xyxy : list[[X1, Y1, X2, Y2], ...]
A list of boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_confs : list[float, ...]
boxes_conf : list[float, ...]
A list of detection confidences corresponding to boxes_xyxy.
boxes_cls : list[int, ...], default=None
A list of detection class corresponding to boxes_xyxy.
Expand All @@ -66,7 +66,7 @@ def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
A list of IDs corresponding to the the list of boxes.
"""

dconfidences = boxes_confs
dconfidences = boxes_conf
dclasses = boxes_cls
dboxes = [to_xywh(b) for b in boxes_xyxy]
dfeatures = self.encoder(img, dboxes)
Expand Down
6 changes: 3 additions & 3 deletions vsensebox/modules/trackers/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def __init__(self, cfg):
"""
self.st = ST(cfg.max_age, cfg.min_hits, cfg.iou_threshold)

def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
def update(self, boxes_xyxy, boxes_conf, boxes_cls=None, img=None):
"""Update the tracker and return a track list.
Parameters
----------
boxes_xyxy : list[[X1, Y1, X2, Y2], ...]
A list of boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_confs : list[float, ...]
boxes_conf : list[float, ...]
A list of detection confidence corresponding to boxes_xyxy.
boxes_cls : list[int, ...], default=None
Being consistent with other trackers, will be ignored.
Expand All @@ -48,7 +48,7 @@ def update(self, boxes_xyxy, boxes_confs, boxes_cls=None, img=None):
A list of IDs corresponding to the the list of boxes.
"""
detection = []
for b, c in zip(boxes_xyxy, boxes_confs):
for b, c in zip(boxes_xyxy, boxes_conf):
b = np.append(b, c)
detection.append(b)
track = self.st.update(np.array(detection)).astype(int)
Expand Down
12 changes: 12 additions & 0 deletions vsensebox/modules/trackers/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@


def checkTrk(tracker, config_yaml, relative_to_vsensebox_root):
"""Automatically check, select, and config the supported tracker according to the
input :obj:`config_yaml`.
Parameters
----------
tracker : tracker object
A tracker object; for example, :class:`Centroid` or :class:`SORT`.
config_yaml : str or dict
A YAML/JSON file path, or a raw/ready dictionary.
relative_to_vsensebox_root : bool
This parameter is passed to the corresponding configurator; for example,
:class:`TCFG_Centroid` or :class:`TCFG_SORT`.
"""
cfg = getCFGDict(config_yaml)
trk_name = USTR.getUnifiedFormat(cfg['tracker'])

Expand Down
1 change: 0 additions & 1 deletion vsensebox/utils/commontools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import cv2
import numpy as np


def getCVMat(img, to_rgb=False):
"""
:meta private:
Expand Down
6 changes: 3 additions & 3 deletions vsensebox/utils/visualizetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def draw_boxes(img,
ids=[],
show_ids=True,
boxes_xyxy=[],
boxes_confs=[],
boxes_conf=[],
boxes_color=(255, 255, 0),
boxes_thickness=2,
text_color=(150, 200, 50),
Expand All @@ -30,7 +30,7 @@ def draw_boxes(img,
Whether to visualize the IDs.
boxes_xyxy : list[[X1, Y1, X2, Y2], ...], default=[]
A list of bounding boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_confs : list[float, ...], default=[]
boxes_conf : list[float, ...], default=[]
A list of detection confidences corresponding to bounding boxes.
boxes_color : tuple(int, int, int), default=(255, 255, 0)
Color space of bounding boxes.
Expand Down Expand Up @@ -69,7 +69,7 @@ def draw_boxes(img,
)
conf = 0.0
try:
conf = format(boxes_confs[i], '.2f')
conf = format(boxes_conf[i], '.2f')
cv2.putText(img, str(conf), (int(boxes_xyxy[i][0]) + 5, int(boxes_xyxy[i][3]) - 5),
text_font, text_font_scale, text_color, text_thickness)
except Exception as e:
Expand Down
17 changes: 8 additions & 9 deletions vsensebox/vsense/vsense.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

class VSense(object):

"""
VSense is used to operate the object detection and tracking.
"""VSense is used to operate the object detection and tracking.
Attributes
----------
Expand Down Expand Up @@ -69,7 +68,7 @@ def detect(self, img, config_yaml=None, img_is_mat=False):
boxes_xywh=boxes_xywh,
boxes_xyxy=boxes_xyxy,
keypoints=keypoints,
boxes_confs=confs,
boxes_conf=confs,
boxes_cls=cls
)

Expand All @@ -96,7 +95,7 @@ def track(self, img=None, config_yaml=None, img_is_mat=False):
self._yaml_trk = config_yaml
boxes_xyxy, self.assets.ids = self._tracker.update(
self.assets.boxes_xyxy,
self.assets.boxes_confs,
self.assets.boxes_conf,
boxes_cls=self.assets.boxes_cls,
img=img
)
Expand All @@ -113,7 +112,7 @@ class VSenseAssets(object):
A list of bounding boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_xywh : list[[X, Y, W, H], ...], optional
A list of bounding boxes; for example, [[X, Y, W, H], [X, Y, W, H], ...].
boxes_confs : list[float, ...], optional
boxes_conf : list[float, ...], optional
A list of detection confidences corresponding to bounding boxes.
boxes_cls : list[int, ...], optional
A list of detection class corresponding to bounding boxes.
Expand All @@ -132,7 +131,7 @@ def __init__(self):
"""
self.boxes_xyxy = []
self.boxes_xywh = []
self.boxes_confs = []
self.boxes_conf = []
self.boxes_cls = []
self.keypoints = []
self.ids = []
Expand All @@ -142,7 +141,7 @@ def __init__(self):
def update(self,
boxes_xyxy=[],
boxes_xywh=[],
boxes_confs=[],
boxes_conf=[],
boxes_cls=[],
keypoints=[],
ids=[],
Expand All @@ -156,7 +155,7 @@ def update(self,
A list of bounding boxes; for example, [[X1, Y1, X2, Y2], [X1, Y1, X2, Y2], ...].
boxes_xywh : list[[X, Y, W, H], ...], optional
A list of bounding boxes; for example, [[X, Y, W, H], [X, Y, W, H], ...].
boxes_confs : list[float, ...], optional
boxes_conf : list[float, ...], optional
A list of detection confidences corresponding to bounding boxes.
boxes_cls : list[int, ...], optional
A list of detection class corresponding to bounding boxes.
Expand All @@ -171,7 +170,7 @@ def update(self,
"""
self.boxes_xyxy = boxes_xyxy
self.boxes_xywh = boxes_xywh
self.boxes_confs = boxes_confs
self.boxes_conf = boxes_conf
self.boxes_cls = boxes_cls
self.keypoints = keypoints
self.ids = ids
Expand Down

0 comments on commit 5f3158b

Please sign in to comment.