-
Notifications
You must be signed in to change notification settings - Fork 60
修改 lanms 包安装的判定条件 #740
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
修改 lanms 包安装的判定条件 #740
Changes from all commits
cbc7a7c
e477498
ea2b967
45d310b
3325e01
4959180
fbe32b1
96c677c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import json | ||
import os | ||
|
||
import numpy as np | ||
|
||
from mindocr.postprocess.nms_py.lanms_py import calculate_iou, merge_quadrangle_n9, standard_nms, weighted_merge | ||
|
@@ -6,6 +9,15 @@ | |
box2 = np.array([8, 10, 8, 50, 30, 50, 30, 10, 0.7]) | ||
box3 = np.array([9, 10, 9, 60, 30, 60, 30, 10, 1.1]) | ||
|
||
origin_boxes_test = [] | ||
expect_processed_boxes_test = [] | ||
lanms_test_jsons_path = os.path.join("tests/ut/lanms_test_jsons") | ||
for file in os.listdir(lanms_test_jsons_path): | ||
with open(os.path.join(lanms_test_jsons_path, file)) as f: | ||
data = json.loads(f.readline()) | ||
origin_boxes_test.append(np.array(data["origin_boxes"])) | ||
expect_processed_boxes_test.append(sorted(np.array(data["processed_boxes"]), key=lambda x: x[0])) | ||
|
||
|
||
class TestLanmsPy: | ||
def test_calculate_iou(self): | ||
|
@@ -16,8 +28,15 @@ def test_weighted_merge(self): | |
assert np.allclose(weighted_merge(box1, box2), expect_result, rtol=1e-2) is True | ||
|
||
def test_standard_nms(self): | ||
assert np.allclose(standard_nms([box2, box3], 0.5), box3, 1e-5) | ||
assert np.allclose(standard_nms([box2, box3], 0.5), box3, 1e-5) is True | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议添加断言错误的提示消息,以便在断言失败时方便问题定位 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
同上 |
||
def test_lanms(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 希望测试方法名清晰地描述它们的功能,如test_standard_nms、test_calculate_iou描述都是清晰的,但 test_lanms 稍显笼统,不便明确含义,建议可以更具体一些(如 test_merge_quadrangle_n9_with_multiple_boxes) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
lanms 是完整的算法。这个是 E2E 的测试。 |
||
expect_result = np.array([[8.611, 10, 8.611, 56.11, 30, 56.11, 30, 10, 1.8], [0, 0, 0, 20, 10, 20, 10, 0, 0.8]]) | ||
assert np.allclose(merge_quadrangle_n9([box1, box2, box3]), expect_result, 1e-2) | ||
assert np.allclose(merge_quadrangle_n9([box1, box2, box3]), expect_result, 1e-2) is True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np.allclose 可直接返回比较结果,无需使用 is True There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
是的,之后统一清理小问题。 |
||
|
||
def test_real_situations(self): | ||
real_results = [] | ||
for origin_box_test in origin_boxes_test: | ||
real_results.append(sorted(merge_quadrangle_n9(origin_box_test), key=lambda x: x[0])) | ||
for i, real_result in enumerate(real_results): | ||
assert np.allclose(real_result, expect_processed_boxes_test[i], 1e-2) is True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议添加断言错误的提示消息,以便在断言失败时方便问题定位 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
测试内容在函数名称已经写明。 |
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 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.
本部分代码较短,变量名称已经覆盖意义,多余的注释意义不大。