Transform datasets for CNN model

I have created datasets of training, validation, and test with the color images as list. Multiple images for a dataset were read from the different folders with their corresponding labels. The images were loaded with “image.imread” and append in a list and corresponding labels were append in a list as int. For example, the training dataset was created by

list of array

DPN_Train_image = list()
DPN_Train_Label = list()

appending the reading image and corresponding label

DPN_Train_image.append(image.imread(data path + DPN_Train_image_read))
DPN_Train_Label.append(int(DPN_Train_Folder_Label))

Now, I want to transform the images as

transform data

transform = transforms.Compose([transforms.ToPILImage(),
transforms.Resize((128, 32)),
transforms.RandomHorizontalFlip(p=0.5),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5],
[0.5, 0.5, 0.5])])

And then, I want to put the transformed data() in one directory “train_loader”. I tried

Train_x_Train_y_dataset = (DPN_Train_image, DPN_Train_Label)
train_loader = utils.data.DataLoader(Train_x_Train_y_dataset, batch_size=batch_size, num_workers=num_workers)

The “train_loader” will be used in a model

model.train()
for data, target in train_loader:
# move tensors to GPU if CUDA is available
if train_on_gpu:
data, target = data.cuda(), target.cuda()

I have tried to transform the image after reading and also tried after created the image list. Also tried various ways but nither of the work for the data sets. How should I solv it?

This doesn’t seem related to quantization. Please update the post with the correct label (maybe vision)

why not just write your own dataloader? It will be a lot easier

1 Like

I think the problem is with image loading and storing or list of imagesaaaa