Skip to content

fix dbnet eval on ctw1500 #771

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

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion mindocr/postprocess/det_db_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ def _extract_preds(self, pred: np.ndarray, bitmap: np.ndarray):
continue

poly = Polygon(points)
poly = np.array(expand_poly(points, distance=poly.area * self._expand_ratio / poly.length))
poly_list = expand_poly(points, distance=poly.area * self._expand_ratio / poly.length)
if self._is_uneven_nested_list(poly_list):
poly = np.array(poly_list, dtype=object)
else:
poly = np.array(poly_list)
if self._out_poly and len(poly) > 1:
continue
poly = poly.reshape(-1, 2)
Expand All @@ -134,6 +138,18 @@ def _extract_preds(self, pred: np.ndarray, bitmap: np.ndarray):
return polys, scores
return np.array(polys), np.array(scores).astype(np.float32)

def _is_uneven_nested_list(self, arr_list):
if not isinstance(arr_list, list):
return False

first_length = len(arr_list[0]) if isinstance(arr_list[0], list) else None

for sublist in arr_list:
if not isinstance(sublist, list) or len(sublist) != first_length:
return True

return False

@staticmethod
def _fit_box(contour):
"""
Expand Down
Loading