Skip to content

Commit 37f4437

Browse files
authored
unlock albumentations version (#14746)
1 parent 2b7b763 commit 37f4437

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

ppocr/data/imaug/iaa_augment.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
import albumentations as A
2525
from albumentations.core.transforms_interface import DualTransform
2626
from albumentations.augmentations.geometric import functional as fgeometric
27+
from packaging import version
28+
29+
ALBU_VERSION = version.parse(A.__version__)
30+
IS_ALBU_NEW_VERSION = ALBU_VERSION >= version.parse("1.4.15")
2731

2832

2933
# Custom resize transformation mimicking Imgaug's behavior with scaling
3034
class ImgaugLikeResize(DualTransform):
31-
def __init__(
32-
self, scale_range=(0.5, 3.0), interpolation=1, always_apply=False, p=1.0
33-
):
34-
super(ImgaugLikeResize, self).__init__(always_apply, p)
35+
def __init__(self, scale_range=(0.5, 3.0), interpolation=1, p=1.0):
36+
super(ImgaugLikeResize, self).__init__(p)
3537
self.scale_range = scale_range
3638
self.interpolation = interpolation
3739

@@ -41,11 +43,10 @@ def apply(self, img, scale=1.0, **params):
4143
new_height = int(height * scale)
4244
new_width = int(width * scale)
4345

44-
# For compatibility with Albumentations 1.4.15 and later
45-
# return fgeometric.resize(
46-
# img, (new_height, new_width), interpolation=self.interpolation
47-
# )
48-
46+
if IS_ALBU_NEW_VERSION:
47+
return fgeometric.resize(
48+
img, (new_height, new_width), interpolation=self.interpolation
49+
)
4950
return fgeometric.resize(
5051
img, new_height, new_width, interpolation=self.interpolation
5152
)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ dependencies = [
5656
"fonttools>=4.24.0",
5757
"fire>=0.3.0",
5858
"requests",
59-
"albumentations==1.4.10",
59+
"albumentations",
6060
# to be compatible with albumentations
61-
"albucore==0.0.13"
61+
"albucore"
6262
]
6363

6464
[project.urls]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cython
1111
Pillow
1212
pyyaml
1313
requests
14-
albumentations==1.4.10
14+
albumentations
1515
# to be compatible with albumentations
16-
albucore==0.0.13
16+
albucore
1717
packaging

0 commit comments

Comments
 (0)