I am trying to get the values of __getitem__ function

I have no idea how to get the return value of the class function
i am new in the python kindly answer me i am tired…

class Dataset(torch.utils.data.Dataset):
    

    def __init__(self, csv_file, root_dir, transform=None):
        
        self.csv = pd.read_csv(csv_file)
        self.root   = root_dir
        self.transform = transform

    def __len__(self):
        return len(self.csv)
    
    def __getitem__(self,idx):
        
        img_name=self.csv.iloc[idx,0]
        landmarks =self.csv.iloc[idx, 4:].as_matrix()
        

        return img_name,landmarks

dataset = Dataset(csv_file='Dataset/loclization.csv', root_dir='Dataset/local/')

i need to get img_name and landmarks

__getitem__(self, idx) is what gets called when you do the index operator ([idx]).

So dataset[idx] actually calls dataset.__getitem__(idx). You can of course also call __getitem__ directly, but it’s meant to be accessed through the [] operator.