def test_random_color_py(degrees=(0.1, 1.9), plot=False):
    '\n    Test Python RandomColor\n    '
    logger.info('Test RandomColor')
    data = ds.ImageFolderDataset(dataset_dir=DATA_DIR, shuffle=False)
    transforms_original = mindspore.dataset.transforms.py_transforms.Compose([F.Decode(), F.Resize((224, 224)), F.ToTensor()])
    ds_original = data.map(operations=transforms_original, input_columns='image')
    ds_original = ds_original.batch(512)
    for (idx, (image, _)) in enumerate(ds_original):
        if (idx == 0):
            images_original = np.transpose(image.asnumpy(), (0, 2, 3, 1))
        else:
            images_original = np.append(images_original, np.transpose(image.asnumpy(), (0, 2, 3, 1)), axis=0)
    data = ds.ImageFolderDataset(dataset_dir=DATA_DIR, shuffle=False)
    transforms_random_color = mindspore.dataset.transforms.py_transforms.Compose([F.Decode(), F.Resize((224, 224)), F.RandomColor(degrees=degrees), F.ToTensor()])
    ds_random_color = data.map(operations=transforms_random_color, input_columns='image')
    ds_random_color = ds_random_color.batch(512)
    for (idx, (image, _)) in enumerate(ds_random_color):
        if (idx == 0):
            images_random_color = np.transpose(image.asnumpy(), (0, 2, 3, 1))
        else:
            images_random_color = np.append(images_random_color, np.transpose(image.asnumpy(), (0, 2, 3, 1)), axis=0)
    num_samples = images_original.shape[0]
    mse = np.zeros(num_samples)
    for i in range(num_samples):
        mse[i] = diff_mse(images_random_color[i], images_original[i])
    logger.info('MSE= {}'.format(str(np.mean(mse))))
    if plot:
        visualize_list(images_original, images_random_color)
Test Python RandomColor
def test_random_color_py(degrees=(0.1, 1.9), plot=False):
    '\n    \n    '
    logger.info('Test RandomColor')
    data = ds.ImageFolderDataset(dataset_dir=DATA_DIR, shuffle=False)
    transforms_original = mindspore.dataset.transforms.py_transforms.Compose([F.Decode(), F.Resize((224, 224)), F.ToTensor()])
    ds_original = data.map(operations=transforms_original, input_columns='image')
    ds_original = ds_original.batch(512)
    for (idx, (image, _)) in enumerate(ds_original):
        if (idx == 0):
            images_original = np.transpose(image.asnumpy(), (0, 2, 3, 1))
        else:
            images_original = np.append(images_original, np.transpose(image.asnumpy(), (0, 2, 3, 1)), axis=0)
    data = ds.ImageFolderDataset(dataset_dir=DATA_DIR, shuffle=False)
    transforms_random_color = mindspore.dataset.transforms.py_transforms.Compose([F.Decode(), F.Resize((224, 224)), F.RandomColor(degrees=degrees), F.ToTensor()])
    ds_random_color = data.map(operations=transforms_random_color, input_columns='image')
    ds_random_color = ds_random_color.batch(512)
    for (idx, (image, _)) in enumerate(ds_random_color):
        if (idx == 0):
            images_random_color = np.transpose(image.asnumpy(), (0, 2, 3, 1))
        else:
            images_random_color = np.append(images_random_color, np.transpose(image.asnumpy(), (0, 2, 3, 1)), axis=0)
    num_samples = images_original.shape[0]
    mse = np.zeros(num_samples)
    for i in range(num_samples):
        mse[i] = diff_mse(images_random_color[i], images_original[i])
    logger.info('MSE= {}'.format(str(np.mean(mse))))
    if plot:
        visualize_list(images_original, images_random_color)