未验证 提交 4e9a68e6 编写于 作者: S Steffy-zxf 提交者: GitHub

update ocr module name (#629)

* fix ocr module name
上级 216673a8
......@@ -67,10 +67,10 @@ PaddleHub采用模型即软件的设计理念,所有的预训练模型与Pytho
安装PaddleHub后,执行命令[hub run](./docs/tutorial/cmdintro.md),即可快速体验无需代码、一键预测的功能:
* 使用[文字识别](https://www.paddlepaddle.org.cn/hublist?filter=en_category&value=TextRecognition)轻量级中文OCR模型chinese_ocr_db_rcnn即可一键快速识别图片中的文字。
* 使用[文字识别](https://www.paddlepaddle.org.cn/hublist?filter=en_category&value=TextRecognition)轻量级中文OCR模型chinese_ocr_db_crnn即可一键快速识别图片中的文字。
```shell
$ wget https://paddlehub.bj.bcebos.com/model/image/ocr/test_ocr.jpg
$ hub run chinese_ocr_db_rcnn --input_path test_ocr.jpg --visualization=True
$ hub run chinese_ocr_db_crnn --input_path test_ocr.jpg --visualization=True
```
预测结果图片保存在当前运行路径下ocr_result文件夹中,如下图所示。
......
## 概述
chinese_ocr_db_rcnn Module用于识别图片当中的汉字。其基于[chinese_text_detection_db Module](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_text_detection_db&en_category=TextRecognition)检测得到的文本框,继续识别文本框中的中文文字。识别文字算法采用CRNN(Convolutional Recurrent Neural Network)即卷积递归神经网络。其是DCNN和RNN的组合,专门用于识别图像中的序列式对象。与CTC loss配合使用,进行文字识别,可以直接从文本词级或行级的标注中学习,不需要详细的字符级的标注。该Module支持直接预测。
chinese_ocr_db_crnn Module用于识别图片当中的汉字。其基于[chinese_text_detection_db Module](https://www.paddlepaddle.org.cn/hubdetail?name=chinese_text_detection_db&en_category=TextRecognition)检测得到的文本框,继续识别文本框中的中文文字。识别文字算法采用CRNN(Convolutional Recurrent Neural Network)即卷积递归神经网络。其是DCNN和RNN的组合,专门用于识别图像中的序列式对象。与CTC loss配合使用,进行文字识别,可以直接从文本词级或行级的标注中学习,不需要详细的字符级的标注。该Module支持直接预测。
<p align="center">
......@@ -12,7 +12,7 @@ chinese_ocr_db_rcnn Module用于识别图片当中的汉字。其基于[chinese_
## 命令行预测
```shell
$ hub run chinese_ocr_db_rcnn --input_path "/PATH/TO/IMAGE"
$ hub run chinese_ocr_db_crnn --input_path "/PATH/TO/IMAGE"
```
## API
......@@ -55,7 +55,7 @@ def recognize_text(images=[],
import paddlehub as hub
import cv2
ocr = hub.Module(name="chinese_ocr_db_rcnn")
ocr = hub.Module(name="chinese_ocr_db_crnn")
result = ocr.recognize_text(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
......@@ -76,7 +76,7 @@ PaddleHub Serving 可以部署一个目标检测的在线服务。
运行启动命令:
```shell
$ hub serving start -m chinese_ocr_db_rcnn
$ hub serving start -m chinese_ocr_db_crnn
```
这样就完成了一个目标检测的服务化API的部署,默认端口号为8866。
......@@ -100,7 +100,7 @@ def cv2_to_base64(image):
# 发送HTTP请求
data = {'images':[cv2_to_base64(cv2.imread("/PATH/TO/IMAGE"))]}
headers = {"Content-type": "application/json"}
url = "http://127.0.0.1:8866/predict/chinese_ocr_db_rcnn"
url = "http://127.0.0.1:8866/predict/chinese_ocr_db_crnn"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印预测结果
......
......@@ -19,19 +19,19 @@ import numpy as np
import paddle.fluid as fluid
import paddlehub as hub
from chinese_ocr_db_rcnn.character import CharacterOps
from chinese_ocr_db_rcnn.utils import draw_ocr, get_image_ext, sorted_boxes
from chinese_ocr_db_crnn.character import CharacterOps
from chinese_ocr_db_crnn.utils import draw_ocr, get_image_ext, sorted_boxes
@moduleinfo(
name="chinese_ocr_db_rcnn",
name="chinese_ocr_db_crnn",
version="1.0.0",
summary=
"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_email="paddle-dev@baidu.com",
type="cv/text_recognition")
class ChineseOCRDBRCNN(hub.Module):
class ChineseOCRDBCRNN(hub.Module):
def _initialize(self, text_detector_module=None):
"""
initialize with the necessary elements
......@@ -355,8 +355,8 @@ class ChineseOCRDBRCNN(hub.Module):
Run as a command
"""
self.parser = argparse.ArgumentParser(
description="Run the chinese_ocr_db_rcnn module.",
prog='hub run chinese_ocr_db_rcnn',
description="Run the chinese_ocr_db_crnn module.",
prog='hub run chinese_ocr_db_crnn',
usage='%(prog)s',
add_help=True)
......@@ -371,7 +371,7 @@ class ChineseOCRDBRCNN(hub.Module):
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.recognize_texts(
results = self.recognize_text(
paths=[args.input_path],
use_gpu=args.use_gpu,
output_dir=args.output_dir,
......@@ -407,7 +407,7 @@ class ChineseOCRDBRCNN(hub.Module):
if __name__ == '__main__':
ocr = ChineseOCRDBRCNN()
ocr = ChineseOCRDBCRNN()
image_path = [
'../doc/imgs/11.jpg', '../doc/imgs/12.jpg', '../test_image.jpg'
]
......
name: chinese_ocr_db_rcnn
dir: "modules/image/text_recognition/chinese_ocr_db_rcnn"
name: chinese_ocr_db_crnn
dir: "modules/image/text_recognition/chinese_ocr_db_crnn"
exclude:
- README.md
......
......@@ -19,9 +19,9 @@ import cv2
import paddlehub as hub
class ChineseOCRDBRCNNTestCase(TestCase):
class ChineseOCRDBCRNNTestCase(TestCase):
def setUp(self):
self.module = hub.Module(name='chinese_ocr_db_rcnn')
self.module = hub.Module(name='chinese_ocr_db_crnn')
self.test_images = [
"../image_dataset/text_recognition/11.jpg",
"../image_dataset/text_recognition/test_image.jpg"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册