Esempio n. 1
0
def exp_gen_and_label_hoi_cand_vcoco():
    exp_name = 'hoi_candidates'
    exp_const = ExpConstants(exp_name=exp_name, out_base_dir=os.path.join(os.getcwd(), 'data_symlinks/vcoco_exp'))
    data_const = VcocoConstants()
    data_const.selected_dets_hdf5 = os.path.join(
        os.getcwd(),
        'data_symlinks/vcoco_exp/select_confident_boxes_in_vcoco/' + \
        'selected_coco_cls_dets.hdf5')
    _exp_gen_and_label_hoi_cand(exp_const, data_const, 'vcoco')
def exp_cache_pose_feats_vcoco():
    exp_name = 'hoi_candidates'
    exp_const = ExpConstants(exp_name=exp_name,
                             out_base_dir=os.path.join(
                                 os.getcwd(), 'data_symlinks/vcoco_exp'))
    data_const = VcocoConstants()
    _exp_cache_pose_feats(exp_const, data_const)
def exp_select_and_evaluate_confident_boxes_in_vcoco():
    exp_name = 'select_confident_boxes_in_vcoco'
    exp_const = ExpConstants(exp_name=exp_name,
                             out_base_dir=os.path.join(
                                 os.getcwd(), 'data_symlinks/vcoco_exp'))
    data_const = VcocoConstants()
    _exp_select_and_evaluate_confident_boxes(exp_const, data_const)
def main():
    data_const = VcocoConstants()
    anno_list = io.load_json_object(data_const.anno_list_json)
    global_ids = [anno['global_id'] for anno in anno_list]
    feats_hdf5 = os.path.join(data_const.proc_dir, 'faster_rcnn_fc7.hdf5')
    feats = h5py.File(feats_hdf5, 'w')
    for global_id in tqdm(global_ids):
        fc7_npy = os.path.join(data_const.faster_rcnn_boxes,
                               f'{global_id}_fc7.npy')
        fc7 = np.load(fc7_npy)
        feats.create_dataset(global_id, data=fc7)

    feats.close()
Esempio n. 5
0
def main():
    data_const = VcocoConstants()

    vcoco_list = io.load_json_object(data_const.anno_list_json)
    global_ids = [anno['global_id'] for anno in vcoco_list]
    subsets = [anno['subset'] for anno in vcoco_list]

    # Create and save splits
    split_ids = split(global_ids, subsets)

    split_ids_json = os.path.join(data_const.proc_dir, 'split_ids.json')
    io.dump_json_object(split_ids, split_ids_json)

    # Create and save split stats
    split_stats = {}
    for subset_name, subset_ids in split_ids.items():
        split_stats[subset_name] = len(subset_ids)
        print(f'{subset_name}: {len(subset_ids)}')

    split_stats_json = os.path.join(data_const.proc_dir,
                                    'split_ids_stats.json')
    io.dump_json_object(split_stats, split_stats_json)
def main():
    data_const = VcocoConstants()
    anno_list = io.load_json_object(data_const.anno_list_json)
    hoi_cls_count = {}
    for anno in tqdm(anno_list):
        if anno['subset'] == 'test':
            continue

        for hoi in anno['hois']:
            hoi_id = hoi['id']
            if hoi_id not in hoi_cls_count:
                hoi_cls_count[hoi_id] = 0
            hoi_cls_count[hoi_id] += len(hoi['connections'])

    upper_limits = [10, 50, 100, 500, 1000, 10000]
    bin_to_hoi_ids = bin_hoi_ids(hoi_cls_count, upper_limits)

    hoi_cls_count_json = os.path.join(data_const.proc_dir,
                                      'hoi_cls_count.json')
    io.dump_json_object(hoi_cls_count, hoi_cls_count_json)

    bin_to_hoi_ids_json = os.path.join(data_const.proc_dir,
                                       'bin_to_hoi_ids.json')
    io.dump_json_object(bin_to_hoi_ids, bin_to_hoi_ids_json)
Esempio n. 7
0
        return anno_list

    def convert(self):
        print('Creating anno list for vcoco...')
        anno_list = self.create_anno_list()
        io.dump_json_object(anno_list, self.const.anno_list_json)

        print('Creating hoi list for vcoco...')
        hoi_list = self.create_hoi_list()
        io.dump_json_object(hoi_list, self.const.hoi_list_json)

        print('Creating object list for vcoco...')
        object_list = self.create_obj_list()
        io.dump_json_object(object_list, self.const.object_list_json)

        print('Creating verb list for vcoco...')
        verb_list = []
        for i, verb in enumerate(self.VCOCO_train.actions):
            verb_list_item = {
                'id': self.VCOCO_train.actions_to_id_map[verb],
                'name': verb
            }
            verb_list.append(verb_list_item)
        io.dump_json_object(verb_list, self.const.verb_list_json)


if __name__ == '__main__':
    vcoco_const = VcocoConstants()
    converter = Convert2Json(vcoco_const)
    converter.convert()
def exp_detect_coco_objects_in_vcoco():
    exp_const = ExpConstants(exp_name='detect_coco_objects_in_vcoco',
                             out_base_dir=os.path.join(
                                 os.getcwd(), 'data_symlinks/vcoco_exp'))
    data_const = VcocoConstants()
    _exp_detect_coco_objects(exp_const, data_const)