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

使用export导出后的formula模型推理出错 #3740

Open
4 tasks done
gaiyinaizhi opened this issue Mar 27, 2025 · 3 comments
Open
4 tasks done

使用export导出后的formula模型推理出错 #3740

gaiyinaizhi opened this issue Mar 27, 2025 · 3 comments
Assignees

Comments

@gaiyinaizhi
Copy link

gaiyinaizhi commented Mar 27, 2025

Checklist:

描述问题

使用如下命令将预训练模型导出后推理出错, 请教下是否还需要其他配置
python main.py -c paddlex/configs/modules/formula_recognition/PP-FormulaNet-L.yaml -o Global.mode=export -o Export.weight_path=/Users/xxx/PP-FormulaNet-L_pretrained.pdparams
其中预训练模型文件为PP-FormulaNet-L.yaml文件中的地址直接下载后的文件
异常信息:
ValueError: In user code: InvalidArgumentError: Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [4, 16, 2, 146] and the shape of Y = [4, 1, 2, 2]. Received [146] in X is not equal to [2] in Y at i:3. [Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at /Users/paddle/xly/workspace/18120d4d-074c-4f46-9fac-8c77f096760e/Paddle/paddle/phi/kernels/funcs/common_shape.h:84) [operator < pd_op.while > error]

环境

  1. 请提供您使用的PaddleX的版本号
    3.0rc最新提交
  2. 请提供您使用的操作系统信息,如Linux/Windows/MacOS
    macos
  3. 请问您使用的Python版本是
    3.10
@gaiyinaizhi
Copy link
Author

在文档中发现这么一句描述, 请教下原因是什么?
除 LaTeX_OCR_rec外, 公式识别模型只支持导出json格式的模型,因此训练时需要设置参数FLAGS_json_format_model=1。

@liuhongen1234567
Copy link
Collaborator

您好,现在paddle支持两种模型,一种是json格式,一种pdmodel格式,PP-FormulaNet-L, PP-FormulaNet-S, UniMERNet 这三个模型静态图导出只支持json模型,所以导出前要加上 FLAGS_json_format_model=1, 也就是 FLAGS_json_format_model=1 python main.py -c paddlex/configs/modules/formula_recognition/PP-FormulaNet-L.yaml -o Global.mode=export -o Export.weight_path=/Users/xxx/PP-FormulaNet-L_pretrained.pdparams,这个参数是用于导出json格式模型的。 而LaTeX_OCR_rec 最好导出时,不加 FLAGS_json_format_model=1 这个参数,也就是 python main.py -c paddlex/configs/modules/formula_recognition/LaTeX_OCR_rec.yaml -o Global.mode=export -o Export.weight_path=https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/LaTeX_OCR_rec_pretrained.pdparams,加上的话,在CPU会跑不通

@liuhongen1234567
Copy link
Collaborator

当然,这两种格式在paddlex中都可以使用,按上述说明导出后的模型是不会影响模块或产线推理的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants