I am new to pytorch and stuck with probably a basic problem. I have two images. One of them is my input which must to be trained wrt other one which is ground truth. I built 250x250 pixelwise data for these two images. I wrote a simple dataset class and dataloader for them . When I check the size of my image, it gives me 1x250 instead of 250x250. So it basically considers every array in my matrix as a separate data but the whole 250x250 matrix is my single data. What am doing wrong? or is it just right?
If i do this correctly, i will load about hundreds of input and target images (250x250 matrices) for my study. Now i just try to learn how to do it.
I am posting my code below. Thank you in advance.
FOLDER_DATASET = “./ames03/”
def __init__(self,mat_path): data_DF = scipy.io.loadmat(mat_path + "ames03.mat") self.images = torch.from_numpy(data_DF['MD']) data_targets = scipy.io.loadmat(mat_path + "ames03_AOA=0.mat") self.targets = torch.from_numpy(data_targets['z1']) def __getitem__(self,index): x = self.images[index] y = self.targets[index] return x, y def __len__(self): return len(self.images)
dataset = CustomData(FOLDER_DATASET)
loader = torch.utils.data.DataLoader(dataset=dataset, batch_size=1)
dataiter = iter(loader)
image, target = dataiter.next()