mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-26 21:24:27 +00:00
unlock albumentations version (#14746)
This commit is contained in:
parent
2b7b76310b
commit
37f44372b1
@ -24,14 +24,16 @@ import numpy as np
|
||||
import albumentations as A
|
||||
from albumentations.core.transforms_interface import DualTransform
|
||||
from albumentations.augmentations.geometric import functional as fgeometric
|
||||
from packaging import version
|
||||
|
||||
ALBU_VERSION = version.parse(A.__version__)
|
||||
IS_ALBU_NEW_VERSION = ALBU_VERSION >= version.parse("1.4.15")
|
||||
|
||||
|
||||
# Custom resize transformation mimicking Imgaug's behavior with scaling
|
||||
class ImgaugLikeResize(DualTransform):
|
||||
def __init__(
|
||||
self, scale_range=(0.5, 3.0), interpolation=1, always_apply=False, p=1.0
|
||||
):
|
||||
super(ImgaugLikeResize, self).__init__(always_apply, p)
|
||||
def __init__(self, scale_range=(0.5, 3.0), interpolation=1, p=1.0):
|
||||
super(ImgaugLikeResize, self).__init__(p)
|
||||
self.scale_range = scale_range
|
||||
self.interpolation = interpolation
|
||||
|
||||
@ -41,11 +43,10 @@ class ImgaugLikeResize(DualTransform):
|
||||
new_height = int(height * scale)
|
||||
new_width = int(width * scale)
|
||||
|
||||
# For compatibility with Albumentations 1.4.15 and later
|
||||
# return fgeometric.resize(
|
||||
# img, (new_height, new_width), interpolation=self.interpolation
|
||||
# )
|
||||
|
||||
if IS_ALBU_NEW_VERSION:
|
||||
return fgeometric.resize(
|
||||
img, (new_height, new_width), interpolation=self.interpolation
|
||||
)
|
||||
return fgeometric.resize(
|
||||
img, new_height, new_width, interpolation=self.interpolation
|
||||
)
|
||||
|
@ -56,9 +56,9 @@ dependencies = [
|
||||
"fonttools>=4.24.0",
|
||||
"fire>=0.3.0",
|
||||
"requests",
|
||||
"albumentations==1.4.10",
|
||||
"albumentations",
|
||||
# to be compatible with albumentations
|
||||
"albucore==0.0.13"
|
||||
"albucore"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
@ -11,7 +11,7 @@ cython
|
||||
Pillow
|
||||
pyyaml
|
||||
requests
|
||||
albumentations==1.4.10
|
||||
albumentations
|
||||
# to be compatible with albumentations
|
||||
albucore==0.0.13
|
||||
albucore
|
||||
packaging
|
||||
|
Loading…
x
Reference in New Issue
Block a user