def test_transforms_works_with_coords( ): # test of backward compatible behavior sz = 16 transforms = image_gen(tfm_norm, tfm_denorm, sz, tfms=None, max_zoom=None, pad=0, crop_type=CropType.NO, tfm_y=TfmType.COORD, sz_y=sz, pad_mode=cv2.BORDER_REFLECT) x, y = transforms(t_rand_img128x128x3, np.array([0, 0, 128, 128, 0, 0, 64, 64])) bbs = partition(y, 4) assert x.shape[ 0] == 3, "The image was converted from NHWC to NCHW (channle first pytorch format)" h, w = x.shape[1:] np.testing.assert_equal(bbs[0], [0, 0, h - buggy_offset, w - buggy_offset], "The outer bounding box was converted correctly") np.testing.assert_equal(bbs[1], [0, 0, h / 2 - buggy_offset, w / 2 - buggy_offset], "The inner bounding box was converted correctly")
def test_transforms_works_with_coords(): # test of backward compatible behavior sz = 16 transforms = image_gen(tfm_norm, tfm_denorm, sz, tfms=None, max_zoom=None, pad=0, crop_type=CropType.NO, tfm_y=TfmType.COORD, sz_y=sz, pad_mode=cv2.BORDER_REFLECT) x, y = transforms(t_rand_img128x128x3, np.array([0,0,128,128, 0,0,64,64])) bbs = partition(y, 4) assert x.shape[0] == 3, "The image was converted from NHWC to NCHW (channle first pytorch format)" h,w = x.shape[1:] np.testing.assert_equal(bbs[0], [0, 0, h-buggy_offset, w-buggy_offset], "The outer bounding box was converted correctly") np.testing.assert_equal(bbs[1], [0, 0, h/2-buggy_offset, w/2-buggy_offset], "The inner bounding box was converted correctly")