File “/ppocr/data/simple_dataset.py“, line 157, in __getitem__ raise Exception(“{} does not exis

PaddleOCR数据集划分导致的问题已解决

报错具体如下:

[2024/07/16 16:38:11] ppocr ERROR: When parsing line E:\python\PaddleOCR-main\yuxi\det\train\yan667_random_color.jpg    [{"transcription": "南京", "points": [[213, 178], [412, 178], [412, 286], [213, 286]], "difficult": false}]
, error happened with msg: Traceback (most recent call last):
  File "/auto/auto/ppocr/data/simple_dataset.py", line 157, in __getitem__
    raise Exception("{} does not exist!".format(img_path))
Exception: ./yuxi/E:\python\PaddleOCR-main\yuxi\det\train\yan667_random_color.jpg does not exist!

1.记得修改gen_ocr_train_val_test.py的第42行

 imagePath = os.path.join(dataAbsPath, "{}\\{}".format(args.recImageDirName, imageName))

为:

 imagePath = os.path.join(dataAbsPath, "{}/{}".format(args.recImageDirName, imageName))

2.如果出现如下报错

[2024/07/16 16:38:11] ppocr ERROR: When parsing line E:\python\PaddleOCR-main\yuxi\det\train\yan667_random_color.jpg    [{"transcription": "南京", "points": [[213, 178], [412, 178], [412, 286], [213, 286]], "difficult": false}]
, error happened with msg: Traceback (most recent call last):
  File "/auto/auto/ppocr/data/simple_dataset.py", line 157, in __getitem__
    raise Exception("{} does not exist!".format(img_path))
Exception: ./yuxi/E:\python\PaddleOCR-main\yuxi\det\train\yan667_random_color.jpg does not exist!

由于我是使用的AutoDL租用的GPU,可能和电脑自带GPU不同,以下是我的解决方案(试错过程哈哈哈哈哈

1)首先,我考虑到绝对路径的问题,想到调用此gen_ocr_train_val_test.py是否可以不使用绝对路径,但是我查看必须要使用绝对路径了,因为它作为PPLabel库的代码,只能用绝对路径分割数据集,那么我就把gen_ocr_train_val_test.py挪进数据集文件夹中,当然也还是不行的哈哈哈哈哈哈哈哈哈哈

2)最后,我根据报错信息修改ppocr/data/simple_dataset.py的第155行进行修改

abs_data_dir = os.path.abspath(self.data_dir)  # 将相对路径转换为绝对路径
img_path = os.path.join(abs_data_dir, file_name)

这次我就成功了!!!!

文章仅作参考   若能给大家带来帮助 ,我将十分开心!!!!!!!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值