You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于获取Paddle OCR检测模型文本检测置信度的技术咨询

获取Paddle OCR文本检测阶段的置信度方法

默认情况下,PaddleOCR的ocr()接口返回结果仅包含识别阶段的置信度,但可以通过以下两种方式获取文本检测阶段的置信度,用于区分真实文本与涂鸦、集装箱锈迹等干扰物:

1. 单独调用检测模型推理

直接初始化仅启用检测功能的PaddleOCR实例,单独运行文本检测任务,结果中会包含每个检测框的置信度:

from paddleocr import PaddleOCR

# 初始化仅检测的模型(关闭识别和角度分类)
ocr_det = PaddleOCR(use_angle_cls=False, det=True, rec=False)
# 对目标图像执行检测
detection_results = ocr_det.ocr("your_image.jpg", rec=False)

# 解析结果:每个元素为[边界框坐标, 检测置信度]
for det_item in detection_results[0]:
    bbox = det_item[0]
    det_confidence = det_item[1]
    print(f"检测框坐标: {bbox}, 检测置信度: {det_confidence}")

检测置信度取值范围为0-1,数值越高代表模型判断该区域为文本的置信程度越强。

2. 同时获取检测与识别置信度

如果需要同时得到检测框、检测置信度、识别文本及识别置信度,可以分别调用检测和识别模型的底层接口,实现联合推理:

from paddleocr import PaddleOCR

# 初始化完整OCR模型(保留检测、识别、角度分类)
ocr = PaddleOCR(use_angle_cls=True)
img_path = "your_image.jpg"

# 第一步:单独执行检测,获取检测框和检测置信度
det_results = ocr.detector.predict(img_path)[0]
det_info = []
for det_line in det_results:
    # 解析检测框坐标和置信度
    bbox = det_line[:8].reshape(4, 2).tolist()
    det_conf = det_line[8]
    det_info.append((bbox, det_conf))

# 第二步:执行完整OCR,获取识别结果
full_results = ocr.ocr(img_path, cls=True)

# 匹配检测框与识别结果(假设检测与识别结果顺序一致)
for idx, (det_item, rec_item) in enumerate(zip(det_info, full_results[0])):
    bbox, det_conf = det_item
    rec_text, rec_conf = rec_item[1]
    print(f"序号{idx+1}:")
    print(f"  检测框: {bbox}")
    print(f"  检测置信度: {det_conf:.4f}")
    print(f"  识别文本: {rec_text}")
    print(f"  识别置信度: {rec_conf:.4f}")

3. 区分文本与干扰物的实践建议

  • 设置检测置信度阈值:例如将阈值设为0.6-0.7,过滤掉检测置信度低于阈值的区域,这类区域更可能是涂鸦、锈迹等非文本干扰物。
  • 结合识别置信度判断:如果检测置信度较高但识别置信度极低,该区域可能是模糊文本或非文本,也可考虑过滤。

针对你提供的OCR结果:

[[[[[641.0, 65.0], [813.0, 61.0], [815.0, 130.0], [643.0, 134.0]], ('FRLU', 0.9880595207214355)], [[[645.0, 156.0], [953.0, 152.0], [954.0, 214.0], [645.0, 217.0]], ('8616911', 0.9634677767753601)], [[[640.0, 243.0], [816.0, 243.0], [816.0, 307.0], [640.0, 307.0]], ('42G1', 0.9629315733909607)]]]

其中的置信度均为识别阶段的结果,若要获取对应检测框的检测置信度,需通过上述方法重新推理。

内容的提问来源于stack exchange,提问作者Jia Qing Cheok

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 21:41:22