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 2024-07-29 10:40:08 +03:00 committed by GitHub
commit 2ca696e064
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 8 deletions

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,