ocr的c++示例执行失败
Created by: xiaolvtaomi
参照c++文档中的ocr的模块,执行最后一步运行方法时报错,如下
134|D1C:/data/local/tmp $ ./ocr_full_api --model_dir=./ocr
Segmentation fault
用到的相关文件: 1,ocr的预测模型,下载链接是attention,本地命名ocr成了文件夹 2,编译出来的可执行文件ocr_full_api 3,编译用的cc文件 ,参考issue修改了shape_t和GetInput(1)
// 3. Prepare input data
//input 0
std::unique_ptr<Tensor> input_tensor(std::move(predictor->GetInput(1)));
input_tensor->Resize(shape_t({1,3,100,380}));
auto* data = input_tensor->mutable_data<float>();
for(int i = 0; i < ShapeProduction(input_tensor->shape()); ++i){
data[i] = 1;
}
//input1
std::unique_ptr<Tensor> init_ids(std::move(predictor->GetInput(0)));
init_ids->Resize(shape_t({1,1}));
auto* data_ids = init_ids->mutable_data<float>();
for(int i = 0; i < ShapeProduction(init_ids->shape()); ++i){
data_ids[i] = 0;
}