mmsegmentation/mmseg/utils
CastleDream 1235217667
[CodeCamp2023-154] Add semantic label to the segmentation visualization results (#3229)
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

[Add semantic label to the segmentation visualization results
分割可视化结果中加上语义信息
#154](https://github.com/open-mmlab/OpenMMLabCamp/discussions/154)

corresponding issue: [跑出来结果之后怎么在结果图片上获取各个语意部分的区域信息?
#2578](https://github.com/open-mmlab/mmsegmentation/issues/2578)

## Modification

1. mmseg/apis/inference.py, add withLabels in visualizer.add_datasample
call, to indicate whether add semantic label
2. mmseg/visualization/local_visualizer.py, add semantic labels by
opencv; modify the demo comment description
3. mmseg/utils/__init__.py, add bdd100k datasets to test
local_visualizer.py

**Current visualize result**
<img width="637" alt="image"
src="https://github.com/open-mmlab/mmsegmentation/assets/35064479/6ef6ce02-1d82-46f8-bde9-a1d69ff62df8">


**Add semantic label**
<img width="637" alt="image"
src="https://github.com/open-mmlab/mmsegmentation/assets/35064479/00716679-b43a-4794-8499-9bfecdb4b78b">

## Test results
**tests/test_visualization/test_local_visualizer.py** test
results:(MMSegmentation/tests/data/pseudo_cityscapes_dataset/leftImg8bit/val/frankfurt/frankfurt_000000_000294_leftImg8bit.png)
<img width="643" alt="image"
src="https://github.com/open-mmlab/mmsegmentation/assets/35064479/6792b7d2-2512-4ea9-8500-1a7ed2d5e0dc">

**demo/inference_demo.ipynb** test results:
<img width="966" alt="image"
src="https://github.com/open-mmlab/mmsegmentation/assets/35064479/dfc0147e-fb1a-490a-b6ff-a8b209352d9b">

-----
## Drawbacks
config opencv thickness according to image size
<img width="496" alt="image"
src="https://github.com/open-mmlab/mmsegmentation/assets/35064479/0a54d72c-62b1-422c-89ae-69dc753fe0fc">

I have no idea of dealing with label overlapping for the time being
2023-08-01 14:38:33 +08:00
..
__init__.py [CodeCamp2023-154] Add semantic label to the segmentation visualization results (#3229) 2023-08-01 14:38:33 +08:00
class_names.py [Feature] add bdd100K datasets (#3158) 2023-07-14 10:09:16 +08:00
collect_env.py [Refactor] Add pyupgrade pre-commit hook (#2078) 2022-09-19 14:06:29 +08:00
io.py [Feature] Add BioMedical data loading (#2176) 2022-10-18 16:30:08 +08:00
misc.py Rename typing.py to typing_utils.py (#2548) 2023-02-01 19:11:38 +08:00
set_env.py rename data to structures (#1854) 2022-08-19 20:50:02 +08:00
typing_utils.py Rename typing.py to typing_utils.py (#2548) 2023-02-01 19:11:38 +08:00