Fixed channel order RGB bug in the inference Code #11624
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The inference section of the tutorial jupyter notebook takes the input image as RGB. This affects the performance of the detector as the detector is trained with BGR format. This effect is not apparent in the provided ballon dataset but can have a huge impact depending on the dataset.
Modification
RGB bug in the inference Code is fixed by creating another variable for image. The model is then sent the image in BGR format and the visualizer is sent the image in RGB format.
import mmcv from mmdet.apis import init_detector, inference_detector img = mmcv.imread('./ballondatasets/balloon/train/7178882742_f090f3ce56_k.jpg',channel_order='rgb') img_bgr = mmcv.imread('./ballondatasets/balloon/train/7178882742_f090f3ce56_k.jpg',channel_order='bgr') checkpoint_file = 'tutorial_exps/epoch_12.pth' model = init_detector(cfg, checkpoint_file, device='cpu') new_result = inference_detector(model, img_bgr) print(new_result)
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repos?
No sure
Checklist