1、Paddlelite Android 运行错误Check failed: op_->CheckShape(),提示in_dims().size() == 4 || in_dims.size() == 5 test error
替换模型以后模型的输入和 Paddle Lite 接收的输入不匹配导致
修改如下:
网络可视化工具查看模型的输入
修改代码:对应模型的三个输入
// Set the data of input image auto inputTensor = predictor_->GetInput(1); std::vector<int64_t> inputShape = {1, 3, inputHeight_, inputWidth_}; inputTensor->Resize(inputShape); auto inputData = inputTensor->mutable_data<float>(); cv::Mat resizedRGBAImage; cv::resize(rgbaImage, resizedRGBAImage, cv::Size(inputShape[3], inputShape[2])); cv::Mat resizedRGBImage; cv::cvtColor(resizedRGBAImage, resizedRGBImage, cv::COLOR_BGRA2RGB); resizedRGBImage.convertTo(resizedRGBImage, CV_32FC3, 1.0 / 255.0f); NHWC3ToNC3HW(reinterpret_cast<const float *>(resizedRGBImage.data), inputData, inputMean_.data(), inputStd_.data(), inputShape[3], inputShape[2]); // Set the size of input image auto sizeTensor = predictor_->GetInput(0); sizeTensor->Resize({1, 2}); auto sizeData = sizeTensor->mutable_data<float>(); sizeData[0] = inputShape[3]; sizeData[1] = inputShape[2]; auto scaleTensor = predictor_->GetInput(2); scaleTensor->Resize({1, 2}); auto scaleData = scaleTensor->mutable_data<float>(); scaleData[0] = 1.f; scaleData[1] = 1.f;