def test_alpha(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.5, 0.51]
     t = RandGibbsNoise(1.0, alpha)
     _ = t(deepcopy(im))
     self.assertGreaterEqual(t.sampled_alpha, 0.5)
     self.assertLessEqual(t.sampled_alpha, 0.51)
Exemplo n.º 2
0
 def test_same_result(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.5, 0.8]
     t = RandGibbsNoise(1.0, alpha)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     assert_allclose(out1, out2, rtol=1e-7, atol=1e-2, type_test="tensor")
 def test_same_result(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.5, 0.8]
     t = RandGibbsNoise(1.0, alpha)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     torch.testing.assert_allclose(out1, out2, rtol=1e-7, atol=0)
     self.assertIsInstance(out1, type(im))
Exemplo n.º 4
0
 def test_same_result(self, im_shape, as_tensor_output, as_tensor_input):
     im = self.get_data(im_shape, as_tensor_input)
     alpha = [0.5, 0.8]
     t = RandGibbsNoise(1.0, alpha, as_tensor_output)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     np.testing.assert_allclose(out1, out2)
     self.assertIsInstance(out1, torch.Tensor if as_tensor_output else np.ndarray)
 def test_alpha_1(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [1.0, 1.0]
     t = RandGibbsNoise(1.0, alpha)
     out = t(deepcopy(im))
     torch.testing.assert_allclose(0 * im, out, rtol=1e-7, atol=0)
 def test_identity(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.0, 0.0]
     t = RandGibbsNoise(1.0, alpha)
     out = t(deepcopy(im))
     torch.testing.assert_allclose(im, out, atol=1e-2, rtol=1e-7)
 def test_0_prob(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.5, 1.0]
     t = RandGibbsNoise(0.0, alpha)
     out = t(im)
     torch.testing.assert_allclose(im, out, rtol=1e-7, atol=0)
Exemplo n.º 8
0
 def test_alpha_1(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [1.0, 1.0]
     t = RandGibbsNoise(1.0, alpha)
     out = t(deepcopy(im))
     assert_allclose(out, 0 * im, rtol=1e-7, atol=1e-2, type_test="tensor")
Exemplo n.º 9
0
 def test_0_prob(self, im_shape, input_type):
     im = self.get_data(im_shape, input_type)
     alpha = [0.5, 1.0]
     t = RandGibbsNoise(0.0, alpha)
     out = t(im)
     assert_allclose(out, im, rtol=1e-7, atol=0, type_test="tensor")
Exemplo n.º 10
0
 def test_alpha_1(self, im_shape, _, as_tensor_input):
     im = self.get_data(im_shape, as_tensor_input)
     alpha = [1.0, 1.0]
     t = RandGibbsNoise(1.0, alpha)
     out = t(deepcopy(im))
     np.testing.assert_allclose(0 * im, out)
Exemplo n.º 11
0
 def test_identity(self, im_shape, _, as_tensor_input):
     im = self.get_data(im_shape, as_tensor_input)
     alpha = [0.0, 0.0]
     t = RandGibbsNoise(1.0, alpha)
     out = t(deepcopy(im))
     np.testing.assert_allclose(im, out, atol=1e-2)
Exemplo n.º 12
0
 def test_0_prob(self, im_shape, as_tensor_output, as_tensor_input):
     im = self.get_data(im_shape, as_tensor_input)
     alpha = [0.5, 1.0]
     t = RandGibbsNoise(0.0, alpha, as_tensor_output)
     out = t(im)
     np.testing.assert_allclose(im, out)