def __init__(self, data_root, image_root):
        """
        A class for reading COCO dataset.

        :param data_root: the folder of the dataset, the folder needs to contain the following files:
        1. dataset_coco.json, download from http://cs.stanford.edu/people/karpathy/deepimagesent/caption_datasets.zip
        2. img_feat.npy and img_box.npy, processed by scrips/coco_region.py, which contain region feature an location info extracted by faster-rcnn
           origin feature can download from https://storage.googleapis.com/up-down-attention/trainval_36.zip
        3. labels.npy, processed by scrips/coco_label.py, which contains the label of images.

        :param image_root: the raw image folder of dataset, we combined train2014 and val2014.
        """

        self.train_img = []
        self.valid_img = []
        self.test_img = []
        self.train_txt = []
        self.valid_txt = []
        self.test_txt = []

        self.text = {}
        self.image = {}

        coco_data = json.load(open(os.path.join(data_root, 'dataset_coco.json'), 'r'))
        for data in coco_data['images']:
            if data['split'] == 'train' or data['split'] == 'restval':
                self.train_img.append(data['imgid'])
                self.train_txt.append(data['sentids'])
            elif data['split'] == 'val':
                self.valid_img.append(data['imgid'])
                self.valid_txt.append(data['sentids'])
            else:
                self.test_img.append(data['imgid'])
                self.test_txt.append(data['sentids'])
            self.image[data['imgid']] = data['filename']
            for sent in data['sentences']:
                self.text[sent['sentid']] = sent['raw']

        self.img_feat = np.load(os.path.join(data_root, 'img_feat.npy'), mmap_mode='r+')
        self.img_box = np.load(os.path.join(data_root, 'img_box.npy'))
        self.label = np.load(os.path.join(data_root, 'labels.npy'))

        for k, v in self.image.items():
            self.image[k] = os.path.join(image_root, v)

        # construct image to text map
        total_image = self.train_img + self.valid_img + self.test_img
        total_text = self.train_txt + self.valid_txt + self.test_txt
        self.image2text = dict(zip(total_image, total_text))

        A class for reading COCO dataset.

        :param data_root: the folder of the dataset, the folder needs to contain the following files:
        1. dataset_coco.json, download from http://cs.stanford.edu/people/karpathy/deepimagesent/caption_datasets.zip
        2. img_feat.npy and img_box.npy, processed by scrips/coco_region.py, which contain region feature an location info extracted by faster-rcnn
           origin feature can download from https://storage.googleapis.com/up-down-attention/trainval_36.zip
        3. labels.npy, processed by scrips/coco_label.py, which contains the label of images.

        :param image_root: the raw image folder of dataset, we combined train2014 and val2014.
        
torchmm/datasets/reader/coco_reader.py