Пример #1
0
 def test_resize3d_nearest_values(self):
     tensorflow_output = np.squeeze(
         resize_3d(self.tensorflow_array, (4, 4, 4), 'nearest').numpy())
     torch_output = np.squeeze(
         resize_3d(self.pytorch_array, (4, 4, 4), 'nearest').numpy())
     print(tensorflow_output)
     np.testing.assert_array_equal(tensorflow_output[0, 0, :], [0, 0, 1, 1])
     np.testing.assert_array_equal(torch_output[0, 0, :], [0, 0, 1, 1])
Пример #2
0
 def test_resize3d_tf(self):
     np.testing.assert_equal(
         resize_3d(self.tensorflow_array, (4, 4, 4)).numpy().shape,
         (1, 4, 4, 4, 1))
Пример #3
0
 def test_resize3d_torch(self):
     image_shape = resize_3d(self.pytorch_array, (4, 4, 4)).numpy().shape
     np.testing.assert_equal(image_shape, (1, 1, 4, 4, 4))
Пример #4
0
 def test_resize3d_bicubic(self):
     with self.assertRaises(AssertionError):
         _ = np.squeeze(
             resize_3d(self.tensorflow_array, (4, 4, 4), 'bicubic').numpy())
Пример #5
0
 def test_resize3d_nearest(self):
     tensorflow_output = np.squeeze(
         resize_3d(self.tensorflow_array, (4, 4, 4), 'nearest').numpy())
     torch_output = np.squeeze(
         resize_3d(self.pytorch_array, (4, 4, 4), 'nearest').numpy())
     np.testing.assert_array_almost_equal(tensorflow_output, torch_output)
Пример #6
0
 def forward(self, data: List[Tensor],
             state: Dict[str, Any]) -> Union[Tensor, List[Tensor]]:
     return [
         resize_3d(elem, self.output_shape, self.resize_mode)
         for elem in data
     ]