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

[Feature] Add points_in_polygons CUDA op for rotated detection. #1600

Merged
merged 20 commits into from
Dec 24, 2021

Conversation

zytx121
Copy link
Contributor

@zytx121 zytx121 commented Dec 20, 2021

Add points_in_polygons CUDA ops for anchor-free rotated detection. It is mainly used to judge whether the points are inside the ground true polygons during sample assignment.

Modification

Several files in mmcv/ops folder.

BC-breaking (Optional)

No.

Use cases (Optional)

from mmcv.ops import points_in_polygons

@zhouzaida
Copy link
Collaborator

Please @AllentDan have a look.

@AllentDan
Copy link
Member

Hi, @zytx121. Unit tests failed on my device.

@zytx121
Copy link
Contributor Author

zytx121 commented Dec 20, 2021

Hi, @zytx121. Unit tests failed on my device.

Sorry, I'll check it as soon as possible.

@zytx121
Copy link
Contributor Author

zytx121 commented Dec 20, 2021

Hi, @zytx121. Unit tests failed on my device.

Please test again. Thx.

@zhouzaida zhouzaida added the CUDA label Dec 20, 2021
Copy link
Member

@AllentDan AllentDan left a comment

Choose a reason for hiding this comment

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

zytx121 and others added 3 commits December 21, 2021 11:49
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
@grimoire
Copy link
Member

Is there any limit about the polygon? Such as convex or clockwise?

Test failed with data:

    points = np.array([[20, 90]])
    polygons = np.array([[0., 0., 100., 100., 10., 90., 0., 100.]])

If there are any limit about the polygon, please update the docstring.

@zytx121
Copy link
Contributor Author

zytx121 commented Dec 21, 2021

Is there any limit about the polygon? Such as convex or clockwise?

Test failed with data:

    points = np.array([[20, 90]])
    polygons = np.array([[0., 0., 100., 100., 10., 90., 0., 100.]])

If there are any limit about the polygon, please update the docstring.

We believe that this method can handle all polygons without adding conditions such as convex or clockwise. As shown in the figure below, this point falls inside the polygon, which is consistent with the test results.

image

def test_points_in_polygons():
    points = np.array([[20, 90]])
    polygons = np.array([[0., 0., 100., 100., 10., 90., 0., 100.]])
    expert_output = np.array([[1.,]])
    points = torch.from_numpy(points).cuda().float()
    polygons = torch.from_numpy(polygons).cuda().float()
    expert_output = torch.from_numpy(expert_output).cuda().float()
    assert torch.allclose(
        points_in_polygons(points, polygons), expert_output, 1e-3)

Note that the format of the polygon is (x,y,x,y,x,y,x,y).

@grimoire
Copy link
Member

@zytx121 Thanks for the explanation. The data did pass the test as you said.

Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

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

LGTM.

zytx121 and others added 2 commits December 21, 2021 15:37
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
@zytx121 zytx121 changed the title [Feature] Add points_in_polygons CUDA ops for rotated detection. [Feature] Add points_in_polygons CUDA op for rotated detection. Dec 22, 2021
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
@ZwwWayne
Copy link
Collaborator

Can be merged after resolving conflicts.

@ZwwWayne ZwwWayne merged commit 304efbb into open-mmlab:master Dec 24, 2021
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.

5 participants