Closed shairubin closed 5 months ago
with open("caffe2/test/test_img/p1.jpg", "rb") as fp: weight = torch.full((3,), 1.0 / 255.0).diag() bias = torch.zeros(3) byte_tensor = torch.tensor(list(fp.read())).byte() im2_tensor = torch.ops.fb.image_decode_to_NCHW(byte_tensor, weight, bias) self.assertEqual(raw_data.shape, im2_tensor.shape) self.assertEqual(raw_data, im2_tensor, atol=0.1, rtol=1e-01)
with open("caffe2/test/test_img/p1.jpg", "rb") as fp: weight = torch.full((3,), 1.0 / 255.0).diag() bias = torch.zeros(3) byte_tensor = torch.tensor(list(fp.read())).byte() im2_tensor = torch.ops.fb.image_decode_to_NCHW(byte_tensor, weight, bias) self.assertEqual(raw_data.shape, im2_tensor.shape) self.assertEqual(raw_data, im2_tensor, atol=0.1, rtol=1e-01)