[CVCUDA] PP-OCR Cls & Rec preprocessor support CV-CUDA (#1470)

* ppocr cls preprocessor use manager

* hwc2chw cvcuda

* ppocr rec preproc use manager

* ocr rec preproc cvcuda

* fix rec preproc bug

* ppocr cls&rec preproc set normalize

* fix pybind

* address comment
This commit is contained in:
Wang Xinyu
2023-03-02 10:50:44 +08:00
committed by GitHub
parent fe2882a1ef
commit 044ab993d2
19 changed files with 424 additions and 306 deletions

View File

@@ -52,10 +52,7 @@ class DBDetectorPreprocessor:
value, int), "The value to set `max_side_len` must be type of int."
self._preprocessor.max_side_len = value
def set_normalize(self,
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225],
is_scale=True):
def set_normalize(self, mean, std, is_scale):
"""Set preprocess normalize parameters, please call this API to
customize the normalize parameters, otherwise it will use the default
normalize parameters.
@@ -340,35 +337,15 @@ class ClassifierPreprocessor:
"""
return self._preprocessor.run(input_ims)
@property
def is_scale(self):
return self._preprocessor.is_scale
@is_scale.setter
def is_scale(self, value):
assert isinstance(
value, bool), "The value to set `is_scale` must be type of bool."
self._preprocessor.is_scale = value
@property
def scale(self):
return self._preprocessor.scale
@scale.setter
def scale(self, value):
assert isinstance(
value, list), "The value to set `scale` must be type of list."
self._preprocessor.scale = value
@property
def mean(self):
return self._preprocessor.mean
@mean.setter
def mean(self, value):
assert isinstance(
value, list), "The value to set `mean` must be type of list."
self._preprocessor.mean = value
def set_normalize(self, mean, std, is_scale):
"""Set preprocess normalize parameters, please call this API to
customize the normalize parameters, otherwise it will use the default
normalize parameters.
:param: mean: (list of float) mean values
:param: std: (list of float) std values
:param: is_scale: (boolean) whether to scale
"""
self._preprocessor.set_normalize(mean, std, is_scale)
@property
def cls_image_shape(self):
@@ -496,37 +473,6 @@ class Classifier(FastDeployModel):
def postprocessor(self, value):
self._model.postprocessor = value
# Cls Preprocessor Property
@property
def is_scale(self):
return self._model.preprocessor.is_scale
@is_scale.setter
def is_scale(self, value):
assert isinstance(
value, bool), "The value to set `is_scale` must be type of bool."
self._model.preprocessor.is_scale = value
@property
def scale(self):
return self._model.preprocessor.scale
@scale.setter
def scale(self, value):
assert isinstance(
value, list), "The value to set `scale` must be type of list."
self._model.preprocessor.scale = value
@property
def mean(self):
return self._model.preprocessor.mean
@mean.setter
def mean(self, value):
assert isinstance(
value, list), "The value to set `mean` must be type of list."
self._model.preprocessor.mean = value
@property
def cls_image_shape(self):
return self._model.preprocessor.cls_image_shape
@@ -575,35 +521,15 @@ class RecognizerPreprocessor:
bool), "The value to set `static_shape_infer` must be type of bool."
self._preprocessor.static_shape_infer = value
@property
def is_scale(self):
return self._preprocessor.is_scale
@is_scale.setter
def is_scale(self, value):
assert isinstance(
value, bool), "The value to set `is_scale` must be type of bool."
self._preprocessor.is_scale = value
@property
def scale(self):
return self._preprocessor.scale
@scale.setter
def scale(self, value):
assert isinstance(
value, list), "The value to set `scale` must be type of list."
self._preprocessor.scale = value
@property
def mean(self):
return self._preprocessor.mean
@mean.setter
def mean(self, value):
assert isinstance(
value, list), "The value to set `mean` must be type of list."
self._preprocessor.mean = value
def set_normalize(self, mean, std, is_scale):
"""Set preprocess normalize parameters, please call this API to
customize the normalize parameters, otherwise it will use the default
normalize parameters.
:param: mean: (list of float) mean values
:param: std: (list of float) std values
:param: is_scale: (boolean) whether to scale
"""
self._preprocessor.set_normalize(mean, std, is_scale)
@property
def rec_image_shape(self):
@@ -728,36 +654,6 @@ class Recognizer(FastDeployModel):
bool), "The value to set `static_shape_infer` must be type of bool."
self._model.preprocessor.static_shape_infer = value
@property
def is_scale(self):
return self._model.preprocessor.is_scale
@is_scale.setter
def is_scale(self, value):
assert isinstance(
value, bool), "The value to set `is_scale` must be type of bool."
self._model.preprocessor.is_scale = value
@property
def scale(self):
return self._model.preprocessor.scale
@scale.setter
def scale(self, value):
assert isinstance(
value, list), "The value to set `scale` must be type of list."
self._model.preprocessor.scale = value
@property
def mean(self):
return self._model.preprocessor.mean
@mean.setter
def mean(self, value):
assert isinstance(
value, list), "The value to set `mean` must be type of list."
self._model.preprocessor.mean = value
@property
def rec_image_shape(self):
return self._model.preprocessor.rec_image_shape