From 5cc7da289edb5b01b6c6c50b4392a76dcedfaca8 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Sun, 23 Jul 2023 01:22:03 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20#212=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/dataset/formats/yolo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/supervision/dataset/formats/yolo.py b/supervision/dataset/formats/yolo.py index 16f9772f..9af7f487 100644 --- a/supervision/dataset/formats/yolo.py +++ b/supervision/dataset/formats/yolo.py @@ -69,7 +69,10 @@ def _with_mask(lines: List[str]) -> bool: def _extract_class_names(file_path: str) -> List[str]: data = read_yaml_file(file_path=file_path) - return data["names"] + names = data["names"] + if isinstance(names, dict): + names = [names[key] for key in sorted(names.keys())] + return names def _image_name_to_annotation_name(image_name: str) -> str: From 532245640b80781c17f4aee025d8df692a508c8b Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Sun, 23 Jul 2023 13:41:57 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Make=20`convert=5Fdetections=5F?= =?UTF-8?q?to=5Ftensor`=20static=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/metrics/detection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/supervision/metrics/detection.py b/supervision/metrics/detection.py index e7234973..5b5f710a 100644 --- a/supervision/metrics/detection.py +++ b/supervision/metrics/detection.py @@ -85,10 +85,10 @@ class ConfusionMatrix: target_tensors = [] for prediction, target in zip(predictions, targets): prediction_tensors.append( - cls.detections_to_tensor(prediction, with_confidence=True) + ConfusionMatrix.detections_to_tensor(prediction, with_confidence=True) ) target_tensors.append( - cls.detections_to_tensor(target, with_confidence=False) + ConfusionMatrix.detections_to_tensor(target, with_confidence=False) ) return cls.from_tensors( predictions=prediction_tensors, @@ -98,9 +98,9 @@ class ConfusionMatrix: iou_threshold=iou_threshold, ) - @classmethod + @staticmethod def detections_to_tensor( - cls, detections: Detections, with_confidence: bool = False + detections: Detections, with_confidence: bool = False ) -> np.ndarray: if detections.class_id is None: raise ValueError(