MCPcopy Create free account
hub / github.com/TingsongYu/PyTorch_Tutorial / __getitem__

Method __getitem__

Code/utils/utils.py:60–67  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

58 self.target_transform = target_transform
59
60 def __getitem__(self, index):
61 fn, label = self.imgs[index]
62 img = Image.open(fn).convert('RGB') # 像素值 0~255,在transfrom.totensor会除以255,使像素值变成 0~1
63
64 if self.transform is not None:
65 img = self.transform(img) # 在这里做transform,转为tensor等等
66
67 return img, label
68
69 def __len__(self):
70 return len(self.imgs)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected