'Setup the RoIDataLayer.'

def setup(self, bottom, top):

    layer_params = yaml.load(self.param_str)
    self._num_classes = layer_params['num_classes']
    self._name_to_top_map = {}
    idx = 0
    top[idx].reshape(cfg.TRAIN.IMS_PER_BATCH, 3, max(cfg.TRAIN.SCALES), cfg.TRAIN.MAX_SIZE)
    self._name_to_top_map['data'] = idx
    idx += 1
    if cfg.TRAIN.HAS_RPN:
        top[idx].reshape(1, 3)
        self._name_to_top_map['im_info'] = idx
        idx += 1
        top[idx].reshape(1, 4)
        self._name_to_top_map['gt_boxes'] = idx
        idx += 1
    else:
        top[idx].reshape(1, 5, 1, 1)
        self._name_to_top_map['rois'] = idx
        idx += 1
        top[idx].reshape(1, 1, 1, 1)
        self._name_to_top_map['labels'] = idx
        idx += 1
        if cfg.TRAIN.BBOX_REG:
            num_reg_class = (2 if cfg.TRAIN.AGNOSTIC else self._num_classes)
            top[idx].reshape(1, (num_reg_class * 4), 1, 1)
            self._name_to_top_map['bbox_targets'] = idx
            idx += 1
            top[idx].reshape(1, (num_reg_class * 4), 1, 1)
            self._name_to_top_map['bbox_inside_weights'] = idx
            idx += 1
            top[idx].reshape(1, (num_reg_class * 4), 1, 1)
            self._name_to_top_map['bbox_outside_weights'] = idx
            idx += 1
    print 'RoiDataLayer:    name_to_top:', self._name_to_top_map
    assert (len(top) == len(self._name_to_top_map))
