Really confused about why the __getitem__()
method is not being called here:
class MaleFacesDataset(Dataset):
def __init__(self, csv_file, root_dir):
self.landmarks_frame = pd.read_csv(csv_file)
self.root_dir = root_dir
self.transform = transform
def __len__(self):
return len(self.landmarks_frame)
def __getitem__(self, idx):
print("GET!")
if torch.is_tensor(idx):
idx = idx.tolist()
img_name = os.path.join(self.root_dir,
self.landmarks_frame.iloc[idx, 0])
image = io.imread(img_name)
sample = image
sample = Image.fromarray(np.uint8(sample)).convert('RGB')
sample = Image.fromarray(sample.astype('uint8'), 'RGB')
if self.transform:
sample = self.transform(sample)
return sample
Have tried rewriting the whole class a few times but still the same problem - any input is appreciated!