def __init__(self, dir, name, shuffle=None):
        """
        Args:
            dir (str): a directory
            name (str): one of 'train' or 'val'
            shuffle (bool): shuffle the dataset.
                Defaults to True if name=='train'.
        """
        assert name in ['train', 'val'], name
        dir = Path(os.path.expanduser(dir))
        assert os.path.isdir(dir), dir
        self.full_dir = dir / name
        if shuffle is None:
            shuffle = name == 'train'
        self.shuffle = shuffle

        with open(dir / "wnids.txt") as f:
            wnids = [x.strip() for x in f.readlines()]
        cls_to_id = {name: id for id, name in enumerate(wnids)}
        assert len(cls_to_id) == 200

        self.imglist = []
        if name == 'train':
            for clsid, cls in enumerate(wnids):
                cls_dir = self.full_dir / cls / "images"
                for img in cls_dir.iterdir():
                    self.imglist.append((str(img), clsid))
        else:
            with open(self.full_dir / "val_annotations.txt") as f:
                for line in f:
                    line = line.strip().split()
                    img, cls = line[0], line[1]
                    img = self.full_dir / "images" / img
                    clsid = cls_to_id[cls]
                    self.imglist.append((str(img), clsid))

        Args:
            dir (str): a directory
            name (str): one of 'train' or 'val'
            shuffle (bool): shuffle the dataset.
                Defaults to True if name=='train'.
        
tensorpack/dataflow/dataset/ilsvrc.py