def test_compare_random_color_op(degrees=None, plot=False):
    '\n    Compare Random Color op in Python and Cpp\n    '
    logger.info('test_random_color_op')
    original_seed = config_get_set_seed(5)
    original_num_parallel_workers = config_get_set_num_parallel_workers(1)
    data1 = ds.TFRecordDataset(C_DATA_DIR, C_SCHEMA_DIR, columns_list=['image'], shuffle=False)
    data2 = ds.TFRecordDataset(C_DATA_DIR, C_SCHEMA_DIR, columns_list=['image'], shuffle=False)
    if (degrees is None):
        c_op = vision.RandomColor()
        p_op = F.RandomColor()
    else:
        c_op = vision.RandomColor(degrees)
        p_op = F.RandomColor(degrees)
    transforms_random_color_py = mindspore.dataset.transforms.py_transforms.Compose([(lambda img: img.astype(np.uint8)), F.ToPIL(), p_op, np.array])
    data1 = data1.map(operations=[vision.Decode(), c_op], input_columns=['image'])
    data2 = data2.map(operations=[vision.Decode()], input_columns=['image'])
    data2 = data2.map(operations=transforms_random_color_py, input_columns=['image'])
    image_random_color_op = []
    image = []
    for (item1, item2) in zip(data1.create_dict_iterator(num_epochs=1, output_numpy=True), data2.create_dict_iterator(num_epochs=1, output_numpy=True)):
        actual = item1['image']
        expected = item2['image']
        image_random_color_op.append(actual)
        image.append(expected)
        assert (actual.shape == expected.shape)
        mse = diff_mse(actual, expected)
        logger.info('MSE= {}'.format(str(np.mean(mse))))
    ds.config.set_seed(original_seed)
    ds.config.set_num_parallel_workers(original_num_parallel_workers)
    if plot:
        visualize_list(image, image_random_color_op)
Compare Random Color op in Python and Cpp
def test_compare_random_color_op(degrees=None, plot=False):
    '\n    \n    '
    logger.info('test_random_color_op')
    original_seed = config_get_set_seed(5)
    original_num_parallel_workers = config_get_set_num_parallel_workers(1)
    data1 = ds.TFRecordDataset(C_DATA_DIR, C_SCHEMA_DIR, columns_list=['image'], shuffle=False)
    data2 = ds.TFRecordDataset(C_DATA_DIR, C_SCHEMA_DIR, columns_list=['image'], shuffle=False)
    if (degrees is None):
        c_op = vision.RandomColor()
        p_op = F.RandomColor()
    else:
        c_op = vision.RandomColor(degrees)
        p_op = F.RandomColor(degrees)
    transforms_random_color_py = mindspore.dataset.transforms.py_transforms.Compose([(lambda img: img.astype(np.uint8)), F.ToPIL(), p_op, np.array])
    data1 = data1.map(operations=[vision.Decode(), c_op], input_columns=['image'])
    data2 = data2.map(operations=[vision.Decode()], input_columns=['image'])
    data2 = data2.map(operations=transforms_random_color_py, input_columns=['image'])
    image_random_color_op = []
    image = []
    for (item1, item2) in zip(data1.create_dict_iterator(num_epochs=1, output_numpy=True), data2.create_dict_iterator(num_epochs=1, output_numpy=True)):
        actual = item1['image']
        expected = item2['image']
        image_random_color_op.append(actual)
        image.append(expected)
        assert (actual.shape == expected.shape)
        mse = diff_mse(actual, expected)
        logger.info('MSE= {}'.format(str(np.mean(mse))))
    ds.config.set_seed(original_seed)
    ds.config.set_num_parallel_workers(original_num_parallel_workers)
    if plot:
        visualize_list(image, image_random_color_op)