✅ [Pass] test in multiclass label&dynamic shape
Browse files
tests/test_tools/test_data_augmentation.py
CHANGED
@@ -54,7 +54,7 @@ def test_mosaic():
|
|
54 |
|
55 |
# Mock parent with image_size and get_more_data method
|
56 |
class MockParent:
|
57 |
-
|
58 |
|
59 |
def get_more_data(self, num_images):
|
60 |
return [(img, boxes) for _ in range(num_images)]
|
|
|
54 |
|
55 |
# Mock parent with image_size and get_more_data method
|
56 |
class MockParent:
|
57 |
+
base_size = 100
|
58 |
|
59 |
def get_more_data(self, num_images):
|
60 |
return [(img, boxes) for _ in range(num_images)]
|
tests/test_tools/test_data_loader.py
CHANGED
@@ -43,14 +43,14 @@ def test_training_data_loader_correctness(train_dataloader: DataLoader):
|
|
43 |
def test_validation_data_loader_correctness(validation_dataloader: DataLoader):
|
44 |
batch_size, images, targets, reverse_tensors, image_paths = next(iter(validation_dataloader))
|
45 |
assert batch_size == 4
|
46 |
-
assert images.shape == (4, 3,
|
47 |
assert targets.shape == (4, 18, 5)
|
48 |
assert reverse_tensors.shape == (4, 5)
|
49 |
expected_paths = [
|
50 |
-
Path("tests/data/images/val/000000151480.jpg"),
|
51 |
Path("tests/data/images/val/000000284106.jpg"),
|
52 |
-
Path("tests/data/images/val/
|
53 |
Path("tests/data/images/val/000000570456.jpg"),
|
|
|
54 |
]
|
55 |
assert list(image_paths) == list(expected_paths)
|
56 |
|
|
|
43 |
def test_validation_data_loader_correctness(validation_dataloader: DataLoader):
|
44 |
batch_size, images, targets, reverse_tensors, image_paths = next(iter(validation_dataloader))
|
45 |
assert batch_size == 4
|
46 |
+
assert images.shape == (4, 3, 512, 768)
|
47 |
assert targets.shape == (4, 18, 5)
|
48 |
assert reverse_tensors.shape == (4, 5)
|
49 |
expected_paths = [
|
|
|
50 |
Path("tests/data/images/val/000000284106.jpg"),
|
51 |
+
Path("tests/data/images/val/000000151480.jpg"),
|
52 |
Path("tests/data/images/val/000000570456.jpg"),
|
53 |
+
Path("tests/data/images/val/000000323571.jpg"),
|
54 |
]
|
55 |
assert list(image_paths) == list(expected_paths)
|
56 |
|
tests/test_utils/test_bounding_box_utils.py
CHANGED
@@ -182,7 +182,7 @@ def test_bbox_nms():
|
|
182 |
dtype=float32,
|
183 |
)
|
184 |
|
185 |
-
nms_cfg = NMSConfig(min_confidence=0.5, min_iou=0.5)
|
186 |
|
187 |
# Batch 1:
|
188 |
# - box 1 is kept with class 0 as it has a higher confidence than box 4 i.e. box 4 is filtered out
|
@@ -197,16 +197,24 @@ def test_bbox_nms():
|
|
197 |
[
|
198 |
[0.0, 0.0, 0.0, 160.0, 120.0, 0.6682],
|
199 |
[1.0, 160.0, 120.0, 320.0, 240.0, 0.6457],
|
|
|
|
|
|
|
|
|
200 |
],
|
201 |
[
|
202 |
[0.0, 16.0, 12.0, 176.0, 132.0, 0.6900],
|
203 |
[2.0, 0.0, 120.0, 160.0, 240.0, 0.6570],
|
|
|
|
|
|
|
|
|
204 |
],
|
205 |
]
|
206 |
)
|
207 |
|
208 |
output = bbox_nms(cls_dist, bbox, nms_cfg)
|
209 |
-
|
210 |
for out, exp in zip(output, expected_output):
|
211 |
assert allclose(out, exp, atol=1e-4), f"Output: {out} Expected: {exp}"
|
212 |
|
|
|
182 |
dtype=float32,
|
183 |
)
|
184 |
|
185 |
+
nms_cfg = NMSConfig(min_confidence=0.5, min_iou=0.5, max_bbox=400)
|
186 |
|
187 |
# Batch 1:
|
188 |
# - box 1 is kept with class 0 as it has a higher confidence than box 4 i.e. box 4 is filtered out
|
|
|
197 |
[
|
198 |
[0.0, 0.0, 0.0, 160.0, 120.0, 0.6682],
|
199 |
[1.0, 160.0, 120.0, 320.0, 240.0, 0.6457],
|
200 |
+
[0.0, 160.0, 120.0, 320.0, 240.0, 0.5744],
|
201 |
+
[2.0, 0.0, 0.0, 160.0, 120.0, 0.5498],
|
202 |
+
[1.0, 16.0, 12.0, 176.0, 132.0, 0.5498],
|
203 |
+
[2.0, 160.0, 120.0, 320.0, 240.0, 0.5250],
|
204 |
],
|
205 |
[
|
206 |
[0.0, 16.0, 12.0, 176.0, 132.0, 0.6900],
|
207 |
[2.0, 0.0, 120.0, 160.0, 240.0, 0.6570],
|
208 |
+
[1.0, 0.0, 0.0, 160.0, 120.0, 0.5622],
|
209 |
+
[2.0, 0.0, 0.0, 160.0, 120.0, 0.5498],
|
210 |
+
[1.0, 0.0, 120.0, 160.0, 240.0, 0.5498],
|
211 |
+
[0.0, 0.0, 120.0, 160.0, 240.0, 0.5374],
|
212 |
],
|
213 |
]
|
214 |
)
|
215 |
|
216 |
output = bbox_nms(cls_dist, bbox, nms_cfg)
|
217 |
+
print(output)
|
218 |
for out, exp in zip(output, expected_output):
|
219 |
assert allclose(out, exp, atol=1e-4), f"Output: {out} Expected: {exp}"
|
220 |
|