Skip to content

华为昇腾300I如何部署paddleocr #17411

@perces

Description

@perces

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

你好,Atlas 300I Duo 支持paddleocr了么?我用910B的镜像(docker pull ccr-2vdh3abv-pub.cnc.bj.baidubce.com/device/paddle-npu:cann800-ubuntu20-npu-910b-base-aarch64-gcc84)部署paddleocr失败了,感觉可能还是硬件层的问题,不知道现在支持这个硬件了么?

Image

🏃‍♂️ Environment (运行环境)

Atlas 300I Duo

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

from paddleocr import PaddleOCR
import cv2
import os

import paddle

import time

os.environ['PADDLE_PDX_DISABLE_DEV_MODEL_WL'] = "true"

print(paddle.utils.run_check())

text_det_limit_side_len = 64
text_det_thresh = 0.3
text_det_box_thresh = 0.6
text_det_unclip_ratio = 2.0
ocr = PaddleOCR(
use_doc_orientation_classify=True,
use_doc_unwarping=True,
use_textline_orientation=True,
device="npu:1",
text_detection_model_name="PP-OCRv5_server_det",
text_recognition_model_name='PP-OCRv5_server_rec',
text_recognition_batch_size=16,
text_det_limit_type='min',
text_det_limit_side_len=text_det_limit_side_len,
text_det_thresh=text_det_thresh, # 文本检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点,默认值0.3
text_det_box_thresh=text_det_box_thresh, # 文本检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域,默认值0.6
text_det_unclip_ratio=text_det_unclip_ratio, # 文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大,默认值2.0
)
print('load success')

def warmup():
imgsDir = 'errTest'
for i in range(5):
for file in os.listdir(imgsDir):
imgPath = os.path.join(imgsDir, file)
result = ocr.predict(imgPath, use_textline_orientation=True, use_doc_orientation_classify=False,
use_doc_unwarping=False)
print('warm up complete!')

imgsDir = 'err922'
tl = []
warmup()
for file in os.listdir(imgsDir):
imgPath = os.path.join(imgsDir, file)
print(imgPath)
t1 = time.time()
ppocrResult = ocr.predict(imgPath, use_textline_orientation=True, use_doc_orientation_classify=False,
use_doc_unwarping=False)
# print(ppocrResult)
t2 = time.time()
tl.append(1000 * (t2 - t1))
ppocrResult[0].save_to_img(
save_path="./res1106" + "" + str(text_det_limit_side_len) + "" + str(text_det_thresh) + "" + str(
text_det_box_thresh) + "
" + str(text_det_unclip_ratio))
print(f'{imgPath} cost {1000 * (t2 - t1)}ms')
if len(ppocrResult) > 0:
for i, res in enumerate(ppocrResult):
resJson = res.json
text_infos = []
page_index = i + 1
rec_texts = resJson['res']['rec_texts']
rec_scores = resJson['res']['rec_scores']
rec_polys = resJson['res']['rec_polys']
for j in range(len(rec_texts)):
text = rec_texts[j]
score = rec_scores[j]
polys = rec_polys[j]
text_infos.append([polys, (text, score)])
print(text_infos)
# ocrResult.append(pageInfos)
# ppocrResult[0].print(ppocrResult)
print(f'avg cost {sum(tl) / len(tl)}ms')

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions