diff --git a/supervision/dataset/formats/yolo.py b/supervision/dataset/formats/yolo.py index 0b57d001..da070a0f 100644 --- a/supervision/dataset/formats/yolo.py +++ b/supervision/dataset/formats/yolo.py @@ -58,7 +58,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: 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(