[Enhance] Upgrage visualization to custom colors of different classes.#6716
[Enhance] Upgrage visualization to custom colors of different classes.#6716ZwwWayne merged 28 commits intoopen-mmlab:devfrom jbwang1997:visualization
Conversation
|
When learning visualization in mmdetection, I find the colors are still in the BGR format. It is a legacy of mmcv.visualization. Do you have a plan to update mmcv.visualization. |
|
Hi @jbwang1997 , For now, we do not have a plan to upgrade mmcv.visualization. Do you mean that the arguments in the API implemented in mmdet still use the BGR format as input? |
|
You can follow https://mmcv.readthedocs.io/en/latest/community/contributing.html#code-style to prepare pre-commit hook |
I have followed this ,but still reported same error. |
tools/test.py
Outdated
| default=0.3, | ||
| help='score threshold (default: 0.3)') | ||
| parser.add_argument( | ||
| '--show-colors', |
There was a problem hiding this comment.
Please provide a simple example to illustrate the usage.
There was a problem hiding this comment.
--show-colors can be a single color or a color file.
# single color input
python tools/test.py \
configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py \
checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
--show \
--show-colors green
# single color file
python tools/test.py \
configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py \
checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
--show \
--show-colors colors.txt
There was a problem hiding this comment.
It is not a good way to load colors from txt file
|
Hi, we have discussed this PR today. Maybe you can follow MMSegmentation, an example: https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/datasets/coco_stuff.py. You can have a look at MMSeg codes, and use Dataset.PALETTE to set colors. |
|
Ok, this is much better than directly setting colors in the command line. I will change the code as soon as possible. |
You can follow https://github.com/cocodataset/panopticapi/blob/master/panoptic_coco_categories.json to set labels color Meanwhile, it is suggested to support random color, if labels are more than given colors. |
|
@BIGWangYuDong I have a few questions. The color style in mmsegmentation is RGB. Do I need to change it into BGR to fit the mmcv.color_val or directly use the RGB colors and discard mmcv.color_val. |
|
Please @AronLin have a look |
We can directly use the RGB format palette. |
|
Hello, I have added unit tests in the last commit. For updating the visualization image, could you tell me which image needs to update? |
AronLin
left a comment
There was a problem hiding this comment.
Oh, we should modify the argument coments of imshow_det_bboxes. The color can be list now.
mmdet/apis/inference.py
Outdated
| def show_result_pyplot(model, | ||
| img, | ||
| result, | ||
| palette=None, | ||
| score_thr=0.3, | ||
| title='result', | ||
| wait_time=0): |
There was a problem hiding this comment.
Avoid break using positional arguments.
| def show_result_pyplot(model, | |
| img, | |
| result, | |
| palette=None, | |
| score_thr=0.3, | |
| title='result', | |
| wait_time=0): | |
| def show_result_pyplot(model, | |
| img, | |
| result, | |
| score_thr=0.3, | |
| title='result', | |
| wait_time=0, | |
| palette=None,): |
There was a problem hiding this comment.
Thank you for your suggestion.
|
Panoptic visualization is based on this PR. We should merge it asap. Kindly ping @ZwwWayne . |
open-mmlab#6716) * Update visualization * Fix a help text mistake * short function docs * Fix for iosrt * Back to master * Check by pre-commit * Update dataset_warppers palette * Custom colors for visualizaton * Update visualization in image_demo.py * align palette with panopticapi * delete palette from checkpoint meta * Use tuple to represent color * Update visualization * Modify image_demo.py * Check test error * Check test error * Fix error for empty case * Delete redundant functions * Check visualization * Add default case * Fix bug * Fix bugs * Add unit tests * Change coments * Avoid break using positional arguments. * Add copyright * Modify comments * fix lint Co-authored-by: Guangchen Lin <347630870@qq.com>
#6716) * Update visualization * Fix a help text mistake * short function docs * Fix for iosrt * Back to master * Check by pre-commit * Update dataset_warppers palette * Custom colors for visualizaton * Update visualization in image_demo.py * align palette with panopticapi * delete palette from checkpoint meta * Use tuple to represent color * Update visualization * Modify image_demo.py * Check test error * Check test error * Fix error for empty case * Delete redundant functions * Check visualization * Add default case * Fix bug * Fix bugs * Add unit tests * Change coments * Avoid break using positional arguments. * Add copyright * Modify comments * fix lint Co-authored-by: Guangchen Lin <347630870@qq.com>
open-mmlab#6716) * Update visualization * Fix a help text mistake * short function docs * Fix for iosrt * Back to master * Check by pre-commit * Update dataset_warppers palette * Custom colors for visualizaton * Update visualization in image_demo.py * align palette with panopticapi * delete palette from checkpoint meta * Use tuple to represent color * Update visualization * Modify image_demo.py * Check test error * Check test error * Fix error for empty case * Delete redundant functions * Check visualization * Add default case * Fix bug * Fix bugs * Add unit tests * Change coments * Avoid break using positional arguments. * Add copyright * Modify comments * fix lint Co-authored-by: Guangchen Lin <347630870@qq.com>




Motivation
To custom colors for objects with different classes.

Modification
The main changes are in image.py
I also add a new argument named --show-colors in test.py to custom colors in the command line.