def test_resize(self): """ test resize """ img = self.img_data op_class = 'pil' img_size = (200, 100) pil_data = run_ops( [ ops.DecodeImage(op_class=op_class), ops.ResizeImage( op_class=op_class, size=img_size) ], img) self.assertEqual(type(pil_data), PIL.Image.Image) pil_data = np.array(pil_data) op_class = 'opencv' opencv_data = run_ops( [ ops.DecodeImage(op_class=op_class), ops.ResizeImage( op_class=op_class, size=img_size) ], img) self.assertEqual(type(opencv_data), np.ndarray) self.assertEqual(pil_data.shape, opencv_data.shape) self.assertEqual(pil_data.shape, (100, 200, 3))
def test_randcrop(self): """ test random crop """ img = self.img_data img_size = (200, 100) crop_size = (50, 20) op_class = 'pil' pil_data = run_ops( [ ops.DecodeImage(op_class=op_class), ops.ResizeImage( size=img_size, op_class=op_class), ops.RandCropImage( crop_size, op_class=op_class) ], img) self.assertEqual(type(pil_data), PIL.Image.Image) pil_data = np.array(pil_data) op_class = 'opencv' opencv_data = run_ops( [ ops.DecodeImage(op_class=op_class), ops.ResizeImage( size=img_size, op_class=op_class), ops.RandCropImage( crop_size, op_class=op_class) ], img) self.assertEqual(type(opencv_data), np.ndarray) self.assertEqual(pil_data.shape, opencv_data.shape) self.assertEqual(pil_data.shape, (crop_size[1], crop_size[0], 3))