Merge pull request #1410 from arthurcerveira/refactor/lazy-loading-for-benchmarks

Refactor the metric benchmarks to use dataset lazy loading
This commit is contained in:
Linas Kondrackis authored and GitHub committed 2024-07-29 10:40:08 +03:00
commit 2ca696e064
1 file changed
+6 -8
+6 -8
View File
@@ -391,11 +391,10 @@ class ConfusionMatrix:
```
"""
predictions, targets = [], []
for img_name, img in dataset.images.items():
predictions_batch = callback(img)
for _, image, annotation in dataset:
predictions_batch = callback(image)
predictions.append(predictions_batch)
targets_batch = dataset.annotations[img_name]
targets.append(targets_batch)
targets.append(annotation)
return cls.from_detections(
predictions=predictions,
targets=targets,
@@ -604,11 +603,10 @@ class MeanAveragePrecision:
```
"""
predictions, targets = [], []
for img_name, img in dataset.images.items():
predictions_batch = callback(img)
for _, image, annotation in dataset:
predictions_batch = callback(image)
predictions.append(predictions_batch)
targets_batch = dataset.annotations[img_name]
targets.append(targets_batch)
targets.append(annotation)
return cls.from_detections(
predictions=predictions,
targets=targets,