Closed dingshenglan closed 5 years ago
I add get_filtered_cat_ids() in the ‘datasets.py':
def get_filtered_cat_ids(coco, img_ids): object_instances = coco.loadAnns(coco.getAnnIds(imgIds=img_ids)) def catgory_filter(): return lambda x: x['category_id'] in [1, 2, 4, 5, 6] return [object_instances for object_instances in filter(catgory_filter(), object_instances)]
Then I changed the init() in ’EvalDataset‘class:
def init(self, data_root, ann_file, camera_name, object_names, transform): self.data_root = data_root self.coco = COCO(os.path.join(self.data_root, 'annotations', ann_file))
img_ids = get_filtered_img_ids(self.coco, camera_name) self.object_instances = get_filtered_cat_ids(self.coco, img_ids) self.object_names_map = {cat['id']: cat['name'] for cat in self.coco.dataset['categories']} #self.object_indices_map = {object_name: i for i, object_name in enumerate(object_names)} self.object_indices_map = {'blue_funnel':6,'funnel':4,'oil_bottle':1,'fluid_bottle':2,'engine':5} self.object_ids_map = {cat['name']: cat['id'] for cat in self.coco.dataset['categories']} #self.object_ids_map = self.object_indices_map self.transform = transform
The 'end to end eval' can read the dataset:
loading annotations into memory... Done (t=0.72s) creating index... index created! using camera: kinect2
But, I get thsi error:
RuntimeError Traceback (most recent call last) in 3 with torch.no_grad(): 4 for input, target, object_index, object_id in tqdm(val_loader): ----> 5 position_error, orientation_error = forward_batch(model, input, target, object_index, object_id) 6 position_errors.extend(position_error) 7 orientation_errors.extend(orientation_error)
RuntimeError Traceback (most recent call last)
Sorry, Maybe I change wrong
I add get_filtered_cat_ids() in the ‘datasets.py':
Then I changed the init() in ’EvalDataset‘class:
The 'end to end eval' can read the dataset:
But, I get thsi error: