(self, index)
| 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) |
nothing calls this directly
no outgoing calls
no test coverage detected