Args: name (str): 'train' or 'val' or 'test' dir_structure (str): same as in :meth:`ILSVRC12.__init__()`. Returns: list: list of (image filename, label)
(self, name, dir_structure='original')
| 58 | tarfile.open(fpath, 'r:gz').extractall(self.dir) |
| 59 | |
| 60 | def get_image_list(self, name, dir_structure='original'): |
| 61 | """ |
| 62 | Args: |
| 63 | name (str): 'train' or 'val' or 'test' |
| 64 | dir_structure (str): same as in :meth:`ILSVRC12.__init__()`. |
| 65 | Returns: |
| 66 | list: list of (image filename, label) |
| 67 | """ |
| 68 | assert name in ['train', 'val', 'test'] |
| 69 | assert dir_structure in ['original', 'train'] |
| 70 | add_label_to_fname = (name != 'train' and dir_structure != 'original') |
| 71 | if add_label_to_fname: |
| 72 | synset = self.get_synset_1000() |
| 73 | |
| 74 | fname = os.path.join(self.dir, name + '.txt') |
| 75 | assert os.path.isfile(fname), fname |
| 76 | with open(fname) as f: |
| 77 | ret = [] |
| 78 | for line in f.readlines(): |
| 79 | name, cls = line.strip().split() |
| 80 | cls = int(cls) |
| 81 | |
| 82 | if add_label_to_fname: |
| 83 | name = os.path.join(synset[cls], name) |
| 84 | |
| 85 | ret.append((name.strip(), cls)) |
| 86 | assert len(ret), fname |
| 87 | return ret |
| 88 | |
| 89 | def get_per_pixel_mean(self, size=None): |
| 90 | """ |
no test coverage detected