Example #1
0
def test_resize_and_pad_masks():
    image_width = int(TEST_IMAGE.width * 0.5)
    image_height = int(TEST_IMAGE.height * 0.5)

    coco = load_coco(COCO_PATH)
    _, sample_masks = load_target_cls_and_masks(coco, img_id=2)

    result = resize_and_pad_masks(sample_masks, image_width, image_height)
    expected_shape = [(image_height, image_width)]
    assert [mask.shape for mask in result] == expected_shape
Example #2
0
def test_load_target_cls_and_masks():
    coco = load_coco(COCO_PATH)
    result = load_target_cls_and_masks(coco, img_id=4)
    expected_label = [2, 2]

    assert len(result) == 2
    assert result[0].shape == (2, )
    assert (expected_label == result[0]).all()

    expected_mask_shapes = [(768, 1024), (768, 1024)]
    assert [mask.shape for mask in result[1]] == expected_mask_shapes
Example #3
0
def test_load_target_cls_and_masks_invalid_argument():
    with pytest.raises(TypeError):
        coco = load_coco(COCO_PATH)
        load_target_cls_and_masks(coco, img_id="not an integer")
Example #4
0
def test_load_coco():
    coco = load_coco(COCO_PATH)
    assert isinstance(coco, COCO)