How to add new sample to CIFAR10 torchvision?
Hi I want to add my own images to the CIFAR10 dataset in torchvision, how can I do that?
train_data = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=train_transform)
train_data.add # or a workaround!

thanks

You can either create a custom dataset for CIFAR10, using the raw cifar10 images here or you can still use the CIFAR10 dataset inside your new custom dataset and then add your logic in the __getitem__() method.
This is a simple example to get you going :
class CIFAR10_2(torch.utils.data.Dataset):
    def __init__(self, dataset_path='/cifar10', transformations=None, should_download=True):
        self.dataset_train = torchvision.datasets.CIFAR10(dataset_path, download=should_download)
        self.transformations = transformations

    def __getitem__(self, index):
        # do as you wish , add your logic here
        (img, label) = self.dataset_train[index]
        # for transformations for example
        if self.transformations is not None:
            return self.transformations(img), label
        return img, label

    def __len__(self):
        return len(self.dataset_train)

you can get fancy and add logic for test,validation, etc and do what ever you like.
