Skip to content

Commit

Permalink
[Fix] ImgAugWrapper: Do not cilp polygons if not applicables (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaotongxiao authored Sep 23, 2022
1 parent 7947448 commit e9d4364
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mmocr/datasets/transforms/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
from typing import Any, Dict, List, Optional, Tuple, Union

import imgaug
Expand Down Expand Up @@ -154,7 +155,11 @@ def _augment_polygons(self, aug: imgaug.augmenters.meta.Augmenter,
removed_poly_inds.append(i)
continue
new_poly = []
for point in poly.clip_out_of_image(imgaug_polys.shape)[0]:
try:
poly = poly.clip_out_of_image(imgaug_polys.shape)[0]
except Exception as e:
warnings.warn(f'Failed to clip polygon out of image: {e}')
for point in poly:
new_poly.append(np.array(point, dtype=np.float32))
new_poly = np.array(new_poly, dtype=np.float32).flatten()
# Under some conditions, imgaug can generate "polygon" with only
Expand Down

0 comments on commit e9d4364

Please sign in to comment.