我正在关注 cpp教程。我已经用自己的模型替换了模型,并替换了输入和输出张量,here和here。模型具有约束力,但在评估步骤中突然中止。
据我所知,我的代码和模型没有任何问题。我试图将输入图像更改为各种尺寸和颜色模式(灰度和 rgb),但没有任何效果。
所做的更改:
int main(int argc, char* argv[])
{
init_apartment();
// did they pass in the args
if (ParseArgs(argc, argv) == false)
{
printf("Usage: %s [imagefile] [cpu|directx]", argv[0]);
return -1;
}
// Get model path
auto modelPath = GetModelPath();
// load the model
printf("Loading modelfile '%ws' on the '%s' device\n", modelPath.c_str(), deviceName.c_str());
DWORD ticks = GetTickCount();
auto model = LearningModel::LoadFromFilePath(modelPath);
ticks = GetTickCount() - ticks;
printf("model file loaded in %d ticks\n", ticks);
// load the image
printf("Loading the image...\n");
auto imageFrame = LoadImageFile(imagePath);
// now create a session and binding
LearningModelSession session(model, LearningModelDevice(deviceKind));//Exception thrown at this line
LearningModelBinding binding(session);
// bind the intput image
printf("Binding...\n");
binding.Bind(L"conv2d_1_input_01", ImageFeatureValue::CreateFromVideoFrame(imageFrame));
// temp: bind the output (we don't support unbound outputs yet)
printf("Now...\n");
vector<int64_t> shape({ 1, 2 });
binding.Bind(L"dense_1_Softmax_0", TensorFloat::Create(shape));
// now run the model
printf("Running the model...\n");
ticks = GetTickCount();
printf("why");
auto results = session.Evaluate(binding, L"RunId");
printf("why");
ticks = GetTickCount() - ticks;
printf("model run took %d ticks\n", ticks);
// get the output
auto resultTensor = results.Outputs().Lookup(L"dense_1_Softmax_0").as<TensorFloat>();
auto resultVector = resultTensor.GetAsVectorView();
PrintResults(resultVector);
}
控制台输出: https ://imgur.com/wKd9RXK
错误:
[文本形式的控制台输出]
在“默认”设备上加载模型文件“D:\Projects\Windows-Machine-Learning-master\Samples\SqueezeNetObjectDetection\Desktop\cpp\Debug\wifi3.onnx”
以 531 个刻度加载的模型文件
正在加载图像...
捆绑...
现在...
运行模型...
为什么
错误消息:
调试错误!
程序:.../CPP.exe
abort() 已被调用
型号链接:https ://www.dropbox.com/s/fudgynpislpsyta/wifi3.onnx?dl=0
调试器输出:
在 SqueezeNetObjectDetectionCPP.exe 中的 0x75013442 处引发异常:Microsoft C++ 异常:内存位置 0x006FF5C8 处的 winrt::hresult_error。发生了