PaddlePaddle/PaddleOCR · error · TypeError

Interpolation types only nearest, linear, cubic, area are su

Error message

Interpolation types only nearest, linear, cubic, area are supported!

What it means

get_interpolation in ppocr/data/imaug/abinet_aug.py maps a style string to an OpenCV interpolation flag; 'random' picks one of the four flags, and anything other than random/nearest/linear/cubic/area raises TypeError. This is ABINet training-data augmentation config validation, so the error means an invalid 'interpolation' entry in the transform config.

Source

Thrown at ppocr/data/imaug/abinet_aug.py:52

def sample_uniform(low, high, size=None):
    return np.random.uniform(low, high, size=size)


def get_interpolation(type="random"):
    if type == "random":
        choice = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA]
        interpolation = choice[random.randint(0, len(choice) - 1)]
    elif type == "nearest":
        interpolation = cv2.INTER_NEAREST
    elif type == "linear":
        interpolation = cv2.INTER_LINEAR
    elif type == "cubic":
        interpolation = cv2.INTER_CUBIC
    elif type == "area":
        interpolation = cv2.INTER_AREA
    else:
        raise TypeError(
            "Interpolation types only nearest, linear, cubic, area are supported!"
        )
    return interpolation


class CVRandomRotation(object):
    def __init__(self, degrees=15):
        assert isinstance(degrees, numbers.Number), "degree should be a single number."
        assert degrees >= 0, "degree must be positive."
        self.degrees = degrees

    @staticmethod
    def get_params(degrees):
        return sample_sym(degrees)

    def __call__(self, img):
        angle = self.get_params(self.degrees)
        src_h, src_w = img.shape[:2]

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Set interpolation to one of: 'random', 'nearest', 'linear', 'cubic', 'area' in the transform config.
  2. Note 'bilinear' is NOT accepted — the OpenCV name here is 'linear'.
  3. Check the YAML/JSON config actually loaded (print the resolved transform args) to catch overrides.

Example fix

# config.yml / transform args
# before
- CVGeometry:
    interpolation: bilinear
# after
- CVGeometry:
    interpolation: linear
Defensive patterns

Strategy: validation

Validate before calling

VALID_INTERP = {'random', 'nearest', 'linear', 'cubic', 'area'}

def valid_interpolation(s) -> bool:
    return isinstance(s, str) and s.lower() in VALID_INTERP

Type guard

def is_interpolation_style(v) -> bool:
    return isinstance(v, str) and v in {'random','nearest','linear','cubic','area'}

Prevention

When it happens

Trigger: An augmentation pipeline config (or CVGeometry/CVColorJitter-style transform constructed with interpolation='bilinear', 'lanczos', or 'RANDOM') reaching get_interpolation; only exact lowercase strings are accepted.

Common situations: Copying augmentation YAML from other repos (Albumentations/torchvision names like 'bilinear'); training ABINet rec models with hand-edited config files; case mismatches.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/a876d765b5ec031d. Report an issue: GitHub.