Skip to content

5344 implement pq metric#5377

Merged
Nic-Ma merged 27 commits intoProject-MONAI:devfrom
yiheng-wang-nv:5344-implement-pq-metric
Nov 8, 2022
Merged

5344 implement pq metric#5377
Nic-Ma merged 27 commits intoProject-MONAI:devfrom
yiheng-wang-nv:5344-implement-pq-metric

Conversation

@yiheng-wang-nv
Copy link
Copy Markdown
Contributor

@yiheng-wang-nv yiheng-wang-nv commented Oct 21, 2022

Fixes #5344 .

Description

This PR implements the metric of Panoptic Quality.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@yiheng-wang-nv
Copy link
Copy Markdown
Contributor Author

yiheng-wang-nv commented Oct 21, 2022

Update:
this draft PR is WIP, and so far I've implemented the class of the metric.
The implementation refers to:
https://github.com/TissueImageAnalytics/CoNIC/blob/main/misc/utils.py
and fixes some of its bugs, such as calculate when the predictions or labels do not have background (instance id = 0).

I discussed with @KumoLiu , and according to my understand of the original paper, the predictions should only have 1 channel, since for each pixel, it should only belong to one instance. Therefore, the ground truth of an image with shape [H, W] must have the shape [H, W], thus to be consistent with other metrics in MONAI, I limit the input into shape [B1HW], am I understand right? Hi @drbeh , may need your help to confirm it, thanks!

@yiheng-wang-nv
Copy link
Copy Markdown
Contributor Author

/black

@bhashemian
Copy link
Copy Markdown
Member

Update: this draft PR is WIP, and so far I've implemented the class of the metric. The implementation refers to: https://github.com/TissueImageAnalytics/CoNIC/blob/main/misc/utils.py and fixes some of its bugs, such as calculate when the predictions or labels do not have background (instance id = 0).

I discussed with @KumoLiu , and according to my understand of the original paper, the predictions should only have 1 channel, since for each pixel, it should only belong to one instance. Therefore, the ground truth of an image with shape [H, W] must have the shape [H, W], thus to be consistent with other metrics in MONAI, I limit the input into shape [B1HW], am I understand right? Hi @drbeh , may need your help to confirm it, thanks!

Hi @yiheng-wang-nv, thanks for implementing PQ metrics.

You are right, in the paper, the PQ metrics is calculated per class for the input is one dimensional for each PQ calculation; however, these PQs are averaged afterwards to create the metrics that we can denote as mPQ, and this is the actual metrics that we need.

Unlike the rest of MONAI metrics that are designed for semantic segmentation, this metrics is used for instance segmentation and they can have multiple channels. Having said that, it still depends how the data is being represented, for instance look at the ground truth of this dataset, where one channel is for instances and one channel for classes: https://conic-challenge.grand-challenge.org/Data/

I believe we can have two classes, one for binary PQ metrics where it assumes only one-channel inputs, and another for multi-class PQ where it accepts two channels (one for instance and one for classes) and you call the binary PQ inside it for each class.
OR, maybe it is better to have one class but accepting two one-channel tensors (instance map and class map) so for the binary one the second tensor is not needed.

Please let me know if you have any question.

@bhashemian
Copy link
Copy Markdown
Member

Hi @yiheng-wang-nv, please let me know when this PR is ready for review. Thanks

@bhashemian
Copy link
Copy Markdown
Member

@yiheng-wang-nv, it would be great if this can output SQ (segmentation quality) and RQ (recognition quality) in addition to PQ which is the combination of them. Thanks

Signed-off-by: Yiheng Wang <[email protected]>
@yiheng-wang-nv
Copy link
Copy Markdown
Contributor Author

Hi @drbeh , I modified the metric implementation to align with CoNiC challenge's version, and if calling compute_panoptic_quality directly, users can also do binary PQ calculation. As for the MPQ, we can use PanopticQualityMetric class and with the default setting: reduction = "mean_batch", the metric will return three (1, N) tensors which stand for PQ, SQ and PR, where N equals to number of classes. The calculation is the same as in CoNiC's function.

Could you please help to re-review it? Thanks, and if the format meets the requirements, I'll add unit tests asap.

@yiheng-wang-nv yiheng-wang-nv force-pushed the 5344-implement-pq-metric branch 5 times, most recently from 80494a7 to 29e476e Compare November 2, 2022 09:56
@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 7, 2022

/black

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 7, 2022

/build

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Nov 7, 2022

/build

Copy link
Copy Markdown
Member

@bhashemian bhashemian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our today's conversation, I am reviewing it. Please let me finish it first.

Copy link
Copy Markdown
Member

@bhashemian bhashemian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yiheng-wang-nv, nice work! I left few comments and it would be great if you can address them. Thanks

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 8, 2022

/black

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 8, 2022

/build

@Nic-Ma Nic-Ma enabled auto-merge (squash) November 8, 2022 14:23
Signed-off-by: monai-bot <[email protected]>
@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 8, 2022

/build

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Nov 8, 2022

/build

@Nic-Ma Nic-Ma merged commit 9f15b01 into Project-MONAI:dev Nov 8, 2022
@yiheng-wang-nv yiheng-wang-nv deleted the 5344-implement-pq-metric branch November 9, 2022 02:48
bhashemian added a commit to bhashemian/MONAI that referenced this pull request Nov 23, 2022
Fixes Project-MONAI#5344 .

### Description

This PR implements the metric of Panoptic Quality.


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Yiheng Wang <[email protected]>
Co-authored-by: Behrooz Hashemian <[email protected]>
Co-authored-by: Dženan Zukić <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panoptic Quality metric for instance segmentation

8 participants