airockchip / rknn_model_zoo

Apache License 2.0
1.05k stars 192 forks source link

PPOCR-System not working with custom ppocr_keys_v1.txt #136

Open livelove1987 opened 4 months ago

livelove1987 commented 4 months ago

When im trying to use smaller ppocr_keys_v1.txt ( like only english letters ) im getting such error:

Traceback (most recent call last):
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/ppocr_system.py", line 140, in <module>
    filter_boxes, filter_rec_res = system_model.run(img)
                                   ^^^^^^^^^^^^^^^^^^^^^
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/ppocr_system.py", line 48, in run
    rec_res = self.text_recognizer.run(img_crop_list)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/ppocr_rec.py", line 80, in run
    output = self.ctc_postprocess(preds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/utils/rec_postprocess.py", line 125, in __call__
    text = self.decode(preds_idx, preds_prob, is_remove_duplicate=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/utils/rec_postprocess.py", line 87, in decode
    char_list = [
                ^
  File "/home/livelove/Desktop/coding-projects/rocketchips_converter/rknn_model_zoo/examples/PPOCR/PPOCR-System/python/utils/rec_postprocess.py", line 88, in <listcomp>
    self.character[text_id]
    ~~~~~~~~~~~~~~^^^^^^^^^
IndexError: list index out of range

Thats because text_index ( code which uses that var for text_id in text_index[batch_idx][selection] ) even when dict is size of 59 letters is returning such indexes [5033 3589 5529 631 631 631 632 5127]