Validates the submitted predictions object Checks that there is a prediction for each test image, and raises a warning if that is not the case. Returns only predictions made for test images.
(self, name: str, predictions: dict)
| 110 | ) |
| 111 | |
| 112 | def _validate_predictions(self, name: str, predictions: dict) -> dict: |
| 113 | """Validates the submitted predictions object Checks that there is a prediction |
| 114 | for each test image, and raises a warning if that is not the case. |
| 115 | |
| 116 | Returns only predictions made for test images. |
| 117 | """ |
| 118 | test_images = deeplabcut.benchmark.metrics.load_test_images(self.ground_truth, self.metadata) |
| 119 | missing_images = set(test_images) - set(predictions.keys()) |
| 120 | if len(missing_images) > 0: |
| 121 | warnings.warn( |
| 122 | f"Missing {len(missing_images)} test images in the predictions for " |
| 123 | f"{name}: {list(missing_images)} Metrics will be computed as if no " |
| 124 | "individuals were detected in those images.", |
| 125 | stacklevel=2, |
| 126 | ) |
| 127 | |
| 128 | return {img: predictions.get(img, tuple()) for img in test_images} |
| 129 | |
| 130 | |
| 131 | @dataclasses.dataclass |