Skip to content

Commit 4a5ac67

Browse files
Add tests
Signed-off-by: Ashwin Vaidya <[email protected]>
1 parent 56feddf commit 4a5ac67

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/python/unit/visualizer/test_scene.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
from PIL import Image
1010

11-
from model_api.models.result import AnomalyResult, ClassificationResult
11+
from model_api.models.result import AnomalyResult, ClassificationResult, DetectionResult
1212
from model_api.models.result.classification import Label
1313
from model_api.visualizer import Visualizer
1414

@@ -49,3 +49,17 @@ def test_classification_scene(mock_image: Image, tmpdir: Path):
4949
mock_image, classification_result, tmpdir / "classification_scene.jpg"
5050
)
5151
assert Path(tmpdir / "classification_scene.jpg").exists()
52+
53+
54+
def test_detection_scene(mock_image: Image, tmpdir: Path):
55+
"""Test if the detection scene is created."""
56+
detection_result = DetectionResult(
57+
bboxes=np.array([[0, 0, 128, 128], [32, 32, 96, 96]]),
58+
labels=np.array([1, 2]),
59+
label_names=["person", "car"],
60+
scores=np.array([0.85, 0.75]),
61+
saliency_map=(np.ones((1, 2, 6, 8)) * 255).astype(np.uint8),
62+
)
63+
visualizer = Visualizer()
64+
visualizer.save(mock_image, detection_result, tmpdir / "detection_scene.jpg")
65+
assert Path(tmpdir / "detection_scene.jpg").exists()

0 commit comments

Comments
 (0)