Example #1
0
    def test_load_cifar100_dataset(self):
        # if not os.path.exists('./datasets/cifar100'):
        #     return

        dataset = data_utils.load_cifar100_dataset(root=self.dataset_dir)

        img = dataset[0][0]

        assert img.shape == (3, 32, 32)
Example #2
0
def get_cifar100_images(num_samples, root="./datasets", **kwargs):
    """
    Loads randomly sampled CIFAR-100 training images.

    Args:
        num_samples (int): The number of images to randomly sample.
        root (str): The root directory where all datasets are stored.

    Returns:
        Tensor: Batch of num_samples images in np array form.
    """
    dataset = data_utils.load_cifar100_dataset(root=root,
                                               split='train',
                                               download=True,
                                               transform_data=False,
                                               **kwargs)

    images = get_random_images(dataset, num_samples)

    return images
def get_cifar100_images_with_index(index, root="./dataset", **kwargs):
    """
    Loads sampled CIFAR-100 training images with index.

    Args:
        index (ndarray): The index of images.
        root (str): The root directory where all datasets are stored.

    Returns:
        ndarray: Batch of len(index) images in np array form.
    """
    dataset = data_utils.load_cifar100_dataset(root=root,
                                               split='train',
                                               download=True,
                                               transform_data=False,
                                               **kwargs)

    images = get_index_images(dataset, index)

    return images
Example #4
0
    def test_load_cifar100_dataset(self):
        dataset = data_utils.load_cifar100_dataset(root=self.dataset_dir)

        img = dataset[0][0]

        assert img.shape == (3, 32, 32)