MCPcopy Create free account
hub / github.com/LTH14/mar / ImageFolderWithFilename

Class ImageFolderWithFilename

util/loader.py:8–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class ImageFolderWithFilename(datasets.ImageFolder):
9 def __getitem__(self, index: int):
10 """
11 Args:
12 index (int): Index
13
14 Returns:
15 tuple: (sample, target, filename).
16 """
17 path, target = self.samples[index]
18 sample = self.loader(path)
19 if self.transform is not None:
20 sample = self.transform(sample)
21 if self.target_transform is not None:
22 target = self.target_transform(target)
23
24 filename = path.split(os.path.sep)[-2:]
25 filename = os.path.join(*filename)
26 return sample, target, filename
27
28
29class CachedFolder(datasets.DatasetFolder):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected