lets say i have these transformations
transform_all = transforms.Compose([transforms.ToTensor(),
transforms.Resize((500,500))])
minor_class_transform = transforms.Compose([transforms.RandomPerspective()])
.
I’m aware that the transformations will be applied on the fly for every sample. I want that transform_all is applied to every single datapoint since its doing normalization etc. Then i want that minor_class_transform is applied for every datapoint which is in an minority class. When i apply minority class transformation will non-transformed datapoints also added to the sample?
This is how i apply transformations in my custom dataset class.
def __getitem__(self, idx):
x, y_1, y_2 = self.samples[idx]
x = cv2.imread(x)
x = self.transform_all(x)
if y_2 == 0:
x = self.minor_class_transform(x)
return x, y_1, y_2
I want that transform_all is applied to every single datapoint and that not a single image is without transform_all. Then im using minor_class_transform to do data augmenting for minority class images, but i also want that when minor_class_transform is not applied then such images are in the sample.