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

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

unique-chan
Copy link

@unique-chan unique-chan commented Feb 4, 2025

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 named train_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 sometimes valid_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

  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. The documentation has been modified accordingly, like docstring or example tutorials.

@CLAassistant
Copy link

CLAassistant commented Feb 4, 2025

CLA assistant check
All committers have signed the CLA.

@unique-chan unique-chan changed the title invalid value of results['img_shape'] fixed for correct usage in tran… RRandomCrop Runtime Error Fixed! Feb 4, 2025
@unique-chan unique-chan changed the title RRandomCrop Runtime Error Fixed! 1) RRandomCrop Runtime Error Fixed 2) mAP calculation error Fixed when #class of model > # class of data! Feb 4, 2025
@unique-chan unique-chan changed the title 1) RRandomCrop Runtime Error Fixed 2) mAP calculation error Fixed when #class of model > # class of data! 1) RRandomCrop Runtime Error Fixed; 2) mAP Print Error Fixed when #class of model > # class of data! Feb 4, 2025
@unique-chan unique-chan changed the title 1) RRandomCrop Runtime Error Fixed; 2) mAP Print Error Fixed when #class of model > # class of data! 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)! Feb 5, 2025
@unique-chan unique-chan changed the title 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)! 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! Feb 5, 2025
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.

2 participants