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

Refactor: Consolidate Bounding box Transformation and IoU Calculation Functions #587

Merged
merged 21 commits into from
Nov 26, 2024

Conversation

hglee98
Copy link
Contributor

@hglee98 hglee98 commented Nov 7, 2024

Description

This PR aims to refactor bbox transformation and iou calculation function.

Closes: N/A

We recommend to link at least one existing issue for PR. Before your create a PR, please check if there is an issue for this change.

Change(s)

1. New Module Creation

  • Added netspresso_trainer.utils.bbox_utils module
    • Note: Module location may be subject to change after further discussion

2. IOU Metrics Consolidation

  • Unified various IOU calculation implementations into a single comprehensive module
  • Extended supported IOU metrics:
    • Standard IOU
    • Generalized IOU (GIOU)
    • Distance IOU (DIOU)
    • Complete IOU (CIOU)

3. Introduction of Universal transform_bbox Function

Previous Implementation

Previously, we needed separate functions for each bbox format conversion:

# Old approach - Multiple specific functions
new_bbox = cxcywh2xyxy(original_bbox)
new_bbox = xyxy2cxcywh(original_bbox)
new_bbox = xyxy2cxcywhn(original_bbox, img_size)

New Implementation

# New approach - Single unified function
new_bbox = transform_bbox(original_bbox, "cxcywh -> xyxy")
new_bbox = transform_bbox(original_bbox, "xyxy -> cxcywh")
new_bbox = transform_bbox(original_bbox, "xyxy -> cxcywhn", img_size=img_size)

Code Formatting

If you PR to either master or dev branch, you should follow the code linting process. Please check your code with lint_check.sh in ./scripts directory.
For more information, please read the contribution guide in CONTRIBUTING.md.

Changelog

If your PR is granted to dev branch, codeowner will add a brief summary of the change to the Upcoming Release section of the CHANGELOG.md file including a link to the PR (formatted in markdown) and a link to your github profile.

For example,

- Added a new feature by `@myusername` in [PR 2023](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/2023)

Please enable Allow edits and access to secrets by maintainers so that our maintainers can update the CHANGELOG.md.

@hglee98 hglee98 requested a review from illian01 as a code owner November 7, 2024 08:41
@illian01 illian01 added refactoring Changes code or architecture internally without changing the output. enhancement New feature or request labels Nov 12, 2024
@hglee98 hglee98 requested a review from illian01 November 15, 2024 06:00
Copy link
Collaborator

@illian01 illian01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@illian01 illian01 merged commit c9e7d40 into Nota-NetsPresso:dev Nov 26, 2024
2 checks passed
@hglee98 hglee98 deleted the 582-enhance-bbox-utils branch December 6, 2024 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Changes code or architecture internally without changing the output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants