Skip to content
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

[Feature] add -with-labels arg to inferencer for visualization without labels #3466

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Conversation

haruishi43
Copy link
Contributor

@haruishi43 haruishi43 commented Dec 8, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

It is difficult to visualize without "labels" when using the inferencer.

  • While using the MMSegInferencer, the visualized prediction contains labels on the mask, but it is difficult to pass withLabels=False without rewriting the config (which is harder to do when you initialize the inferencer with a model name rather than the config).
  • I thought it would be easier to just pass withLabels=False to inferencer.__call__() since you can also pass opacity and other parameters anyway.

Modification

Please briefly describe what modification is made in this PR.

  • Added with_labels to visualize_kwargs inside MMSegInferencer.
  • Modified to visualize() function.
  • add -with-labels args to image_demo.py and image_demo_with_inferencer.py scripts.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

  • visualize with label
python demo/image_demo.py demo/demo.png configs/pidnet/pidnet-s_2xb6-120k_1024x1024-cityscapes.py checkpoints/pidnet-s_2xb6-120k_1024x1024-cityscapes_20230302_191700-bb8e3bcc.pth --device mps --opacity 1 --with-labels
python demo/image_demo_with_inferencer.py demo/demo.png configs/pidnet/pidnet-s_2xb6-120k_1024x1024-cityscapes.py --checkpoint  checkpoints/pidnet-s_2xb6-120k_1024x1024-cityscapes_20230302_191700-bb8e3bcc.pth --show  --device cpu --opacity 1 --with-labels
  • visualize without label
python demo/image_demo.py demo/demo.png configs/pidnet/pidnet-s_2xb6-120k_1024x1024-cityscapes.py checkpoints/pidnet-s_2xb6-120k_1024x1024-cityscapes_20230302_191700-bb8e3bcc.pth --device mps --opacity 1
python demo/image_demo_with_inferencer.py demo/demo.png configs/pidnet/pidnet-s_2xb6-120k_1024x1024-cityscapes.py --checkpoint  checkpoints/pidnet-s_2xb6-120k_1024x1024-cityscapes_20230302_191700-bb8e3bcc.pth --show  --device cpu --opacity 1

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMDet3D.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@haruishi43 haruishi43 changed the title add withLabels args to inferencer add withLabels args to inferencer for visualization without labels Dec 13, 2023
@haruishi43 haruishi43 changed the title add withLabels args to inferencer for visualization without labels Add withLabels args to inferencer for visualization without labels Dec 13, 2023
@haruishi43 haruishi43 changed the title Add withLabels args to inferencer for visualization without labels Add withLabels arg to inferencer for visualization without labels Dec 13, 2023
@xiexinch xiexinch changed the title Add withLabels arg to inferencer for visualization without labels [Feature] add -with-labels arg to inferencer for visualization without labels Dec 14, 2023
@xiexinch xiexinch merged commit c7ac97d into open-mmlab:dev-1.x Dec 14, 2023
6 of 8 checks passed
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
…t labels (open-mmlab#3466)

Thanks for your contribution and we appreciate it a lot. The following
instructions would make your pull request more healthy and more easily
get feedback. If you do not understand some items, don't worry, just
make the pull request and seek help from maintainers.

## Motivation

It is difficult to visualize without "labels" when using the inferencer.

- While using the `MMSegInferencer`, the visualized prediction contains
labels on the mask, but it is difficult to pass `withLabels=False`
without rewriting the config (which is harder to do when you initialize
the inferencer with a model name rather than the config).
- I thought it would be easier to just pass `withLabels=False` to
`inferencer.__call__()` since you can also pass `opacity` and other
parameters anyway.

## Modification

Please briefly describe what modification is made in this PR.

- Added `with_labels` to `visualize_kwargs` inside `MMSegInferencer`.
- Modified to `visualize()` function.

## BC-breaking (Optional)

Does the modification introduce changes that break the
backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the
downstream projects should modify their code to keep compatibility with
this PR.

## Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases
here, and update the documentation.

## Checklist

1. Pre-commit or other linting tools are used to fix the potential lint
issues.
2. The modification is covered by complete unit tests. If not, please
add more unit test to ensure the correctness.
3. If the modification has potential influence on downstream projects,
this PR should be tested with downstream projects, like MMDet or
MMDet3D.
4. The documentation has been modified accordingly, like docstring or
example tutorials.

---------

Co-authored-by: xiexinch <xiexinch@outlook.com>
@bjzhb666
Copy link

What about using tools/test.py. Tha same problem occurs.
#3427

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.

3 participants