1) RRandomCrop Runtime Error Fixed (when only one bounding box exists in the cropped); 2) mAP Print Error Fixed (when #class of model > # class of data); 3) confusion matrix color-theme error fixed! #1083
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.
transform pipeline
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
[1]
I tried to use
dict(type='RRandomCrop')
in the list namedtrain_pipeline
of my configuration *py file, but it occurs bbox shape mismatch error, if only one valid bounding box exists in the cropped image!** Error message:
File "/home/yechani9/PycharmProjects/AMOD-ExpKit/mmdetection/mmdet/core/bbox/assigners/max_iou_assigner.py", line 111, in assign
overlaps = self.iou_calculator(gt_bboxes, bboxes)
File "/home/yechani9/PycharmProjects/AMOD-ExpKit/mmdetection/mmdet/core/bbox/iou_calculators/iou2d_calculator.py", line 65, in call
return bbox_overlaps(bboxes1, bboxes2, mode, is_aligned)
File "/home/yechani9/PycharmProjects/AMOD-ExpKit/mmdetection/mmdet/core/bbox/iou_calculators/iou2d_calculator.py", line 198, in bbox_overlaps
assert bboxes1.shape[:-2] == bboxes2.shape[:-2]
AssertionError
[2]
I tried to fix the minor error of
print_map_summary()
when # class of model > # class of data.I know " # class of model > # class of data " seems quite nonsense, but sometimes this situation may be intentional (e.g. Pretraining with 4 classes -> Fine-tuning with 10 classes: One simple strategy is to use the model with 10 classes even in pretraining.
[3]
Confusion matrix does not reflect the color-map from `args.color_theme'!
Modification
For [1],
In RRandomCrop/_crop_data(),
valid_inds
should be 1-dimensional, but sometimesvalid_inds
become 0-dimensional, when only one valid bounding box exists in the cropped image, which occurs bbox shape mismatch error! Therefore, I added "valid_inds = np.atleast_1d(valid_inds)" in _crop_data(), in order to avoid such error!For [2],
I modified some of the code to do Print AP per class, keeping in mind the actual number of classes available.
For [3], I added
color_theme=args.color_theme
!...
plot_confusion_matrix(
confusion_matrix,
dataset.CLASSES + ('background', ),
save_dir=args.save_dir,
show=args.show,
color_theme=args.color_theme # added
)
BC-breaking (Optional)
Does the modification introduce changes that break the back-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.
Luckily, I believe there will be no compatibility issue, as my change is minor!
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist