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

Method __init__

tensorpack/dataflow/dataset/places.py:15–46  ·  view source on GitHub ↗

Args: dir: path to the Places365-Standard dataset in its "easy directory structure". See http://places2.csail.mit.edu/download.html name: one of "train" or "val" shuffle (bool): shuffle the dataset. Defaults to True if name=='train'.

(self, dir, name, shuffle=None)

Source from the content-addressed store, hash-verified

13 Produces BGR images of shape (256, 256, 3) in range [0, 255].
14 """
15 def __init__(self, dir, name, shuffle=None):
16 """
17 Args:
18 dir: path to the Places365-Standard dataset in its "easy directory
19 structure". See http://places2.csail.mit.edu/download.html
20 name: one of "train" or "val"
21 shuffle (bool): shuffle the dataset. Defaults to True if name=='train'.
22 """
23 assert name in ['train', 'val'], name
24 dir = os.path.expanduser(dir)
25 assert os.path.isdir(dir), dir
26 self.name = name
27 if shuffle is None:
28 shuffle = name == 'train'
29 self.shuffle = shuffle
30
31 label_file = os.path.join(dir, name + ".txt")
32 all_files = []
33 labels = set()
34 with open(label_file) as f:
35 for line in f:
36 filepath = os.path.join(dir, line.strip())
37 line = line.strip().split("/")
38 label = line[1]
39 all_files.append((filepath, label))
40 labels.add(label)
41 self._labels = sorted(labels)
42 # class ids are sorted alphabetically:
43 # https://github.com/CSAILVision/places365/blob/master/categories_places365.txt
44 labelmap = {label: id for id, label in enumerate(self._labels)}
45 self._files = [(path, labelmap[x]) for path, x in all_files]
46 logger.info("Found {} images in {}.".format(len(self._files), label_file))
47
48 def get_label_names(self):
49 """

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
appendMethod · 0.80
formatMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected