-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeCamp #1503] Add InstanceSegMetric to MMEval #70
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need deepcopy~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way, we would do 5 for loops, which may be time consuming.
mmeval/metrics/instance_seg.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is too complicated and needs to be simplified~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename
in function name rename_gt
seems a bit weird, what is be renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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