From de859b4a3dc35c439d63fb4732b67bae12adcbb1 Mon Sep 17 00:00:00 2001 From: gaotingquan Date: Sun, 26 Sep 2021 04:45:12 +0000 Subject: [PATCH] fix: compatible with opencv under version 4.4.0 --- deploy/python/preprocess.py | 3 +++ ppcls/data/preprocess/ops/operators.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/deploy/python/preprocess.py b/deploy/python/preprocess.py index aaa0bef3..5d7fc929 100644 --- a/deploy/python/preprocess.py +++ b/deploy/python/preprocess.py @@ -78,6 +78,9 @@ class UnifiedResize(object): if backend.lower() == "cv2": if isinstance(interpolation, str): interpolation = _cv2_interp_from_str[interpolation.lower()] + # compatible with opencv < version 4.4.0 + elif not interpolation: + interpolation = cv2.INTER_LINEAR self.resize_func = partial(cv2.resize, interpolation=interpolation) elif backend.lower() == "pil": if isinstance(interpolation, str): diff --git a/ppcls/data/preprocess/ops/operators.py b/ppcls/data/preprocess/ops/operators.py index 4418f529..e46823d2 100644 --- a/ppcls/data/preprocess/ops/operators.py +++ b/ppcls/data/preprocess/ops/operators.py @@ -59,6 +59,9 @@ class UnifiedResize(object): if backend.lower() == "cv2": if isinstance(interpolation, str): interpolation = _cv2_interp_from_str[interpolation.lower()] + # compatible with opencv < version 4.4.0 + elif not interpolation: + interpolation = cv2.INTER_LINEAR self.resize_func = partial(cv2.resize, interpolation=interpolation) elif backend.lower() == "pil": if isinstance(interpolation, str): -- GitLab