|
8 | 8 | import numpy as np |
9 | 9 | from PIL import Image |
10 | 10 |
|
11 | | -from model_api.models.result import AnomalyResult, ClassificationResult |
| 11 | +from model_api.models.result import AnomalyResult, ClassificationResult, DetectionResult |
12 | 12 | from model_api.models.result.classification import Label |
13 | 13 | from model_api.visualizer import Visualizer |
14 | 14 |
|
@@ -49,3 +49,17 @@ def test_classification_scene(mock_image: Image, tmpdir: Path): |
49 | 49 | mock_image, classification_result, tmpdir / "classification_scene.jpg" |
50 | 50 | ) |
51 | 51 | 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