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

Method __init__

Code/utils/utils.py:48–58  ·  view source on GitHub ↗
(self, txt_path, transform = None, target_transform = None)

Source from the content-addressed store, hash-verified

46
47class MyDataset(Dataset):
48 def __init__(self, txt_path, transform = None, target_transform = None):
49 fh = open(txt_path, 'r')
50 imgs = []
51 for line in fh:
52 line = line.rstrip()
53 words = line.split()
54 imgs.append((words[0], int(words[1])))
55
56 self.imgs = imgs # 最主要就是要生成这个list, 然后DataLoader中给index,通过getitem读取图片数据
57 self.transform = transform
58 self.target_transform = target_transform
59
60 def __getitem__(self, index):
61 fn, label = self.imgs[index]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected