Skip to content

How to use recent text detectors with RapidOCR? #7

@halqadasi

Description

@halqadasi

If I want to use one of the text detectors in this link instead of DB algorithm (default). I use paddleocr_convert but it throws an error. This is an example to convert SAST algorithm to onnex:

from paddleocr_convert import PaddleOCRModelConvert

converter = PaddleOCRModelConvert()
save_dir = 'models'
url = 'https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar'
converter(url, save_dir)

The error log:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\paddleocr_convert\main.py:49, in PaddleOCRModelConvert.__call__(self, model_path, save_dir, txt_path, is_del_raw)
     48 try:
---> 49     self.change_to_dynamic(save_onnx_path)
     50 except Exception as e:

File ~\anaconda3\lib\site-packages\paddleocr_convert\main.py:113, in PaddleOCRModelConvert.change_to_dynamic(self, onnx_path)
    112 onnx_model = onnx.load_model(onnx_path)
--> 113 dim_shapes = onnx_model.graph.input[0].type.tensor_type.shape.ListFields()[0][1]
    115 dynamic_name = 'DynamicDimension'

IndexError: list index out of range

The above exception was the direct cause of the following exception:

ConvertError                              Traceback (most recent call last)
Cell In[24], line 7
      5 # online
      6 url = 'https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar'
----> 7 converter(url, save_dir)

File ~\anaconda3\lib\site-packages\paddleocr_convert\main.py:51, in PaddleOCRModelConvert.__call__(self, model_path, save_dir, txt_path, is_del_raw)
     49     self.change_to_dynamic(save_onnx_path)
     50 except Exception as e:
---> 51     raise ConvertError(
     52         'change the model to dynamic meets error.') from e
     54 if is_rec:
     55     txt_path = self.get_file_path(txt_path, '.')

ConvertError: change the model to dynamic meets error.

Could you please tell me how I can use different text detection algorithms instead of the specified ones in this page here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions