Exemplo n.º 1
0
 def __init__(self, split):
     if split == 'test':
         args = DatasetCatalog.get(cfg.test.dataset)
     else:
         args = DatasetCatalog.get(cfg.train.dataset)
     self.ann_file = args['ann_file']
     self.coco = coco.COCO(self.ann_file)
def _evaluator_factory(cfg):
    task = cfg.task
    data_source = DatasetCatalog.get(cfg.test.dataset)['id']
    module = '.'.join(['lib.evaluators', data_source, task])
    path = os.path.join('lib/evaluators', data_source, task+'.py')
    evaluator = imp.load_source(module, path).Evaluator(cfg.result_dir)
    return evaluator
Exemplo n.º 3
0
    def __init__(self, result_dir):
        self.result_dir = os.path.join(result_dir, cfg.test.dataset)
        os.system('mkdir -p {}'.format(self.result_dir))

        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        cls = cfg.cls_type
        model_path = os.path.join('data/linemod', cls, cls + '.ply')
        self.model = pvnet_data_utils.get_ply_model(model_path)
        self.diameter = linemod_config.diameters[cls] / 100

        self.proj2d = []
        self.add = []
        self.cmd5 = []

        self.icp_proj2d = []
        self.icp_add = []
        self.icp_cmd5 = []

        self.mask_ap = []

        self.height = 480
        self.width = 640

        model = inout.load_ply(model_path)
        model['pts'] = model['pts'] * 1000
        self.icp_refiner = icp_utils.ICPRefiner(
            model, (self.width, self.height)) if cfg.test.icp else None
Exemplo n.º 4
0
def make_visualizer(cfg):
    task = cfg.task
    data_source = DatasetCatalog.get(cfg.test.dataset)['id']
    module = '.'.join(['lib.visualizers', data_source, task])
    path = os.path.join('lib/visualizers', data_source, task+'.py')
    visualizer = imp.load_source(module, path).Visualizer()
    return visualizer
Exemplo n.º 5
0
    def __init__(self, result_dir):
        self.result_dir = result_dir
        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        model_path = 'data/custom/model.ply'
        self.model = pvnet_data_utils.get_ply_model(model_path)
        self.diameter = np.loadtxt('data/custom/diameter.txt').item()

        self.proj2d = []
        self.add = []
        self.icp_add = []
        self.cmd5 = []
        self.mask_ap = []
        self.icp_render = icp_utils.SynRenderer(
            cfg.cls_type) if cfg.test.icp else None
Exemplo n.º 6
0
    def __init__(self, result_dir):
        self.results = []
        self.img_ids = []
        self.aps = []

        self.result_dir = result_dir
        os.system('mkdir -p {}'.format(self.result_dir))

        args = DatasetCatalog.get(cfg.test.dataset)
        ann_file = 'data/ctw/test/ctw_val_instance.json'
        self.coco = coco.COCO(ann_file)

        self.json_category_id_to_contiguous_id = {
            v: i for i, v in enumerate(self.coco.getCatIds())
        }
        self.contiguous_category_id_to_json_id = {
            v: k for k, v in self.json_category_id_to_contiguous_id.items()
        }
Exemplo n.º 7
0
    def __init__(self, result_dir):
        self.result_dir = result_dir
        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        cls = cfg.cls_type
        model_path = os.path.join('data/linemod', cls, cls + '.ply')
        self.model = pvnet_data_utils.get_ply_model(model_path)
        self.diameter = linemod_config.diameters[cls] / 100

        self.proj2d = []
        self.add = []
        self.icp_add = []
        self.cmd5 = []
        self.mask_ap = []
        self.icp_render = icp_utils.SynRenderer(
            cfg.cls_type) if cfg.test.icp else None
Exemplo n.º 8
0
    def __init__(self, result_dir):
        self.result_dir = result_dir
        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        model_path = os.path.join(data_root, 'model.ply')
        self.model = pvnet_data_utils.get_ply_model(model_path)
        self.diameter = np.loadtxt(os.path.join(data_root, 'diameter.txt')).item()

        self.proj2d = []
        self.add = []
        self.icp_add = []
        self.cmd5 = []
        self.translational_error = [] # in cm
        self.rotational_error = [] # in degrees
        self.mask_ap = []
        self.data = {}
        self.icp_render = icp_utils.SynRenderer(cfg.cls_type) if cfg.test.icp else None
Exemplo n.º 9
0
    def __init__(self, result_dir):
        self.result_dir = os.path.join(result_dir, cfg.test.dataset)
        os.system('mkdir -p {}'.format(self.result_dir))

        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        cls = cfg.cls_type
        self.cls = cls
        model_path = os.path.join('data/linemod', cls, cls + '.ply')
        self.model = pvnet_data_utils.get_ply_model(model_path)
        #         with open('/mbrdi/sqnap1_colomirror/gupansh/ape_model.pkl','wb') as fp:
        #             pickle.dump(self.model, fp)
        #         print('saved..')
        #         input()
        self.diameter = linemod_config.diameters[cls] / 100

        self.proj2d = []
        self.add = []
        self.cmd5 = []

        self.icp_proj2d = []
        self.icp_add = []
        self.icp_cmd5 = []

        self.mask_ap = []

        self.height = 480
        self.width = 640
        if cfg.test.icp:
            self.icp_refiner = ext_.Synthesizer(os.path.realpath(model_path))
            self.icp_refiner.setup(self.width, self.height)

        with open('data/linemod/' + cls + '/translation_min.pkl', 'rb') as fp:
            self.translation_min = pickle.load(fp)
        with open('data/linemod/' + cls + '/translation_max.pkl', 'rb') as fp:
            self.translation_max = pickle.load(fp)
Exemplo n.º 10
0
    def __init__(self, result_dir):
        self.result_dir = result_dir
        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.obj_id = int(args['obj_id'])
        self.coco = coco.COCO(self.ann_file)
        self.gt_img_ids = self.coco.getImgIds(catIds=[self.obj_id])

        model_dir = 'data/tless/models_cad'
        obj_path = os.path.join(model_dir,
                                'obj_{:02d}.ply'.format(self.obj_id))
        self.model = inout.load_ply(obj_path)
        self.model_pts = self.model['pts'] / 1000.

        model_info = yaml.load(open(os.path.join(model_dir,
                                                 'models_info.yml')))
        self.diameter = model_info[self.obj_id]['diameter'] / 1000.

        self.vsd = []
        self.adi = []
        self.cmd5 = []

        self.icp_vsd = []
        self.icp_adi = []
        self.icp_cmd5 = []

        self.pose_per_id = []
        self.pose_icp_per_id = []
        self.img_ids = []

        self.height = 540
        self.width = 720

        if cfg.test.icp or cfg.test.vsd:
            self.icp_refiner = icp_utils.ICPRefiner(self.model,
                                                    (self.width, self.height))
Exemplo n.º 11
0
 def __init__(self):
     args = DatasetCatalog.get(cfg.test.dataset)
     self.ann_file = args['ann_file']
     self.coco = coco.COCO(self.ann_file)
Exemplo n.º 12
0
 def __init__(self):
     args = DatasetCatalog.get(cfg.test.dataset)
     self.ann_file = args['ann_file']
     self.coco = coco.COCO(self.ann_file)
     self.mesh = trimesh.load(os.path.join(args['data_root'], "model.ply"))