更多详情参考[An end-to-end trainable neural network for image-based sequence recognition and its application to scene text recognition](https://arxiv.org/pdf/1507.05717.pdf)
## 命令行预测
```shell
$ hub run chinese_ocr_db_crnn_mobile --input_path"/PATH/TO/IMAGE"
"The module can recognize the chinese texts in an image. Firstly, it will detect the text box positions based on the differentiable_binarization_chn module. Then it recognizes the chinese texts. ",
"The module can recognize the chinese texts in an image. Firstly, it will detect the text box positions based on the differentiable_binarization_chn module. Then it recognizes the chinese texts. ",
author="paddle-dev",
author="paddle-dev",
...
@@ -92,7 +92,7 @@ class ChineseOCRDBCRNN(hub.Module):
...
@@ -92,7 +92,7 @@ class ChineseOCRDBCRNN(hub.Module):
"""
"""
ifnotself._text_detector_module:
ifnotself._text_detector_module:
self._text_detector_module=hub.Module(
self._text_detector_module=hub.Module(
name='chinese_text_detection_db')
name='chinese_text_detection_db_mobile')
returnself._text_detector_module
returnself._text_detector_module
defread_images(self,paths=[]):
defread_images(self,paths=[]):
...
@@ -149,7 +149,6 @@ class ChineseOCRDBCRNN(hub.Module):
...
@@ -149,7 +149,6 @@ class ChineseOCRDBCRNN(hub.Module):
padding_im[:,:,0:resized_w]=resized_image
padding_im[:,:,0:resized_w]=resized_image
returnpadding_im
returnpadding_im
@serving
defrecognize_text(self,
defrecognize_text(self,
images=[],
images=[],
paths=[],
paths=[],
...
@@ -194,7 +193,10 @@ class ChineseOCRDBCRNN(hub.Module):
...
@@ -194,7 +193,10 @@ class ChineseOCRDBCRNN(hub.Module):
"The module can recognize the chinese texts in an image. Firstly, it will detect the text box positions based on the differentiable_binarization_chn module. Then it recognizes the chinese texts. ",
images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths
paths (list[str]): The paths of images. If paths not images
use_gpu (bool): Whether to use gpu.
batch_size(int): the program deals once with one
output_dir (str): The directory to store output images.
visualization (bool): Whether to save image or not.
box_thresh(float): the threshold of the detected text box's confidence
text_thresh(float): the threshold of the recognize chinese texts' confidence
Returns:
res (list): The result of chinese texts and save path of images.
"""
ifuse_gpu:
try:
_places=os.environ["CUDA_VISIBLE_DEVICES"]
int(_places[0])
except:
raiseRuntimeError(
"Environment Variable CUDA_VISIBLE_DEVICES is not set correctly. If you wanna use gpu, please set CUDA_VISIBLE_DEVICES via export CUDA_VISIBLE_DEVICES=cuda_device_id."
"Environment Variable CUDA_VISIBLE_DEVICES is not set correctly. If you wanna use gpu, please set CUDA_VISIBLE_DEVICES via export CUDA_VISIBLE_DEVICES=cuda_device_id."