# PaddleOCR **Repository Path**: siriusdemon/paddle-ocr ## Basic Information - **Project Name**: PaddleOCR - **Description**: 一键部署百度OCR服务 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2020-10-27 - **Last Updated**: 2025-09-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PaddleOCR 当然,这是百度技术人员的杰作! ### 安装 ```sh pip install -r requirements ``` ### 启动服务 ```sh export PYTHONPATH=. hub install deploy/hubserving/ocr_system hub serving start -m ocr_system --port 12345 ``` |参数|用途| |-|-| |--modules/-m|PaddleHub Serving预安装模型,以多个Module==Version键值对的形式列出
*`当不指定Version时,默认选择最新版本`*| |--port/-p|服务端口,默认为8866| |--use_multiprocess|是否启用并发方式,默认为单进程方式,推荐多核CPU机器使用此方式
*`Windows操作系统只支持单进程方式`*| |--workers|在并发方式下指定的并发任务数,默认为`2*cpu_count-1`,其中`cpu_count`为CPU核数| 详情看写得非常好的[文档](deploy/hubserving/readme.md)! ### 测试 可以参考官方的[这个](tools/test_hubserving.py),也可以用下面的,都位于 tools 文件夹下。 ```py import json import base64 import requests def cv2_to_base64(image): return base64.b64encode(image).decode('utf8') if __name__ == "__main__": url = "http://127.0.0.1:8866/predict/ocr_system" headers = {"Content-type": "application/json"} img = 'x.png' img = open(img, 'rb').read() data = {"images": [cv2_to_base64(img)]} r = requests.post(url=url, headers=headers, data=json.dumps(data)) print(r.json()) ``` 结果是一个 JSON ```python {'msg': '', 'results': [[{'confidence': 0.979381263256073, 'text': 'optimize-jumps', 'text_region': [[33, 1], [174, 1], [174, 26], [33, 26]]}, {'confidence': 0.997644305229187, 'text': '优化的思路是,首先遍历所有的block中的全部Goto语句,看看这些Goto语句所跳往的block', 'text_region': [[34, 49], [710, 49], [710, 68], [34, 68]]}, {'confidence': 0.9965000748634338, 'text': '是不是一个只含有一个Goto语句的trivialblock,如果是,则直接跳往下一个block,直到所跳', 'text_region': [[33, 74], [710, 73], [710, 93], [33, 94]]}, {'confidence': 0.9759809970855713, 'text': '往的block不是trivialblocke', 'text_region': [[34, 100], [244, 100], [244, 119], [34, 119]]}, {'confidence': 0.9657069444656372, 'text': '我们需要一个哈希表,键是Goto(lab)中的lab,值是从lab出发遇到的第一个nontrivialblock。', 'text_region': [[34, 145], [712, 145], [712, 167], [34, 167]]}, {'confidence': 0.9969562888145447, 'text': '也就是说,那些跳往键的Goto,要改成跳往值。', 'text_region': [[35, 171], [370, 171], [370, 190], [35, 190]]}, {'confidence': 0.9472659230232239, 'text': '//compiler.rs', 'text_region': [[47, 230], [169, 230], [169, 246], [47, 246]]}, {'confidence': 0.9162580966949463, 'text': 'fn get_shortcut(prog: &COProgram) -> HashMap {', 'text_region': [[45, 251], [583, 251], [583, 270], [45, 270]]}, {'confidence': 0.962027370929718, 'text': '//跳往key的人,应该跳往value', 'text_region': [[79, 272], [333, 272], [333, 291], [79, 291]]}, {'confidence': 0.9084468483924866, 'text': 'letmut shortcut=HashMap::new();', 'text_region': [[79, 296], [374, 297], [374, 316], [79, 315]]}, {'confidence': 0.9170700311660767, 'text': 'for (label,code)in &prog.cfg{', 'text_region': [[80, 320], [357, 322], [357, 338], [80, 336]]}, {'confidence': 0.8916361331939697, 'text': 'if letCO::Goto(reflab)=&code{', 'text_region': [[115, 344], [410, 344], [410, 360], [115, 360]]}, {'confidence': 0.922089159488678, 'text': 'letmut target=lab.clone();', 'text_region': [[147, 365], [400, 365], [400, 384], [147, 384]]}, {'confidence': 0.9091756939888, 'text': 'while let CQ::Goto(ref lab_)= ' '&prog.cfg.get(&target).unwrap(){', 'text_region': [[147, 388], [702, 389], [702, 408], [147, 407]]}, {'confidence': 0.9437456130981445, 'text': 'target=lab_.to_string();', 'text_region': [[183, 413], [409, 413], [409, 432], [183, 432]]}, {'confidence': 0.9166429042816162, 'text': 'shortcut.insert(label.clone(), target);', 'text_region': [[148, 457], [484, 458], [484, 478], [148, 477]]}, {'confidence': 0.9836835265159607, 'text': 'returnshortcut;', 'text_region': [[79, 527], [219, 527], [219, 546], [79, 546]]}]], 'status': '0'} ```