samra-irshad:

I want to know when we initialize the object of FaceLandmarksDataset class, do we get all images opened and mapped to dict at once or getitem (self,idx) is implemented when we explicitly call the object with a specific id?


When you initialize the FaceLandmarkDataset, its __init__ method will be called.
In your example, the csv_file will be loaded and assigned to self.landmarks_frame as well as the root directory and transformation.
Indexing the dataset via dataset[0] or iterating the DataLoader will call into __getitem__ and lazily load each sample.
This makes sure you can work with huge datasets, which wouldn’t fit into your system memory.