-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Tests for inference process module. | ||
""" | ||
|
||
import numpy as np | ||
import numpy.typing as npt | ||
import pytest | ||
|
||
from fast_plate_ocr.inference.process import postprocess_output | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model_output, max_plate_slots, model_alphabet, expected_plates", | ||
[ | ||
( | ||
np.array( | ||
[ | ||
[[0.5, 0.4, 0.1], [0.2, 0.6, 0.2], [0.1, 0.4, 0.5]], | ||
[[0.1, 0.1, 0.8], [0.2, 0.2, 0.6], [0.1, 0.4, 0.5]], | ||
], | ||
dtype=np.float32, | ||
), | ||
3, | ||
"ABC", | ||
["ABC", "CCC"], | ||
), | ||
( | ||
np.array( | ||
[[[0.1, 0.4, 0.5], [0.6, 0.2, 0.2], [0.1, 0.5, 0.4]]], | ||
dtype=np.float32, | ||
), | ||
3, | ||
"ABC", | ||
["CAB"], | ||
), | ||
], | ||
) | ||
def test_postprocess_output( | ||
model_output: npt.NDArray, | ||
max_plate_slots: int, | ||
model_alphabet: str, | ||
expected_plates: list[str], | ||
) -> None: | ||
actual_plate = postprocess_output(model_output, max_plate_slots, model_alphabet) | ||
assert actual_plate == expected_plates |