MCPcopy Create free account
hub / github.com/pytorch/tutorials / __getitem__

Method __getitem__

beginner_source/basics/data_tutorial.py:135–143  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

133 return len(self.img_labels)
134
135 def __getitem__(self, idx):
136 img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])
137 image = decode_image(img_path)
138 label = self.img_labels.iloc[idx, 1]
139 if self.transform:
140 image = self.transform(image)
141 if self.target_transform:
142 label = self.target_transform(label)
143 return image, label
144
145
146#################################################################

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected