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 boxes V2 as discussed in #1142 (superseed #1177) #1304
Conversation
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.
LGTM.
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.
don't forget to add to docs
@hal-314 @shijianjian can you consider this here ? #1194 (comment) |
@edgarriba now, matrix transform must be (3,3) when user created N boxes (N, 4, 2) or (B, 3,3) when user pass a batch of N boxes (B,N,4,2). So, it would work fine with the new api: boxes = Boxes.from_tensor(torch.randn(10, 4))
boxes.transform_boxes(torch.eye(3)) Also, the other reported bug regarding coordinates position is fixed when converting back to xywh: |
Hi again @edgarriba |
maybe just |
@edgarriba The remaining points in this PR are:
|
I will take a look on it tomorrow. It is also possible that TV has a bad support for 3D ops and tensors.
No worries on that. They are merely some coding pattern recommendations. I did not pretty follow that either. |
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.
@hal-314 It looks like there are many numeric errors in 3D boxes. Can you take a look?
Marked as draft since tests seems to be broken |
Fix bugs related to "xyxy_plus" and "vertices_plus" + renaming from "bbox_v2" to "boxes" + implemented workaround discussed in #1398 . Now, I think it's ready to merge. Note that the whole #1398 workaround is implemented in one unique commit (07795f9) so it can be easily reverted in the future. Finally, there are two tasks left regarding the new boxes approach:
Those failing tests weren't related to this PRs. I updated the branch with the last commit in the master in hope they get fixed. So, I remove the draft labeling. |
Co-authored-by: Edgar Riba <edgar.riba@gmail.com>
for more information, see https://pre-commit.ci
One thing of concern is that if Boxes module cannot be registered as an class MyBoxProcessor(nn.Module):
def __init__(self,):
self.box = Boxes(...)
MyBoxProcessor().to("cuda") Then the box variable will still be in CPU. Probably put it to the backlog for now. We are still unclear about how this Boxes module will be used in the future. Let's udpate it step by step. |
As workaround, you could override class MyBoxProcessor(nn.Module):
def __init__(self,):
super().__init__()
# self.box = Boxes(...)
def to(self, *args, **kwargs):
print('hi')
# self.box = self.box.to(*args, **kwargs)
super().to(*args, **kwargs)
MyBoxProcessor().to('cuda') |
@hal-314 Yes. We have to move to |
In previous commits, tests were failing in test_boxes.py. the error wasn't related to my code. It was something related to "_IO.string" (I don't access to the CI logs of previous commits). However, boxes tests runs successfully in my local machine: If it happens again, I don't know why and how I could fix them :/ |
Hi @hal-314, can you fix the doctest error so that we can merge? |
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.
LGTM. @shijianjian merge when green lights
Consider this in the future: https://github.com/lilanxiao/Rotated_IoU |
Changes
This PR implements #1142 (issue) and superseeds #1177 (pr). It's the same code with the following differences:
Boxes
andBoxes3D
. They are torchscript classes to allow to be used in traced / scripted code. Without usingtorch.jit.script
decorator, I faced several strange behaviors when scripting.Check #1177 for differences with current
kornia.geometry.bbox
module.#### TODO- Update docs- As suggested by shijianjian in #1177, better explanation and name for*_plus_1
into_tensor
andfrom_tensor
.~~- Fix gradient check test fail for
Boxes3D.to_tensor
. I don't understand why it's happening as it's almost an exact copy ofBoxes.to_tensor
~~- ¿Update CHANGELOG? Is this something I should do?TODO to do in future PRs):
- Check transforms. Care should be taken since transforms assumes +1 convention. At least, it happens with random flips. Check this article.See Clarify keypoints behaviour and their limitations #1398. As temporary fix, we use "+1" convention internally. See whole temporary fix is done in commit "07795f9c78468b42ecd96f4d5d2b8df562deecf7".Type of change
Checklist