-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add oriented bounding box head for object detection tasks #73
base: main
Are you sure you want to change the base?
Conversation
* Added ResNet variants * ResNet50 example * Simplified example * fixed resnet config * [Automated] Updated coverage badge --------- Co-authored-by: Martin Kozlovsky <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
* fixed incorrect class property call * fixed exporter uploading * uploadCheckpoint uploads on every checkpoint epoch * fix temp files names * updated callback readme * pre-commit run
* option to source custom code in CLI * removed empty dicts * [Automated] Updated coverage badge --------- Co-authored-by: GitHub Actions <[email protected]>
* option to source custom code in CLI * removed empty dicts * fixed issue with removed tensor metadata in match case statements
* forbid extra fields in config * fixed configs
* automatic inference of attach index based on type signature * added inference for input and x names
* fixed link in docs * fixed repvgg backbone * fixed efficientnet
* upload logs to mlflow * added mlflwo instance * multithread log upload * fixed upload logs * fixed log file path * removed exceptions * logging exceptions * fixed typo * reverted exception * moved line * replaced warning with error log * Update trainer.py
* add archiver CLI * add archiver callback * add max_det parameter to EfficientBBoxHead * add enum to categorize tasks for the implemented heads * add archiver tests * adjust Archiver to new nn archive format * pre-comit formatting * add LDF creation and adjust to new nn archive format * update requirements.txt * add opencv-python to requirements.txt * add support for ImplicitKeypointBBoxHead * remove support for ObjectDetectionSSD * Update requirements.txt * Added mlflow and removed opencv * [Automated] Updated coverage badge * add support for SegmentationHead and BiSeNetHead * base archiver tests on model from luxonis-train instead of torchvision * adjust head parameters to changes in NN Archive * adjust keypoint detection head parameters to changes in NN Archive * bugfix - make sure self.max_det is used in nms * add max_det parameter to ImplicitKeypointBBoxHead * adjust task categorization for ImplicitKeypointBBoxHead * fixing Windows PermissionError occuring on file deletion * fixing Windows PermissionError occuring on file deletion due to unreleased logging handlers * add method to remove file handlers keeping the log file open * add a logging statement at the end of archiving * add optuna_integration to requirements.txt * add hard-coded solution to determining is_softmax parameter * added help --------- Co-authored-by: Martin Kozlovský <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
* extend NN Archive generation test coverage to cover all implemented heads * [Automated] Updated coverage badge --------- Co-authored-by: GitHub Actions <[email protected]>
* uploading all checkpoints * fix names * removed comment
* handling SIGTERM signal * resume argument takes path
* handling SIGTERM signal * resume argument takes path * basic task group labels support * updated requirements * fixed tests * fixed loader test * Update luxonis_train/models/luxonis_model.py Co-authored-by: conorsim <[email protected]> --------- Co-authored-by: conorsim <[email protected]>
* option to set torch matmul precision for tensor cores * updated readme
* fixed reset not being called * added metric resets * removed inheritance * proper oks reset * removed unnecessary resets * added annotations
* Added seed to config for reproducibility * fixed seg drawing when using torch deterministic backend * added deterministic order of creating nodes * removed seed from example config * added reproducability to inspect * formatting --------- Co-authored-by: DrejcPesjak <[email protected]> Co-authored-by: Martin Kozlovský <[email protected]>
* support for custom loaders and datasets * updated configs * custom loaders in inspect command * updated inspect for multi-task labels * removed custom loader from test config * deleted comment * deleted comment * removed custom dataset * removed comment * skipping archiver test untill fixed in luxonis-ml * [Automated] Updated coverage badge --------- Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Martin Kozlovsky <[email protected]>
Co-authored-by: Martin Kozlovsky <[email protected]> Co-authored-by: Michal Sejak <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
Co-authored-by: Martin Kozlovsky <[email protected]>
Test Results2 files 2 suites 18s ⏱️ For more details on these errors, see this check. Results for commit 4265845. |
Co-authored-by: GitHub Actions <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of code duplication, confusing commented code and incorrect docstrings. Also please make sure the CI pipeline passes (see CONTRIBUTING.md
for more info).
Otherwise looks good
@@ -257,3 +267,135 @@ def _get_final_assignments( | |||
) | |||
|
|||
return assigned_labels, assigned_bboxes, assigned_scores | |||
|
|||
|
|||
class RotatedTaskAlignedAssigner(TaskAlignedAssigner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to a separate file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the name could be changed to OrientedTaskAlignedAssigner
to be consistent with the OBB naming.
return out_target | ||
|
||
|
||
class VarifocalLoss(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VarifocalLoss
is already implemented in luxonis_train.attached_modules.losses.adaptive_detection_loss
luxonis_train/assigners/utils.py
Outdated
"""Select the positive anchor center in gt for rotated bounding | ||
boxes. | ||
|
||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring must be in epytext
""" | ||
super().__init__(**kwargs) | ||
|
||
if not isinstance(self.node, EfficientOBBoxHead): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary; the check is done automatically in BaseAttachedModule
.
gt_cxcywhr = target[:, :, 1:] | ||
mask_gt = (gt_cxcywhr.sum(-1, keepdim=True) > 0).float() | ||
|
||
# TODO: log change of assigner (once common Logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no change of assigner to log
return stack([pt1, pt2, pt3, pt4], -2) | ||
|
||
|
||
def xyxy2xywh(x: Tensor) -> Tensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already torchvision.ops.box_convert
for this
return y | ||
|
||
|
||
def xywh2xyxy(x: Tensor) -> Tensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torchision.ops.box_convert
@@ -269,6 +405,128 @@ def bbox_iou( | |||
return iou | |||
|
|||
|
|||
def probiou( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more readable function name
return iou | ||
|
||
|
||
def batch_probiou(obb1: Tensor, obb2: Tensor, eps: float = 1e-7) -> Tensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is almost identical to probiou
, why do we need both?
@@ -411,6 +669,182 @@ def non_max_suppression( | |||
return output | |||
|
|||
|
|||
def non_max_suppression_obb( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost identical to non_max_suppression
. Can you improve non_max_suppression
to also support oriented bboxes instead of having this function?
Co-authored-by: Martin Kozlovsky <[email protected]>
Co-authored-by: Martin Kozlovsky <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
This PR introduces oriented bounding box functionality for object detection tasks, built on top of
DetectionModel
.Implemented classes