def test_anti_instagram_correctness(self): logger.info('This is going to test that algorithm 1 and 2 give same results') id_scale, id_shift = [1.0, 1.0, 1.0], [0.0, 0.0, 0.0] img = random_image(480, 640) logger.info('algo 1 respects the identity') a = scaleandshift1(img, id_scale, id_shift) self.assert_L1_small(img, a) logger.info('algo 2 respects the identity') b = scaleandshift2(img, id_scale, id_shift) self.assert_L1_small(img, b) logger.info('algo 1 and 2 give the same output with random shift') scale = id_scale shift = np.random.rand(3) img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2) logger.info('algo 1 and 2 give the same output with random scale') scale = np.random.rand(3) shift = id_shift # 0 shift img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2) logger.info('algo 1 and 2 give the same output with random inputs') scale = np.random.rand(3) shift = np.random.rand(3) img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2)
def test_anti_instagram_correctness(self): logger.info( 'This is going to test that algorithm 1 and 2 give same results') id_scale, id_shift = [1.0, 1.0, 1.0], [0.0, 0.0, 0.0] img = random_image(480, 640) logger.info('algo 1 respects the identity') a = scaleandshift1(img, id_scale, id_shift) self.assert_L1_small(img, a) logger.info('algo 2 respects the identity') b = scaleandshift2(img, id_scale, id_shift) self.assert_L1_small(img, b) logger.info('algo 1 and 2 give the same output with random shift') scale = id_scale shift = np.random.rand(3) img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2) logger.info('algo 1 and 2 give the same output with random scale') scale = np.random.rand(3) shift = id_shift # 0 shift img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2) logger.info('algo 1 and 2 give the same output with random inputs') scale = np.random.rand(3) shift = np.random.rand(3) img1 = scaleandshift1(img, scale, shift) img2 = scaleandshift2(img, scale, shift) self.assert_L1_small(img1, img2)
def setup(): img = random_image(Params.shape[0], Params.shape[1]) ai = AntiInstagram() return ai, img