Merge pull request #223 from roboflow/fix/confusion_matrix_plot_bug

🛠️ #212 bug fix
This commit is contained in:
Piotr Skalski 2023-07-23 15:00:58 +02:00 committed by GitHub
commit d3da6afa07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -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:

View File

@ -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(