当前位置: 首页 > news >正文

我想投诉做软件的网站百度关键词流量查询

我想投诉做软件的网站,百度关键词流量查询,芜湖网站开发公司,威海有名的做网站PPOCRLabel 使用PPOCRLabel对ocr预标注结果进行纠正由于PaddleOCR代码库十分混乱,路径经常乱调pip和代码库的代码(pip库和源码冲突),经常报错,因此paddleocr和ppocrlabel都是使用pip包;PPOCRLabel中使用了cv2进行图片数据的读取,…

PPOCRLabel

  • 使用PPOCRLabel对ocr预标注结果进行纠正
  • 由于PaddleOCR代码库十分混乱,路径经常乱调pip和代码库的代码(pip库和源码冲突),经常报错,因此paddleocr和ppocrlabel都是使用pip包;
  • PPOCRLabel中使用了cv2进行图片数据的读取,然cv2对中文路径读取有问题,经常会导致一些图片数据无法进行正常数据,在次基础上,把读取图片由cv2改为pilow,可以规避很多读取错误;
安装
pip install PPOCRLabel==2.1.3
启动
PPOCRLabel --lang ch

修改记录

修改1:
  • 报错:AttributeError: ‘NoneType’ object has no attribute ‘shape’
'NoneType' object has no attribute 'shape'
Traceback (most recent call last):File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\libs\autoDialog.py", line 41, in runh, w, _ = cv2.imdecode(np.fromfile(Imgpath, dtype=np.uint8), 1).shape
AttributeError: 'NoneType' object has no attribute 'shape'
  • 原因:cv2不支持读取带有中文字符路径文件
  h, w, _ = cv2.imdecode(np.fromfile(Imgpath, dtype=np.uint8), 1).shape
  • 解决:使用PIL替换cv2, 将上述代码替换为
# 修改文件:"D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\libs\autoDialog.py", line 41
# 增加PIL读取图片函数
from PIL import Image
def load_image(image_path: str, return_chw: bool = True, size: tuple = None):image = Image.open(image_path).convert("RGB")if size is not None:image = image.resize(size)  # resize imageimage = np.asarray(image)image = image[:, :, ::-1]  # flip color channels from RGB to BGRw, h = image.shape[1], image.shape[0]  # update size after resizeif return_chw:image = image.transpose(2, 0, 1)return image, (w, h)# 替换上面代码
try:image_data, (w, h) = load_image(Imgpath, return_chw=False)
except Exception as e:print(f"load file {Imgpath} fail!")continue
修改2
  • 报错:AttributeError: ‘NoneType’ object has no attribute ‘shape’
Traceback (most recent call last):File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\PPOCRLabel.py", line 1889, in saveFileself._saveFile(imgidx, mode=mode)File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\PPOCRLabel.py", line 1934, in _saveFileself.openNextImg()File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\PPOCRLabel.py", line 1880, in openNextImgself.loadFile(filename)File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\PPOCRLabel.py", line 1550, in loadFileheight, width, depth = cvimg.shape
AttributeError: 'NoneType' object has no attribute 'shape'
  • 原因还是cv2不能读取中文路径文件
  • 解决:
# 修改: File "D:\ProgramData\Anaconda3\envs\paddle\lib\site-packages\PPOCRLabel\PPOCRLabel.py", line 1550, in loadFile
# cvimg = cv2.imdecode(np.fromfile(unicodeFilePath, dtype=np.uint8), 1)
cvimg, _ = load_image(unicodeFilePath, return_chw=False)
修改3
  • 报错:error: (-215:Assertion failed) _src.total() > 0 in function ‘cv::warpPerspective’

    • 报错描述:在对PPOCRLABEL的框进行重新识别是,发生如下报错:
      Can not recognise the detection box in xxxx,png. Please change manually'unicodeFilePath is J:\data\mllm-data\xxxxxxxxx\wKh2CWERPJOAY2x-AAE62o598k0620.pngOpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:3143: error: (-215:Assertion failed) _src.total() > 0 in function 'cv::warpPerspective'
    
    • 原因是我们的ocr预标注数据Label.txt是使用PIL读取图片数据,调用ppocr进行生产的(并不是在PPOCRLabel工具内部生产的), 当我们修改数据框后, PPOCRLabel尝试再次使用cv2进行读取原图,此时由于cv2对路径较为敏感,经常会读取文件失败,才会出现如上情况
  • 解决:
    依旧是修改PPOCRLabel源码, 把cv2读取改为PIL读取,就不惯着cv2的臭毛病…

# 修改如下代码def reRecognition(self):#img = cv2.imdecode(np.fromfile(self.filePath,dtype=np.uint8),1)img, _ = load_image(self.filePath, return_chw=False)
修改4
  • 运行PPOCRLabel源码(paddleocr使用pip安装),报错: AttributeError: ‘Namespace’ object has no attribute ‘return_word_box’
    - File "G:\dongyongfei786\paddle\PaddleOCR\ppstructure\predict_system.py", line 82, in __init__self.return_word_box = args.return_word_box
AttributeError: 'Namespace' object has no attribute 'return_word_box'
  • 原因:
    • paddleocr使用pip安装的源码中(paddleocr=2.7.0.3), D:\ProgramData\Anaconda3\Lib\site-packages\paddleocr\tools\infer\utility.py, 缺少
  # extended functionparser.add_argument("--return_word_box", type=str2bool, default=False, help='Whether return the bbox of each word (split by space) or chinese character. Only used in ppstructure for layout recovery')

赞赏

  • 都说书中自有黄金屋,在这个“以钱为尊”的年代,没钱那可是万万不能,如果上述对各位帅哥美女有帮助的话,也可动一下发财的小手,你的支持的我做大的动力;
  • 后续有需要考虑打成一个whl,供需要的小伙伴使用;
  • 后续如果还有改动,会继续更新;
    在这里插入图片描述
http://www.hkea.cn/news/910594/

相关文章:

  • 携程网站建设进度及实施过程网络营销的缺点及建议
  • 石家庄网站建设哪家专业中国联通腾讯
  • 能访问各种网站的浏览器百度一下网页搜索
  • 自己做网站花多少钱雅虎搜索
  • 哈尔滨招标信息网网站推广优化排名教程
  • 个人可以建论坛网站吗福清网络营销
  • 济南做网站优化价格百度推广网站一年多少钱
  • 做网上商城网站哪家好杭州seo靠谱
  • 做营销网站制作关键词优化课程
  • 网站移动终端建设口碑营销成功案例
  • 美国做试管婴儿 网站推广普通话宣传语
  • 网站备案信息查询系统软文发布平台媒体
  • 泊头哪给做网站的好制作网页的教程
  • 漳州建设银行网站首页在百度上打广告找谁
  • 网站免费建站k网络营销策划方案书
  • 网站建设类公网店推广的作用
  • 安平做网站除了百度指数还有哪些指数
  • 做网站公司 蓝纤科技知乎怎么申请关键词推广
  • 临沂免费做网站发表文章的平台有哪些
  • 网站推广的方式包括哪些广西网站建设制作
  • 杭州营销网站建设东莞网站建设哪家公司好
  • 企业做营销型网站手机如何制作网页
  • 连云港网站关键词优化seo自学教程
  • 网站全站出售淘宝关键词排名怎么查询
  • 龙口市规划建设局网站查询收录
  • 学校网站建设注意什么东莞网站营销推广
  • 网站设计模板是什么百度网盘人工客服电话多少
  • wordpress文章收缩长春seo优化企业网络跃升
  • 网站地图调用希爱力双效片骗局
  • 珠海网站建设维护友情链接买卖代理