【问题标题】:layoutparser gives error "module layoutparser has no attribute ocr"layoutparser 给出错误“模块 layoutparser 没有属性 ocr”
【发布时间】:2021-10-25 09:45:29
【问题描述】:

我正在尝试使用新的 layoutparser 包来做一些 OCR。但是,来自 R 背景的我很难启动并运行它。

我通过安装它(工作正常):

pip install layoutparser
pip install "layoutparser[ocr]"

现在,当我运行以下命令时,出现错误:

import layoutparser as lp

import matplotlib.pyplot as plt

import pandas as pd
import numpy as np
import cv2

ocr_agent = lp.ocr.TesseractAgent()
AttributeError: module layoutparser has no attribute ocr

【问题讨论】:

    标签: python ocr


    【解决方案1】:
    ocr_agent = lp.TesseractAgent()
    

    【讨论】:

    • 如果您向我们解释为什么您的代码可以解决 OP 的问题,我相信这会对社区有所帮助
    【解决方案2】:

    这对我有用(至少没有 python 错误):

    import layoutparser.ocr as ocr
    ocr_agent = ocr.TesseractAgent()
    

    但需要解释为什么以下内容不起作用:

    import layoutparser as lp
    ocr_agent = lp.ocr.TesseractAgent()
    

    【讨论】:

      猜你喜欢
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-29
      • 2014-01-29
      • 2021-07-17
      相关资源
      最近更新 更多