cs-chan / Total-Text-Dataset

Total Text Dataset. It consists of 1555 images with more than 3 different text orientations: Horizontal, Multi-Oriented, and Curved, one of a kind.
BSD 3-Clause "New" or "Revised" License
747 stars 140 forks source link

about DetEval.py evaluation speed boosting. #16

Closed princewang1994 closed 5 years ago

princewang1994 commented 5 years ago

Hi, I found that the evaluation in this code run extremely slowly and most time-consuming operation in your code is area/area_of_intersection/iou. These functions are based on mask counting, which depends highly on the size of images(some big-size images can be bottleck of computing). I have replaced mask counting operation with polygon coordinate computing(which uses shapely, a geometry lib written in python) so that it highly boosts the evaluatoin process.
Can I make a PR? Hope for your replying, thx.

ckchng commented 5 years ago

Oh yes you are most welcome, thanks for wanting to contribute! And I assume that you have already tested out your code? In particular, does the library provides an exact solution instead of approximation when it comes to calculating the area of intersection?

princewang1994 commented 5 years ago

I have compared the result of mask counting method and polygon based method, their result have a bit difference(1 to 3 pixels in computing iou between 2 polygons with area about 10000 pixels) because mask counting based implement discretize the coordinates to pixels. In fact, I think the polygon based method produce more precise result.

ckchng commented 5 years ago

Yup that makes sense. Also, less than 1 percent of differences is probably negligible in practice.

princewang1994 commented 5 years ago

Thx for your replying, I will make a pull request soon! 😆