Exemplo n.º 1
0
 def generic_test(self, dataset_info, n_inst, loader_fun):
     datasets_root = DENSEPOSE_ANNOTATIONS_DIR
     annotations_fpath = maybe_prepend_base_path(
         datasets_root, dataset_info.annotations_fpath)
     images_root = maybe_prepend_base_path(datasets_root,
                                           dataset_info.images_root)
     image_annotation_dicts = loader_fun(
         annotations_json_file=annotations_fpath,
         image_root=images_root,
         dataset_name=dataset_info.name,
     )
     num_valid = sum(1 for image_annotation_dict in image_annotation_dicts
                     for ann in image_annotation_dict["annotations"]
                     if DensePoseDataRelative.validate_annotation(ann)[0])
     self.assertEqual(num_valid, n_inst)
Exemplo n.º 2
0
 def _extract_data_for_visualizers_from_entry(
     cls: type, vis_specs: List[str], entry: Dict[str, Any]
 ):
     dp_list = []
     bbox_list = []
     for annotation in entry["annotations"]:
         is_valid, _ = DensePoseDataRelative.validate_annotation(annotation)
         if not is_valid:
             continue
         bbox = torch.as_tensor(annotation["bbox"])
         bbox_list.append(bbox)
         dp_data = DensePoseDataRelative(annotation)
         dp_list.append(dp_data)
     datas = []
     for vis_spec in vis_specs:
         datas.append(bbox_list if "bbox" == vis_spec else (bbox_list, dp_list))
     return datas
Exemplo n.º 3
0
    def _transform_densepose(self, annotation, transforms):
        if not self.densepose_on:
            return annotation

        # Handle densepose annotations
        is_valid, reason_not_valid = DensePoseDataRelative.validate_annotation(
            annotation)
        if is_valid:
            densepose_data = DensePoseDataRelative(annotation, cleanup=True)
            densepose_data.apply_transform(transforms,
                                           self.densepose_transform_data)
            annotation["densepose"] = densepose_data
        else:
            # logger = logging.getLogger(__name__)
            # logger.debug("Could not load DensePose annotation: {}".format(reason_not_valid))
            DensePoseDataRelative.cleanup_annotation(annotation)
            # NOTE: annotations for certain instances may be unavailable.
            # 'None' is accepted by the DensePostList data structure.
            annotation["densepose"] = None
        return annotation