Skip to content

Commit

Permalink
correct evaluation for external masks
Browse files Browse the repository at this point in the history
Summary:
Evaluation with external masks is required for DP Chimps dataset, which does not have DensePose specific segmentation annotations.
However, `minival_100` dataset contains some pure mask annotations that are taken into consideration by this logic.
This fixes the logic to suit both use cases.

Reviewed By: ppwwyyxx

Differential Revision: D21229297

fbshipit-source-id: a01b8d6578acd48c726294128fb643a0b585e979
  • Loading branch information
vkhalidov authored and facebook-github-bot committed Apr 27, 2020
1 parent e6b1fd3 commit f4761e2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion projects/DensePose/densepose/densepose_coco_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,22 @@ def computeDPIoU(self, imgId, catId):
mask = np.array(mask > 0.5, dtype=np.uint8)
rle_mask = self._generate_rlemask_on_image(mask, imgId, g)
elif "segmentation" in g:
rle_mask = g["segmentation"]
segmentation = g["segmentation"]
if isinstance(segmentation, list) and segmentation:
# polygons
im_h, im_w = self.size_mapping[imgId]
rles = maskUtils.frPyObjects(segmentation, im_h, im_w)
rle_mask = maskUtils.merge(rles)
elif isinstance(segmentation, dict):
if isinstance(segmentation["counts"], list):
# uncompressed RLE
im_h, im_w = self.size_mapping[imgId]
rle_mask = maskUtils.frPyObjects(segmentation, im_h, im_w)
else:
# compressed RLE
rle_mask = segmentation
else:
rle_mask = self._generate_rlemask_on_image(None, imgId, g)
else:
rle_mask = self._generate_rlemask_on_image(None, imgId, g)
gtmasks.append(rle_mask)
Expand Down

0 comments on commit f4761e2

Please sign in to comment.