MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_image_list

Method get_image_list

tensorpack/dataflow/dataset/ilsvrc.py:60–87  ·  view source on GitHub ↗

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')

Source from the content-addressed store, hash-verified

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 """

Callers 5

__init__Method · 0.95
get_imglistFunction · 0.95
get_imglistFunction · 0.95
get_imglistFunction · 0.95
get_imglistFunction · 0.95

Calls 3

get_synset_1000Method · 0.95
joinMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected