mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-25 04:29:22 +01:00
fix type checking of inputs for np.array (#271)
* fix type checking of inputs for np.array inputs type of np.ndarray is not checked correctly. * add docstr for /preprocessor.py add docstr about np.ndarray, shape and order
This commit is contained in:
@@ -37,7 +37,7 @@ class OCRDetectionPreprocessor(Preprocessor):
|
||||
inputs:
|
||||
- A string containing an HTTP link pointing to an image
|
||||
- A string containing a local path to an image
|
||||
- An image loaded in PIL or opencv directly
|
||||
- An image loaded in PIL(PIL.Image.Image) or opencv(np.ndarray) directly, 3 channels RGB
|
||||
Returns:
|
||||
outputs: the preprocessed image
|
||||
"""
|
||||
@@ -45,6 +45,8 @@ class OCRDetectionPreprocessor(Preprocessor):
|
||||
img = np.array(load_image(inputs))
|
||||
elif isinstance(inputs, PIL.Image.Image):
|
||||
img = np.array(inputs)
|
||||
elif isinstance(inputs, np.ndarray):
|
||||
img = inputs
|
||||
else:
|
||||
raise TypeError(
|
||||
f'inputs should be either str, PIL.Image, np.array, but got {type(inputs)}'
|
||||
|
||||
Reference in New Issue
Block a user