I am following the cpp tutorial. I have replaced the model with my own and replaces the input and output tensors, here and here. The Model is binding but on evaluation step abruptly aborts.
As far as I know, there is nothing wrong with my code and model. I have tried to change the input image into various sizes and color modes(grayscale and rgb) but nothing works.
Changes made:
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);
}
Console output: https://i.stack.imgur.com/fyoau.jpg
Error:
https://i.stack.imgur.com/xytE7.jpg
[Console output in text form]
Loading modelfile 'D:\Projects\Windows-Machine-Learning-master\Samples\SqueezeNetObjectDetection\Desktop\cpp\Debug\wifi3.onnx' on the 'default' device
model file loaded in 531 ticks
Loading the image...
Binding...
Now...
Running the model...
why
Errormsg:
Debug Error!
Program: .../CPP.exe
abort() has been called
Model link: https://www.dropbox.com/s/fudgynpislpsyta/wifi3.onnx?dl=0
Output by Debugger:
Exception thrown at 0x75013442 in SqueezeNetObjectDetectionCPP.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x006FF5C8. occurred