Skip to content

Commit

Permalink
fix dbnet eval on ctw1500
Browse files Browse the repository at this point in the history
  • Loading branch information
alien-0119 committed Nov 15, 2024
1 parent 9d2f8f8 commit 8ec84e7
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit 8ec84e7

Please sign in to comment.