2 Copyright (c) 2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
20 from accuracy_checker.config import ConfigError
21 from accuracy_checker.postprocessor import PostprocessingExecutor
23 from accuracy_checker.representation import (
28 ClassificationAnnotation
31 from .common import make_representation, make_segmentation_representation
34 def postprocess_data(executor, annotations, predictions):
35 return executor.full_process(annotations, predictions)
38 class TestPostprocessor:
39 def test_without_apply_to_and_sources_filter_raise_config_error_exception(self):
40 config = [{'type': 'filter', 'labels': [1]}]
42 with pytest.raises(ConfigError):
43 PostprocessingExecutor(config)
45 def test_both_provided_apply_to_and_sources_filter_raise_config_error_exception(self):
48 'apply_to': 'prediction',
49 'annotation_source': 'annotation',
53 with pytest.raises(ConfigError):
54 PostprocessingExecutor(config)
56 def test_filter_annotations_unsupported_source_type_in_container_raise_type_error_exception(self):
57 config = [{'type': 'filter', 'annotation_source': 'annotation', 'labels': [1]}]
58 annotation = ContainerAnnotation({'annotation': ClassificationAnnotation()})
59 executor = PostprocessingExecutor(config)
61 with pytest.raises(TypeError):
62 postprocess_data(executor, [annotation], [None])
64 def test_filter_annotations_source_not_found_raise_config_error_exception(self):
65 config = [{'type': 'filter', 'annotation_source': 'ann', 'labels': [1]}]
66 annotation = ContainerAnnotation({
67 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
69 executor = PostprocessingExecutor(config)
71 with pytest.raises(ConfigError):
72 postprocess_data(executor, [annotation], [None])
74 def test_filter_predictions_unsupported_source_type_raise_type_error_exception(self):
77 'prediction_source': 'detection_out',
79 'remove_filtered': False
81 prediction = ContainerPrediction({'detection_out': ClassificationAnnotation()})
82 executor = PostprocessingExecutor(config)
84 with pytest.raises(TypeError):
85 postprocess_data(executor, [None], [prediction])
87 def test_filter_predictions_source_not_found_raise_config_error_exception(self):
89 'type': 'filter', 'prediction_source': 'undefined', 'labels': [1]
91 prediction = ContainerPrediction({'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]})
92 executor = PostprocessingExecutor(config)
94 with pytest.raises(ConfigError):
95 postprocess_data(executor, [None], [prediction])
97 def test_filter_container_annotations_by_labels_with_ignore_using_source(self):
99 'type': 'filter', 'annotation_source': 'annotation', 'labels': [1], 'remove_filtered': False
101 annotation = ContainerAnnotation({
102 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
104 expected = ContainerAnnotation({
105 'annotation': make_representation(
106 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
110 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
112 assert annotation == expected
114 def test_filter_container_annotations_by_labels_with_ignore_using_apply_to(self):
117 'apply_to': 'annotation',
119 'remove_filtered': False
121 annotation = ContainerAnnotation({
122 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
124 expected = ContainerAnnotation({
125 'annotation': make_representation(
126 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
130 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
132 assert annotation == expected
134 def test_filter_regular_annotations_by_labels_with_ignore(self):
135 config = [{'type': 'filter', 'apply_to': 'annotation', 'labels': [1], 'remove_filtered': False}]
136 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
137 expected = make_representation(
138 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
141 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
143 assert annotation == expected
145 def test_filter_multi_source_annotations_by_labels_with_ignore(self):
148 'annotation_source': ['annotation1', 'annotation2'],
150 'remove_filtered': False
152 annotation = ContainerAnnotation({
153 'annotation1': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0],
154 'annotation2': make_representation('1 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
156 expected = ContainerAnnotation({
157 'annotation1': make_representation(
158 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
160 'annotation2': make_representation(
161 '1 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [0, 1]}]
165 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
167 assert annotation == expected
169 def test_filter_multi_source_annotations_by_labels_with_ignore_using_apply_to(self):
172 'apply_to': 'annotation',
174 'remove_filtered': False
176 annotation = ContainerAnnotation({
177 'annotation1': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0],
178 'annotation2': make_representation('1 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
180 expected = ContainerAnnotation({
181 'annotation1': make_representation(
182 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
184 'annotation2': make_representation(
185 '1 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [0, 1]}]
188 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
190 assert annotation == expected
192 def test_filter_regular_annotations_by_labels_with_remove_using_annotation_source_warm_user_warning(self):
195 'annotation_source': 'annotation',
197 'remove_filtered': True
199 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
200 expected = make_representation('0 0 0 10 10', is_ground_truth=True)[0]
202 with pytest.warns(UserWarning):
203 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
205 assert annotation == expected
207 def test_filter_regular_annotations_by_labels_with_remove_using_apply_to(self):
208 config = [{'type': 'filter', 'apply_to': 'annotation', 'labels': [1], 'remove_filtered': True}]
209 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
210 expected = make_representation('0 0 0 10 10', is_ground_truth=True)[0]
212 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
214 assert annotation == expected
216 def test_filter_annotations_by_labels_with_remove_on_container(self):
219 'annotation_source': 'annotation',
221 'remove_filtered': True
223 annotation = ContainerAnnotation({
224 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
226 expected = ContainerAnnotation({
227 'annotation': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
230 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
232 assert annotation == expected
234 def test_filter_annotations_by_labels_with_remove_on_container_using_apply_to(self):
235 config = [{'type': 'filter', 'apply_to': 'annotation', 'labels': [1], 'remove_filtered': True}]
236 annotation = ContainerAnnotation({
237 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
239 expected = ContainerAnnotation({
240 'annotation': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
243 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
245 assert annotation == expected
247 def test_filter_multi_source_annotations_by_labels_with_remove(self):
250 'annotation_source': ['annotation1', 'annotation2'],
251 'labels': [1], 'remove_filtered': True
253 annotation = ContainerAnnotation({
254 'annotation1': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0],
255 'annotation2': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
257 expected = ContainerAnnotation({
258 'annotation1': make_representation('0 0 0 10 10', is_ground_truth=True)[0],
259 'annotation2': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
262 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
264 assert annotation == expected
266 def test_filter_multi_source_by_labels_with_remove_on_container_using_apply_to(self):
267 config = [{'type': 'filter', 'apply_to': 'annotation', 'labels': [1], 'remove_filtered': True}]
268 annotation = ContainerAnnotation({
269 'annotation1': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0],
270 'annotation2': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
272 expected = ContainerAnnotation({
273 'annotation1': make_representation('0 0 0 10 10', is_ground_truth=True)[0],
274 'annotation2': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
277 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
279 assert annotation == expected
281 def test_filter_predictions_by_labels_with_ignore(self):
282 config = [{'type': 'filter', 'apply_to': 'prediction', 'labels': ['to_be_filtered'], 'remove_filtered': False}]
283 prediction = DetectionPrediction(labels=['some_label', 'to_be_filtered'])
284 expected = DetectionPrediction(labels=['some_label', 'to_be_filtered'], metadata={'difficult_boxes': [1]})
286 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
288 assert prediction == expected
290 def test_filter_predictions_by_labels_with_ignore_on_container(self):
293 'prediction_source': 'detection_out',
295 'remove_filtered': False
297 prediction = ContainerPrediction({
298 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
300 expected = ContainerPrediction({'detection_out': make_representation(
301 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
304 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
306 assert prediction == expected
308 def test_filter_predictions_by_labels_with_ignore_on_container_using_apply_to(self):
309 config = [{'type': 'filter', 'apply_to': 'prediction', 'labels': [1], 'remove_filtered': False}]
310 prediction = ContainerPrediction({
311 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
313 expected = ContainerPrediction({'detection_out': make_representation(
314 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
317 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
319 assert prediction == expected
321 def test_filter_multi_source_predictions_by_labels_with_ignore(self):
323 'type': 'filter', 'prediction_source': ['detection_out1', 'detection_out2'], 'labels': [1],
324 'remove_filtered': False
326 prediction = ContainerPrediction({
327 'detection_out1': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0],
328 'detection_out2': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
330 expected = ContainerPrediction({
331 'detection_out1': make_representation(
332 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
334 'detection_out2': make_representation(
335 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
339 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
341 assert prediction == expected
343 def test_filter_multi_source_predictions_by_labels_with_ignore_using_apply_to(self):
345 'type': 'filter', 'apply_to': 'prediction', 'labels': [1], 'remove_filtered': False
347 prediction = ContainerPrediction({
348 'detection_out1': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0],
349 'detection_out2': make_representation('1 0 0 10 10; 1 0 0 11 11', score=1)[0]
351 expected = ContainerPrediction({
352 'detection_out1': make_representation(
353 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
355 'detection_out2': make_representation(
356 '1 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [0, 1]}]
360 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
362 assert prediction == expected
364 def test_filter_predictions_by_labels_with_remove(self):
365 config = [{'type': 'filter', 'apply_to': 'prediction', 'labels': [1], 'remove_filtered': True}]
366 prediction = make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)
367 expected = make_representation('0 0 0 10 10', score=1)
369 postprocess_data(PostprocessingExecutor(config), [None], prediction)
371 assert prediction == expected
373 def test_filter_predictions_by_labels_with_remove_on_container(self):
375 'type': 'filter', 'prediction_source': 'detection_out', 'labels': [0], 'remove_filtered': True
377 prediction = ContainerPrediction({
378 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
380 expected = ContainerPrediction({'detection_out': make_representation('1 0 0 11 11', score=1)[0]})
382 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
384 assert prediction == expected
386 def test_filter_predictions_by_labels_with_remove_on_container_using_apply_to(self):
387 config = [{'type': 'filter', 'apply_to': 'prediction', 'labels': [0], 'remove_filtered': True}]
388 prediction = ContainerPrediction({
389 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
391 expected = ContainerPrediction({'detection_out': make_representation('1 0 0 11 11', score=1)[0]})
393 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
395 assert prediction == expected
397 def test_filter_multi_source_predictions_by_labels_with_remove(self):
400 'prediction_source': ['detection_out1', 'detection_out2'],
402 'remove_filtered': True
404 prediction = ContainerPrediction({
405 'detection_out1': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0],
406 'detection_out2': make_representation('0 0 0 10 10', score=1)[0]
408 expected = ContainerPrediction({
409 'detection_out1': make_representation('0 0 0 10 10', score=1)[0],
410 'detection_out2': make_representation('0 0 0 10 10', score=1)[0]
413 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
415 assert prediction == expected
417 def test_filter_multi_source_predictions_by_labels_with_remove_using_apply_to(self):
418 config = [{'type': 'filter', 'apply_to': 'prediction', 'labels': [1], 'remove_filtered': True}]
419 prediction = ContainerPrediction({
420 'detection_out1': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0],
421 'detection_out2': make_representation('0 0 0 10 10', score=1)[0]
423 expected = ContainerPrediction({
424 'detection_out1': make_representation('0 0 0 10 10', score=1)[0],
425 'detection_out2': make_representation('0 0 0 10 10', score=1)[0]
428 postprocess_data(PostprocessingExecutor(config), [None], [prediction])
430 assert prediction == expected
432 def test_filter_regular_annotations_and_regular_predictions_by_labels_with_ignore_using_apply_to(self):
433 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': False}]
434 prediction = make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
435 expected_prediction = make_representation(
436 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
438 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
439 expected_annotation = make_representation(
440 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
443 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
445 assert prediction == expected_prediction and annotation == expected_annotation
447 def test_filter_regular_annotations_and_regular_predictions_by_labels_with_remove_using_apply_to(self):
448 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': True}]
449 prediction = make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)
450 expected_prediction = make_representation('0 0 0 10 10', score=1)
451 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)
452 expected_annotation = make_representation('0 0 0 10 10', is_ground_truth=True)
454 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
456 assert prediction == expected_prediction and annotation == expected_annotation
458 def test_filter_container_annotations_and_regular_predictions_by_labels_with_ignore_using_apply_to(self):
459 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': False}]
460 prediction = make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
461 expected_prediction = make_representation(
462 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
464 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
465 expected_annotation = make_representation(
466 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
469 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
471 assert prediction == expected_prediction and annotation == expected_annotation
473 def test_filter_container_annotations_and_regular_predictions_by_labels_with_remove_using_apply_to(self):
474 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': True}]
475 prediction = make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
476 expected_prediction = make_representation('0 0 0 10 10', score=1)[0]
477 annotation = ContainerAnnotation({
478 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
480 expected_annotation = ContainerAnnotation({
481 'annotation': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
484 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
486 assert prediction == expected_prediction and annotation == expected_annotation
488 def test_filter_regular_annotations_and_container_predictions_by_labels_with_ignore_using_apply_to(self):
489 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': False}]
490 prediction = ContainerPrediction({
491 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
493 expected_prediction = ContainerPrediction({
494 'detection_out': make_representation(
495 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
498 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
499 expected_annotation = make_representation(
500 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
503 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
505 assert prediction == expected_prediction and annotation == expected_annotation
507 def test_filter_regular_annotations_and_container_predictions_by_labels_with_remove_using_apply_to(self):
508 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': True}]
509 prediction = ContainerPrediction({
510 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
512 expected_prediction = ContainerPrediction({'detection_out': make_representation('0 0 0 10 10', score=1)[0]})
513 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
514 expected_annotation = make_representation('0 0 0 10 10', is_ground_truth=True)[0]
516 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
518 assert prediction == expected_prediction and annotation == expected_annotation
520 def test_filter_container_annotations_and_container_predictions_by_labels_with_ignore_using_apply_to(self):
521 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': False}]
522 prediction = ContainerPrediction({
523 'detection_out': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
525 expected_prediction = ContainerPrediction({
526 'detection_out': make_representation(
527 '0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}]
530 annotation = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
531 expected_annotation = make_representation(
532 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
535 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
537 assert prediction == expected_prediction and annotation == expected_annotation
539 def test_filter_container_annotations_and_container_predictions_by_labels_with_remove_using_apply_to(self):
540 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': True}]
541 prediction = ContainerPrediction({
542 'prediction': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]
544 expected_prediction = ContainerPrediction({'prediction': make_representation('0 0 0 10 10', score=1)[0]})
545 annotation = ContainerAnnotation({
546 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
548 expected_annotation = ContainerAnnotation({
549 'annotation': make_representation('0 0 0 10 10', is_ground_truth=True)[0]
552 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
554 assert prediction == expected_prediction and annotation == expected_annotation
556 def test_filter_container_annotations_and_container_predictions_by_labels_with_ignore_using_sources(self):
557 config = [{'type': 'filter', 'apply_to': 'all', 'labels': [1], 'remove_filtered': False}]
558 prediction = ContainerPrediction({'prediction': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]})
559 expected_prediction = ContainerPrediction({
560 'prediction': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1, meta=[{'difficult_boxes': [1]}])[0]
562 annotation = ContainerAnnotation({
563 'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]
565 expected_annotation = ContainerAnnotation({
566 'annotation': make_representation(
567 '0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True, meta=[{'difficult_boxes': [1]}]
571 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
573 assert prediction == expected_prediction and annotation == expected_annotation
575 def test_filter_container_annotations_and_container_predictions_by_labels_with_remove_using_sources(self):
576 config = [{'type': 'filter', 'annotation_source': 'annotation', 'prediction_source': 'prediction',
577 'labels': [1], 'remove_filtered': True}]
578 prediction = ContainerPrediction({'prediction': make_representation('0 0 0 10 10; 1 0 0 11 11', score=1)[0]})
579 expected_prediction = ContainerPrediction({'prediction': make_representation('0 0 0 10 10', score=1)[0]})
580 annotation = ContainerAnnotation(
581 {'annotation': make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)[0]})
582 expected_annotation = ContainerAnnotation(
583 {'annotation': make_representation('0 0 0 10 10', is_ground_truth=True)[0]})
585 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
587 assert prediction == expected_prediction and annotation == expected_annotation
589 def test_filter_annotations_by_min_confidence_do_nothing(self):
590 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_confidence': 0.5, 'remove_filtered': True}]
591 annotations = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)
592 expected_annotations = make_representation('0 0 0 10 10; 1 0 0 11 11', is_ground_truth=True)
594 postprocess_data(PostprocessingExecutor(config), annotations, [None])
596 assert np.array_equal(annotations, expected_annotations)
598 def test_filter_predictions_by_min_confidence_with_ignore(self):
599 config = [{'type': 'filter', 'apply_to': 'prediction', 'min_confidence': 0.5, 'remove_filtered': False}]
601 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.3, 0.8])[0],
602 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.5, 0.4])[0]
604 expected_predictions = [
605 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.3, 0.8], meta=[{'difficult_boxes': [0]}])[0],
606 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.5, 0.4], meta=[{'difficult_boxes': [1]}])[0]
609 executor = PostprocessingExecutor(config)
610 postprocess_data(executor, [None, None], predictions)
612 assert np.array_equal(predictions, expected_predictions)
614 def test_filter_predictions_by_min_confidence_with_remove(self):
615 config = [{'type': 'filter', 'apply_to': 'prediction', 'min_confidence': 0.5, 'remove_filtered': True}]
617 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.3, 0.8])[0],
618 make_representation('0 0 0 10 10; 1 0 0 11 11', score=[0.5, 0.4])[0]
620 expected_predictions = [
621 make_representation('1 0 0 11 11', score=0.8)[0],
622 make_representation('0 0 0 10 10', score=0.5)[0]
625 postprocess_data(PostprocessingExecutor(config), [None, None], predictions)
627 assert np.array_equal(predictions, expected_predictions)
629 def test_filter_annotations_by_height_range_with_ignored(self):
632 'apply_to': 'annotation',
633 'height_range': '(10.0, 20.0)',
634 'remove_filtered': False
637 make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True)[0],
638 make_representation('0 0 5 0 35; 1 0 10 0 40', is_ground_truth=True)[0]
641 make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True, meta=[{'difficult_boxes': [1]}])[0],
642 make_representation('0 0 5 0 35; 1 0 10 0 40', is_ground_truth=True, meta=[{'difficult_boxes': [0, 1]}])[0]
645 postprocess_data(PostprocessingExecutor(config), annotations, [None, None])
647 assert np.array_equal(annotations, expected)
649 def test_filter_annotations_by_height_range_with_remove(self):
650 config = [{'type': 'filter', 'apply_to': 'annotation', 'height_range': '(10.0, 20.0)', 'remove_filtered': True}]
652 make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True)[0],
653 make_representation('0 0 5 0 35; 1 0 10 0 40', is_ground_truth=True)[0]
656 make_representation('0 0 5 0 15', is_ground_truth=True)[0],
657 make_representation('', is_ground_truth=True)[0]
660 postprocess_data(PostprocessingExecutor(config), annotations, [None, None])
662 assert np.array_equal(annotations, expected)
664 def test_filter_predictions_by_height_range_with_ignored(self):
667 'apply_to': 'prediction',
668 'height_range': '(10.0, 20.0)',
669 'remove_filtered': False
672 make_representation('0 0 5 0 15; 1 0 10 0 15', score=1)[0],
673 make_representation('0 0 5 0 35; 1 0 10 0 40', score=1)[0]
676 make_representation('0 0 5 0 15; 1 0 10 0 15', score=1, meta=[{'difficult_boxes': [1]}])[0],
677 make_representation('0 0 5 0 35; 1 0 10 0 40', score=1, meta=[{'difficult_boxes': [0, 1]}])[0]
680 postprocess_data(PostprocessingExecutor(config), [None, None], predictions)
682 assert np.array_equal(predictions, expected)
684 def test_filter_predictions_by_height_range_with_remove(self):
685 config = [{'type': 'filter', 'apply_to': 'prediction', 'height_range': '(10.0, 20.0)', 'remove_filtered': True}]
687 make_representation('0 0 5 0 15; 1 0 10 0 15', score=1)[0],
688 make_representation('0 0 5 0 35; 1 0 10 0 40', score=1)[0]
691 make_representation('0 0 5 0 15', score=1)[0],
692 make_representation('', score=1)[0]
695 postprocess_data(PostprocessingExecutor(config), [None, None], predictions)
697 assert np.array_equal(predictions, expected)
699 def test_filter_predictions_by_unknown_min_visibility_raises_value_error_exception(self):
700 config = [{'type': 'filter', 'apply_to': 'prediction', 'min_visibility': 'unknown'}]
702 make_representation('0 0 5 0 15; 1 0 10 0 15', score=1)[0],
703 make_representation('0 0 5 0 35; 1 0 10 0 40', score=1)[0]
706 with pytest.raises(ValueError):
707 postprocess_data(PostprocessingExecutor(config), [None], predictions)
709 def test_filter_annotations_by_unknown_min_visibility_raises_value_error_exception(self):
710 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'unknown'}]
711 annotations = [DetectionPrediction(y_mins=[5.0, 10.0], y_maxs=[15.0, 40.0])]
713 with pytest.raises(ValueError):
714 postprocess_data(PostprocessingExecutor(config), annotations, [None])
716 def test_filter_predictions_by_visibility_raises_value_error_with_unknown_visibility(self):
717 config = [{'type': 'filter', 'apply_to': 'prediction', 'min_visibility': 'heavy occluded'}]
718 predictions = [DetectionPrediction(
719 y_mins=[5.0, 10.0], y_maxs=[15.0, 40.0], metadata={'visibilities': ['unknown']}
722 with pytest.raises(ValueError):
723 postprocess_data(PostprocessingExecutor(config), [None], predictions)
725 def test_filter_annotations_by_visibility_raises_value_error_with_unknown_visibility(self):
726 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'heavy occluded'}]
727 annotations = [DetectionAnnotation(
728 y_mins=[5.0, 10.0], y_maxs=[15.0, 40.0], metadata={'visibilities': ['unknown']}
731 with pytest.raises(ValueError):
732 postprocess_data(PostprocessingExecutor(config), annotations, [None])
734 def test_filter_by_visibility_does_nothing_with_annotations_without_visibility(self):
735 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'heavy occluded'}]
737 make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True)[0],
738 make_representation('0 0 5 0 35; 1 0 10 0 40', is_ground_truth=True)[0]
741 make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True, meta=[{'difficult_boxes': []}])[0],
742 make_representation('0 0 5 0 35; 1 0 10 0 40', is_ground_truth=True, meta=[{'difficult_boxes': []}])[0]
745 postprocess_data(PostprocessingExecutor(config), annotations, [None, None])
747 assert np.array_equal(annotations, expected)
749 def test_filter_by_visibility_does_nothing_with_predictions_without_visibility(self):
750 config = [{'type': 'filter', 'apply_to': 'prediction', 'min_visibility': 'heavy occluded'}]
752 DetectionPrediction(y_mins=[5.0, 10.0], y_maxs=[15.0, 40.0]),
753 DetectionPrediction(y_mins=[5.0, 10.0], y_maxs=[35.0, 50.0])
756 DetectionPrediction(y_mins=[5.0, 10.0], y_maxs=[15.0, 40.0], metadata={'difficult_boxes': []}),
757 DetectionPrediction(y_mins=[5.0, 10.0], y_maxs=[35.0, 50.0], metadata={'difficult_boxes': []})
760 postprocess_data(PostprocessingExecutor(config), [None, None], predictions)
762 assert np.array_equal(predictions, expected)
764 def test_filter_by_visibility_does_nothing_with_default_visibility_level_and_heavy_occluded(self):
765 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'heavy occluded'}]
766 annotation = make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True)[0]
767 expected = make_representation(
768 '0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True, meta=[{'difficult_boxes': []}]
771 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
773 assert annotation == expected
775 def test_filter_by_visibility_does_nothing_with_default_visibility_level_and_partially_occluded(self):
776 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'partially occluded'}]
777 annotation = make_representation('0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True)[0]
778 expected = make_representation(
779 '0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True, meta=[{'difficult_boxes': []}]
782 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
784 assert annotation == expected
786 def test_filter_by_visibility_filters_partially_occluded_remove_filtered(self):
787 config = [{'type': 'filter', 'apply_to': 'annotation', 'min_visibility': 'partially occluded',
788 'remove_filtered': True}]
789 annotation = make_representation(
790 '0 0 5 0 15; 1 0 10 0 15', is_ground_truth=True,
791 meta=[{'visibilities': ['heavy occluded', 'partially occluded']}]
793 expected = make_representation(
794 '1 0 10 0 15', is_ground_truth=True, meta=[{'visibilities': ['heavy occluded', 'partially occluded']}]
797 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
799 assert annotation == expected
801 def test_nms(self, mocker):
802 mock = mocker.patch('accuracy_checker.postprocessor.nms.NMS.process_all', return_value=([], []))
803 config = [{'type': 'nms', 'overlap': 0.4}]
804 postprocess_data(PostprocessingExecutor(config), [], [])
805 mock.assert_called_once_with([], [])
807 def test_resize_prediction_boxes(self):
808 config = [{'type': 'resize_prediction_boxes'}]
809 annotation = DetectionAnnotation(metadata={'image_size': [(100, 100, 3)]})
810 prediction = make_representation('0 0 0 5 5; 1 7 7 8 8', score=1)[0]
811 expected = make_representation('0 0 0 500 500; 1 700 700 800 800', score=1)[0]
813 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
815 assert prediction == expected
817 def test_clip_annotation_denormalized_boxes(self):
818 config = [{'type': 'clip_boxes', 'apply_to': 'annotation', 'boxes_normalized': False}]
819 meta = {'image_size': [(10, 10, 3)]}
820 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True, meta=[meta])[0]
821 expected = make_representation('0 0 0 5 5; 1 9 10 10 10', is_ground_truth=True, meta=[meta])[0]
823 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
825 assert annotation == expected
827 def test_clip_annotation_normalized_boxes(self):
828 config = [{'type': 'clip_boxes', 'apply_to': 'annotation', 'boxes_normalized': True}]
829 meta = {'image_size': [(10, 10, 3)]}
830 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True, meta=[meta])[0]
831 expected = make_representation('0 0 0 1 1; 1 1 1 1 1', is_ground_truth=True, meta=[meta])[0]
833 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
835 assert annotation == expected
837 def test_clip_annotation_denormalized_boxes_with_size(self):
838 config = [{'type': 'clip_boxes', 'apply_to': 'annotation', 'boxes_normalized': False, 'size': 10}]
839 meta = {'image_size': [(10, 10, 3)]}
840 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True, meta=[meta])[0]
841 expected = make_representation('0 0 0 5 5; 1 9 10 10 10', is_ground_truth=True, meta=[meta])[0]
843 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
845 assert annotation == expected
847 def test_clip_annotation_normalized_boxes_with_size_as_normalized(self):
848 config = [{'type': 'clip_boxes', 'apply_to': 'annotation', 'boxes_normalized': True, 'size': 10}]
849 meta = {'image_size': [(10, 10, 3)]}
850 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True, meta=[meta])[0]
851 expected = make_representation('0 0 0 1 1; 1 1 1 1 1', is_ground_truth=True, meta=[meta])[0]
853 postprocess_data(PostprocessingExecutor(config), [annotation], [None])
855 assert annotation == expected
857 def test_clip_prediction_denormalized_boxes(self):
858 config = [{'type': 'clip_boxes', 'apply_to': 'prediction', 'boxes_normalized': False}]
859 annotation = DetectionAnnotation(metadata={'image_size': [(10, 10, 3)]})
860 prediction = make_representation('0 -1 0 5 5; 1 9 11 10 10', score=1)[0]
861 expected = make_representation('0 0 0 5 5; 1 9 10 10 10', score=1)[0]
863 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
865 assert prediction == expected
867 def test_clip_prediction_normalized_boxes(self):
868 config = [{'type': 'clip_boxes', 'apply_to': 'prediction', 'boxes_normalized': True}]
869 annotation = DetectionAnnotation(metadata={'image_size': [(10, 10, 3)]})
870 prediction = make_representation('0 -1 0 5 5; 1 9 11 10 10', score=1)[0]
871 expected = make_representation('0 0 0 1 1; 1 1 1 1 1', score=1)[0]
872 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
874 assert prediction == expected
876 def test_clip_predictions_denormalized_boxes_with_size(self):
877 config = [{'type': 'clip_boxes', 'apply_to': 'prediction', 'boxes_normalized': False, 'size': 10}]
878 annotation = DetectionAnnotation(metadata={'image_size': [(10, 10, 3)]})
879 prediction = make_representation('0 -1 0 5 5; 1 9 11 10 10', score=1)[0]
880 expected = make_representation('0 0 0 5 5; 1 9 10 10 10', score=1)[0]
882 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
884 assert prediction == expected
886 def test_clip_predictions_normalized_boxes_with_size_as_normalized(self):
887 config = [{'type': 'clip_boxes', 'apply_to': 'prediction', 'boxes_normalized': True, 'size': 10}]
888 annotation = DetectionAnnotation(metadata={'image_size': [(10, 10, 3)]})
889 prediction = make_representation('0 -1 0 5 5; 1 9 11 10 10', score=1)[0]
890 expected = make_representation('0 0 0 1 1; 1 1 1 1 1', score=1)[0]
892 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
894 assert prediction == expected
896 def test_cast_to_int_default(self):
897 config = [{'type': 'cast_to_int'}]
898 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
899 prediction = make_representation('0 -1.1 0.5 5.9 5.1; 1 -9.9 11.5 10.9 10.1', score=1)[0]
900 expected_annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
901 expected_prediction = make_representation('0 -1 0 6 5; 1 -10 12 11 10', score=1)[0]
903 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
905 assert prediction == expected_prediction and annotation == expected_annotation
907 def test_cast_to_int_to_nearest(self):
908 config = [{'type': 'cast_to_int', 'round_policy': 'nearest'}]
909 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
910 prediction = make_representation('0 -1.1 0.5 5.9 5.1; 1 -9.9 11.5 10.9 10.1', score=1)[0]
911 expected_annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
912 expected_prediction = make_representation('0 -1 0 6 5; 1 -10 12 11 10', score=1)[0]
914 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
916 assert prediction == expected_prediction and annotation == expected_annotation
918 def test_cast_to_int_to_nearest_to_zero(self):
919 config = [{'type': 'cast_to_int', 'round_policy': 'nearest_to_zero'}]
920 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
921 prediction = make_representation('0 -1.1 0.5 5.9 5.1; 1 -9.9 11.5 10.9 10.1', score=1)[0]
922 expected_annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
923 expected_prediction = make_representation('0 -1 0 5 5; 1 -9 11 10 10', score=1)[0]
925 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
927 assert prediction == expected_prediction and annotation == expected_annotation
929 def test_cast_to_int_to_lower(self):
930 config = [{'type': 'cast_to_int', 'round_policy': 'lower'}]
931 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
932 prediction = make_representation('0 -1.1 0.5 5.9 5.1; 1 -9.9 11.5 10.9 10.1', score=1)[0]
933 expected_annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
934 expected_prediction = make_representation('0 -2 0 5 5; 1 -10 11 10 10', score=1)[0]
936 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
938 assert prediction == expected_prediction and annotation == expected_annotation
940 def test_cast_to_int_to_greater(self):
941 config = [{'type': 'cast_to_int', 'round_policy': 'greater'}]
942 annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
943 prediction = make_representation('0 -1.1 0.5 5.9 5.1; 1 -9.9 11.5 10.9 10.1', score=1)[0]
944 expected_annotation = make_representation('0 -1 0 5 5; 1 9 11 10 10', is_ground_truth=True)[0]
945 expected_prediction = make_representation('0 -1 1 6 6; 1 -9 12 11 11', score=1)[0]
947 postprocess_data(PostprocessingExecutor(config), [annotation], [prediction])
949 assert prediction == expected_prediction and annotation == expected_annotation
951 def test_cast_to_int_to_unknown_raise_config_error(self):
952 config = [{'type': 'cast_to_int', 'round_policy': 'unknown'}]
954 with pytest.raises(ConfigError):
955 postprocess_data(PostprocessingExecutor(config), [None], [None])
957 def test_extend_segmentation_mask_with_float_filling_raise_config_error(self):
958 config = [{'type': 'extend_segmentation_mask', 'filling_label': 0.5}]
960 with pytest.raises(ConfigError):
961 postprocess_data(PostprocessingExecutor(config), [None], [None])
963 def test_extend_segmentation_mask_default(self):
964 config = [{'type': 'extend_segmentation_mask'}]
965 annotation = make_segmentation_representation(np.zeros((5, 5)), ground_truth=True)
966 prediction = make_segmentation_representation(np.zeros((7, 7)), ground_truth=False)
967 expected_annotation_mask = np.zeros((7, 7))
968 expected_annotation_mask[0, :] = 255
969 expected_annotation_mask[:, 0] = 255
970 expected_annotation_mask[-1, :] = 255
971 expected_annotation_mask[:, -1] = 255
972 expected_prediction_mask = np.zeros((7, 7))
973 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
974 assert np.array_equal(prediction[0].mask, expected_prediction_mask)
975 assert np.array_equal(annotation[0].mask, expected_annotation_mask)
977 def test_extend_segmentation_mask_do_nothing(self):
978 config = [{'type': 'extend_segmentation_mask'}]
979 annotation = make_segmentation_representation(np.zeros((5, 5)), ground_truth=True)
980 prediction = make_segmentation_representation(np.zeros((5, 5)), ground_truth=False)
981 expected_mask = np.zeros((5, 5))
982 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
983 assert np.array_equal(prediction[0].mask, expected_mask)
984 assert np.array_equal(annotation[0].mask, expected_mask)
986 def test_extend_segmentation_mask_asymmetrical(self):
987 config = [{'type': 'extend_segmentation_mask'}]
988 annotation = make_segmentation_representation(np.zeros((5, 5)), ground_truth=True)
989 prediction = make_segmentation_representation(np.zeros((6, 7)), ground_truth=False)
990 expected_annotation_mask = np.zeros((6, 7))
991 expected_annotation_mask[:, 0] = 255
992 expected_annotation_mask[-1, :] = 255
993 expected_annotation_mask[:, -1] = 255
994 expected_prediction_mask = np.zeros((6, 7))
995 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
996 assert np.array_equal(prediction[0].mask, expected_prediction_mask)
997 assert np.array_equal(annotation[0].mask, expected_annotation_mask)
999 def test_extend_segmentation_mask_raise_config_error_if_prediction_less_annotation(self):
1000 config = [{'type': 'extend_segmentation_mask'}]
1001 annotation = make_segmentation_representation(np.zeros((5, 5)), ground_truth=True)
1002 prediction = make_segmentation_representation(np.zeros((4, 4)), ground_truth=False)
1003 with pytest.raises(ConfigError):
1004 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
1006 def test_extend_segmentation_mask_with_filling_label(self):
1007 config = [{'type': 'extend_segmentation_mask', 'filling_label': 1}]
1008 annotation = make_segmentation_representation(np.zeros((5, 5)), ground_truth=True)
1009 prediction = make_segmentation_representation(np.zeros((7, 7)), ground_truth=False)
1010 expected_annotation_mask = np.zeros((7, 7))
1011 expected_annotation_mask[0, :] = 1
1012 expected_annotation_mask[:, 0] = 1
1013 expected_annotation_mask[-1, :] = 1
1014 expected_annotation_mask[:, -1] = 1
1015 expected_prediction_mask = np.zeros((7, 7))
1016 postprocess_data(PostprocessingExecutor(config), annotation, prediction)
1017 assert np.array_equal(prediction[0].mask, expected_prediction_mask)
1018 assert np.array_equal(annotation[0].mask, expected_annotation_mask)
1021 class TestPostprocessorExtraArgs:
1022 def test_cast_to_int_raise_config_error_on_extra_args(self):
1023 config = {'type': 'cast_to_int', 'something_extra': 'extra'}
1024 with pytest.raises(ConfigError):
1025 postprocess_data(PostprocessingExecutor(config), [None], [None])
1027 def test_clip_boxes_raise_config_error_on_extra_args(self):
1028 config = {'type': 'clip_boxes', 'size': 1, 'something_extra': 'extra'}
1029 with pytest.raises(ConfigError):
1030 postprocess_data(PostprocessingExecutor(config), [None], [None])
1032 def test_correct_yolo_v2_boxes_raise_config_error_on_extra_args(self):
1033 config = {'type': 'correct_yolo_v2_boxes', 'something_extra': 'extra'}
1034 with pytest.raises(ConfigError):
1035 postprocess_data(PostprocessingExecutor(config), [None], [None])
1037 def test_encode_segmentation_mask_raise_config_error_on_extra_args(self):
1038 config = {'type': 'encode_segmentation_mask', 'something_extra': 'extra'}
1039 with pytest.raises(ConfigError):
1040 postprocess_data(PostprocessingExecutor(config), [None], [None])
1042 def test_filter_raise_config_error_on_extra_args(self):
1043 config = {'type': 'filter', 'something_extra': 'extra'}
1044 with pytest.raises(ConfigError):
1045 postprocess_data(PostprocessingExecutor(config), [None], [None])
1047 def test_nms_raise_config_error_on_extra_args(self):
1048 config = {'type': 'nms', 'something_extra': 'extra'}
1049 with pytest.raises(ConfigError):
1050 postprocess_data(PostprocessingExecutor(config), [None], [None])
1052 def test_normalize_landmarks_points_raise_config_error_on_extra_args(self):
1053 config = {'type': 'normalize_landmarks_points', 'something_extra': 'extra'}
1054 with pytest.raises(ConfigError):
1055 postprocess_data(PostprocessingExecutor(config), [None], [None])
1057 def test_resize_prediction_boxes_raise_config_error_on_extra_args(self):
1058 config = {'type': 'resize_prediction_boxes', 'something_extra': 'extra'}
1059 with pytest.raises(ConfigError):
1060 postprocess_data(PostprocessingExecutor(config), [None], [None])
1062 def test_resize_segmentation_mask_raise_config_error_on_extra_args(self):
1063 config = {'type': 'resize_segmentation_mask', 'something_extra': 'extra'}
1064 with pytest.raises(ConfigError):
1065 postprocess_data(PostprocessingExecutor(config), [None], [None])
1067 def test_extend_segmentation_mask_raise_config_error_on_extra_args(self):
1068 config = {'type': 'resize_segmentation_mask', 'something_extra': 'extra'}
1069 with pytest.raises(ConfigError):
1070 postprocess_data(PostprocessingExecutor(config), [None], [None])