[CodeCamp #1503] Add InstanceSegMetric to MMEval#70
[CodeCamp #1503] Add InstanceSegMetric to MMEval#70Pzzzzz5142 wants to merge 24 commits intoopen-mmlab:mainfrom
Conversation
| - pts_semantic_mask(numpy.ndarray): Ground truth semantic masks. | ||
| """ | ||
| for prediction, groundtruth in zip(predictions, groundtruths): | ||
| self._results.append((deepcopy(prediction), deepcopy(groundtruth))) |
There was a problem hiding this comment.
If we don't use deepcopy, the metric itself will change the value of the tensor inplace which may cause confusion.
Co-authored-by: yancong <32220263+ice-tong@users.noreply.github.com>
Co-authored-by: yancong <32220263+ice-tong@users.noreply.github.com>
mmeval/metrics/instance_seg.py
Outdated
| gt_semantic_masks = [] | ||
| gt_instance_masks = [] | ||
| pred_instance_masks = [] | ||
| pred_instance_labels = [] | ||
| pred_instance_scores = [] | ||
|
|
||
| for result_pred, result_gt in results: | ||
| gt_semantic_masks.append(result_gt['pts_semantic_mask']) | ||
| gt_instance_masks.append(result_gt['pts_instance_mask']) | ||
| pred_instance_masks.append(result_pred['pts_instance_mask']) | ||
| pred_instance_labels.append(result_pred['instance_labels']) | ||
| pred_instance_scores.append(result_pred['instance_scores']) |
There was a problem hiding this comment.
A suggestion that simplify the code~
| gt_semantic_masks = [] | |
| gt_instance_masks = [] | |
| pred_instance_masks = [] | |
| pred_instance_labels = [] | |
| pred_instance_scores = [] | |
| for result_pred, result_gt in results: | |
| gt_semantic_masks.append(result_gt['pts_semantic_mask']) | |
| gt_instance_masks.append(result_gt['pts_instance_mask']) | |
| pred_instance_masks.append(result_pred['pts_instance_mask']) | |
| pred_instance_labels.append(result_pred['instance_labels']) | |
| pred_instance_scores.append(result_pred['instance_scores']) | |
| gt_semantic_masks = [gt['pts_semantic_mask'] for _, gt in results] | |
| gt_instance_masks = [gt['pts_instance_mask'] for _, gt in results] | |
| pred_instance_masks = [pred['pts_instance_mask'] for pred, _ in results] | |
| pred_instance_labels = [pred['instance_labels'] for pred, _ in results] | |
| pred_instance_scores = [pred['instance_scores'] for pred, _ in results] |
There was a problem hiding this comment.
In this way, we would do 5 for loops, which may be time consuming.
| Example: | ||
| >>> import numpy as np | ||
| >>> from mmeval import InstanceSegMetric | ||
| >>> seg_valid_class_ids = (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 24, | ||
| >>> 28, 33, 34, 36, 39) | ||
| >>> class_labels = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', | ||
| ... 'window', 'bookshelf', 'picture', 'counter', 'desk', | ||
| ... 'curtain', 'refrigerator', 'showercurtrain', 'toilet', | ||
| ... 'sink', 'bathtub', 'garbagebin') | ||
| >>> dataset_meta = dict( | ||
| ... seg_valid_class_ids=seg_valid_class_ids, classes=class_labels) | ||
| >>> |
There was a problem hiding this comment.
The example is too complicated and needs to be simplified~
There was a problem hiding this comment.
It is hard to simplify it for this metric need many code to generate input.
mmeval/metrics/instance_seg.py
Outdated
| infos.append(info) | ||
| return infos | ||
|
|
||
| def rename_gt(self, gt_semantic_masks, gt_instance_masks, valid_class_ids): |
There was a problem hiding this comment.
The rename in function name rename_gt seems a bit weird, what is be renamed?
There was a problem hiding this comment.
It seems that this function rename the input ground truth in order to evaluate in ScanNet protocol provided by ScanNet repo.
Co-authored-by: yancong <32220263+ice-tong@users.noreply.github.com>
Co-authored-by: yancong <32220263+ice-tong@users.noreply.github.com>
Co-authored-by: yancong <32220263+ice-tong@users.noreply.github.com>
Motivation
Add InstanceSegMetric to MMEval
pr in mmdetection3d: openmmlab/mmdetection3d
Modification