PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.38k stars 7.83k forks source link

list index out of range when using PP-OCRv4 #10935

Closed m0hamedAit closed 1 year ago

m0hamedAit commented 1 year ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

5 frames /usr/local/lib/python3.10/dist-packages/paddleocr/paddleocr.py in ocr(self, img, det, rec, cls, bin, inv, alpha_color) 659 for idx, img in enumerate(imgs): 660 img = preprocess_image(img) --> 661 dt_boxes, recres, = self.call(img, cls) 662 if not dt_boxes and not rec_res: 663 ocr_res.append(None)

/usr/local/lib/python3.10/dist-packages/paddleocr/tools/infer/predict_system.py in call(self, img, cls) 103 len(img_crop_list), elapse)) 104 --> 105 rec_res, elapse = self.text_recognizer(img_crop_list) 106 time_dict['rec'] = elapse 107 logger.debug("rec_res num : {}, elapsed : {}".format(

/usr/local/lib/python3.10/dist-packages/paddleocr/tools/infer/predict_rec.py in call(self, img_list) 626 preds = outputs[0] 627 self.predictor.try_shrink_memory() --> 628 rec_result = self.postprocess_op(preds) 629 for rno in range(len(rec_result)): 630 rec_res[indices[beg_img_no + rno]] = rec_result[rno]

/usr/local/lib/python3.10/dist-packages/paddleocr/ppocr/postprocess/rec_postprocess.py in call(self, preds, label, *args, *kwargs) 119 def call(self, preds, label=None, args, **kwargs): 120 if isinstance(preds, tuple) or isinstance(preds, list): --> 121 preds = preds[-1] 122 if isinstance(preds, paddle.Tensor): 123 preds = preds.numpy()

/usr/local/lib/python3.10/dist-packages/paddleocr/ppocr/postprocess/rec_postprocess.py in decode(self, text_index, text_prob, is_remove_duplicate) 81 selection &= text_index[batch_idx] != ignored_token 82 83 char_list = [ ---> 84 self.character[text_id] 85 for text_id in text_index[batch_idx][selection] 86 ]

/usr/local/lib/python3.10/dist-packages/paddleocr/ppocr/postprocess/rec_postprocess.py in (.0) 82 83 char_list = [ ---> 84 self.character[text_id] 85 for text_id in text_index[batch_idx][selection] 86 ]

IndexError: list index out of range

zzc81824130 commented 8 months ago

请问最后怎么解决的?

m0hamedAit commented 8 months ago

请问最后怎么解决的?

If I remember correctly, I reinstalled PaddleOCR using the following command: pip install paddleocr==2.7.0.3 --upgrade PyMuPDF==1.20.2. In my case, I had to install swig, pcre, and bison>3.5 before running this command.