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

C++版本使用FastDeploy和PaddleDetection时,关于异常捕获问题 #2589

Open
sunshine-app opened this issue Jan 16, 2025 · 1 comment
Assignees

Comments

@sunshine-app
Copy link

// 创建模型
model = std::make_sharedfastdeploy::vision::detection::PaddleDetectionModel(model_buffer, params_buffer, config_file, option);

问题:
model_buffer和params_buffer是解密后输入的参数,但是这两个值可能会因为密码错误的情况下报错,报错信息:
[Paddle2ONNX] Failed to parse PaddlePaddle model from memory buffer.
[Paddle2ONNX] Failed to load program of PaddlePaddle model from memory.
[ERROR] Failed to parse PaddlePaddle model.

请问这样的异常信息怎么进行捕获呢,避免程序直接异常退出?
catch (const std::exception& e) { // 捕获所有标准异常
init_model_status = 0;
std::cerr << "Standard exception: " << e.what() << std::endl;
}
catch (...) { // 捕获所有其他异常(非标准异常)
init_model_status = 0;
std::cerr << "Unknown exception occurred" << std::endl;
}
两种方式不能捕获到异常信息。设置option.DisablePaddleLogInfo()也无效。

@Jiang-Jia-Jun
Copy link
Collaborator

在Paddle2ONNX的代码中,在转换失败时,调用了std::abort来退出,你可能得搜一下Python层如何catch这种错误。 或者是修改Paddle2ONNX源码

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