/home/PaddleOCR/ppocr/utils/ppocr_keys_v1.txt读取出错
Created by: moronism189
λ fa83723faf1f /tf/ocr python3 test4PaddleOcr.py grep: warning: GREP_OPTIONS is deprecated; please use an alias or script Namespace(cls=False, cls_batch_num=30, cls_image_shape='3, 48, 192', cls_model_dir='/root/.paddleocr/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_max_side_len=960, det_model_dir='/root/.paddleocr/det', enable_mkldnn=False, gpu_mem=2000, image_dir=None, 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='/root/.paddleocr/rec/ch', use_angle_cls=False, use_gpu=True, use_space_char=True, use_tensorrt=False, use_zero_copy_run=False) character_dict_path: /home/PaddleOCR/ppocr/utils/ppocr_keys_v1.txt Traceback (most recent call last): File "test4PaddleOcr.py", line 8, in ocr = PaddleOCR(gpu_mem=2000) # need to run only once to download and load model into memory File "/home/PaddleOCR/paddleocr.py", line 222, in init super().init(postprocess_params) File "/home/PaddleOCR/tools/infer/predict_system.py", line 42, in init self.text_recognizer = predict_rec.TextRecognizer(args) File "/home/PaddleOCR/tools/infer/predict_rec.py", line 61, in init self.char_ops = CharacterOps(char_ops_params) File "/home/PaddleOCR/ppocr/utils/character.py", line 47, in init with open(character_dict_path, "rb") as fin: TypeError: invalid file: PosixPath('/home/PaddleOCR/ppocr/utils/ppocr_keys_v1.txt')
测试程序test4PaddleOcr.py如下: from paddleocr import PaddleOCR ocr = PaddleOCR(gpu_mem=2000) # need to run only once to download and load model into memory img_path = 'image/brand.jpg' result = ocr.ocr(img_path, det=False) for line in result: print(line)