Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: (NotFound) Cannot open file .paddleocr/2.0/det/inference.pdmodel, please confirm whether the file is normal. #1964

Closed
lexiaoyuan opened this issue Feb 6, 2021 · 13 comments

Comments

@lexiaoyuan
Copy link

lexiaoyuan commented Feb 6, 2021

windows + anaconda下,PaddleOCR可以运行成功,可以识别单张图片和图像集合。但是运行python PPOCRLabel.py --lang ch,就报错:

Namespace(cls=True, cls_batch_num=30, cls_image_shape='3, 48, 192', cls_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/cls', cls_thresh=0.9, det=True, det_algorithm='DB', det_db_box_thresh=0.5, det_db_thresh=0.3, det_db_unclip_ratio=2.0, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_limit_side_len=960, det_limit_type='max', det_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/det', drop_score=0.5, enable_mkldnn=False, gpu_mem=8000, image_dir='', ir_optim=True, label_list=['0', '180'], lang='ch', max_text_length=25, rec=True, rec_algorithm='CRNN', rec_batch_num=30, rec_char_dict_path='./ppocr/utils/ppocr_keys_v1.txt', rec_char_type='ch', rec_image_shape='3, 32, 320', rec_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/rec/ch', use_angle_cls=True, use_gpu=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_zero_copy_run=False)
Traceback (most recent call last):
  File "PPOCRLabel.py", line 2005, in <module>
    sys.exit(main())
  File "PPOCRLabel.py", line 1993, in main
    app, _win = get_main_app(sys.argv)
  File "PPOCRLabel.py", line 1985, in get_main_app
    win = MainWindow(lang=args.lang,
  File "PPOCRLabel.py", line 111, in __init__
    self.ocr = PaddleOCR(use_pdserving=False, use_angle_cls=True, det=True, cls=True, use_gpu=False, lang=lang)
  File "..\paddleocr.py", line 269, in __init__
    super().__init__(postprocess_params)
  File "..\tools\infer\predict_system.py", line 42, in __init__
    self.text_detector = predict_det.TextDetector(args)
  File "..\tools\infer\predict_det.py", line 97, in __init__
    self.predictor, self.input_tensor, self.output_tensors = utility.create_predictor(
  File "..\tools\infer\utility.py", line 135, in create_predictor
    predictor = inference.create_predictor(config)
RuntimeError: (NotFound) Cannot open file C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel, please confirm whether the file is normal.
  [Hint: Expected static_cast<bool>(fin.is_open()) == true, but received static_cast<bool>(fin.is_open()):0 != true:1.] (at D:\v2.0.0\paddle\paddle\fluid\inference\api\analysis_predictor.cc:829)

C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel这个文件是存在的。

@lexiaoyuan
Copy link
Author

windows + anaconda下,PaddleOCR可以运行成功,可以识别单张图片和图像集合。但是运行python PPOCRLabel.py --lang ch,就报错:

Namespace(cls=True, cls_batch_num=30, cls_image_shape='3, 48, 192', cls_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/cls', cls_thresh=0.9, det=True, det_algorithm='DB', det_db_box_thresh=0.5, det_db_thresh=0.3, det_db_unclip_ratio=2.0, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_limit_side_len=960, det_limit_type='max', det_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/det', drop_score=0.5, enable_mkldnn=False, gpu_mem=8000, image_dir='', ir_optim=True, label_list=['0', '180'], lang='ch', max_text_length=25, rec=True, rec_algorithm='CRNN', rec_batch_num=30, rec_char_dict_path='./ppocr/utils/ppocr_keys_v1.txt', rec_char_type='ch', rec_image_shape='3, 32, 320', rec_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/rec/ch', use_angle_cls=True, use_gpu=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_zero_copy_run=False)
Traceback (most recent call last):
  File "PPOCRLabel.py", line 2005, in <module>
    sys.exit(main())
  File "PPOCRLabel.py", line 1993, in main
    app, _win = get_main_app(sys.argv)
  File "PPOCRLabel.py", line 1985, in get_main_app
    win = MainWindow(lang=args.lang,
  File "PPOCRLabel.py", line 111, in __init__
    self.ocr = PaddleOCR(use_pdserving=False, use_angle_cls=True, det=True, cls=True, use_gpu=False, lang=lang)
  File "..\paddleocr.py", line 269, in __init__
    super().__init__(postprocess_params)
  File "..\tools\infer\predict_system.py", line 42, in __init__
    self.text_detector = predict_det.TextDetector(args)
  File "..\tools\infer\predict_det.py", line 97, in __init__
    self.predictor, self.input_tensor, self.output_tensors = utility.create_predictor(
  File "..\tools\infer\utility.py", line 135, in create_predictor
    predictor = inference.create_predictor(config)
RuntimeError: (NotFound) Cannot open file C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel, please confirm whether the file is normal.
  [Hint: Expected static_cast<bool>(fin.is_open()) == true, but received static_cast<bool>(fin.is_open()):0 != true:1.] (at D:\v2.0.0\paddle\paddle\fluid\inference\api\analysis_predictor.cc:829)

C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel这个文件是存在的。

已解决。C盘.paddleocr目录下的模型文件是第一次运行时下载下来的,不知道在程序里为什么会报这个错误。

在utility.py里自己指定model_dir为自己下载并解压的模型文件路径就好了。
例:

if mode == "det":
    # model_dir = args.det_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_det_infer'
elif mode == 'cls':
    # model_dir = args.cls_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_cls_infer'
else:
    # model_dir = args.rec_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_rec_infer'

其中E:/PaddleOCR/inference目录下就是参考https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_en/quickstart_en.md新建的inference及下载并解压的目录

@littletomatodonkey
Copy link
Collaborator

好的,不建议使用带中文的文件路径哈

@JunLei01
Copy link

你好,这个utility.py文件是在哪里的?我在环境中好像没找到这个

@wuliaodeashuai
Copy link

为什么还是报错啊

@lingchen-xn
Copy link

你好,这个utility.py文件是在哪里的?我在环境中好像没找到这个

同问

@ZY945
Copy link

ZY945 commented Aug 27, 2023

@JunLei01 @lingchen-xn
在这里,
image
如果是虚拟环境,在虚拟环境文件夹里
image

@ZY945
Copy link

ZY945 commented Aug 27, 2023

@ZY945 这个文件里修改路径----指的是模型的路径,修改时注意缩进和是否需要防止转义

@Hygge1024
Copy link

windows + anaconda下,PaddleOCR可以运行成功,可以识别单张图片和图像集合。但是运行python PPOCRLabel.py --lang ch,就报错:

Namespace(cls=True, cls_batch_num=30, cls_image_shape='3, 48, 192', cls_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/cls', cls_thresh=0.9, det=True, det_algorithm='DB', det_db_box_thresh=0.5, det_db_thresh=0.3, det_db_unclip_ratio=2.0, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_limit_side_len=960, det_limit_type='max', det_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/det', drop_score=0.5, enable_mkldnn=False, gpu_mem=8000, image_dir='', ir_optim=True, label_list=['0', '180'], lang='ch', max_text_length=25, rec=True, rec_algorithm='CRNN', rec_batch_num=30, rec_char_dict_path='./ppocr/utils/ppocr_keys_v1.txt', rec_char_type='ch', rec_image_shape='3, 32, 320', rec_model_dir='C:\\Users\\徐仕成/.paddleocr/2.0/rec/ch', use_angle_cls=True, use_gpu=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_zero_copy_run=False)
Traceback (most recent call last):
  File "PPOCRLabel.py", line 2005, in <module>
    sys.exit(main())
  File "PPOCRLabel.py", line 1993, in main
    app, _win = get_main_app(sys.argv)
  File "PPOCRLabel.py", line 1985, in get_main_app
    win = MainWindow(lang=args.lang,
  File "PPOCRLabel.py", line 111, in __init__
    self.ocr = PaddleOCR(use_pdserving=False, use_angle_cls=True, det=True, cls=True, use_gpu=False, lang=lang)
  File "..\paddleocr.py", line 269, in __init__
    super().__init__(postprocess_params)
  File "..\tools\infer\predict_system.py", line 42, in __init__
    self.text_detector = predict_det.TextDetector(args)
  File "..\tools\infer\predict_det.py", line 97, in __init__
    self.predictor, self.input_tensor, self.output_tensors = utility.create_predictor(
  File "..\tools\infer\utility.py", line 135, in create_predictor
    predictor = inference.create_predictor(config)
RuntimeError: (NotFound) Cannot open file C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel, please confirm whether the file is normal.
  [Hint: Expected static_cast<bool>(fin.is_open()) == true, but received static_cast<bool>(fin.is_open()):0 != true:1.] (at D:\v2.0.0\paddle\paddle\fluid\inference\api\analysis_predictor.cc:829)

C:\Users\徐仕成/.paddleocr/2.0/det/inference.pdmodel这个文件是存在的。

已解决。C盘.paddleocr目录下的模型文件是第一次运行时下载下来的,不知道在程序里为什么会报这个错误。

在utility.py里自己指定model_dir为自己下载并解压的模型文件路径就好了。 例:

if mode == "det":
    # model_dir = args.det_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_det_infer'
elif mode == 'cls':
    # model_dir = args.cls_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_cls_infer'
else:
    # model_dir = args.rec_model_dir
    model_dir = 'E:/PaddleOCR/inference/ch_ppocr_mobile_v2.0_rec_infer'

其中E:/PaddleOCR/inference目录下就是参考https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_en/quickstart_en.md新建的inference及下载并解压的目录

解决了。中文路径有影响,还需要在代码中更改绝对路基

@damaocode
Copy link

解决办法有用,感谢,另外用google搜索才第一条搜出来的,百度真垃圾

@sulmz
Copy link

sulmz commented Nov 14, 2023

为什么中国人开发的开源模型,会对中文路径支持不做优化呢?费解

@S1024K
Copy link

S1024K commented Nov 21, 2023

image
模型文件变成这样的了,和题主的不太一样了,直接从https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.7/doc/doc_ch/models_list.md 下载,分别下载det,cls和rec这三个,然后更改路径为你下载的路径即可。

@Jain-cc
Copy link

Jain-cc commented May 6, 2024

这个问题卡了一天,就是中文路径的问题,编译后的程序改全英文路径后OK了
我一直以为是文件权限或者文件完整性问题

@Ericlong1111
Copy link

大佬们,为什么我按上述修改了下载路径,仍然报错,只能修改用户名了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests