コード例 #1
0
    def test_jpeg_compress(self, image_batch, channels_first):
        test_input, test_output = image_batch
        jpeg_compression = JpegCompression(clip_values=(0, 255))

        image_mode = "RGB" if test_input.shape[-1] == 3 else "L"
        test_single_input = np.squeeze(test_input[0]).astype(np.uint8)
        test_single_output = np.squeeze(test_output[0]).astype(np.uint8)

        assert_array_equal(jpeg_compression._compress(test_single_input, image_mode), test_single_output)
コード例 #2
0
def test_jpeg_compress(art_warning, image_batch, channels_first):
    try:
        test_input, test_output = image_batch
        # Run only for grayscale [1] and RGB [3] data because testing `_compress` which is applied internally only to
        # either grayscale or RGB data.
        if test_input.shape[-1] in [1, 3]:
            jpeg_compression = JpegCompression(clip_values=(0, 255))

            image_mode = "RGB" if test_input.shape[-1] == 3 else "L"
            test_single_input = np.squeeze(test_input[0]).astype(np.uint8)
            test_single_output = np.squeeze(test_output[0]).astype(np.uint8)

            assert_array_equal(jpeg_compression._compress(test_single_input, image_mode), test_single_output)
    except ARTTestException as e:
        art_warning(e)