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

[BUG] PaddleOCR OnnxSlim failure track #29

Open
inisis opened this issue Oct 17, 2024 · 3 comments
Open

[BUG] PaddleOCR OnnxSlim failure track #29

inisis opened this issue Oct 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@inisis
Copy link
Owner

inisis commented Oct 17, 2024

Steps to reproduce

git clone https://github.com/PaddlePaddle/PaddleOCR
git checkout e621d034b584fae03c22cd51c26f6a52d62417b6
cd PaddleOCR

mkdir -p inference
wget https://paddleocr.bj.bcebos.com/openatom/ch_ppstructure_openatom_SLANetv2_infer.tar -P inference
tar xvf inference/ch_ppstructure_openatom_SLANetv2_infer.tar -C inference

cd ppstructure/
python table/predict_structure.py \
    --table_model_dir=../inference/ch_ppstructure_openatom_SLANetv2_infer \
    --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt \
    --image_dir=docs/table/table.jpg \
    --output=../output/table_slanet_lcnetv2 \
    --use_gpu=False \
    --table_max_len=512

cd ../
paddle2onnx --model_dir inference/ch_ppstructure_openatom_SLANetv2_infer \
--model_filename inference.pdmodel \
--params_filename inference.pdiparams \
--save_file ./inference/ch_ppstructure_openatom_SLANetv2_infer/model.onnx \
--enable_onnx_checker True

onnxslim inference/ch_ppstructure_openatom_SLANetv2_infer/model.onnx inference/ch_ppstructure_openatom_SLANetv2_infer/model.onnx

cd ppstructure/
python table/predict_structure.py \
    --table_model_dir=../inference/ch_ppstructure_openatom_SLANetv2_infer/model.onnx \
    --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt \
    --image_dir=docs/table/table.jpg \
    --output=../output/table_slanet_lcnetv2 \
    --use_gpu=False \
    --use_onnx=True \
    --table_max_len=512

image

@inisis inisis self-assigned this Oct 19, 2024
@inisis inisis added the bug Something isn't working label Oct 19, 2024
@inisis inisis changed the title PaddleOCR OnnxSlim failure track [BUG] PaddleOCR OnnxSlim failure track Oct 19, 2024
@inisis
Copy link
Owner Author

inisis commented Oct 20, 2024

image

(paddle) (base) root@ubuntu20:~/OnnxSlim# python
Python 3.10.15 (main, Oct  3 2024, 07:27:34) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import onnxruntime as rt
>>> sess = rt.InferenceSession('slim.onnx')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/miniconda3/envs/paddle/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/root/miniconda3/envs/paddle/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 480, in _create_inference_session
    sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from slim.onnx failed:Node (Loop.0) Op (Loop) [TypeInferenceError] Graph attribute inferencing failed: Size mismatch validating subgraph inputs. Got 29 inputs but subgraph has 25 inputs and requires 25 inputs. Either provide all subgraph inputs, or just the required inputs.

@inisis
Copy link
Owner Author

inisis commented Oct 20, 2024

When a model contains subgraph, it's usually a good practice to not remove unused inputs, because for subgraph, unused inputs works like Identity operator to pass information down

@inisis
Copy link
Owner Author

inisis commented Oct 20, 2024

fixed f6c77ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant